From: Vidya Sagar <vidyas@nvidia.com>
To: <rafael@kernel.org>, <lenb@kernel.org>, <saket.dumbre@intel.com>,
<lpieralisi@kernel.org>, <guohanjun@huawei.com>,
<sudeep.holla@kernel.org>, <will@kernel.org>,
<catalin.marinas@arm.com>, <joro@8bytes.org>,
<robin.murphy@arm.com>, <jgg@ziepe.ca>, <nicolinc@nvidia.com>,
<praan@google.com>
Cc: <vsethi@nvidia.com>, <sdonthineni@nvidia.com>,
<kthota@nvidia.com>, <sagar.tv@gmail.com>,
<linux-acpi@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<acpica-devel@lists.linux.dev>, <iommu@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, Vidya Sagar <vidyas@nvidia.com>
Subject: [PATCH V1 3/3] iommu/arm-smmu-v3: Honor IORT Root Complex PASID descriptors
Date: Fri, 24 Apr 2026 00:44:17 +0530 [thread overview]
Message-ID: <20260423191417.2031652-4-vidyas@nvidia.com> (raw)
In-Reply-To: <20260423191417.2031652-1-vidyas@nvidia.com>
The SMMUv3 driver currently calls pci_enable_pasid() for any PCI
master that exposes a PASID capability, regardless of whether the
upstream Root Complex actually supports PASID and regardless of the
RC's declared Max PASID Width. With IORT spec E.c (RC node revision
>= 4) firmware reports both, so we can do better:
- If the IORT Root Complex node says PASID is not supported
(Flags bit 0 == 0 at byte offset 36), enabling PASID on the
endpoint is futile - the RC will not forward the PASID prefix to
the SMMU - so skip pci_enable_pasid() silently.
- If the IORT Root Complex node reports a Max PASID Width (bits[4:0]
of PASID Capabilities at offset 33), clamp the endpoint's
pci_max_pasids() result by 1 << width before computing the SMMU
SSID width. This prevents master->ssid_bits from exceeding what
the RC can actually carry.
Both behaviours are gated on iort_pci_rc_pasid_max_width_known(), i.e.
RC node revision >= 4, so platforms with older IORT firmware see no
behavioural change and continue to enable PASID purely on the basis
of the endpoint capability.
Use the new IOMMU_FWSPEC_PCI_RC_PASID fwspec flag (set by IORT) for
the support check, and call iort_pci_rc_pasid_max_width_for_dev() for
the width clamp; both pieces are wired up in
iort_iommu_configure_id() by the previous patch.
Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 26 ++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
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 e8d7dbe495f0..2b269307fd33 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -3071,16 +3071,28 @@ static void arm_smmu_enable_ats(struct arm_smmu_master *master)
static int arm_smmu_enable_pasid(struct arm_smmu_master *master)
{
- int ret;
- int features;
- int num_pasids;
+ struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(master->dev);
struct pci_dev *pdev;
+ int features, num_pasids, ret, rc_width;
if (!dev_is_pci(master->dev))
return -ENODEV;
pdev = to_pci_dev(master->dev);
+ /*
+ * IORT E.c (RC node revision >= 4) reports whether the root
+ * complex actually supports PASID. If it does not, enabling
+ * PASID on the endpoint is futile - the RC will not forward
+ * the PASID prefix - so skip silently. Older firmware is
+ * treated as "unknown / assume supported" to preserve the
+ * pre-E.c behaviour.
+ */
+ if (fwspec &&
+ !(fwspec->flags & IOMMU_FWSPEC_PCI_RC_PASID) &&
+ iort_pci_rc_pasid_max_width_known(master->dev))
+ return 0;
+
features = pci_pasid_features(pdev);
if (features < 0)
return features;
@@ -3089,6 +3101,14 @@ static int arm_smmu_enable_pasid(struct arm_smmu_master *master)
if (num_pasids <= 0)
return num_pasids;
+ /* Clamp by what the root complex can carry, when known. */
+ rc_width = iort_pci_rc_pasid_max_width_for_dev(master->dev);
+ if (rc_width >= 0)
+ num_pasids = min_t(int, num_pasids, 1 << rc_width);
+
+ if (num_pasids <= 1)
+ return 0;
+
ret = pci_enable_pasid(pdev, features);
if (ret) {
dev_err(&pdev->dev, "Failed to enable PASID\n");
--
2.25.1
prev parent reply other threads:[~2026-04-23 19:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 19:14 [PATCH V1 0/3] ACPI/IORT: Honor Root Complex PASID descriptors on SMMUv3 Vidya Sagar
2026-04-23 19:14 ` [PATCH V1 1/3] ACPICA: IORT: Add Root Complex PASID Flags field Vidya Sagar
2026-04-23 19:14 ` [PATCH V1 2/3] ACPI/IORT: Plumb Root Complex PASID descriptors into iommu_fwspec Vidya Sagar
2026-04-23 19:14 ` Vidya Sagar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260423191417.2031652-4-vidyas@nvidia.com \
--to=vidyas@nvidia.com \
--cc=acpica-devel@lists.linux.dev \
--cc=catalin.marinas@arm.com \
--cc=guohanjun@huawei.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kthota@nvidia.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=nicolinc@nvidia.com \
--cc=praan@google.com \
--cc=rafael@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sagar.tv@gmail.com \
--cc=saket.dumbre@intel.com \
--cc=sdonthineni@nvidia.com \
--cc=sudeep.holla@kernel.org \
--cc=vsethi@nvidia.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox