Re: [PATCH 2/2] ARM: dma-mapping: allow larger DMA mask than supported

From: Christoph Hellwig
Date: Tue May 21 2019 - 09:07:03 EST


On Tue, May 21, 2019 at 02:00:47PM +0100, Russell King - ARM Linux admin wrote:
> On Tue, May 21, 2019 at 02:47:29PM +0200, Christoph Hellwig wrote:
> > Since Linux 5.1 we allow drivers to just set the largest DMA mask they
> > support instead of falling back to smaller ones.
>
> This doesn't make sense. "they" is confusing - why would a driver set
> a DMA mask larger than the driver supports? Or is "they" not
> referring to the drivers (in which case, what is it referring to?)

The current plan is:

- the driver sets whatever the device supports, and unless that mask
is too small to be supportable it will always succeed

Which replaces the previous scheme of:

- the driver tries to set whatever the device supports. If there are
addressing limitation outside the device (e.g. the PCIe root port,
or the AXI interconnect) that will fail, and the device will set
a 32-bit mask instead which it assumes will generally work.

> The point of this check is to trap the case where we have, for example,
> 8GB of memory, but dma_addr_t is 32-bit. We can allocate in the high
> 4GB, but we can't represent the address in a dma_addr_t.

Yep, and that is what patch 1/2 should handle by truncating the
dma mask to something that can work. I don't actually have hardware
I could test this scenario on, though.