Message ID | 328318841455e505370ef8ecad97b646c033dc8a.1562148527.git.lukas@wunner.de (mailing list archive) |
---|---|
State | Accepted |
Commit | 8d8bef50365847134b51c1ec46786bc2873e4e47 |
Headers | show |
Series | [for-5.3] spi: bcm2835: Fix 3-wire mode if DMA is enabled | expand |
Am 03.07.19 um 12:29 schrieb Lukas Wunner: > Commit 6935224da248 ("spi: bcm2835: enable support of 3-wire mode") > added 3-wire support to the BCM2835 SPI driver by setting the REN bit > (Read Enable) in the CS register when receiving data. The REN bit puts > the transmitter in high-impedance state. The driver recognizes that > data is to be received by checking whether the rx_buf of a transfer is > non-NULL. > > Commit 3ecd37edaa2a ("spi: bcm2835: enable dma modes for transfers > meeting certain conditions") subsequently broke 3-wire support because > it set the SPI_MASTER_MUST_RX flag which causes spi_map_msg() to replace > rx_buf with a dummy buffer if it is NULL. As a result, rx_buf is > *always* non-NULL if DMA is enabled. > > Reinstate 3-wire support by not only checking whether rx_buf is non-NULL, > but also checking that it is not the dummy buffer. > > Fixes: 3ecd37edaa2a ("spi: bcm2835: enable dma modes for transfers meeting certain conditions") > Reported-by: Nuno Sá <nuno.sa@analog.com> > Signed-off-by: Lukas Wunner <lukas@wunner.de> > Cc: stable@vger.kernel.org # v4.2+ > Cc: Martin Sperl <kernel@martin.sperl.org> Acked-by: Stefan Wahren <wahrenst@gmx.net> Please use my new address in the future
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index 6f243a90c844..840b1b8ff3dc 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -834,7 +834,8 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr, bcm2835_wr(bs, BCM2835_SPI_CLK, cdiv); /* handle all the 3-wire mode */ - if ((spi->mode & SPI_3WIRE) && (tfr->rx_buf)) + if (spi->mode & SPI_3WIRE && tfr->rx_buf && + tfr->rx_buf != ctlr->dummy_rx) cs |= BCM2835_SPI_CS_REN; else cs &= ~BCM2835_SPI_CS_REN;
Commit 6935224da248 ("spi: bcm2835: enable support of 3-wire mode") added 3-wire support to the BCM2835 SPI driver by setting the REN bit (Read Enable) in the CS register when receiving data. The REN bit puts the transmitter in high-impedance state. The driver recognizes that data is to be received by checking whether the rx_buf of a transfer is non-NULL. Commit 3ecd37edaa2a ("spi: bcm2835: enable dma modes for transfers meeting certain conditions") subsequently broke 3-wire support because it set the SPI_MASTER_MUST_RX flag which causes spi_map_msg() to replace rx_buf with a dummy buffer if it is NULL. As a result, rx_buf is *always* non-NULL if DMA is enabled. Reinstate 3-wire support by not only checking whether rx_buf is non-NULL, but also checking that it is not the dummy buffer. Fixes: 3ecd37edaa2a ("spi: bcm2835: enable dma modes for transfers meeting certain conditions") Reported-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: stable@vger.kernel.org # v4.2+ Cc: Martin Sperl <kernel@martin.sperl.org> --- drivers/spi/spi-bcm2835.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)