From: Jason Gunthorpe <jgg@ziepe.ca>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Eric Badger <ebadger@purestorage.com>,
David Woodhouse <dwmw2@infradead.org>,
Lu Baolu <baolu.lu@linux.intel.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
"open list:INTEL IOMMU (VT-d)" <iommu@lists.linux.dev>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iommu/vt-d: Check for non-NULL domain on device release
Date: Tue, 16 Jan 2024 22:20:20 -0400 [thread overview]
Message-ID: <20240117022020.GH50608@ziepe.ca> (raw)
In-Reply-To: <46a61123-dd22-46cb-8b2a-15431fcc03f1@arm.com>
On Wed, Jan 17, 2024 at 01:57:34AM +0000, Robin Murphy wrote:
> > > ---
> > > drivers/iommu/intel/iommu.c | 10 ++++++----
> > > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > Unfortunately this issue is likely systemic in all the drivers.
>
> All two of the drivers which support deferred attach, that is.
We could call release_device on an unlikely error unwind path with a
NULL domain for all drivers.
> > Something I've been thinking about for a while now is to have the
> > option for the core code release to set the driver to a specific
> > releasing domain (probably a blocking or identity global static)
> >
> > A lot of drivers are open coding this internally in their release
> > functions, like Intel. But it really doesn't deserve to be special.
>
> Either way it shouldn't apply in this case, though. Crash kernels *are*
> special. The whole point of deferred attach is that we don't disturb
> anything unless we've got as far as definitely using a given default domain
> (from which we can infer the relevant client device should have been reset
> and quiesced).
If only it were so simple.. It assumes drivers are structured to reset
their devices using only MMIO before doing anything to setup DMA and
trigger an iommu attach. A lot of drivers aren't and this whole scheme
turns a bit sketchy.
Some devices can't even do it at all. eg mlx5 has the crashing kernel
quiet the device before passing over to the crash kernel because there
is no way beyond FLR to regain control of a mlx5 device.
> Thus regardless of why release might get called, if a
> deferred attach never happened then the release should still avoid touching
> any hardware configuration either.
Interesting point.. Makes sense to me
> I'd suggest using dev->iommu->attach_deferred as the condition rather than a
> NULL domain, to be clear that it's the *only* valid reason to not have a
> domain at this point.
So if we take this release_domain approach and we have the core code
not call it for the defered attach case then the driver's
release_device should just free memory allocated by probe and not
touch the data structures?
Then the idea is that drivers would only manipulate their STE/DTE/etc
under attach and never in probe/release.
Jason
next prev parent reply other threads:[~2024-01-17 2:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-13 18:17 [PATCH] iommu/vt-d: Check for non-NULL domain on device release Eric Badger
2024-01-16 15:22 ` Jason Gunthorpe
2024-01-16 23:15 ` Eric Badger
2024-01-17 1:57 ` Robin Murphy
2024-01-17 2:20 ` Jason Gunthorpe [this message]
2024-01-31 7:10 ` Baolu Lu
2024-02-21 15:40 ` Jason Gunthorpe
2024-02-22 11:53 ` Baolu Lu
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=20240117022020.GH50608@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=baolu.lu@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=ebadger@purestorage.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.