From: Jason Gunthorpe <jgg@ziepe.ca>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>,
Hanjun Guo <guohanjun@huawei.com>,
Sudeep Holla <sudeep.holla@arm.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>, Russell King <linux@armlinux.org.uk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Danilo Krummrich <dakr@kernel.org>,
Stuart Yoder <stuyoder@gmail.com>,
Laurentiu Tudor <laurentiu.tudor@nxp.com>,
Nipun Gupta <nipun.gupta@amd.com>,
Nikhil Agarwal <nikhil.agarwal@amd.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Rob Herring <robh@kernel.org>,
Saravana Kannan <saravanak@google.com>,
Bjorn Helgaas <bhelgaas@google.com>,
linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
devicetree@vger.kernel.org, linux-pci@vger.kernel.org,
Charan Teja Kalla <quic_charante@quicinc.com>
Subject: Re: [PATCH 2/2] iommu: Get DT/ACPI parsing into the proper probe path
Date: Wed, 19 Feb 2025 14:29:24 -0400 [thread overview]
Message-ID: <20250219182924.GN3696814@ziepe.ca> (raw)
In-Reply-To: <4a7823b2-2634-4148-8446-ad01a09b6880@arm.com>
On Mon, Feb 17, 2025 at 03:00:46PM +0000, Robin Murphy wrote:
> On 14/02/2025 8:14 pm, Jason Gunthorpe wrote:
> > On Thu, Feb 13, 2025 at 11:49:00PM +0000, Robin Murphy wrote:
> >
> > > much just calling the same path twice. At client driver probe time,
> > > dev->driver is obviously set; conversely at device_add(), or a
> > > subsequent bus_iommu_probe(), any device waiting for an IOMMU really
> >
> > Could you put the dev->driver test into iommu_device_use_default_domain()?
> >
> > It looks like many of the cases are just guarding that call.
> >
> > > should *not* have a driver already, so we can use that as a condition to
> > > disambiguate the two cases, and avoid recursing back into the IOMMU core
> > > at the wrong times.
> >
> > Which sounds like this:
> >
> > > + mutex_unlock(&iommu_probe_device_lock);
> > > + dev->bus->dma_configure(dev);
> > > + mutex_lock(&iommu_probe_device_lock);
> > > + }
> >
> > Shouldn't call iommu_device_use_default_domain() ?
>
> Semantically it shouldn't really be called at this stage, but it won't be
> anyway since "to_<x>_driver(NULL)->driver_managed_dma" is not false -
> trouble is it's also not true ;)
That case in PCI I understood, but the other cases seemed like they
would be OK, especially if group is NULL
> > This is the test I mean, if iommu_group is set then
> > dev->iommu->iommu_dev->ops is supposed to be valid too. It seems like
> > it should be done earlier..
>
> Yeah, looking at it now I'm really not sure why this ended up in this order
> - I guess I was effectively adding the dma_configure() call to the front of
> the existing iommu_fwspec_ops() check, and then I moved the lockdep_assert()
> up to make more sense. But then the ops check probably should have been
> after the group check to begin with, for much the same reasoning as above.
> I'll sort that out for v2.
I guess check it at the top and then check it again after re-locking.
> > > + * And if we do now see any replay calls, they would indicate someone
> > > + * misusing the dma_configure path outside bus code.
> > > + */
> > > + if (dev_iommu_fwspec_get(dev) && dev->driver)
> > > + dev_WARN(dev, "late IOMMU probe at driver bind, something fishy here!\n");
> >
> > WARN_ON_ONCE or dump_stack() to get the stack trace out?
>
> Indeed, hence dev_WARN() (!= dev_warn())
Oh, I've never seen that variation before!
Jason
next prev parent reply other threads:[~2025-02-19 18:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 23:48 [PATCH 0/2] iommu: Fix the longstanding probe issues Robin Murphy
2025-02-13 23:48 ` [PATCH 1/2] iommu: Handle race with default domain setup Robin Murphy
2025-02-14 12:57 ` Charan Teja Kalla
2025-02-17 16:29 ` Robin Murphy
2025-02-14 19:43 ` Jason Gunthorpe
2025-02-13 23:49 ` [PATCH 2/2] iommu: Get DT/ACPI parsing into the proper probe path Robin Murphy
2025-02-14 17:29 ` Bjorn Helgaas
2025-02-14 20:14 ` Jason Gunthorpe
2025-02-17 15:00 ` Robin Murphy
2025-02-19 18:29 ` Jason Gunthorpe [this message]
2025-02-19 22:43 ` Rob Herring
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=20250219182924.GN3696814@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=bhelgaas@google.com \
--cc=dakr@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=guohanjun@huawei.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=laurentiu.tudor@nxp.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=linux-pci@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lpieralisi@kernel.org \
--cc=nikhil.agarwal@amd.com \
--cc=nipun.gupta@amd.com \
--cc=quic_charante@quicinc.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=saravanak@google.com \
--cc=stuyoder@gmail.com \
--cc=sudeep.holla@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