On 6/15/26 22:48, Nathan Chen wrote:
From: Nathan Chen <[email protected]>

Introduce a support_ats() handler that returns whether ATS is supported
for a device associated with a host IOMMU device, checking if the
IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED capability bit is set.

Implement this handler in a new function for iommufd.

Suggested-by: Shameer Kolothum <[email protected]>
Signed-off-by: Nathan Chen <[email protected]>
---
  include/system/host_iommu_device.h | 9 +++++++++
  backends/iommufd.c                 | 8 ++++++++
  2 files changed, 17 insertions(+)

diff --git a/include/system/host_iommu_device.h 
b/include/system/host_iommu_device.h
index f000301583..2cb5365340 100644
--- a/include/system/host_iommu_device.h
+++ b/include/system/host_iommu_device.h
@@ -133,6 +133,15 @@ struct HostIOMMUDeviceClass {
       * Returns: true on success, false on failure.
       */
      bool (*get_pasid_info)(HostIOMMUDevice *hiod, PasidInfo *pasid_info);
+    /**
+     *  @support_ats: Returns true if ATS can be used by the device,
+     *  false if the host IOMMU reports it is unavailable.
+     *
+     *  @hiod: handle to the host IOMMU device
+     *
+     *  Returns: true if ATS is supported, false otherwise
+     */
+    bool (*support_ats)(HostIOMMUDevice *hiod);
  };
/*
diff --git a/backends/iommufd.c b/backends/iommufd.c
index 410b044370..7cc6767b4b 100644
--- a/backends/iommufd.c
+++ b/backends/iommufd.c
@@ -573,6 +573,13 @@ static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int 
cap, Error **errp)
      }
  }
+static bool hiod_iommufd_support_ats(HostIOMMUDevice *hiod)
+{
+    HostIOMMUDeviceCaps *caps = &hiod->caps;
+
+    return !(caps->hw_caps & IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED);
+}
+
  static bool hiod_iommufd_get_pasid_info(HostIOMMUDevice *hiod,
                                          PasidInfo *pasid_info)
  {
@@ -595,6 +602,7 @@ static void hiod_iommufd_class_init(ObjectClass *oc, const 
void *data)
hiodc->get_cap = hiod_iommufd_get_cap;
      hiodc->get_pasid_info = hiod_iommufd_get_pasid_info;
+    hiodc->support_ats = hiod_iommufd_support_ats;
  };
static const TypeInfo types[] = {

Reviewed-by: Cédric Le Goater <[email protected]>

Thanks,

C.


Reply via email to