]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
pcie: Helper function to check if ATS is enabled
authorCLEMENT MATHIEU--DRIF <clement.mathieu--drif@eviden.com>
Tue, 20 May 2025 07:18:52 +0000 (07:18 +0000)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 1 Jun 2025 10:38:53 +0000 (06:38 -0400)
ats_enabled checks whether the capability is
present or not. If so, we read the configuration space to get
the status of the feature (enabled or not).

Signed-off-by: Clement Mathieu--Drif <clement.mathieu--drif@eviden.com>
Message-Id: <20250520071823.764266-4-clement.mathieu--drif@eviden.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/pci/pcie.c
include/hw/pci/pcie.h

index db9756d8619a6bedba3c57cf7f4b8968521f97a1..36de709801437ea5afdb930ecf9f9be1fc7bbd33 100644 (file)
@@ -1248,3 +1248,12 @@ bool pcie_pasid_enabled(const PCIDevice *dev)
     return (pci_get_word(dev->config + dev->exp.pasid_cap + PCI_PASID_CTRL) &
                 PCI_PASID_CTRL_ENABLE) != 0;
 }
+
+bool pcie_ats_enabled(const PCIDevice *dev)
+{
+    if (!pci_is_express(dev) || !dev->exp.ats_cap) {
+        return false;
+    }
+    return (pci_get_word(dev->config + dev->exp.ats_cap + PCI_ATS_CTRL) &
+                PCI_ATS_CTRL_ENABLE) != 0;
+}
index dff98ff2c6755a5354a5c7e66a5d0993a675cf4b..497d0bc2d2d5a5ab47536f9eb148997b06058ace 100644 (file)
@@ -156,4 +156,5 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width,
                      bool exec_perm, bool priv_mod);
 
 bool pcie_pasid_enabled(const PCIDevice *dev);
+bool pcie_ats_enabled(const PCIDevice *dev);
 #endif /* QEMU_PCIE_H */