Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-19 Thread Xuan Zhuo
On Tue, 18 Apr 2023 22:10:03 -0700, Christoph Hellwig wrote: > On Tue, Apr 18, 2023 at 02:18:52PM +0800, Xuan Zhuo wrote: > > Sorry, rethink about this, I think we maybe misunderstand something. > > > > First of all, let me give you a brief introduce of virtio device and pci > > device. > > If

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-18 Thread Christoph Hellwig
On Tue, Apr 18, 2023 at 02:18:52PM +0800, Xuan Zhuo wrote: > Sorry, rethink about this, I think we maybe misunderstand something. > > First of all, let me give you a brief introduce of virtio device and pci > device. > If I make mistake, please point out. > > > First, when one virtio pci

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-18 Thread Xuan Zhuo
On Tue, 11 Apr 2023 05:16:19 -0700, Christoph Hellwig wrote: > On Tue, Apr 11, 2023 at 03:23:43PM +0800, Xuan Zhuo wrote: > > > If a direct map or not is used is a decision done by the platform code, > > > often based on firmware tables. You can't just override that. > > > > > > Can Virtio

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-12 Thread Christoph Hellwig
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.

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Xuan Zhuo
Here, this has cc the maintainers of AF_XDP. For on the same page, I summarize it. 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

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Christoph Hellwig
On Tue, Apr 11, 2023 at 03:12:13PM +0800, Xuan Zhuo wrote: > > Hi Jason > > Can we force virtio core to use dma api without VIRTIO_F_ACCESS_PLATFORM? So in your last mail you asked for it to be the other way around? But, no you can't do this either unless you control the platform as in the Xen

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Christoph Hellwig
On Tue, Apr 11, 2023 at 03:23:43PM +0800, Xuan Zhuo wrote: > > If a direct map or not is used is a decision done by the platform code, > > often based on firmware tables. You can't just override that. > > > Can Virtio Device set its own dma_ops? It is a device on the virtual bus. It > sets its

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Jason Wang
On Tue, Apr 11, 2023 at 3:21 PM Xuan Zhuo wrote: > > > Hi Jason > > Can we force virtio core to use dma api without VIRTIO_F_ACCESS_PLATFORM? > > I don't think so. Without ACCESS_PLATFORM it's not DMA, so DMA API should be avoided. And we have several software devices for virtio now. I'd

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Gerd Hoffmann
On Tue, Apr 11, 2023 at 12:54:46PM +0800, Jason Wang wrote: > On Tue, Apr 11, 2023 at 12:10 PM Christoph Hellwig wrote: > > > > On Tue, Apr 11, 2023 at 11:56:47AM +0800, Jason Wang wrote: > > > > The DMA device for virtio_pci is the underlying PCI device, always. > > > > !VIRTIO_F_ACCESS_PLATFORM

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Xuan Zhuo
On Mon, 10 Apr 2023 23:45:33 -0700, Christoph Hellwig wrote: > On Tue, Apr 11, 2023 at 02:33:29PM +0800, Xuan Zhuo wrote: > > Do you mean my idea is wrong, right? > > > > Can you explain it? Why can't we support a device that uses only dirct map? > > If a direct map or not is used is a decision

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Xuan Zhuo
Hi Jason Can we force virtio core to use dma api without VIRTIO_F_ACCESS_PLATFORM? Thanks. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Xuan Zhuo
On Tue, 11 Apr 2023 14:51:29 +0800, Xuan Zhuo wrote: > On Mon, 10 Apr 2023 23:46:56 -0700, Christoph Hellwig > wrote: > > On Tue, Apr 11, 2023 at 02:28:00PM +0800, Xuan Zhuo wrote: > > > > That is just completely broken, virtio or not. Highlevel code like > > > > sockets must never do dma

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Xuan Zhuo
On Mon, 10 Apr 2023 23:46:56 -0700, Christoph Hellwig wrote: > On Tue, Apr 11, 2023 at 02:28:00PM +0800, Xuan Zhuo wrote: > > > That is just completely broken, virtio or not. Highlevel code like > > > sockets must never do dma mappings themselves. > > > > AF_XDP provides some API for net

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Christoph Hellwig
On Tue, Apr 11, 2023 at 02:28:00PM +0800, Xuan Zhuo wrote: > > That is just completely broken, virtio or not. Highlevel code like > > sockets must never do dma mappings themselves. > > AF_XDP provides some API for net driver. This API will do dma map or dma sync. > > cc AF_XDP maintainers. So

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Christoph Hellwig
On Tue, Apr 11, 2023 at 02:33:29PM +0800, Xuan Zhuo wrote: > Do you mean my idea is wrong, right? > > Can you explain it? Why can't we support a device that uses only dirct map? If a direct map or not is used is a decision done by the platform code, often based on firmware tables. You can't

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Xuan Zhuo
On Mon, 10 Apr 2023 23:30:29 -0700, Christoph Hellwig wrote: > > > Can you please explain what you're even trying to do? > > > > I want to force a device use direct dma map. > > You fundamentally can't do that. It can't work. Do you mean my idea is wrong, right? Can you explain it? Why can't

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Xuan Zhuo
On Mon, 10 Apr 2023 23:20:59 -0700, Christoph Hellwig wrote: > On Tue, Apr 11, 2023 at 02:11:17PM +0800, Xuan Zhuo wrote: > > NO, all dma maping is done inside xdp socket. That is done > > when setup. > > That is just completely broken, virtio or not. Highlevel code like > sockets must never do

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Christoph Hellwig
> > Can you please explain what you're even trying to do? > > I want to force a device use direct dma map. You fundamentally can't do that. It can't work. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Xuan Zhuo
On Mon, 10 Apr 2023 20:26:20 -0700, Christoph Hellwig wrote: > On Tue, Apr 11, 2023 at 09:56:19AM +0800, Xuan Zhuo wrote: > > Do you mean we should not change the dma_ops from the outside of the core > > kernel/dma/? > > Basically, yes. That plus probing for the IOMMU drivers. > > > How about

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Christoph Hellwig
On Tue, Apr 11, 2023 at 02:11:17PM +0800, Xuan Zhuo wrote: > NO, all dma maping is done inside xdp socket. That is done > when setup. That is just completely broken, virtio or not. Highlevel code like sockets must never do dma mappings themselves. ___

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-11 Thread Xuan Zhuo
On Tue, 11 Apr 2023 11:56:47 +0800, Jason Wang wrote: > On Tue, Apr 11, 2023 at 11:31 AM Christoph Hellwig 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

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Jason Wang
On Tue, Apr 11, 2023 at 1:14 PM Christoph Hellwig wrote: > > On Tue, Apr 11, 2023 at 12:54:46PM +0800, Jason Wang wrote: > > Ok, just to clarify, I meant there could be a case where the virtqueue > > is emulated by software, in this case we need check whether the > > virtqueue has a dma device or

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Christoph Hellwig
On Tue, Apr 11, 2023 at 12:54:46PM +0800, Jason Wang wrote: > Ok, just to clarify, I meant there could be a case where the virtqueue > is emulated by software, in this case we need check whether the > virtqueue has a dma device or not in vring_use_dma_api(). If not we > need return false. Well,

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Jason Wang
On Tue, Apr 11, 2023 at 12:10 PM Christoph Hellwig wrote: > > On Tue, Apr 11, 2023 at 11:56:47AM +0800, Jason Wang wrote: > > > 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

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Christoph Hellwig
On Tue, Apr 11, 2023 at 11:56:47AM +0800, Jason Wang wrote: > > 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

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Jason Wang
On Tue, Apr 11, 2023 at 11:31 AM Christoph Hellwig 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

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Christoph Hellwig
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

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Christoph Hellwig
On Tue, Apr 11, 2023 at 09:56:19AM +0800, Xuan Zhuo wrote: > Do you mean we should not change the dma_ops from the outside of the core > kernel/dma/? Basically, yes. That plus probing for the IOMMU drivers. > How about adding one new "dma_direct" to struct devive? Why would we? Can you please

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Jason Wang
On Tue, Apr 11, 2023 at 10:01 AM Xuan Zhuo wrote: > > On Mon, 10 Apr 2023 08:27:14 -0700, Christoph Hellwig > wrote: > > On Mon, Apr 10, 2023 at 01:14:13PM +0800, Jason Wang wrote: > > > > But rethink, this is unreliable. Some platforms have returned their own > > > > ops, > > > > including

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Xuan Zhuo
On Mon, 10 Apr 2023 08:27:14 -0700, Christoph Hellwig wrote: > On Mon, Apr 10, 2023 at 01:14:13PM +0800, Jason Wang wrote: > > > But rethink, this is unreliable. Some platforms have returned their own > > > ops, > > > including X86. > > > > > > Because the priority of dev->dma_ops is higher

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Christoph Hellwig
On Mon, Apr 10, 2023 at 01:14:13PM +0800, Jason Wang wrote: > > But rethink, this is unreliable. Some platforms have returned their own ops, > > including X86. > > > > Because the priority of dev->dma_ops is higher than get_arch_dma_ops(), we > > should not let dev->dma_ops be null. We should

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Xuan Zhuo
On Mon, 10 Apr 2023 02:40:58 -0400, "Michael S. Tsirkin" wrote: > On Mon, Apr 10, 2023 at 02:03:37PM +0800, Xuan Zhuo wrote: > > On Mon, 10 Apr 2023 13:14:13 +0800, Jason Wang wrote: > > > On Mon, Apr 10, 2023 at 11:48 AM Xuan Zhuo > > > wrote: > > > > > > > > On Fri, 7 Apr 2023 07:02:34

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Michael S. Tsirkin
On Mon, Apr 10, 2023 at 02:03:37PM +0800, Xuan Zhuo wrote: > On Mon, 10 Apr 2023 13:14:13 +0800, Jason Wang wrote: > > On Mon, Apr 10, 2023 at 11:48 AM Xuan Zhuo > > wrote: > > > > > > On Fri, 7 Apr 2023 07:02:34 -0400, "Michael S. Tsirkin" > > > wrote: > > > > On Thu, Apr 06, 2023 at

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-10 Thread Xuan Zhuo
On Mon, 10 Apr 2023 13:14:13 +0800, Jason Wang wrote: > On Mon, Apr 10, 2023 at 11:48 AM Xuan Zhuo wrote: > > > > On Fri, 7 Apr 2023 07:02:34 -0400, "Michael S. Tsirkin" > > wrote: > > > On Thu, Apr 06, 2023 at 10:20:09AM -0700, Guenter Roeck wrote: > > > > Hi, > > > > > > > > On Mon, Mar 27,

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-09 Thread Jason Wang
On Mon, Apr 10, 2023 at 11:48 AM Xuan Zhuo wrote: > > On Fri, 7 Apr 2023 07:02:34 -0400, "Michael S. Tsirkin" > wrote: > > On Thu, Apr 06, 2023 at 10:20:09AM -0700, Guenter Roeck wrote: > > > Hi, > > > > > > On Mon, Mar 27, 2023 at 12:05:33PM +0800, Xuan Zhuo wrote: > > > > Added

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-09 Thread Xuan Zhuo
On Fri, 7 Apr 2023 07:02:34 -0400, "Michael S. Tsirkin" wrote: > On Thu, Apr 06, 2023 at 10:20:09AM -0700, Guenter Roeck wrote: > > Hi, > > > > On Mon, Mar 27, 2023 at 12:05:33PM +0800, Xuan Zhuo wrote: > > > Added virtqueue_dma_dev() to get DMA device for virtio. Then the > > > caller can do dma

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-07 Thread Guenter Roeck
On 4/6/23 20:17, Xuan Zhuo wrote: On Thu, 6 Apr 2023 10:20:09 -0700, Guenter Roeck wrote: Hi, On Mon, Mar 27, 2023 at 12:05:33PM +0800, Xuan Zhuo wrote: Added virtqueue_dma_dev() to get DMA device for virtio. Then the caller can do dma operation in advance. The purpose is to keep memory

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-07 Thread Michael S. Tsirkin
On Thu, Apr 06, 2023 at 10:20:09AM -0700, Guenter Roeck wrote: > Hi, > > On Mon, Mar 27, 2023 at 12:05:33PM +0800, Xuan Zhuo wrote: > > Added virtqueue_dma_dev() to get DMA device for virtio. Then the > > caller can do dma operation in advance. The purpose is to keep memory > > mapped across

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-06 Thread Xuan Zhuo
On Thu, 6 Apr 2023 10:20:09 -0700, Guenter Roeck wrote: > Hi, > > On Mon, Mar 27, 2023 at 12:05:33PM +0800, Xuan Zhuo wrote: > > Added virtqueue_dma_dev() to get DMA device for virtio. Then the > > caller can do dma operation in advance. The purpose is to keep memory > > mapped across multiple

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-06 Thread Guenter Roeck
Hi, On Mon, Mar 27, 2023 at 12:05:33PM +0800, Xuan Zhuo wrote: > Added virtqueue_dma_dev() to get DMA device for virtio. Then the > caller can do dma operation in advance. The purpose is to keep memory > mapped across multiple add/get buf operations. > > Signed-off-by: Xuan Zhuo > Acked-by:

[PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-03-26 Thread Xuan Zhuo
Added virtqueue_dma_dev() to get DMA device for virtio. Then the caller can do dma operation in advance. The purpose is to keep memory mapped across multiple add/get buf operations. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/virtio/virtio.c | 6 ++