iommu/amd: Pass struct iommu_dev_data to set_dte_entry()
authorVasant Hegde <vasant.hegde@amd.com>
Mon, 5 Feb 2024 11:55:59 +0000 (11:55 +0000)
committerJoerg Roedel <jroedel@suse.de>
Fri, 9 Feb 2024 12:16:21 +0000 (13:16 +0100)
Pass iommu_dev_data structure instead of passing indivisual variables.

No functional changes intended.

Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20240205115615.6053-2-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/iommu.c

index 2e50f116672f478b9c74dd3d26550fa66b2fee5b..743465cb677f68c1b414c46d40f860d3e72c1491 100644 (file)
@@ -1700,12 +1700,14 @@ static int setup_gcr3_table(struct protection_domain *domain, int pasids)
        return 0;
 }
 
-static void set_dte_entry(struct amd_iommu *iommu, u16 devid,
-                         struct protection_domain *domain, bool ats, bool ppr)
+static void set_dte_entry(struct amd_iommu *iommu,
+                         struct iommu_dev_data *dev_data)
 {
        u64 pte_root = 0;
        u64 flags = 0;
        u32 old_domid;
+       u16 devid = dev_data->devid;
+       struct protection_domain *domain = dev_data->domain;
        struct dev_table_entry *dev_table = get_dev_table(iommu);
 
        if (domain->iop.mode != PAGE_MODE_NONE)
@@ -1725,10 +1727,10 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 devid,
 
        flags = dev_table[devid].data[1];
 
-       if (ats)
+       if (dev_data->ats_enabled)
                flags |= DTE_FLAG_IOTLB;
 
-       if (ppr)
+       if (dev_data->ppr)
                pte_root |= 1ULL << DEV_ENTRY_PPR;
 
        if (domain->dirty_tracking)
@@ -1804,12 +1806,10 @@ static void do_attach(struct iommu_dev_data *dev_data,
                      struct protection_domain *domain)
 {
        struct amd_iommu *iommu;
-       bool ats;
 
        iommu = rlookup_amd_iommu(dev_data->dev);
        if (!iommu)
                return;
-       ats   = dev_data->ats_enabled;
 
        /* Update data structures */
        dev_data->domain = domain;
@@ -1824,8 +1824,7 @@ static void do_attach(struct iommu_dev_data *dev_data,
        domain->dev_cnt                 += 1;
 
        /* Update device table */
-       set_dte_entry(iommu, dev_data->devid, domain,
-                     ats, dev_data->ppr);
+       set_dte_entry(iommu, dev_data);
        clone_aliases(iommu, dev_data->dev);
 
        device_flush_dte(dev_data);
@@ -2008,8 +2007,7 @@ static void update_device_table(struct protection_domain *domain)
 
                if (!iommu)
                        continue;
-               set_dte_entry(iommu, dev_data->devid, domain,
-                             dev_data->ats_enabled, dev_data->ppr);
+               set_dte_entry(iommu, dev_data);
                clone_aliases(iommu, dev_data->dev);
        }
 }