@samitouri / QOSamiQemu / commits / 6befa55274

iommufd: Introduce handler for device ATS support

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 <skolothumtho@nvidia.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Shameer Kolothum <skolothumtho@nvidia.com> Signed-off-by: Nathan Chen <nathanc@nvidia.com> Link: https://lore.kernel.org/qemu-devel/20260623204943.989903-2-nathanc@nvidia.com Signed-off-by: Cédric Le Goater <clg@redhat.com>

Nathan Chen committed Jun 23, 2026 at 13:49 UTC 6befa5527418bcece6a81adb5e047bae43b733bf
2 files changed +17
backends/iommufd.c
+8
@@ -638,6 +638,13 @@ static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp)
638 }
639 }
640
641 +static bool hiod_iommufd_support_ats(HostIOMMUDevice *hiod)
642 +{
643 + HostIOMMUDeviceCaps *caps = &hiod->caps;
644 +
645 + return !(caps->hw_caps & IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED);
646 +}
647 +
648 static bool hiod_iommufd_get_pasid_info(HostIOMMUDevice *hiod,
649 PasidInfo *pasid_info)
650 {
@@ -660,6 +667,7 @@ static void hiod_iommufd_class_init(ObjectClass *oc, const void *data)
667
668 hiodc->get_cap = hiod_iommufd_get_cap;
669 hiodc->get_pasid_info = hiod_iommufd_get_pasid_info;
670 + hiodc->support_ats = hiod_iommufd_support_ats;
671 };
672
673 static const TypeInfo types[] = {
include/system/host_iommu_device.h
+9
@@ -133,6 +133,15 @@ struct HostIOMMUDeviceClass {
133 * Returns: true on success, false on failure.
134 */
135 bool (*get_pasid_info)(HostIOMMUDevice *hiod, PasidInfo *pasid_info);
136 + /**
137 + * @support_ats: Returns true if ATS can be used by the device,
138 + * false if the host IOMMU reports it is unavailable.
139 + *
140 + * @hiod: handle to the host IOMMU device
141 + *
142 + * Returns: true if ATS is supported, false otherwise
143 + */
144 + bool (*support_ats)(HostIOMMUDevice *hiod);
145 };
146
147 /*