Re: remove the ->mapping_error method from dma_map_ops V2

From: Christoph Hellwig
Date: Thu Nov 29 2018 - 11:23:28 EST


On Wed, Nov 28, 2018 at 11:19:15AM -0800, Linus Torvalds wrote:
> Let me just paste it back in here:
>
> "Which is what we ALREADY do for these exact reasons. If the DMA
> mappings means that you'd need to add one more page to that list of
> reserved pages, then so be it."
>
> So no, I'm not at all confused.
>
> Let me re-iterate: the argument that all addresses have to be dma'able is
> garbage.
>
> *Exactly* as with kmalloc and limited virtual addresses, we can limit
> physical addresses.

We can. At least in theory. The problem is that depending on the
crazy mapping from physical and kernel virtual address to dma addresses
these might be pages at pretty random places. Look at fun like
arch/x86/pci/sta2x11-fixup.c for how ugly these mappings could look.

It also means that we might have setup swiotlb on just about every
32-bit architecture, even if it has no real addressing limit except for
the one we imposed. I don't really see how this is a win for us just
to be able to report more detailed error codes, which would be nice
to have, but the lack of which hasn't really harmed us.

So as far as I'm concerned I'd go either with the series that we are
discussing here, or change the map_page method to return an errno
and the dma_addr_t in the argument. As Davem pointed out that can lead
to less optimal code, but it would still be better than the indirect
call we have. But then again I think the series as posted here might
and up much simpler and good enough without opening up this rathole.