[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250818234241.GF802098@nvidia.com>
Date: Mon, 18 Aug 2025 20:42:41 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Nicolin Chen <nicolinc@...dia.com>
Cc: robin.murphy@....com, joro@...tes.org, bhelgaas@...gle.com,
will@...nel.org, robin.clark@....qualcomm.com, yong.wu@...iatek.com,
matthias.bgg@...il.com, angelogioacchino.delregno@...labora.com,
thierry.reding@...il.com, vdumpa@...dia.com, jonathanh@...dia.com,
rafael@...nel.org, lenb@...nel.org, kevin.tian@...el.com,
yi.l.liu@...el.com, baolu.lu@...ux.intel.com,
linux-arm-kernel@...ts.infradead.org, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-mediatek@...ts.infradead.org, linux-tegra@...r.kernel.org,
linux-acpi@...r.kernel.org, linux-pci@...r.kernel.org,
patches@...ts.linux.dev, pjaroszynski@...dia.com, vsethi@...dia.com,
helgaas@...nel.org, etzhao1900@...il.com
Subject: Re: [PATCH v3 3/5] iommu: Add iommu_get_domain_for_dev_locked()
helper
On Mon, Aug 18, 2025 at 10:22:52AM -0700, Nicolin Chen wrote:
> > Because this is a very common pattern in drivers.
> >
> > Once that is done we can see what calls to iommu_get_domain_for_dev()
> > are even left,
>
> ... I found that in SMMUv3 driver, iommu_get_domain_for_dev() is
> used to get the RID domain for an SVA domain:
> arm_smmu_set_pasid()
> arm_smmu_blocking_set_dev_pasid()
>
> These two are already given an "old" (SVA) domain pointer, FWIW.
>
> So, we may change to passing in the old domain as you suggested,
> yet we still have to fix the iommu_get_domain_for_dev() in order
> to reflect the RID domain correctly for the driver that calls it
> (or even potentially) in some group->mutex locked context where
> the RID domain might not be naturally passed in.
It could probably be avoided by keeping track of more information in
the master, but also it is not so bad to use a _locked version here.
> > arguably we should be trying to eliminate this badly
> > locked thing...
>
> Any suggestion?
Bit by bit.. I counted 58 by grep
Changing attach will get rid of alot of them
Then there is stuff like this:
domain = iommu_get_domain_for_dev(emu->card->dev);
if (!domain || domain->type == IOMMU_DOMAIN_IDENTITY)
return;
Which should be more like
if (iommu_get_translation_mode(dev) == IDENTITY)
With sensible internal locking
So that is another bunch. Not sure what will be left after.
Not saying to do all that here, just prefer we move toward that direction.
Jason
Powered by blists - more mailing lists