stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled" failed to apply to 5.2-stable tree
@ 2019-08-07 16:48 gregkh
  2019-08-07 20:58 ` Lukas Wunner
  0 siblings, 1 reply; 5+ messages in thread
From: gregkh @ 2019-08-07 16:48 UTC (permalink / raw)
  To: lukas, broonie, kernel, nuno.sa, wahrenst; +Cc: stable


The patch below does not apply to the 5.2-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 8d8bef50365847134b51c1ec46786bc2873e4e47 Mon Sep 17 00:00:00 2001
From: Lukas Wunner <lukas@wunner.de>
Date: Wed, 3 Jul 2019 12:29:31 +0200
Subject: [PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
Link: https://lore.kernel.org/r/328318841455e505370ef8ecad97b646c033dc8a.1562148527.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>

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;


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: FAILED: patch "[PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled" failed to apply to 5.2-stable tree
  2019-08-07 16:48 FAILED: patch "[PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled" failed to apply to 5.2-stable tree gregkh
@ 2019-08-07 20:58 ` Lukas Wunner
  2019-08-08  5:56   ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Lukas Wunner @ 2019-08-07 20:58 UTC (permalink / raw)
  To: gregkh; +Cc: broonie, kernel, nuno.sa, wahrenst, stable

On Wed, Aug 07, 2019 at 06:48:07PM +0200, gregkh@linuxfoundation.org wrote:
> The patch below does not apply to the 5.2-stable tree.

That's odd, it works for me:

$ git fetch linux-stable
$ git checkout linux-stable/linux-5.2.y
Checking out files: 100% (43562/43562), done.
HEAD is now at 5697a9d... Linux 5.2.7
$ git am /tmp/pt
Applying: spi: bcm2835: Fix 3-wire mode if DMA is enabled

Could you be a little more specific why it couldn't be applied
when you tried it?

Thanks,

Lukas

> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> From 8d8bef50365847134b51c1ec46786bc2873e4e47 Mon Sep 17 00:00:00 2001
> From: Lukas Wunner <lukas@wunner.de>
> Date: Wed, 3 Jul 2019 12:29:31 +0200
> Subject: [PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> 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>
> Link: https://lore.kernel.org/r/328318841455e505370ef8ecad97b646c033dc8a.1562148527.git.lukas@wunner.de
> Signed-off-by: Mark Brown <broonie@kernel.org>
> 
> 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;
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FAILED: patch "[PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled" failed to apply to 5.2-stable tree
  2019-08-07 20:58 ` Lukas Wunner
@ 2019-08-08  5:56   ` Greg KH
  2019-08-08  6:23     ` Lukas Wunner
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2019-08-08  5:56 UTC (permalink / raw)
  To: Lukas Wunner; +Cc: broonie, kernel, nuno.sa, wahrenst, stable

On Wed, Aug 07, 2019 at 10:58:49PM +0200, Lukas Wunner wrote:
> On Wed, Aug 07, 2019 at 06:48:07PM +0200, gregkh@linuxfoundation.org wrote:
> > The patch below does not apply to the 5.2-stable tree.
> 
> That's odd, it works for me:
> 
> $ git fetch linux-stable
> $ git checkout linux-stable/linux-5.2.y
> Checking out files: 100% (43562/43562), done.
> HEAD is now at 5697a9d... Linux 5.2.7
> $ git am /tmp/pt
> Applying: spi: bcm2835: Fix 3-wire mode if DMA is enabled
> 
> Could you be a little more specific why it couldn't be applied
> when you tried it?

Sorry, that's the problem of form letters, sometimes they are wrong :(

The patch applies everywhere, but breaks the build in all trees.  So it
needs to be modified to build properly.  I need to write up a different
error message for this type of failure one of these days, luckily it is
pretty rare.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FAILED: patch "[PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled" failed to apply to 5.2-stable tree
  2019-08-08  5:56   ` Greg KH
@ 2019-08-08  6:23     ` Lukas Wunner
  2019-08-08 10:01       ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Lukas Wunner @ 2019-08-08  6:23 UTC (permalink / raw)
  To: Greg KH; +Cc: broonie, kernel, nuno.sa, wahrenst, stable

On Thu, Aug 08, 2019 at 07:56:25AM +0200, Greg KH wrote:
> On Wed, Aug 07, 2019 at 10:58:49PM +0200, Lukas Wunner wrote:
> > On Wed, Aug 07, 2019 at 06:48:07PM +0200, gregkh@linuxfoundation.org wrote:
> > > The patch below does not apply to the 5.2-stable tree.
> 
> The patch applies everywhere, but breaks the build in all trees.

Ugh, yes you are right, my apologies.

The reason is that v5.3 converted spi-bcm2835.c to use the
"spi_controller" nomenclature instead of "spi_master" with
commit 5f336ea53b6b ("spi: bcm2835: Replace spi_master by
spi_controller").

The replacement patch below should hopefully not break the
build.  It's the same as upstream commit 8d8bef503658,
except one occurrence of "ctlr" is replaced by "master".

Thanks!

-- >8 --
From 8d8bef50365847134b51c1ec46786bc2873e4e47 Mon Sep 17 00:00:00 2001
From: Lukas Wunner <lukas@wunner.de>
Date: Wed, 3 Jul 2019 12:29:31 +0200
Subject: [PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
Link: https://lore.kernel.org/r/328318841455e505370ef8ecad97b646c033dc8a.1562148527.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>

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_master *master,
 	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 != master->dummy_rx)
 		cs |= BCM2835_SPI_CS_REN;
 	else
 		cs &= ~BCM2835_SPI_CS_REN;


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: FAILED: patch "[PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled" failed to apply to 5.2-stable tree
  2019-08-08  6:23     ` Lukas Wunner
@ 2019-08-08 10:01       ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2019-08-08 10:01 UTC (permalink / raw)
  To: Lukas Wunner; +Cc: broonie, kernel, nuno.sa, wahrenst, stable

On Thu, Aug 08, 2019 at 08:23:29AM +0200, Lukas Wunner wrote:
> On Thu, Aug 08, 2019 at 07:56:25AM +0200, Greg KH wrote:
> > On Wed, Aug 07, 2019 at 10:58:49PM +0200, Lukas Wunner wrote:
> > > On Wed, Aug 07, 2019 at 06:48:07PM +0200, gregkh@linuxfoundation.org wrote:
> > > > The patch below does not apply to the 5.2-stable tree.
> > 
> > The patch applies everywhere, but breaks the build in all trees.
> 
> Ugh, yes you are right, my apologies.
> 
> The reason is that v5.3 converted spi-bcm2835.c to use the
> "spi_controller" nomenclature instead of "spi_master" with
> commit 5f336ea53b6b ("spi: bcm2835: Replace spi_master by
> spi_controller").
> 
> The replacement patch below should hopefully not break the
> build.  It's the same as upstream commit 8d8bef503658,
> except one occurrence of "ctlr" is replaced by "master".

Thanks for this, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-08 10:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-07 16:48 FAILED: patch "[PATCH] spi: bcm2835: Fix 3-wire mode if DMA is enabled" failed to apply to 5.2-stable tree gregkh
2019-08-07 20:58 ` Lukas Wunner
2019-08-08  5:56   ` Greg KH
2019-08-08  6:23     ` Lukas Wunner
2019-08-08 10:01       ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).