Re: [PATCH 09/10] sh: don't allow non-coherent DMA for NOMMU

From: Rich Felker
Date: Fri Aug 28 2020 - 11:10:00 EST


On Fri, Aug 28, 2020 at 11:26:57AM +0200, Ulf Hansson wrote:
> On Fri, 28 Aug 2020 at 06:24, Christoph Hellwig <hch@xxxxxx> wrote:
> >
> > On Thu, Aug 27, 2020 at 10:11:53PM -0400, Rich Felker wrote:
> > > > This change broke SD card support on J2 because MMC_SPI spuriously
> > > > depends on HAS_DMA. It looks like it can be fixed just by removing
> > > > that dependency from drivers/mmc/host/Kconfig.
> > >
> > > It can't. mmp_spi_probe fails with ENOMEM, probably due to trying to
> > > do some DMA setup thing that's not going to be needed if the
> > > underlying SPI device doesn't support/use DMA.
> >
> > Adding the linux-mmc and linux-spi lists, as that seems pretty odd.
>
> The mmc_spi driver needs modernizations, so I am not surprised to see
> odd things.
>
> My guess is that in ->probe() we check "if
> (spi->master->dev.parent->dma_mask)" - > and runs dma_map*()
> operations, which fails and leads to bailing out of ->probe() to
> return an error code.
>
> However, by looking at the code, one get the feeling that the DMA
> support is somewhat prepared to be made optional. I guess it has never
> been really tested, as the Kconfig option has "depends on HAS_DMA" -
> and it's been like that as long as I can remember.

It always worked on our "byte-banged" SPI controller, with no DMA
controller present, before Christoph's changes in this patch series,
and seems to be working now (although I have some other, hopefully
unrelated regressions to debug) with #ifdef CONFIG_HAS_DMA around the
if (spi->master->dev.parent->dma_mask) block in mmc_spi_probe. That's
probably not the right fix though -- why isn't it checking
host->dma_dev instead and only attempting DMA setup if dma_dev is
non-null?

Rich