From: Ruihan Li
Sent: 15 May 2023 14:10
When hcd->localmem_pool is non-null, localmem_pool is used to allocate DMA memory. In this case, the dma address will be properly returned (in dma_handle), and dma_mmap_coherent should be used to map this memory into the user space. However, the current implementation uses pfn_remap_range, which is supposed to map normal pages.
I've an (out of tree) driver that does the same. Am I right in thinking that this does still work?
I can't change the driver to use dma_map_coherent() because it doesn't let me mmap from a page offset within a 16k allocation.
In this case the memory area is an 8MB shared transfer area to an FPGA PCIe target sparsely filled with 16kB allocation (max 512 allocs). The discontinuous physical memory blocks appear as logically contiguous to both the FPGA logic and when mapped to userspace. (But not to driver code.)
I don't really want to expose the 16k allocation size to userspace. If we need more than 8MB then the allocation size would need changing.
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)