[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] PCI: pass pdev to pci_ats_{device,enabled}()



commit 6ada70ef0f124bd7d10590bb44f8092bac63c859
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Jan 13 12:33:53 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Jan 13 12:33:53 2026 +0100

    PCI: pass pdev to pci_ats_{device,enabled}()
    
    This not only brings both in sync with {en,dis}able_ats_device() but also
    prepares for doing the same to pci_find_{,next_}ext_capability().
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
 xen/drivers/passthrough/amd/iommu_cmd.c     |  2 +-
 xen/drivers/passthrough/amd/pci_amd_iommu.c |  8 +++-----
 xen/drivers/passthrough/ats.h               | 12 +++++-------
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_cmd.c 
b/xen/drivers/passthrough/amd/iommu_cmd.c
index 6b80c57f44..665e882a2d 100644
--- a/xen/drivers/passthrough/amd/iommu_cmd.c
+++ b/xen/drivers/passthrough/amd/iommu_cmd.c
@@ -285,7 +285,7 @@ void amd_iommu_flush_iotlb(u8 devfn, const struct pci_dev 
*pdev,
     if ( !ats_enabled )
         return;
 
-    if ( !pci_ats_enabled(pdev->seg, pdev->bus, pdev->devfn) )
+    if ( !pci_ats_enabled(pdev) )
         return;
 
     iommu = find_iommu_for_device(pdev->sbdf);
diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c 
b/xen/drivers/passthrough/amd/pci_amd_iommu.c
index 3a14770855..5d4e8edbe8 100644
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -121,7 +121,7 @@ static bool use_ats(
 {
     return !ivrs_dev->block_ats &&
            iommu_has_cap(iommu, PCI_CAP_IOTLB_SHIFT) &&
-           pci_ats_device(iommu->sbdf.seg, pdev->bus, pdev->devfn);
+           pci_ats_device(pdev);
 }
 
 static int __must_check amd_iommu_setup_domain_device(
@@ -274,8 +274,7 @@ static int __must_check amd_iommu_setup_domain_device(
 
     ASSERT(pcidevs_locked());
 
-    if ( use_ats(pdev, iommu, ivrs_dev) &&
-         !pci_ats_enabled(iommu->sbdf.seg, bus, pdev->devfn) )
+    if ( use_ats(pdev, iommu, ivrs_dev) && !pci_ats_enabled(pdev) )
     {
         if ( devfn == pdev->devfn )
             enable_ats_device(pdev, &iommu->ats_devices);
@@ -418,8 +417,7 @@ static void amd_iommu_disable_domain_device(const struct 
domain *domain,
 
     ASSERT(pcidevs_locked());
 
-    if ( pci_ats_device(iommu->sbdf.seg, bus, pdev->devfn) &&
-         pci_ats_enabled(iommu->sbdf.seg, bus, pdev->devfn) )
+    if ( pci_ats_device(pdev) && pci_ats_enabled(pdev) )
         disable_ats_device(pdev);
 
     BUG_ON ( iommu->dev_table.buffer == NULL );
diff --git a/xen/drivers/passthrough/ats.h b/xen/drivers/passthrough/ats.h
index 68b1c600eb..2da255dabe 100644
--- a/xen/drivers/passthrough/ats.h
+++ b/xen/drivers/passthrough/ats.h
@@ -27,27 +27,25 @@ extern bool ats_enabled;
 int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list);
 void disable_ats_device(struct pci_dev *pdev);
 
-static inline int pci_ats_enabled(int seg, int bus, int devfn)
+static inline int pci_ats_enabled(const struct pci_dev *pdev)
 {
     u32 value;
     int pos;
 
-    pos = pci_find_ext_capability(PCI_SBDF(seg, bus, devfn),
-                                  PCI_EXT_CAP_ID_ATS);
+    pos = pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS);
     BUG_ON(!pos);
 
-    value = pci_conf_read16(PCI_SBDF(seg, bus, devfn), pos + ATS_REG_CTL);
+    value = pci_conf_read16(pdev->sbdf, pos + ATS_REG_CTL);
 
     return value & ATS_ENABLE;
 }
 
-static inline int pci_ats_device(int seg, int bus, int devfn)
+static inline int pci_ats_device(const struct pci_dev *pdev)
 {
     if ( !ats_enabled )
         return 0;
 
-    return pci_find_ext_capability(PCI_SBDF(seg, bus, devfn),
-                                   PCI_EXT_CAP_ID_ATS);
+    return pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS);
 }
 
 #endif /* DRIVERS__PASSTHROUGH__ATS_H */
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.