Re: spi-mem and gpio chipselects

From: Chris Packham
Date: Mon Nov 04 2019 - 15:06:52 EST


On Mon, 2019-11-04 at 12:44 +0000, Mark Brown wrote:
> On Mon, Nov 04, 2019 at 12:35:24AM +0000, Chris Packham wrote:
>
> > I'm working on a platform that has a slightly complicated scheme for
> > SPI chip-selects using gpios[1]. The spi controller driver in this case
> > supports the spi-mem operations which appear to bypass the generic
> > spi_set_cs().
> > Would there be any harm in adding calls to spi_set_cs() to spi-mem.c?
> > Naively spi_mem_access_start() and spi_mem_access_end() seem like
> > convenient places to start.
>
> That's only going to work in cases where the controller translates
> things into a single SPI operation on the flash which I'm not sure is
> always going to be the case. We'd need a way to guarantee that the
> controller is going to do that in order to avoid data corruption issues.

In my particular case (spi-bcm-qspi.c) bcm_qspi_bspi_exec_mem_op() does
seem to assert the native chip-select then do it's operation. As I
understand the wait_for_completion_timeout() will schedule so other
tasks may run but spi_mem_access_start() has taken an io_mutex so
anything that accesses that spi bus will block.