virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>,
	xuanzhuo@linux.alibaba.com, virtualization@lists.linux.dev,
	linux-kernel@vger.kernel.org, hch@infradead.org
Subject: Re: [PATCH V5 4/9] virtio: introduce vring_mapping_token
Date: Mon, 18 Aug 2025 08:02:57 -0400	[thread overview]
Message-ID: <20250818075749-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAJaqyWcxV+f6dhKLscGGy0bw2YWJ8NaJ4QN+Qe3Ax7C+Lf4X-g@mail.gmail.com>

On Mon, Aug 18, 2025 at 11:09:44AM +0200, Eugenio Perez Martin wrote:
> On Thu, Aug 14, 2025 at 12:42 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Thu, Aug 14, 2025 at 11:36:22AM +0800, Jason Wang wrote:
> > > > > diff --git a/include/linux/virtio.h b/include/linux/virtio.h
> > > > > index addbc209275a..37029df94aaf 100644
> > > > > --- a/include/linux/virtio.h
> > > > > +++ b/include/linux/virtio.h
> > > > > @@ -40,6 +40,13 @@ struct virtqueue {
> > > > >       void *priv;
> > > > >  };
> > > > >
> > > > > +union vring_mapping_token {
> > > > > +     /* Device that performs DMA */
> > > > > +     struct device *dma_dev;
> > > > > +     /* Transport specific token used for doing map */
> > > > > +     void *opaque;
> > > >
> > > > Please just declare whatever structure you want it to be.
> > >
> > > It's an opaque one and so
> > >
> > > 1) the virtio core knows nothing about that because it could be
> > > transport or device specific
> > > 2) no assumption of the type and usage, it just receive it from the
> > > transport and pass it back when doing the mapping
> > >
> > > It should work like page->private etc.
> > >
> > > Does this make sense?
> > >
> > > Thanks
> >
> > I fully expect most devices simply to use DMA here and no weird
> > tricks. vduse is the weird one, but I don't see us making it
> > grow much beyond that.
> >
> > So I think for now we can just make it vduse_iova_domain *. If we see
> > it's getting out of hand with too many types, we can think of solutions.
> >
> 
> I've sent my series of adding ASID to VDUSE, which uses this series'
> token on each vq group, on top of this version of the DMA rework.

But then I see it drops it from vduse_iova_domain. So it does not
look like they union is going to keep growing in an unmanageable way.

> This patch [1] and the next one are the one that reworks the token to
> an empty struct, so virtio can handle it in an opaque way and VDUSE
> can convert it back and forth in a type safe way, skipping the void *.
> Please let me know if you prefer to import a VDUSE header into the
> virtio config header or to make a VDUSE forward declaration instead of
> going through the empty struct to preserve layer boundaries.

Personally for now I'd be happier with just a forward declaration.
I just like seeing things at a glance: "it's a union, and
can be one of two types", is better for me than
"it can be anything grep the source to figure out what it is".
And a forward declaration is opaque by design.


> There is one usage I've not been able to convert though. Jason, could
> you take a look? It is marked as TODO in my series. I'm not sure if
> that's also an abuse of the void * in the DMA rework to be honest, but
> it should be easy to correct.
> 
> [1] https://lore.kernel.org/all/20250818085711.3461758-4-eperezma@redhat.com/T/#u


  reply	other threads:[~2025-08-18 12:03 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13  5:48 [PATCH V5 0/9] Refine virtio mapping API Jason Wang
2025-08-13  5:48 ` [PATCH V5 1/9] virtio_ring: constify virtqueue pointer for DMA helpers Jason Wang
2025-08-13  7:14   ` Eugenio Perez Martin
2025-09-21 20:55   ` Michael S. Tsirkin
2025-09-21 21:42     ` Michael S. Tsirkin
2025-08-13  5:48 ` [PATCH V5 2/9] virtio_ring: switch to use dma_{map|unmap}_page() Jason Wang
2025-08-13  7:15   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 3/9] virtio: rename dma helpers Jason Wang
2025-08-13  7:16   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 4/9] virtio: introduce vring_mapping_token Jason Wang
2025-08-13  7:46   ` Eugenio Perez Martin
2025-08-13  8:55   ` Michael S. Tsirkin
2025-08-13  9:13     ` Eugenio Perez Martin
2025-08-14  3:39       ` Jason Wang
2025-08-14  3:36     ` Jason Wang
2025-08-14 10:42       ` Michael S. Tsirkin
2025-08-15  1:02         ` Jason Wang
2025-08-15 10:04           ` Michael S. Tsirkin
2025-08-18  9:09         ` Eugenio Perez Martin
2025-08-18 12:02           ` Michael S. Tsirkin [this message]
2025-08-13  8:58   ` Michael S. Tsirkin
2025-08-14  3:37     ` Jason Wang
2025-08-13  5:48 ` [PATCH V5 5/9] virtio_ring: rename dma_handle to map_handle Jason Wang
2025-08-13  7:47   ` Eugenio Perez Martin
2025-09-21 20:54   ` Michael S. Tsirkin
2025-09-21 21:41     ` Michael S. Tsirkin
2025-08-13  5:48 ` [PATCH V5 6/9] virtio: introduce map ops in virtio core Jason Wang
2025-08-13  8:40   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 7/9] vdpa: support mapping token Jason Wang
2025-08-13  8:45   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 8/9] vdpa: introduce map ops Jason Wang
2025-08-13  8:46   ` Eugenio Perez Martin
2025-08-13  5:48 ` [PATCH V5 9/9] vduse: switch to use virtio map API instead of DMA API Jason Wang
2025-08-13  9:02   ` Eugenio Perez Martin
2025-08-14  3:33     ` Jason Wang
2025-08-14  6:42       ` Eugenio Perez Martin

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=20250818075749-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=hch@infradead.org \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@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;
as well as URLs for NNTP newsgroup(s).