On Fri, May 09, 2025 at 01:04:58PM +1000, Alexey Kardashevskiy wrote: > Ping?
Sorry for late reply from vacation. > Also, since there is pushback on 01/12 "dma-buf: Introduce > dma_buf_get_pfn_unlocked() kAPI", what is the plan now? Thanks, As disscussed in the thread, this kAPI is not well considered but IIUC the concept of "importer mapping" is still valid. We need more investigation about all the needs - P2P, CC memory, private bus channel, and work out a formal API. However in last few months I'm focusing on high level TIO flow - TSM framework, IOMMUFD based bind/unbind, so no much progress here and is still using this temporary kAPI. But as long as "importer mapping" is alive, the dmabuf fd for KVM is still valid and we could enable TIO based on that. > > > On 29/4/25 17:50, Alexey Kardashevskiy wrote: > > > > > > On 29/4/25 16:48, Alexey Kardashevskiy wrote: > > > On 8/1/25 01:27, Xu Yilun wrote: > > > > This series is based on an earlier kvm-coco-queue version (v6.12-rc2) > > > > > > Has this been pushed somewhere public? The patchset does not apply on top > > > of v6.12-rc2, for example (I fixed locally). Sorry, not yet. I'm trying to solve this ... same for the QEMU tree. > > > Also, is there somewhere a QEMU tree using this? I am trying to use this > > > new DMA_BUF feature and this require quite some not so obvious plumbing. > > > Thanks, > > > > > > More to the point, to make it work, QEMU needs to register VFIO MMIO BAR > > with KVM_SET_USER_MEMORY_REGION2 which passes slot->guest_memfd to KVM > > which essentially comes from > > VFIORegion->mmaps[0].mem->ram_block->guest_memfd. But since you disabled > > mmap for private MMIO, there is no MR which QEMU would even try registering > > as KVM memslot and there are many ways to fix it. I took a shortcut and > > reenabled mmap() but wonder what exactly you did. Makes sense? Thanks, Yes, QEMU needs change. 08/12 "vfio/pci: Create host unaccessible dma-buf for private deviceā adds a new flag VFIO_REGION_INFO_FLAG_PRIVATE to indicate user could create dmabuf on this region. I'm also not very serious about QEMU changes now, just FYI: I use VFIO_REGION_INFO_FLAG_PRIVATE flag to revive region->mmaps. int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *region, ... + if (region->flags & VFIO_REGION_INFO_FLAG_PRIVATE) { + region->nr_mmaps = 1; + region->mmaps = g_new0(VFIOMmap, region->nr_mmaps); + region->mmaps[0].offset = 0; + region->mmaps[0].size = region->size; + region->mmaps[0].dmabuf_fd = -1; } Then in vfio_region_mmap(), use a new memory_region_init_dmabuf() to populate the MR. int vfio_region_mmap(VFIORegion *region) + if (use_dmabuf) { + /* create vfio dmabuf fd */ + ret = vfio_create_dmabuf(region->vbasedev, region->nr, + region->mmaps[i].offset, + region->mmaps[i].size); + if (ret < 0) { + goto sub_unmap; + } + + region->mmaps[i].dmabuf_fd = ret; + + name = g_strdup_printf("%s dmabuf[%d]", + memory_region_name(region->mem), i); + memory_region_init_dmabuf(®ion->mmaps[i].mem, + memory_region_owner(region->mem), + name, region->mmaps[i].size, + region->mmaps[i].dmabuf_fd); + g_free(name); + } else { Thanks, Yilun