From: Shyam Saini <shyamsaini@linux.microsoft.com>
To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
devicetree@vger.kernel.org, virtualization@lists.linux.dev
Cc: jgg@ziepe.ca, will@kernel.org, jacob.pan@linux.microsoft.com,
eric.auger@redhat.com, code@tyhicks.com,
eahariha@linux.microsoft.com, vijayb@linux.microsoft.com,
bboscaccy@linux.microsoft.com
Subject: [PATCH v3 2/3] iommu/of: fix device tree configuration for PCI devices
Date: Wed, 6 Aug 2025 14:55:38 -0700 [thread overview]
Message-ID: <20250806215539.1240561-3-shyamsaini@linux.microsoft.com> (raw)
In-Reply-To: <20250806215539.1240561-1-shyamsaini@linux.microsoft.com>
Individual PCI devices lack dedicated device tree nodes, but
their IOMMU configuration (including reserved IOVA regions) is often
defined at the PCI host controller level in the device tree. The
"iommu-addresses" property in reserved-memory nodes specifies IOVA
ranges that should be reserved for specific devices.
Currently, PCI devices cannot access these configurations because their
dev->of_node is NULL, preventing of_iommu_get_resv_regions() from
discovering reserved regions defined in the device tree.
Fix this by assigning the PCI host controller's device tree node to
PCI devices during IOMMU configuration, enabling them to inherit the
host controller's device tree properties. This allows PCI devices to
properly discover and reserve IOVA regions specified in the device tree.
Link: https://lore.kernel.org/linux-iommu/20250529183815.GA236098@ziepe.ca/
Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
---
drivers/iommu/of_iommu.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
index 6b989a62def20..077482917e3e8 100644
--- a/drivers/iommu/of_iommu.c
+++ b/drivers/iommu/of_iommu.c
@@ -145,6 +145,17 @@ int of_iommu_configure(struct device *dev, struct device_node *master_np,
err = pci_for_each_dma_alias(to_pci_dev(dev),
of_pci_iommu_init, &info);
of_pci_check_device_ats(dev, master_np);
+
+ /*
+ * For PCI devices, ensure the device's of_node points to the
+ * PCI host controller's device tree node so that reserved regions
+ * and other DT-specific IOMMU configuration can be found.
+ * PCI devices typically don't have individual DT nodes, but
+ * their configuration (including reserved regions) is defined
+ * at the PCI host controller level.
+ */
+ if (!err && master_np && !dev->of_node)
+ dev->of_node = of_node_get(master_np);
} else {
err = of_iommu_configure_device(master_np, dev, id);
}
--
2.34.1
next prev parent reply other threads:[~2025-08-06 21:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 21:55 [PATCH v3 0/3] arm-smmu: select suitable MSI IOVA Shyam Saini
2025-08-06 21:55 ` [PATCH v3 1/3] arm-smmu: move MSI_IOVA macro definitions Shyam Saini
2025-08-07 14:32 ` kernel test robot
2025-08-06 21:55 ` Shyam Saini [this message]
2025-08-08 12:15 ` [PATCH v3 2/3] iommu/of: fix device tree configuration for PCI devices Jason Gunthorpe
2025-08-14 23:30 ` Shyam Saini
2025-08-15 0:39 ` Jason Gunthorpe
2025-08-15 2:32 ` Shyam Saini
2025-08-18 15:53 ` Jason Gunthorpe
2025-08-26 1:15 ` Shyam Saini
2025-08-26 12:36 ` Jason Gunthorpe
2025-08-26 22:19 ` Shyam Saini
2025-08-06 21:55 ` [PATCH v3 3/3] arm-smmu: select suitable MSI IOVA Shyam Saini
2025-08-06 23:58 ` Jason Gunthorpe
2025-08-07 17:55 ` kernel test robot
2025-08-11 22:34 ` Jacob Pan
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=20250806215539.1240561-3-shyamsaini@linux.microsoft.com \
--to=shyamsaini@linux.microsoft.com \
--cc=bboscaccy@linux.microsoft.com \
--cc=code@tyhicks.com \
--cc=devicetree@vger.kernel.org \
--cc=eahariha@linux.microsoft.com \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jacob.pan@linux.microsoft.com \
--cc=jgg@ziepe.ca \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=vijayb@linux.microsoft.com \
--cc=virtualization@lists.linux.dev \
--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;
as well as URLs for NNTP newsgroup(s).