mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] iommu: Report effective PCIe ATS support status
@ 2026-03-17 11:16 Shameer Kolothum
  2026-03-17 11:16 ` [PATCH v2 1/2] iommu: Add device ATS supported capability Shameer Kolothum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shameer Kolothum @ 2026-03-17 11:16 UTC (permalink / raw)
  To: iommu, linux-kernel
  Cc: joro, will, robin.murphy, baolu.lu, jgg, kevin.tian, skhawaja,
	nicolinc, nathanc, mochs, kjaju, skolothumtho

Hi,

Changes from v1:
 https://lore.kernel.org/all/20260303150348.233997-1-skolothumtho@nvidia.com/
 - Addressed feedback and picked up R-by tags. Thanks!
 - Inverted flag to IOMMU_CAP_PCI_ATS_SUPPORTED for IOMMU drivers(patch #1).
 - Updated comments and commit messages to clarify the semantics.

---

PCIe ATS may be disabled by platform firmware, root complex limitations,
or host kernel policy, even when a device advertises the ATS capability
in its PCI config space.

Userspace currently cannot determine whether ATS is effectively supported
for a device. This may lead to incorrect assumptions when ATS appears
present in PCI config space but is disabled by the platform, e.g., in use
cases such as VFIO device pass-through.

This series introduces a new IOMMU capability, IOMMU_CAP_PCI_ATS_SUPPORTED,
to allow drivers to report the effective ATS decision for a device. It also
extends iommufd to expose this information via IOMMU_GET_HW_INFO.

For UAPI compatibility, the iommufd interface exposes this as a negative
capability, IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED. On older kernels the flag
will be absent, and userspace will retain the existing behaviour (i.e.
assume ATS is usable if advertised via PCIe CAP).

Please see the related QEMU discussion for SMMUv3 accelerator use case
here[0].

Please take a look and let me know.

Thanks,
Shameer

[0] https://lore.kernel.org/qemu-devel/CH3PR12MB7548515EDA96BD03F64DCAA2AB62A@CH3PR12MB7548.namprd12.prod.outlook.com/

Shameer Kolothum (2):
  iommu: Add device ATS supported capability
  iommufd: Report ATS not supported status via IOMMU_GET_HW_INFO

 include/linux/iommu.h                       | 2 ++
 include/uapi/linux/iommufd.h                | 4 ++++
 drivers/iommu/amd/iommu.c                   | 6 ++++++
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 +++
 drivers/iommu/intel/iommu.c                 | 2 ++
 drivers/iommu/iommufd/device.c              | 4 ++++
 6 files changed, 21 insertions(+)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] iommu: Add device ATS supported capability
  2026-03-17 11:16 [PATCH v2 0/2] iommu: Report effective PCIe ATS support status Shameer Kolothum
@ 2026-03-17 11:16 ` Shameer Kolothum
  2026-03-17 11:16 ` [PATCH v2 2/2] iommufd: Report ATS not supported status via IOMMU_GET_HW_INFO Shameer Kolothum
  2026-03-17 13:05 ` [PATCH v2 0/2] iommu: Report effective PCIe ATS support status Jörg Rödel
  2 siblings, 0 replies; 4+ messages in thread
From: Shameer Kolothum @ 2026-03-17 11:16 UTC (permalink / raw)
  To: iommu, linux-kernel
  Cc: joro, will, robin.murphy, baolu.lu, jgg, kevin.tian, skhawaja,
	nicolinc, nathanc, mochs, kjaju, skolothumtho, Jason Gunthorpe

PCIe ATS may be disabled by platform firmware, root complex limitations,
or kernel policy even when a device advertises the ATS capability in its
PCI configuration space.

Add a new IOMMU_CAP_PCI_ATS_SUPPORTED capability to allow IOMMU drivers
to report the effective ATS decision for a device.

When this capability is true for a device, ATS may be enabled for that
device, but it does not imply that ATS is currently enabled.

A subsequent patch will extend iommufd to expose the effective ATS
status to userspace.

Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com>
---
 include/linux/iommu.h                       | 2 ++
 drivers/iommu/amd/iommu.c                   | 6 ++++++
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 +++
 drivers/iommu/intel/iommu.c                 | 2 ++
 4 files changed, 13 insertions(+)

diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 54b8b48c762e..33fa39e17f3c 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -271,6 +271,8 @@ enum iommu_cap {
 	 */
 	IOMMU_CAP_DEFERRED_FLUSH,
 	IOMMU_CAP_DIRTY_TRACKING,	/* IOMMU supports dirty tracking */
+	/* ATS is supported and may be enabled for this device */
+	IOMMU_CAP_PCI_ATS_SUPPORTED,
 };
 
 /* These are the possible reserved region types */
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 81c4d7733872..f1814fee5182 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2985,6 +2985,12 @@ static bool amd_iommu_capable(struct device *dev, enum iommu_cap cap)
 
 		return amd_iommu_hd_support(iommu);
 	}
+	case IOMMU_CAP_PCI_ATS_SUPPORTED: {
+		struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);
+
+		return amd_iommu_iotlb_sup &&
+			 (dev_data->flags & AMD_IOMMU_DEVICE_FLAG_ATS_SUP);
+	}
 	default:
 		break;
 	}
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 4d00d796f078..dec5cac98f7c 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -107,6 +107,7 @@ static const char * const event_class_str[] = {
 };
 
 static int arm_smmu_alloc_cd_tables(struct arm_smmu_master *master);
+static bool arm_smmu_ats_supported(struct arm_smmu_master *master);
 
 static void parse_driver_options(struct arm_smmu_device *smmu)
 {
@@ -2494,6 +2495,8 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap)
 		return true;
 	case IOMMU_CAP_DIRTY_TRACKING:
 		return arm_smmu_dbm_capable(master->smmu);
+	case IOMMU_CAP_PCI_ATS_SUPPORTED:
+		return arm_smmu_ats_supported(master);
 	default:
 		return false;
 	}
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index ef7613b177b9..5dca8e525c73 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -3220,6 +3220,8 @@ static bool intel_iommu_capable(struct device *dev, enum iommu_cap cap)
 		return ecap_sc_support(info->iommu->ecap);
 	case IOMMU_CAP_DIRTY_TRACKING:
 		return ssads_supported(info->iommu);
+	case IOMMU_CAP_PCI_ATS_SUPPORTED:
+		return info->ats_supported;
 	default:
 		return false;
 	}
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] iommufd: Report ATS not supported status via IOMMU_GET_HW_INFO
  2026-03-17 11:16 [PATCH v2 0/2] iommu: Report effective PCIe ATS support status Shameer Kolothum
  2026-03-17 11:16 ` [PATCH v2 1/2] iommu: Add device ATS supported capability Shameer Kolothum
@ 2026-03-17 11:16 ` Shameer Kolothum
  2026-03-17 13:05 ` [PATCH v2 0/2] iommu: Report effective PCIe ATS support status Jörg Rödel
  2 siblings, 0 replies; 4+ messages in thread
From: Shameer Kolothum @ 2026-03-17 11:16 UTC (permalink / raw)
  To: iommu, linux-kernel
  Cc: joro, will, robin.murphy, baolu.lu, jgg, kevin.tian, skhawaja,
	nicolinc, nathanc, mochs, kjaju, skolothumtho, Jason Gunthorpe

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>
---
 include/uapi/linux/iommufd.h   | 4 ++++
 drivers/iommu/iommufd/device.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h
index 1dafbc552d37..507ee9bcba01 100644
--- a/include/uapi/linux/iommufd.h
+++ b/include/uapi/linux/iommufd.h
@@ -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,
 };
 
 /**
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 344d620cdecc..92c5d5ef8d00 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -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()
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] iommu: Report effective PCIe ATS support status
  2026-03-17 11:16 [PATCH v2 0/2] iommu: Report effective PCIe ATS support status Shameer Kolothum
  2026-03-17 11:16 ` [PATCH v2 1/2] iommu: Add device ATS supported capability Shameer Kolothum
  2026-03-17 11:16 ` [PATCH v2 2/2] iommufd: Report ATS not supported status via IOMMU_GET_HW_INFO Shameer Kolothum
@ 2026-03-17 13:05 ` Jörg Rödel
  2 siblings, 0 replies; 4+ messages in thread
From: Jörg Rödel @ 2026-03-17 13:05 UTC (permalink / raw)
  To: Shameer Kolothum
  Cc: iommu, linux-kernel, will, robin.murphy, baolu.lu, jgg,
	kevin.tian, skhawaja, nicolinc, nathanc, mochs, kjaju

On Tue, Mar 17, 2026 at 11:16:01AM +0000, Shameer Kolothum wrote:
> Shameer Kolothum (2):
>   iommu: Add device ATS supported capability
>   iommufd: Report ATS not supported status via IOMMU_GET_HW_INFO
> 
>  include/linux/iommu.h                       | 2 ++
>  include/uapi/linux/iommufd.h                | 4 ++++
>  drivers/iommu/amd/iommu.c                   | 6 ++++++
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 +++
>  drivers/iommu/intel/iommu.c                 | 2 ++
>  drivers/iommu/iommufd/device.c              | 4 ++++
>  6 files changed, 21 insertions(+)

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-17 13:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-17 11:16 [PATCH v2 0/2] iommu: Report effective PCIe ATS support status Shameer Kolothum
2026-03-17 11:16 ` [PATCH v2 1/2] iommu: Add device ATS supported capability Shameer Kolothum
2026-03-17 11:16 ` [PATCH v2 2/2] iommufd: Report ATS not supported status via IOMMU_GET_HW_INFO Shameer Kolothum
2026-03-17 13:05 ` [PATCH v2 0/2] iommu: Report effective PCIe ATS support status Jörg Rödel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®