From: Christoph Hellwig <hch@infradead.org>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: "Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
virtualization@lists.linux-foundation.org,
"Christoph Hellwig" <hch@infradead.org>,
"Björn Töpel" <bjorn@kernel.org>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
"Guenter Roeck" <linux@roeck-us.net>
Subject: Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()
Date: Wed, 12 Apr 2023 04:54:54 -0700 [thread overview]
Message-ID: <ZDacDi/THFo0UIfu@infradead.org> (raw)
In-Reply-To: <1681265026.6082013-1-xuanzhuo@linux.alibaba.com>
On Wed, Apr 12, 2023 at 10:03:46AM +0800, Xuan Zhuo wrote:
> We discusses this question last at [1]. We planned to pass one device to xsk.
> Then xsk can use the DMA API on this device. The device can be one hw
> device(such as PCI, mmio) or virtio device. If it is one hw device, no problem.
What do you mean with one here? A virtio device should never be baken
by more than one hardware device.
> If it is one virtio device, then we expect that DMA API on that will return
> direct dma map, because the dma_ops of the virtio device is NULL. But on some
> platform such as sparc64 or some case of x86, the arch has own dma_ops. So we
> wrong.
No, you can't expect a device to use any particular dma ops. Most
platforms support either the direct mapping or some form of IOMMU.
But for virtio thinks are even more complicated - unless
VIRTIO_F_ACCESS_PLATFORM is set (which really must be set for all
real hardware devices for them to work), the DMA API isn't even used
at all. That means the virtual platform (i.e.g qemu) does DMA based
on physical addresses and virtio ignores all the plaform DMA setup.
> And as the discuss of this thread, we cannot get direct dma address from
> virtio device by DMA API. So, we need xsk to expose the DMA ops to the
> virtio-net driver when virtio core can not use the DMA API.
>
> All the processing of dma inside xsk:
> 1. map/unmap at enable/disable
> 2. dma sync
For the VIRTIO_F_ACCESS_PLATFORM you can just use the DMA API like
any other device, but this really should be done inside virtio instead
of an upper layer.
For the !VIRTIO_F_ACCESS_PLATFORM case there is no need to sync,
and the dma mapping is a simple virt_to_phys or page_to_phys, so
there's no real need to premap to start with.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2023-04-12 11:55 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
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 [this message]
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=ZDacDi/THFo0UIfu@infradead.org \
--to=hch@infradead.org \
--cc=bjorn@kernel.org \
--cc=linux@roeck-us.net \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--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).