From: Jean-Philippe Brucker <jean-philippe@linaro.org>
To: Eric Auger <eric.auger@redhat.com>
Cc: akihiko.odaki@daynix.com, will@kernel.org, joro@8bytes.org,
virtualization@lists.linux-foundation.org, iommu@lists.linux.dev,
robin.murphy@arm.com
Subject: Re: [PATCH] iommu/virtio: Detach domain on endpoint release
Date: Wed, 10 May 2023 17:20:34 +0100 [thread overview]
Message-ID: <20230510162034.GA3390634@myrica> (raw)
In-Reply-To: <e58c48e0-6339-41ec-e65b-e3104c65bb81@redhat.com>
On Wed, May 10, 2023 at 05:37:22PM +0200, Eric Auger wrote:
> Hi Jean,
>
> On 4/14/23 17:07, Jean-Philippe Brucker wrote:
> > When an endpoint is released, for example a PCIe VF is disabled or a
> > function hot-unplugged, it should be detached from its domain. Send a
> > DETACH request.
> >
> > Fixes: edcd69ab9a32 ("iommu: Add virtio-iommu driver")
> > Reported-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> > Link: https://lore.kernel.org/all/15bf1b00-3aa0-973a-3a86-3fa5c4d41d2c@daynix.com/
> > Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> > ---
> > drivers/iommu/virtio-iommu.c | 23 +++++++++++++++++++++++
> > 1 file changed, 23 insertions(+)
> >
> > diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
> > index 5b8fe9bfa9a5..3d3d4462359e 100644
> > --- a/drivers/iommu/virtio-iommu.c
> > +++ b/drivers/iommu/virtio-iommu.c
> > @@ -788,6 +788,28 @@ static int viommu_attach_dev(struct iommu_domain *domain, struct device *dev)
> > return 0;
> > }
> >
> > +static void viommu_detach_dev(struct viommu_endpoint *vdev)
> > +{
> > + int i;
> > + struct virtio_iommu_req_detach req;
> > + struct viommu_domain *vdomain = vdev->vdomain;
> > + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(vdev->dev);
> > +
> > + if (!vdomain)
> > + return;
> > +
> > + req = (struct virtio_iommu_req_detach) {
> > + .head.type = VIRTIO_IOMMU_T_DETACH,
> > + .domain = cpu_to_le32(vdomain->id),
> > + };
> > +
> > + for (i = 0; i < fwspec->num_ids; i++) {
> > + req.endpoint = cpu_to_le32(fwspec->ids[i]);
> > + WARN_ON(viommu_send_req_sync(vdev->viommu, &req, sizeof(req)));
> > + }
> just a late question: don't you need to decrement vdomain's nr_endpoints?
>
Ah yes, I'll fix that, thank you. I think attach() could use some cleanup
as well: if the request fails then we should keep the nr_endpoints
reference on the previous domain. But that's less urgent.
Thanks,
Jean
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
prev parent reply other threads:[~2023-05-10 16:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 15:07 [PATCH] iommu/virtio: Detach domain on endpoint release Jean-Philippe Brucker
2023-05-10 8:11 ` Jean-Philippe Brucker
[not found] ` <ZGT+44a6RYZ999kz@nvidia.com>
2023-05-18 13:56 ` Jean-Philippe Brucker
[not found] ` <ZGYvMDbkBN+2UgzG@nvidia.com>
2023-05-18 16:49 ` Jean-Philippe Brucker
2023-05-10 15:37 ` Eric Auger
2023-05-10 16:20 ` Jean-Philippe Brucker [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=20230510162034.GA3390634@myrica \
--to=jean-philippe@linaro.org \
--cc=akihiko.odaki@daynix.com \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=robin.murphy@arm.com \
--cc=virtualization@lists.linux-foundation.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