On 2019-05-23 4:26 a.m., Christoph Hellwig wrote: > On Thu, May 23, 2019 at 10:06:28AM +0000, Koenig, Christian wrote: >> Ok, we certainly don't have a system which exercise this user case. >> Could ask around if we have an ARM SOC with that properties somewhere. >> >> But asking the other way around: Where is the right place to start >> fixing all this? dma_map_resource()? > > That is the the big gorrilla in the room. The offset applies to the > device whos BARs/resources we map. The current dma_map_resource API > does not even have the right information. So I think we need to > enhance the API to pass a second struct device and we could fix it > there and then in the next steps add a map_sg version of > dma_map_resource and eventually also convert the PCIe P2P map_sg > over to that. IMO, this logic belongs in pci_p2pdma_map_* helpers that call dma_map_* helpers when appropriate. Changing dma_map_resource() to take two devices won't always make sense. For example, there are existing use cases of dma_map_resource() that work with the Intel IOAT DMA engine and thus it's known that those transactions will always go through the IOMMU if it's enabled; and therefore the existing dma_map_resource() is appropriate. Logan