@@ -2455,7 +2455,7 @@ static void protection_domain_init(struct protection_domain *domain, int nid)
24552455 domain -> iop .pgtbl .cfg .amd .nid = nid ;
24562456}
24572457
2458- struct protection_domain * protection_domain_alloc (unsigned int type , int nid )
2458+ struct protection_domain * protection_domain_alloc (int nid )
24592459{
24602460 struct protection_domain * domain ;
24612461 int domid ;
@@ -2476,15 +2476,10 @@ struct protection_domain *protection_domain_alloc(unsigned int type, int nid)
24762476 return domain ;
24772477}
24782478
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 )
24812480{
24822481 struct io_pgtable_ops * pgtbl_ops ;
24832482
2484- /* No need to allocate io pgtable ops in passthrough mode */
2485- if (!(type & __IOMMU_DOMAIN_PAGING ))
2486- return 0 ;
2487-
24882483 switch (pgtable ) {
24892484 case AMD_IOMMU_V1 :
24902485 domain -> pd_mode = PD_MODE_V1 ;
@@ -2518,27 +2513,19 @@ static bool amd_iommu_hd_support(struct amd_iommu *iommu)
25182513 return iommu && (iommu -> features & FEATURE_HDSUP );
25192514}
25202515
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 )
25242518{
25252519 bool dirty_tracking = flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING ;
25262520 struct amd_iommu * iommu = get_amd_iommu_from_dev (dev );
25272521 struct protection_domain * domain ;
25282522 int ret ;
25292523
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 ));
25382525 if (!domain )
25392526 return ERR_PTR (- ENOMEM );
25402527
2541- ret = pdom_setup_pgtable (domain , type , pgtable );
2528+ ret = pdom_setup_pgtable (domain , pgtable );
25422529 if (ret ) {
25432530 pdom_id_free (domain -> id );
25442531 kfree (domain );
@@ -2550,7 +2537,7 @@ static struct iommu_domain *do_iommu_domain_alloc(unsigned int type,
25502537 domain -> domain .geometry .force_aperture = true;
25512538 domain -> domain .pgsize_bitmap = domain -> iop .pgtbl .cfg .pgsize_bitmap ;
25522539
2553- domain -> domain .type = type ;
2540+ domain -> domain .type = IOMMU_DOMAIN_UNMANAGED ;
25542541 domain -> domain .ops = iommu -> iommu .ops -> default_domain_ops ;
25552542
25562543 if (dirty_tracking )
@@ -2564,7 +2551,6 @@ amd_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
25642551 const struct iommu_user_data * user_data )
25652552
25662553{
2567- unsigned int type = IOMMU_DOMAIN_UNMANAGED ;
25682554 struct amd_iommu * iommu = get_amd_iommu_from_dev (dev );
25692555 const u32 supported_flags = IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
25702556 IOMMU_HWPT_ALLOC_PASID ;
@@ -2577,20 +2563,19 @@ amd_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
25772563 if (!amd_iommu_pasid_supported ())
25782564 return ERR_PTR (- EOPNOTSUPP );
25792565
2580- return do_iommu_domain_alloc (type , dev , flags , AMD_IOMMU_V2 );
2566+ return do_iommu_domain_alloc (dev , flags , AMD_IOMMU_V2 );
25812567 }
25822568
25832569 /* Allocate domain with v1 page table for dirty tracking */
25842570 if (flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING ) {
25852571 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 );
25882573
25892574 return ERR_PTR (- EOPNOTSUPP );
25902575 }
25912576
25922577 /* 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 );
25942579}
25952580
25962581void amd_iommu_domain_free (struct iommu_domain * dom )
0 commit comments