iommu/amd: Convert to using amd_io_pgtable
authorSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Tue, 15 Dec 2020 07:36:56 +0000 (01:36 -0600)
committerJoerg Roedel <jroedel@suse.de>
Thu, 28 Jan 2021 15:51:17 +0000 (16:51 +0100)
Make use of the new struct amd_io_pgtable in preparation to remove
the struct domain_pgtable.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Link: https://lore.kernel.org/r/20201215073705.123786-5-suravee.suthikulpanit@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/amd_iommu.h
drivers/iommu/amd/iommu.c

index b8dae3941f0fd8765ca31006d4645a05ce5d31c2..bf9723b35e7742880e5fa34f1b094d907e64d8d6 100644 (file)
@@ -56,6 +56,7 @@ extern void amd_iommu_domain_direct_map(struct iommu_domain *dom);
 extern int amd_iommu_domain_enable_v2(struct iommu_domain *dom, int pasids);
 extern int amd_iommu_flush_page(struct iommu_domain *dom, u32 pasid,
                                u64 address);
+extern void amd_iommu_update_and_flush_device_table(struct protection_domain *domain);
 extern int amd_iommu_flush_tlb(struct iommu_domain *dom, u32 pasid);
 extern int amd_iommu_domain_set_gcr3(struct iommu_domain *dom, u32 pasid,
                                     unsigned long cr3);
index 2a4730380462eeeb5234e3ea6edae3710c487ae8..763efee815245b83aa4d251ccd3862e4f75dfc5a 100644 (file)
@@ -88,8 +88,6 @@ struct kmem_cache *amd_iommu_irq_cache;
 
 static void update_domain(struct protection_domain *domain);
 static void detach_device(struct device *dev);
-static void update_and_flush_device_table(struct protection_domain *domain,
-                                         struct domain_pgtable *pgtable);
 
 /****************************************************************************
  *
@@ -1501,7 +1499,7 @@ static bool increase_address_space(struct protection_domain *domain,
 
        pgtable.root  = pte;
        pgtable.mode += 1;
-       update_and_flush_device_table(domain, &pgtable);
+       amd_iommu_update_and_flush_device_table(domain);
        domain_flush_complete(domain);
 
        /*
@@ -1876,17 +1874,16 @@ static void free_gcr3_table(struct protection_domain *domain)
 }
 
 static void set_dte_entry(u16 devid, struct protection_domain *domain,
-                         struct domain_pgtable *pgtable,
                          bool ats, bool ppr)
 {
        u64 pte_root = 0;
        u64 flags = 0;
        u32 old_domid;
 
-       if (pgtable->mode != PAGE_MODE_NONE)
-               pte_root = iommu_virt_to_phys(pgtable->root);
+       if (domain->iop.mode != PAGE_MODE_NONE)
+               pte_root = iommu_virt_to_phys(domain->iop.root);
 
-       pte_root |= (pgtable->mode & DEV_ENTRY_MODE_MASK)
+       pte_root |= (domain->iop.mode & DEV_ENTRY_MODE_MASK)
                    << DEV_ENTRY_MODE_SHIFT;
        pte_root |= DTE_FLAG_IR | DTE_FLAG_IW | DTE_FLAG_V | DTE_FLAG_TV;
 
@@ -1976,7 +1973,7 @@ static void do_attach(struct iommu_dev_data *dev_data,
 
        /* Update device table */
        amd_iommu_domain_get_pgtable(domain, &pgtable);
-       set_dte_entry(dev_data->devid, domain, &pgtable,
+       set_dte_entry(dev_data->devid, domain,
                      ats, dev_data->iommu_v2);
        clone_aliases(dev_data->pdev);
 
@@ -2283,22 +2280,20 @@ static int amd_iommu_domain_get_attr(struct iommu_domain *domain,
  *
  *****************************************************************************/
 
-static void update_device_table(struct protection_domain *domain,
-                               struct domain_pgtable *pgtable)
+static void update_device_table(struct protection_domain *domain)
 {
        struct iommu_dev_data *dev_data;
 
        list_for_each_entry(dev_data, &domain->dev_list, list) {
-               set_dte_entry(dev_data->devid, domain, pgtable,
+               set_dte_entry(dev_data->devid, domain,
                              dev_data->ats.enabled, dev_data->iommu_v2);
                clone_aliases(dev_data->pdev);
        }
 }
 
-static void update_and_flush_device_table(struct protection_domain *domain,
-                                         struct domain_pgtable *pgtable)
+void amd_iommu_update_and_flush_device_table(struct protection_domain *domain)
 {
-       update_device_table(domain, pgtable);
+       update_device_table(domain);
        domain_flush_devices(domain);
 }
 
@@ -2308,7 +2303,7 @@ static void update_domain(struct protection_domain *domain)
 
        /* Update device table */
        amd_iommu_domain_get_pgtable(domain, &pgtable);
-       update_and_flush_device_table(domain, &pgtable);
+       amd_iommu_update_and_flush_device_table(domain);
 
        /* Flush domain TLB(s) and wait for completion */
        domain_flush_tlb_pde(domain);