Re: [PATCH v3 0/6] Prerequisites for NXP LS104xA SMMU enablement

From: Robin Murphy
Date: Fri May 31 2019 - 13:48:55 EST


On 31/05/2019 18:08, Christoph Hellwig wrote:
On Fri, May 31, 2019 at 06:03:30PM +0100, Robin Murphy wrote:
The thing needs to be completely redone as it abuses parts of the
iommu API in a completely unacceptable way.

`git grep iommu_iova_to_phys drivers/{crypto,gpu,net}`

:(

I guess one alternative is for the offending drivers to maintain their own
lookup tables of mapped DMA addresses - I think at least some of these
things allow storing some kind of token in a descriptor, which even if it's
not big enough for a virtual address might be sufficient for an index.

Well, we'll at least need DMA API wrappers that work on the dma addr
only and hide this madness underneath. And then tell if an given device
supports this and fail the probe otherwise.

Bleh, I'm certainly not keen on formalising any kind of dma_to_phys()/dma_to_virt() interface for this. Or are you just proposing something like dma_unmap_sorry_sir_the_dog_ate_my_homework() for drivers which have 'lost' the original VA they mapped?

Robin.