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 device is probed, then the virtio pci driver will be > called. Then we got one pci_device. Yes. > 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. Yes. > If we call DMA API inside virtio, we use the pci-device. The virtio-device is > not used for DMA API. Exactly. > 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? Because firmware doesn't know about your virtio-device. It is just a made up Linux concept, and the IOMMU and firmware tables for it don't know about it. DMA must only ever be done on actual physical (including "physical" devices emulated by a hypervisor) devices, not on devices made up by Linux. _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization