]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommufd: Report ATS not supported status via IOMMU_GET_HW_INFO
authorShameer Kolothum <skolothumtho@nvidia.com>
Tue, 17 Mar 2026 11:16:03 +0000 (11:16 +0000)
committerJoerg Roedel <joerg.roedel@amd.com>
Tue, 17 Mar 2026 13:05:05 +0000 (14:05 +0100)
If the IOMMU driver reports that ATS is not supported for a device, set
the IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED flag in the returned hardware
capabilities.

This uses a negative flag for UAPI compatibility. Existing userspace
assumes ATS is supported if no flag is present. This also ensures that
new userspace works correctly on both old and new kernels, where a
zero value implies ATS support.

When this flag is set, ATS cannot be used for the device. When it is
clear, ATS may be enabled when an appropriate HWPT is attached.

Reviewed-by: Samiullah Khawaja <skhawaja@google.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/iommufd/device.c
include/uapi/linux/iommufd.h

index 344d620cdecc46a2557ccfedd5b4cb86d8c4e425..92c5d5ef8d0091ef1027a7ea99ea9a16dcb44482 100644 (file)
@@ -1624,6 +1624,10 @@ int iommufd_get_hw_info(struct iommufd_ucmd *ucmd)
        if (device_iommu_capable(idev->dev, IOMMU_CAP_DIRTY_TRACKING))
                cmd->out_capabilities |= IOMMU_HW_CAP_DIRTY_TRACKING;
 
+       /* Report when ATS cannot be used for this device */
+       if (!device_iommu_capable(idev->dev, IOMMU_CAP_PCI_ATS_SUPPORTED))
+               cmd->out_capabilities |= IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED;
+
        cmd->out_max_pasid_log2 = 0;
        /*
         * Currently, all iommu drivers enable PASID in the probe_device()
index 1dafbc552d37de51a93a23d9ce1cf3db7abbbc85..507ee9bcba01ffd7bc3b1698d34511a230deb7f1 100644 (file)
@@ -695,11 +695,15 @@ enum iommu_hw_info_type {
  * @IOMMU_HW_CAP_PCI_PASID_PRIV: Privileged Mode Supported, user ignores it
  *                               when the struct
  *                               iommu_hw_info::out_max_pasid_log2 is zero.
+ * @IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED: ATS is not supported or cannot be used
+ *                                      on this device (absence implies ATS
+ *                                      may be enabled)
  */
 enum iommufd_hw_capabilities {
        IOMMU_HW_CAP_DIRTY_TRACKING = 1 << 0,
        IOMMU_HW_CAP_PCI_PASID_EXEC = 1 << 1,
        IOMMU_HW_CAP_PCI_PASID_PRIV = 1 << 2,
+       IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED = 1 << 3,
 };
 
 /**