Re: [PATCH v2 2/2] mmc: sdhci-tegra: Specify valid DMA mask

Arnd Bergmann
2016-03-04T08:38:34Z

On Friday 04 March 2016 15:43:56 Alexandre Courbot wrote:
> >
> > Yeah, I'm not too sure what is the point of setting the fake mask to
> > be honest, but you are definitely right that it is a contradiction to
> > call a DMA function on a device that is not DMA-capable.
>
> Ah, I finally got it - we are just setting it to the *address* of
> host->dma_mask so the device's DMA mask does not end up being a NULL
> pointer.
>
> That actually changes things a bit. DMA-capable devices are clearly
> expected to set the mask themselves, but the only one to do it is
> host/mtk-sd.c. And dma_set_mask() is only called in dw_mmc and
> sdhci-acpi's enable_dma callback.
>
> This means most DMA-capable devices (including Tegra, but not only)
> are simply left with no DMA setup at all.
>
> Probably we can detect when the host did not do any DMA setup in the
> probe function and attempt some sane defaults depending on what the
> hardware says it is capable of?

When the host leaves an empty DMA mask, the intended meaning is
that the device is not on a DMA capable bus, so if we run into
that case, we should instead fix the creation of the device
rather than the driver that looks at the data.

Arnd