[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH ats_vtd v5 07/22] pcie: helper functions to check if PASID and AT
From: |
CLEMENT MATHIEU--DRIF |
Subject: |
[PATCH ats_vtd v5 07/22] pcie: helper functions to check if PASID and ATS are enabled |
Date: |
Tue, 2 Jul 2024 05:52:36 +0000 |
From: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
ats_enabled and pasid_enabled check whether the capabilities are
present or not. If so, we read the configuration space to get
the status of the feature (enabled or not).
Signed-off-by: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
---
hw/pci/pcie.c | 18 ++++++++++++++++++
include/hw/pci/pcie.h | 3 +++
2 files changed, 21 insertions(+)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index d6a052b616..4efd84fed5 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -1201,3 +1201,21 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset,
uint8_t pasid_width,
dev->exp.pasid_cap = offset;
}
+
+bool pcie_pasid_enabled(const PCIDevice *dev)
+{
+ if (!pci_is_express(dev) || !dev->exp.pasid_cap) {
+ return false;
+ }
+ 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;
+}
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
index b870958c99..0c127b29dc 100644
--- a/include/hw/pci/pcie.h
+++ b/include/hw/pci/pcie.h
@@ -154,4 +154,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler
*hotplug_dev,
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 */
--
2.45.2
- Re: [PATCH ats_vtd v5 20/22] pci: add a pci-level API for ATS, (continued)
- [PATCH ats_vtd v5 22/22] intel_iommu: add support for ATS, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 21/22] intel_iommu: set the address mask even when a translation fails, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 19/22] memory: add an API for ATS support, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 07/22] pcie: helper functions to check if PASID and ATS are enabled,
CLEMENT MATHIEU--DRIF <=
- [PATCH ats_vtd v5 18/22] atc: add unit tests, CLEMENT MATHIEU--DRIF, 2024/07/02
- Re: [PATCH ats_vtd v5 00/22] ATS support for VT-d, Michael S. Tsirkin, 2024/07/02
- Re: [PATCH ats_vtd v5 00/22] ATS support for VT-d, Yi Liu, 2024/07/02
- Re: [PATCH ats_vtd v5 00/22] ATS support for VT-d, Yi Liu, 2024/07/03