virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
	virtualization@lists.linux-foundation.org,
	Guenter Roeck <linux@roeck-us.net>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()
Date: Tue, 11 Apr 2023 11:56:47 +0800	[thread overview]
Message-ID: <CACGkMEtD0BLBXv7S-TLY-Y483_Lx4UskLyPmEC2wyGa8VE_R6w@mail.gmail.com> (raw)
In-Reply-To: <ZDTUn6TUqzrF06mr@infradead.org>

On Tue, Apr 11, 2023 at 11:31 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Tue, Apr 11, 2023 at 10:09:40AM +0800, Jason Wang wrote:
> > We want to support AF_XDP for virtio-net. It means AF_XDP needs to
> > know the dma device to perform DMA mapping. So we introduce a helper
> > to expose the dma dev of the virtio device.
>
> The whole virtio architecture is based around the core code doing
> the DMA mapping.  I can't see how you can just export a helper to
> expose the dma device.  You'd have to complete rework the layering
> of the virtio code if you want to do it in the upper level drivers.
> And why would you want to do this?  The low-level code is the only
> piece that can actually know if you need to do a dma mapping.  All
> the kernel subsystems that don't do it inside the low-level drivers
> or helpers closely associtated are a giant and hard to fix map
> (see usb for the prime exhibit).
>
> So the first question is:  why do you want this for XF_ADP,

Xuan, is it possible to set up the DMA mapping inside the virtio
driver itself? I vaguely remember at least the RX buffer mapping is
done by the driver. If this is true, we can avoid exposing DMA details
to the upper layer.

> and
> the next question will be how to do that without making a complete
> mess.
>
> > This works fine as long as VIRTIO_F_ACCESS_PLATFORM is negotiated. But
> > when it is not, the virtio driver needs to use a physical address so
> > we want to expose the virtio device without dma_ops in the hope that
> > it will go for direct mapping where the physical address is used. But
> > it may not work on some specific setups (arches that assume an IOMMU
> > or have arch dma ops).
>
> The DMA device for virtio_pci is the underlying PCI device, always.
> !VIRTIO_F_ACCESS_PLATFORM means there is no dma device at all.  Because
> of all these things you can't just expose a pointer to the dma_device
> as that is just a completely wrong way of thinking about the problem.

Ok, so if there's no DMA at all we should avoid using the DMA API
completely. This means we should check dma_dev against NULL in
virtio_has_dma_quirk().

Thanks

>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2023-04-11  3:57 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27  4:05 [PATCH vhost v6 00/11] virtio core prepares for AF_XDP Xuan Zhuo
2023-03-27  4:05 ` [PATCH vhost v6 01/11] virtio_ring: split: separate dma codes Xuan Zhuo
2023-03-28  6:26   ` Jason Wang
2023-03-27  4:05 ` [PATCH vhost v6 02/11] virtio_ring: packed: " Xuan Zhuo
2023-03-27  4:05 ` [PATCH vhost v6 03/11] virtio_ring: packed-indirect: " Xuan Zhuo
2023-03-27  4:05 ` [PATCH vhost v6 04/11] virtio_ring: split: support premapped Xuan Zhuo
2023-03-28  6:27   ` Jason Wang
2023-03-27  4:05 ` [PATCH vhost v6 05/11] virtio_ring: packed: " Xuan Zhuo
2023-03-28  6:27   ` Jason Wang
2023-03-27  4:05 ` [PATCH vhost v6 06/11] virtio_ring: packed-indirect: " Xuan Zhuo
2023-03-28  6:29   ` Jason Wang
2023-03-27  4:05 ` [PATCH vhost v6 07/11] virtio_ring: update document for virtqueue_add_* Xuan Zhuo
2023-03-28  6:30   ` Jason Wang
2023-03-27  4:05 ` [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev() Xuan Zhuo
2023-04-06 17:20   ` Guenter Roeck
2023-04-07  3:17     ` Xuan Zhuo
2023-04-07 12:34       ` Guenter Roeck
2023-04-07 11:02     ` Michael S. Tsirkin
2023-04-10  3:29       ` Xuan Zhuo
2023-04-10  5:14         ` Jason Wang
2023-04-10  6:03           ` Xuan Zhuo
2023-04-10  6:40             ` Michael S. Tsirkin
2023-04-10  6:42               ` Xuan Zhuo
2023-04-10 15:27           ` Christoph Hellwig
2023-04-11  1:56             ` Xuan Zhuo
2023-04-11  2:09               ` Jason Wang
2023-04-11  3:31                 ` Christoph Hellwig
2023-04-11  3:56                   ` Jason Wang [this message]
2023-04-11  4:09                     ` Christoph Hellwig
2023-04-11  4:54                       ` Jason Wang
2023-04-11  5:14                         ` Christoph Hellwig
2023-04-11  5:19                           ` Jason Wang
2023-04-11  8:55                         ` Gerd Hoffmann
2023-04-11  6:11                     ` Xuan Zhuo
2023-04-11  6:20                       ` Christoph Hellwig
2023-04-11  6:28                         ` Xuan Zhuo
2023-04-11  6:46                           ` Christoph Hellwig
2023-04-11  6:51                             ` Xuan Zhuo
2023-04-11  7:04                               ` Xuan Zhuo
2023-04-12  2:03                           ` Xuan Zhuo
2023-04-12 11:54                             ` Christoph Hellwig
2023-04-11  3:26               ` Christoph Hellwig
2023-04-11  6:23                 ` Xuan Zhuo
2023-04-11  6:30                   ` Christoph Hellwig
2023-04-11  6:33                     ` Xuan Zhuo
2023-04-11  6:45                       ` Christoph Hellwig
2023-04-11  7:23                         ` Xuan Zhuo
2023-04-11 12:16                           ` Christoph Hellwig
2023-04-18  6:18                             ` Xuan Zhuo
2023-04-19  5:10                               ` Christoph Hellwig
2023-04-19  6:16                                 ` Xuan Zhuo
2023-04-11  7:12           ` Xuan Zhuo
2023-04-11  8:59             ` Jason Wang
2023-04-11 12:17             ` Christoph Hellwig
2023-03-27  4:05 ` [PATCH vhost v6 09/11] virtio_ring: correct the expression of the description of virtqueue_resize() Xuan Zhuo
2023-03-27  4:05 ` [PATCH vhost v6 10/11] virtio_ring: separate the logic of reset/enable from virtqueue_resize Xuan Zhuo
2023-03-27  4:05 ` [PATCH vhost v6 11/11] virtio_ring: introduce virtqueue_reset() Xuan Zhuo

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=CACGkMEtD0BLBXv7S-TLY-Y483_Lx4UskLyPmEC2wyGa8VE_R6w@mail.gmail.com \
    --to=jasowang@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux@roeck-us.net \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --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).