mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Koichiro Den <den@valinux.co.jp>
To: "Joerg Roedel (AMD)" <joro@8bytes.org>,
	Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Magnus Damm <damm+renesas@opensource.se>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Lu Baolu <baolu.lu@linux.intel.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	Marek Vasut <marek.vasut@mailbox.org>,
	iommu@lists.linux.dev, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] iommu/ipmmu-vmsa: Move device initialization to probe_device()
Date: Thu,  5 Nov 2026 01:22:50 +0900	[thread overview]
Message-ID: <20261104162251.1749998-3-den@valinux.co.jp> (raw)
In-Reply-To: <20261104162251.1749998-1-den@valinux.co.jp>

Move the IPMMU instance lookup and private-data setup to
ipmmu_probe_device(), using fwspec->iommu_fwnode. This prepares for
per-device attachment state managed by ipmmu_probe_device() and
ipmmu_release_device().

No functional change intended.

Cc: stable@vger.kernel.org
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
 drivers/iommu/ipmmu-vmsa.c | 47 +++++++++++++-------------------------
 1 file changed, 16 insertions(+), 31 deletions(-)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 99586c68ef35..cea9348ac10d 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -709,22 +709,6 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
 	return domain->iop->iova_to_phys(domain->iop, iova);
 }
 
-static int ipmmu_init_platform_device(struct device *dev,
-				      const struct of_phandle_args *args)
-{
-	struct platform_device *ipmmu_pdev;
-
-	ipmmu_pdev = of_find_device_by_node(args->np);
-	if (!ipmmu_pdev)
-		return -ENODEV;
-
-	dev_iommu_priv_set(dev, platform_get_drvdata(ipmmu_pdev));
-
-	put_device(&ipmmu_pdev->dev);
-
-	return 0;
-}
-
 static const struct soc_device_attribute soc_needs_opt_in[] = {
 	{ .family = "R-Car Gen3", },
 	{ .family = "R-Car Gen4", },
@@ -778,20 +762,10 @@ static bool ipmmu_device_is_allowed(struct device *dev)
 static int ipmmu_of_xlate(struct device *dev,
 			  const struct of_phandle_args *spec)
 {
-	int ret;
-
 	if (!ipmmu_device_is_allowed(dev))
 		return -ENODEV;
 
-	ret = iommu_fwspec_add_ids(dev, spec->args, 1);
-	if (ret)
-		return ret;
-
-	/* Initialize once - xlate() will call multiple times */
-	if (to_ipmmu(dev))
-		return 0;
-
-	return ipmmu_init_platform_device(dev, spec);
+	return iommu_fwspec_add_ids(dev, spec->args, 1);
 }
 
 static int ipmmu_init_arm_mapping(struct device *dev)
@@ -839,14 +813,25 @@ static int ipmmu_init_arm_mapping(struct device *dev)
 
 static struct iommu_device *ipmmu_probe_device(struct device *dev)
 {
-	struct ipmmu_vmsa_device *mmu = to_ipmmu(dev);
+	struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
+	struct platform_device *ipmmu_pdev;
+	struct ipmmu_vmsa_device *mmu;
+
+	if (!fwspec)
+		return ERR_PTR(-ENODEV);
+
+	ipmmu_pdev = of_find_device_by_node(to_of_node(fwspec->iommu_fwnode));
+	if (!ipmmu_pdev)
+		return ERR_PTR(-ENODEV);
+
+	mmu = platform_get_drvdata(ipmmu_pdev);
+	put_device(&ipmmu_pdev->dev);
 
-	/*
-	 * Only let through devices that have been verified in xlate()
-	 */
 	if (!mmu)
 		return ERR_PTR(-ENODEV);
 
+	dev_iommu_priv_set(dev, mmu);
+
 	return &mmu->iommu;
 }
 
-- 
2.54.0


  parent reply	other threads:[~2026-11-04 16:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 16:22 [PATCH 0/3] iommu/ipmmu-vmsa: Keep shared micro-TLBs enabled Koichiro Den
2026-11-04 16:22 ` [PATCH 1/3] iommu/ipmmu-vmsa: Propagate errors from iommu_fwspec_add_ids() Koichiro Den
2026-11-04 16:22 ` Koichiro Den [this message]
2026-11-04 16:22 ` [PATCH 3/3] iommu/ipmmu-vmsa: Keep shared micro-TLBs enabled while in use Koichiro Den
2026-11-04 17:42   ` Robin Murphy
2026-11-05  2:34     ` Koichiro Den

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=20261104162251.1749998-3-den@valinux.co.jp \
    --to=den@valinux.co.jp \
    --cc=baolu.lu@linux.intel.com \
    --cc=damm+renesas@opensource.se \
    --cc=geert+renesas@glider.be \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=marek.vasut@mailbox.org \
    --cc=robin.murphy@arm.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

all inboxes | Powered by JetHome®