mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Arun Iyengar <aiyengar1990@gmail.com>
Cc: "Joerg Roedel (AMD)" <joro@8bytes.org>,
	Will Deacon <will@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
	"Rob Herring (Arm)" <robh@kernel.org>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] iommu: Don't let a driver bind while bus_iommu_probe() still probes its device
Date: Thu, 12 Nov 2026 17:57:04 +0000	[thread overview]
Message-ID: <472df1c1-e1fb-454a-96bf-4a01dcd383aa@arm.com> (raw)
In-Reply-To: <CAEy9hNXRwH9qD-=Gj3NiY=ZVrVq02hAj0dPU+o8YfEmCcbSdNg@mail.gmail.com>

On 2026-11-12 5:32 pm, Arun Iyengar wrote:
> Please don't apply v1, and it should not go to stable. On re-reading
> I found three problems:
> 
> 1. "A fwspec without a group means a probe is in progress" does not
>     hold on ACPI. On the driver bind path acpi_iommu_configure_id()
>     creates a fwspec, and nothing there probes the device or frees the
>     fwspec. So a device whose IOMMU probe failed earlier would get
>     -EPROBE_DEFER from iommu_device_use_default_domain() on every bind
>     attempt, where today it binds without the IOMMU. OF does not have
>     this, because of_iommu_configure() either probes or frees.
> 
> 2. Drivers with driver_managed_dma never call
>     iommu_device_use_default_domain(), so the window stays open for
>     them (e.g. pcieport with a modular IOMMU driver), and the changed
>     WARN condition can then hide it.
> 
> 3. Replaying dma_configure for a device whose driver is inside probe()
>     is wider than I described. It applies to every such device on the
>     bus that has no group yet, including a client that went ahead
>     without its IOMMU after the deferred probe timeout; that client
>     would get its group and default domain while its driver is probing,
>     without a warning.
> 
> The race itself is as in the commit message: the client's dma_configure
> sees the dev->iommu or fwspec of a concurrent bus_iommu_probe() replay
> while iommu_probe_device_lock is dropped.
> 
> For v2 I intend to mark the in-progress probe explicitly in dev->iommu,
> have of_iommu_configure() and acpi_iommu_configure_id() defer any caller
> other than the replay while the mark is set, and leave the replay
> condition and iommu_device_use_default_domain() alone. The other
> ordering in the commit message (the client sets dev->driver before the
> replay check) would then still warn, although nothing is wrong there
> besides the warning; I would look at that separately. If you would
> rather see this solved another way, please say so.
> 
> Tudor: you are on Cc because this is the same "!dev->iommu" gate on the
> readiness check as in your thread
> <20260323-iommu-ready-check-v1-1-5f6fef8f9f59@linaro.org>, for a
> different case (one IOMMU, concurrent bind).

Really the dev->driver checks are less than ideal, as they're inherently 
racy with an unavoidable false-positive window. What we could really do 
with - which might now be viable with the recent atomic device flags - 
is a specific indicator that a device has got far enough into binding a 
driver to be past the point of waiting or an IOMMU. The 
BUS_NOTIFY_BIND_DRIVER call is in fact in more or less the right place 
for that, so we could potentially do the flag management from 
iommu_bus_notifier() rather than clutter up the driver core with yet 
more hooks, but the flag itself can't be in dev->iommu, since its whole 
meaning is "we assumed this device didn't have an IOMMU and now it's too 
late to safely change that".

Thanks,
Robin.

      reply	other threads:[~2026-11-12 17:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 17:19 Arun Iyengar via B4 Relay
2026-11-12 17:32 ` Arun Iyengar
2026-11-12 17:57   ` Robin Murphy [this message]

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=472df1c1-e1fb-454a-96bf-4a01dcd383aa@arm.com \
    --to=robin.murphy@arm.com \
    --cc=aiyengar1990@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=robh@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tudor.ambarus@linaro.org \
    --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®