Re: [PATCH v1 RFC 1/2] spi: introduce fallback to pio

Mark Brown
2020-06-11T13:40:47Z

[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

On Thu, Jun 11, 2020 at 08:58:29PM +0800, Robin Gong wrote:
> Add SPI_CONTROLLER_FALLBACK to fallback to pio mode in case dma transfer
> failed.
> If spi client driver want to enable this feature please set master->flags
> with SPI_MASTER_FALLBACK and add master->fallback checking in its can_dma()
> as spi-imx.c

If we were going to do this I don't see why we'd have a flag for this
rather than just doing it unconditionally but...

> ret = ctlr->transfer_one(ctlr, msg->spi, xfer);
> if (ret < 0) {
> + if (ctlr->cur_msg_mapped &&
> + (ctlr->flags & SPI_CONTROLLER_FALLBACK)) {
> + __spi_unmap_msg(ctlr, msg);
> + ctlr->fallback = true;
> + goto fallback_pio;
> + }

...I don't think this can work sensibly - this is going to try PIO if
there's *any* error. We might have had some sort of issue during the
transfer for example so have some noise on the bus. Like I said on a
prior version of this I really think that we need to be figuring out if
the DMA controller can support the transaction before we even map the
buffer for it, having the controller just randomly fail underneath the
consumer just does not sound robust.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]