Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>, will@kernel.org, jgg@nvidia.com
Cc: baolu.lu@linux.intel.com, robin.murphy@arm.com, joro@8bytes.org,
	praan@google.com, kevin.tian@intel.com, smostafa@google.com,
	linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org, jamien@nvidia.com, kas@kernel.org,
	Cristian Prundeanu <cpru@amazon.com>,
	Breno Leitao <leitao@kernel.org>,
	xueshuai@linux.alibaba.com, john.garry@arm.com
Subject: Re: [PATCH v13 01/12] iommu: Pass in NULL old_domain when attaching a deferred device
Date: Sat, 5 Dec 2026 15:42:21 +0800	[thread overview]
Message-ID: <538b7bd3-8c4d-4054-b7d2-61635d82d616@linux.intel.com> (raw)
In-Reply-To: <d38f0479995fe866a56bfcedb55368816622f9fa.1794942324.git.nicolinc@nvidia.com>

On 11/18/2026 3:21 AM, Nicolin Chen wrote:
> When a driver defers the default domain attachment of a device, the IOMMU
> core skips the attachment in __iommu_device_set_domain() but still sets the
> group->domain to the group->default_domain. Since the driver has not seen
> this attachment, iommu_deferred_attach() later finalizes it by passing in a
> NULL old_domain.
> 
> However, two other paths pass in the group->domain as the old_domain for a
> deferred device:
>   - __iommu_device_set_domain(), when attaching a non-default domain
>   - pci_dev_reset_iommu_prepare(), when attaching the group->blocking_domain
> 
> A driver uses the given old_domain to clean up the device's state in that
> domain. However, a deferred device has no state in the group->domain, since
> the driver has never attached the device to it. So, the driver would end up
> cleaning up a state that does not exist.
> 
> In practice, the first path is unlikely, since it requires the device to be
> attached to a non-default domain before its first DMA mapping. The second
> path is reachable when an ATS supported device gets reset before its first
> DMA mapping.
> 
> Pass in a NULL old_domain on both paths for a deferred device.
> 
> Note that pci_dev_reset_iommu_done() can keep using the group->domain for
> recovering the device, because pci_dev_reset_iommu_prepare() has unset the
> attach_deferred flag.
> 
> This will be needed for the SMMUv3 driver to support the kdump mode, where
> it relies on the given old_domain to unreference the invalidation entries
> of a master.
> 
> Signed-off-by: Nicolin Chen<nicolinc@nvidia.com>
> ---
>   drivers/iommu/iommu.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>


  parent reply	other threads:[~2026-12-05  7:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 19:21 [PATCH v13 00/12] iommu/arm-smmu-v3: Adopt the crashed kernel's stream table for kdump Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 01/12] iommu: Pass in NULL old_domain when attaching a deferred device Nicolin Chen
2026-12-02 17:31   ` Jason Gunthorpe
2026-12-05  7:42   ` Baolu Lu [this message]
2026-11-17 19:21 ` [PATCH v13 02/12] iommu/arm-smmu-v3: Init the vmid_map ida before the stream table setup Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 03/12] iommu/arm-smmu-v3: Make the ASID space per SMMU instance Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 04/12] iommu/arm-smmu-v3: Pack the MSI vectors of the used sources Nicolin Chen
2026-11-19 10:55   ` John Garry
2026-11-19 16:50     ` Nicolin Chen
2026-12-02 17:31   ` Jason Gunthorpe
2026-11-17 19:21 ` [PATCH v13 05/12] iommu/arm-smmu-v3: Add ARM_SMMU_FEAT_EVTQ for the event queue Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 06/12] iommu/arm-smmu-v3: Disable the EVTQ and the PRIQ in a kdump kernel Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 07/12] iommu/arm-smmu-v3: Add ARM_SMMU_OPT_KDUMP_ADOPT for " Nicolin Chen
2026-11-19 10:55   ` John Garry
2026-11-19 16:49     ` Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 08/12] iommu/arm-smmu-v3-kexec: Reserve crashed kernel's ASIDs and VMIDs Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 09/12] iommu/arm-smmu-v3-kexec: Implement is_attach_deferred() Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 10/12] iommu/arm-smmu-v3: Retain CR0_SMMUEN during kdump device reset Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 11/12] iommu/arm-smmu-v3: Skip RMR bypass for kdump adoption Nicolin Chen
2026-11-17 19:21 ` [PATCH v13 12/12] iommu/arm-smmu-v3: Detect ARM_SMMU_OPT_KDUMP_ADOPT in probe() Nicolin Chen

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=538b7bd3-8c4d-4054-b7d2-61635d82d616@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=cpru@amazon.com \
    --cc=iommu@lists.linux.dev \
    --cc=jamien@nvidia.com \
    --cc=jgg@nvidia.com \
    --cc=john.garry@arm.com \
    --cc=joro@8bytes.org \
    --cc=kas@kernel.org \
    --cc=kevin.tian@intel.com \
    --cc=leitao@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=praan@google.com \
    --cc=robin.murphy@arm.com \
    --cc=smostafa@google.com \
    --cc=will@kernel.org \
    --cc=xueshuai@linux.alibaba.com \
    /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