@@ -2455,7 +2455,7 @@ static void protection_domain_init(struct protection_domain *domain, int nid)
2455
2455
domain -> iop .pgtbl .cfg .amd .nid = nid ;
2456
2456
}
2457
2457
2458
- struct protection_domain * protection_domain_alloc (unsigned int type , int nid )
2458
+ struct protection_domain * protection_domain_alloc (int nid )
2459
2459
{
2460
2460
struct protection_domain * domain ;
2461
2461
int domid ;
@@ -2476,15 +2476,10 @@ struct protection_domain *protection_domain_alloc(unsigned int type, int nid)
2476
2476
return domain ;
2477
2477
}
2478
2478
2479
- static int pdom_setup_pgtable (struct protection_domain * domain ,
2480
- unsigned int type , int pgtable )
2479
+ static int pdom_setup_pgtable (struct protection_domain * domain , int pgtable )
2481
2480
{
2482
2481
struct io_pgtable_ops * pgtbl_ops ;
2483
2482
2484
- /* No need to allocate io pgtable ops in passthrough mode */
2485
- if (!(type & __IOMMU_DOMAIN_PAGING ))
2486
- return 0 ;
2487
-
2488
2483
switch (pgtable ) {
2489
2484
case AMD_IOMMU_V1 :
2490
2485
domain -> pd_mode = PD_MODE_V1 ;
@@ -2518,27 +2513,19 @@ static bool amd_iommu_hd_support(struct amd_iommu *iommu)
2518
2513
return iommu && (iommu -> features & FEATURE_HDSUP );
2519
2514
}
2520
2515
2521
- static struct iommu_domain * do_iommu_domain_alloc (unsigned int type ,
2522
- struct device * dev ,
2523
- u32 flags , int pgtable )
2516
+ static struct iommu_domain * do_iommu_domain_alloc (struct device * dev , u32 flags ,
2517
+ int pgtable )
2524
2518
{
2525
2519
bool dirty_tracking = flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING ;
2526
2520
struct amd_iommu * iommu = get_amd_iommu_from_dev (dev );
2527
2521
struct protection_domain * domain ;
2528
2522
int ret ;
2529
2523
2530
- /*
2531
- * Since DTE[Mode]=0 is prohibited on SNP-enabled system,
2532
- * default to use IOMMU_DOMAIN_DMA[_FQ].
2533
- */
2534
- if (amd_iommu_snp_en && (type == IOMMU_DOMAIN_IDENTITY ))
2535
- return ERR_PTR (- EINVAL );
2536
-
2537
- domain = protection_domain_alloc (type , dev_to_node (dev ));
2524
+ domain = protection_domain_alloc (dev_to_node (dev ));
2538
2525
if (!domain )
2539
2526
return ERR_PTR (- ENOMEM );
2540
2527
2541
- ret = pdom_setup_pgtable (domain , type , pgtable );
2528
+ ret = pdom_setup_pgtable (domain , pgtable );
2542
2529
if (ret ) {
2543
2530
pdom_id_free (domain -> id );
2544
2531
kfree (domain );
@@ -2550,7 +2537,7 @@ static struct iommu_domain *do_iommu_domain_alloc(unsigned int type,
2550
2537
domain -> domain .geometry .force_aperture = true;
2551
2538
domain -> domain .pgsize_bitmap = domain -> iop .pgtbl .cfg .pgsize_bitmap ;
2552
2539
2553
- domain -> domain .type = type ;
2540
+ domain -> domain .type = IOMMU_DOMAIN_UNMANAGED ;
2554
2541
domain -> domain .ops = iommu -> iommu .ops -> default_domain_ops ;
2555
2542
2556
2543
if (dirty_tracking )
@@ -2564,7 +2551,6 @@ amd_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
2564
2551
const struct iommu_user_data * user_data )
2565
2552
2566
2553
{
2567
- unsigned int type = IOMMU_DOMAIN_UNMANAGED ;
2568
2554
struct amd_iommu * iommu = get_amd_iommu_from_dev (dev );
2569
2555
const u32 supported_flags = IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
2570
2556
IOMMU_HWPT_ALLOC_PASID ;
@@ -2577,20 +2563,19 @@ amd_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
2577
2563
if (!amd_iommu_pasid_supported ())
2578
2564
return ERR_PTR (- EOPNOTSUPP );
2579
2565
2580
- return do_iommu_domain_alloc (type , dev , flags , AMD_IOMMU_V2 );
2566
+ return do_iommu_domain_alloc (dev , flags , AMD_IOMMU_V2 );
2581
2567
}
2582
2568
2583
2569
/* Allocate domain with v1 page table for dirty tracking */
2584
2570
if (flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING ) {
2585
2571
if (amd_iommu_hd_support (iommu ))
2586
- return do_iommu_domain_alloc (type , dev , flags ,
2587
- AMD_IOMMU_V1 );
2572
+ return do_iommu_domain_alloc (dev , flags , AMD_IOMMU_V1 );
2588
2573
2589
2574
return ERR_PTR (- EOPNOTSUPP );
2590
2575
}
2591
2576
2592
2577
/* If nothing specific is required use the kernel commandline default */
2593
- return do_iommu_domain_alloc (type , dev , 0 , amd_iommu_pgtable );
2578
+ return do_iommu_domain_alloc (dev , 0 , amd_iommu_pgtable );
2594
2579
}
2595
2580
2596
2581
void amd_iommu_domain_free (struct iommu_domain * dom )
0 commit comments