mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Cam Miller <cam@linux.ibm.com>,
	jpb@kernel.org, joro@8bytes.org, will@kernel.org
Cc: robin.murphy@arm.com, iommu@lists.linux.dev,
	virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
	mjrosato@linux.ibm.com
Subject: Re: [RFC linux v1 3/3] iommu/virtio: Add device links for endpoints
Date: Wed, 25 Nov 2026 21:31:50 +0100	[thread overview]
Message-ID: <f2ce64236c70db1e377c3cb5b6acabcf6e8be8d2.camel@linux.ibm.com> (raw)
In-Reply-To: <20261124155410.768743-4-cam@linux.ibm.com>

On Tue, 2026-11-24 at 10:54 -0500, Cam Miller wrote:
> Make each endpoint a consumer of the virtio-iommu device, so that the
> driver core unbinds each endpoint driver before viommu_remove() runs.
> 
> Before this change, removing a virtio-iommu (for example via "echo 1 >
> /sys/bus/pci/devices/<dev>/remove") tears down the IOMMU groups of all
> its endpoints while their drivers are still bound. The endpoints keep
> stale IOVAs and their later dma_free_contiguous() leads to WARNs in
> __iommu_group_free_device(), endpoint IO hanging, and crash at shutdown.
> 
> Make each endpoint a consumer of the viommu with device_link_add(), as
> arm-smmu and other IOMMU drivers do. The driver core then unbinds the
> endpoint drivers before viommu_remove() runs, so that their DMA teardown
> will still see an intact domain.
> 
> Fixes: edcd69ab9a32 ("iommu: Add virtio-iommu driver")
> Suggested-by: Jean-Philippe Brucker <jpb@kernel.org>
> Signed-off-by: Cam Miller <cam@linux.ibm.com>
> ---
>  drivers/iommu/virtio-iommu.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
> index dd10c3e98a3d..a84a653f269e 100644
> --- a/drivers/iommu/virtio-iommu.c
> +++ b/drivers/iommu/virtio-iommu.c
> @@ -1044,6 +1044,9 @@ static struct iommu_device *viommu_probe_device(struct device *dev)
>  			goto err_free_dev;
>  	}
>  
> +	if (!device_link_add(dev, viommu->dev, DL_FLAG_AUTOREMOVE_SUPPLIER))
> +		dev_dbg(dev, "could not add device link\n");
> +
>  	return &viommu->iommu;
>  
>  err_free_dev:

Looks good to me and like the unbind suppression is also already used
by other IOMMU drivers in this case e.g. arm-smmu in a similar fashion.

Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>

Thanks,
Niklas

      reply	other threads:[~2026-11-25 20:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 15:54 [RFC linux v1 0/3] iommu/virtio: fix remove Cam Miller
2026-11-24 15:54 ` [RFC linux v1 1/3] iommu/virtio: Fix out-of-order teardown in viommu_remove() Cam Miller
2026-11-25 14:59   ` Niklas Schnelle
2026-11-24 15:54 ` [RFC linux v1 2/3] iommu/virtio: Prevent driver unbind via sysfs Cam Miller
2026-11-25 20:14   ` Niklas Schnelle
2026-11-24 15:54 ` [RFC linux v1 3/3] iommu/virtio: Add device links for endpoints Cam Miller
2026-11-25 20:31   ` Niklas Schnelle [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=f2ce64236c70db1e377c3cb5b6acabcf6e8be8d2.camel@linux.ibm.com \
    --to=schnelle@linux.ibm.com \
    --cc=cam@linux.ibm.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=jpb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=robin.murphy@arm.com \
    --cc=virtualization@lists.linux.dev \
    --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®