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 | 10 ++++++++++ backends/iommufd.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/include/system/host_iommu_device.h b/include/system/host_iommu_device.h index f000301583..5615d6cb57 100644 --- a/include/system/host_iommu_device.h +++ b/include/system/host_iommu_device.h @@ -133,6 +133,16 @@ struct HostIOMMUDeviceClass { * Returns: true on success, false on failure. */ bool (*get_pasid_info)(HostIOMMUDevice *hiod, PasidInfo *pasid_info); + /** + * @support_ats: Return whether ATS is supported for the device + * associated with @hiod host IOMMU device, checking if the + * IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED capability bit is set. + * + * @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[] = { -- 2.43.0
