On Thu, Apr 20, 2023 at 09:18:21AM -0700, Christoph Hellwig wrote: > On Thu, Apr 20, 2023 at 05:11:48PM +0800, Xuan Zhuo wrote: > > I know that the current design of DMA API only supports some physical hardware, > > but can it be modified or expanded? > > I think the important point is that for some cases there is no need > to dma map at all, and upper layers should be fine by that by just > doing the dma mapping in helpers called by the driver. > > The virtio drivers then check if platform_access is set, then call the > generic dma mapping helper, or if not just allocate memory using > alloc_pages and also skip all the sync calls. In theory, absolutely. In practice modern virtio devices are ok, the reason we are stuck supporting old legacy ones is because legacy devices are needed to run old guests. And then people turn around and run a new guest on the same device, for example because they switch back and forth e.g. for data recovery? Or because whoever is selling the host wants to opt for maximum compatibility. Teaching all of linux to sometimes use dma and sometimes not is a lot of work, and for limited benefit of these legacy systems. We do it in a limited number of cases but generally making DMA itself DTRT sounds more attractive. So special DMA ops for these makes some sense: yes the firmware described DMA is wrong on these boxes but buggy firmware is not so unusual, is it? Given virtio devices actually are on a virtual bus (the virtio bus) sticking the fake DMA ops on this bus seems to make sense as a way to express this quirk. No? -- MST _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization