On Tue, 11 Apr 2023 05:16:19 -0700, Christoph Hellwig <h...@infradead.org> 
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 Device set its own dma_ops? It is a device on the virtual bus. It
> > sets its own DMA_OPS. I think it is reasonable.
>
> No, it can't.  virtio devices are backed by PCI, platform or other
> bus devices, and the (often virtual) firmware controls how DMA mapping
> is to be performed for them, at least for the platform_access case.


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 device is probed, then the virtio pci driver will be
called. Then we got one pci_device.

Then virtio_pci_probe will alloc one new device, and register it to virtio bus
by register_virtio_device().


So here we have two device: pci-device and virtio-device.

If we call DMA API inside virtio, we use the pci-device. The virtio-device is
not used for DMA API.

Now we want to use the virtio-device to do direct dma. The virtio-device
is created by virtio_pci_probe() of virtio pci driver. And register to virtio
bus. So no firmware and not iommu and the bus is virtio bus, why we can not
change the dma_ops of virtio-device?


Thanks.





































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

Reply via email to