Skip to content

Commit a11661a

Browse files
Shameer Kolothumjoergroedel
authored andcommitted
iommufd: Report ATS not supported status via IOMMU_GET_HW_INFO
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>
1 parent a82efb8 commit a11661a

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/iommu/iommufd/device.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,10 @@ int iommufd_get_hw_info(struct iommufd_ucmd *ucmd)
16241624
if (device_iommu_capable(idev->dev, IOMMU_CAP_DIRTY_TRACKING))
16251625
cmd->out_capabilities |= IOMMU_HW_CAP_DIRTY_TRACKING;
16261626

1627+
/* Report when ATS cannot be used for this device */
1628+
if (!device_iommu_capable(idev->dev, IOMMU_CAP_PCI_ATS_SUPPORTED))
1629+
cmd->out_capabilities |= IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED;
1630+
16271631
cmd->out_max_pasid_log2 = 0;
16281632
/*
16291633
* Currently, all iommu drivers enable PASID in the probe_device()

include/uapi/linux/iommufd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,15 @@ enum iommu_hw_info_type {
695695
* @IOMMU_HW_CAP_PCI_PASID_PRIV: Privileged Mode Supported, user ignores it
696696
* when the struct
697697
* iommu_hw_info::out_max_pasid_log2 is zero.
698+
* @IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED: ATS is not supported or cannot be used
699+
* on this device (absence implies ATS
700+
* may be enabled)
698701
*/
699702
enum iommufd_hw_capabilities {
700703
IOMMU_HW_CAP_DIRTY_TRACKING = 1 << 0,
701704
IOMMU_HW_CAP_PCI_PASID_EXEC = 1 << 1,
702705
IOMMU_HW_CAP_PCI_PASID_PRIV = 1 << 2,
706+
IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED = 1 << 3,
703707
};
704708

705709
/**

0 commit comments

Comments
 (0)