* [PATCH v4 0/1] PCI/ATS: Mandate checking pci_ats_supported() before pci_prepare_ats()
@ 2026-10-01 23:33 Pranjal Shrivastava
2026-10-01 23:33 ` [PATCH v4 1/1] " Pranjal Shrivastava
0 siblings, 1 reply; 3+ messages in thread
From: Pranjal Shrivastava @ 2026-10-01 23:33 UTC (permalink / raw)
To: bhelgaas, linux-pci
Cc: linux-iommu, joerg.roedel, vasant.hegde, baolu.lu, nicolinc, jgg,
skhawaja, Pranjal Shrivastava
Hi Bjorn,
This single-patch submission represents the final core enforcement for the
PCIe ATS robustness hardening effort.
This work was split into two parallel driver-specific consolidation series:
1. Intel & ARM [1]
2. AMD [2]
All the prerequisite driver refactors from both series have now been
merged into the IOMMU tree by Joerg, with the latest merge commit [3].
As the driver-side safety checks are now fully in place, Joerg
requested [4] that this final, PCI core patch be submitted through the
PCIe tree. Hence, I'm sending this as a standalone patch rebased on the
pci tree (for-next branch).
Thanks,
Praan
[1] https://lore.kernel.org/all/20260615235037.259909-1-praan@google.com/
[2] https://lore.kernel.org/all/20260910142655.3281464-1-praan@google.com/
[3] https://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git/commit/?id=622384f54a8415f28bf7cf11cda95ab125488ca1
[4] https://lore.kernel.org/all/arUOoLwpfNlIvIXy@8bytes.org/
Pranjal Shrivastava (1):
PCI/ATS: Mandate checking pci_ats_supported() before pci_prepare_ats()
drivers/pci/ats.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--
2.56.0.rc1.315.gc6ed9934b7-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v4 1/1] PCI/ATS: Mandate checking pci_ats_supported() before pci_prepare_ats()
2026-10-01 23:33 [PATCH v4 0/1] PCI/ATS: Mandate checking pci_ats_supported() before pci_prepare_ats() Pranjal Shrivastava
@ 2026-10-01 23:33 ` Pranjal Shrivastava
2026-10-02 9:14 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Pranjal Shrivastava @ 2026-10-01 23:33 UTC (permalink / raw)
To: bhelgaas, linux-pci
Cc: linux-iommu, joerg.roedel, vasant.hegde, baolu.lu, nicolinc, jgg,
skhawaja, Pranjal Shrivastava
Currently, pci_prepare_ats() internally calls pci_ats_supported() and
returns -EINVAL if the device does not support ATS. While this provides
a silent safety check, it conflates support detection with configuration.
Update pci_prepare_ats() to wrap the internal pci_ats_supported check in
a WARN_ON(). This mandates all callers to call pci_prepare_ats() only if
the function supports ATS.
Update the function documentation to mention that callers must verify
ATS support (via pci_ats_supported()) before calling pci_prepare_ats().
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Suggested-by: Baolu Lu <baolu.lu@linux.intel.com>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Pranjal Shrivastava <praan@google.com>
---
drivers/pci/ats.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
index 9cb23780093d..f1434f86ac40 100644
--- a/drivers/pci/ats.c
+++ b/drivers/pci/ats.c
@@ -56,7 +56,9 @@ EXPORT_SYMBOL_GPL(pci_ats_supported);
* @ps: the IOMMU page shift
*
* This must be done by the IOMMU driver on the PF before any VFs are created to
- * ensure that the VF can have ATS enabled.
+ * ensure that the VF can have ATS enabled. Callers must verify that ATS is
+ * supported by the device (e.g. via pci_ats_supported()) before calling this
+ * function.
*
* Returns 0 on success, or negative on failure.
*/
@@ -64,7 +66,7 @@ int pci_prepare_ats(struct pci_dev *dev, int ps)
{
u16 ctrl;
- if (!pci_ats_supported(dev))
+ if (WARN_ON(!pci_ats_supported(dev)))
return -EINVAL;
if (WARN_ON(dev->ats_enabled))
--
2.56.0.rc1.315.gc6ed9934b7-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v4 1/1] PCI/ATS: Mandate checking pci_ats_supported() before pci_prepare_ats()
2026-10-01 23:33 ` [PATCH v4 1/1] " Pranjal Shrivastava
@ 2026-10-02 9:14 ` sashiko-bot
0 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-02 9:14 UTC (permalink / raw)
To: Pranjal Shrivastava; +Cc: linux-pci
> Currently, pci_prepare_ats() internally calls pci_ats_supported() and
> returns -EINVAL if the device does not support ATS. While this provides
> a silent safety check, it conflates support detection with configuration.
>
> Update pci_prepare_ats() to wrap the internal pci_ats_supported check in
> a WARN_ON(). This mandates all callers to call pci_prepare_ats() only if
> the function supports ATS.
>
> Update the function documentation to mention that callers must verify
> ATS support (via pci_ats_supported()) before calling pci_prepare_ats().
>
> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
> Suggested-by: Baolu Lu <baolu.lu@linux.intel.com>
> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Pranjal Shrivastava <praan@google.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261001233338.918408-1-praan@google.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-02 9:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-01 23:33 [PATCH v4 0/1] PCI/ATS: Mandate checking pci_ats_supported() before pci_prepare_ats() Pranjal Shrivastava
2026-10-01 23:33 ` [PATCH v4 1/1] " Pranjal Shrivastava
2026-10-02 9:14 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox