All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: marvell: fix the IRQ handler complete() condition
@ 2018-10-03  9:05 Miquel Raynal
  2018-10-03 12:15 ` Boris Brezillon
  2018-10-05 14:39 ` Miquel Raynal
  0 siblings, 2 replies; 3+ messages in thread
From: Miquel Raynal @ 2018-10-03  9:05 UTC (permalink / raw)
  To: Boris Brezillon, Richard Weinberger, David Woodhouse,
	Brian Norris, Marek Vasut
  Cc: linux-mtd, daniel, Chris.Packham, Miquel Raynal, stable

With the current implementation, the complete() in the IRQ handler is
supposed to be called only if the register status has one or the other
RDY bit set. Other events might trigger an interrupt as well if
enabled, but should not end-up with a complete() call.

For this purpose, the code was checking if the other bits were set, in
this case complete() was not called. This is wrong as two events might
happen in a very tight time-frame and if the NDSR status read reports
two bits set (eg. RDY(0) and RDDREQ) at the same time, complete() was
not called.

This logic would lead to timeouts in marvell_nfc_wait_op() and has
been observed on PXA boards (NFCv1) in the Hamming write path.

Fixes: 02f26ecf8c77 ("mtd: nand: add reworked Marvell NAND controller driver")
Cc: stable@vger.kernel.org
Reported-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Daniel Mack <daniel@zonque.org>
---
 drivers/mtd/nand/raw/marvell_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
index bc2ef5209783..c7573ccdbacd 100644
--- a/drivers/mtd/nand/raw/marvell_nand.c
+++ b/drivers/mtd/nand/raw/marvell_nand.c
@@ -686,7 +686,7 @@ static irqreturn_t marvell_nfc_isr(int irq, void *dev_id)
 
 	marvell_nfc_disable_int(nfc, st & NDCR_ALL_INT);
 
-	if (!(st & (NDSR_RDDREQ | NDSR_WRDREQ | NDSR_WRCMDREQ)))
+	if (st & (NDSR_RDY(0) | NDSR_RDY(1)))
 		complete(&nfc->complete);
 
 	return IRQ_HANDLED;
-- 
2.17.1

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

* Re: [PATCH] mtd: rawnand: marvell: fix the IRQ handler complete() condition
  2018-10-03  9:05 [PATCH] mtd: rawnand: marvell: fix the IRQ handler complete() condition Miquel Raynal
@ 2018-10-03 12:15 ` Boris Brezillon
  2018-10-05 14:39 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Boris Brezillon @ 2018-10-03 12:15 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
	linux-mtd, daniel, Chris.Packham, stable

On Wed,  3 Oct 2018 11:05:04 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> With the current implementation, the complete() in the IRQ handler is
> supposed to be called only if the register status has one or the other
> RDY bit set. Other events might trigger an interrupt as well if
> enabled, but should not end-up with a complete() call.
> 
> For this purpose, the code was checking if the other bits were set, in
> this case complete() was not called. This is wrong as two events might
> happen in a very tight time-frame and if the NDSR status read reports
> two bits set (eg. RDY(0) and RDDREQ) at the same time, complete() was
> not called.
> 
> This logic would lead to timeouts in marvell_nfc_wait_op() and has
> been observed on PXA boards (NFCv1) in the Hamming write path.
> 
> Fixes: 02f26ecf8c77 ("mtd: nand: add reworked Marvell NAND controller driver")
> Cc: stable@vger.kernel.org
> Reported-by: Daniel Mack <daniel@zonque.org>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Tested-by: Daniel Mack <daniel@zonque.org>

Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>

> ---
>  drivers/mtd/nand/raw/marvell_nand.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> index bc2ef5209783..c7573ccdbacd 100644
> --- a/drivers/mtd/nand/raw/marvell_nand.c
> +++ b/drivers/mtd/nand/raw/marvell_nand.c
> @@ -686,7 +686,7 @@ static irqreturn_t marvell_nfc_isr(int irq, void *dev_id)
>  
>  	marvell_nfc_disable_int(nfc, st & NDCR_ALL_INT);
>  
> -	if (!(st & (NDSR_RDDREQ | NDSR_WRDREQ | NDSR_WRCMDREQ)))
> +	if (st & (NDSR_RDY(0) | NDSR_RDY(1)))
>  		complete(&nfc->complete);
>  
>  	return IRQ_HANDLED;

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

* Re: [PATCH] mtd: rawnand: marvell: fix the IRQ handler complete() condition
  2018-10-03  9:05 [PATCH] mtd: rawnand: marvell: fix the IRQ handler complete() condition Miquel Raynal
  2018-10-03 12:15 ` Boris Brezillon
@ 2018-10-05 14:39 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2018-10-05 14:39 UTC (permalink / raw)
  To: Boris Brezillon, Richard Weinberger, David Woodhouse,
	Brian Norris, Marek Vasut
  Cc: linux-mtd, daniel, Chris.Packham, stable

Hello

Miquel Raynal <miquel.raynal@bootlin.com> wrote on Wed,  3 Oct 2018
11:05:04 +0200:

> With the current implementation, the complete() in the IRQ handler is
> supposed to be called only if the register status has one or the other
> RDY bit set. Other events might trigger an interrupt as well if
> enabled, but should not end-up with a complete() call.
> 
> For this purpose, the code was checking if the other bits were set, in
> this case complete() was not called. This is wrong as two events might
> happen in a very tight time-frame and if the NDSR status read reports
> two bits set (eg. RDY(0) and RDDREQ) at the same time, complete() was
> not called.
> 
> This logic would lead to timeouts in marvell_nfc_wait_op() and has
> been observed on PXA boards (NFCv1) in the Hamming write path.
> 
> Fixes: 02f26ecf8c77 ("mtd: nand: add reworked Marvell NAND controller driver")
> Cc: stable@vger.kernel.org
> Reported-by: Daniel Mack <daniel@zonque.org>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Tested-by: Daniel Mack <daniel@zonque.org>
> ---
>  drivers/mtd/nand/raw/marvell_nand.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> index bc2ef5209783..c7573ccdbacd 100644
> --- a/drivers/mtd/nand/raw/marvell_nand.c
> +++ b/drivers/mtd/nand/raw/marvell_nand.c
> @@ -686,7 +686,7 @@ static irqreturn_t marvell_nfc_isr(int irq, void *dev_id)
>  
>  	marvell_nfc_disable_int(nfc, st & NDCR_ALL_INT);
>  
> -	if (!(st & (NDSR_RDDREQ | NDSR_WRDREQ | NDSR_WRCMDREQ)))
> +	if (st & (NDSR_RDY(0) | NDSR_RDY(1)))
>  		complete(&nfc->complete);
>  
>  	return IRQ_HANDLED;

Applied to nand/next.

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

end of thread, other threads:[~2018-10-05 21:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03  9:05 [PATCH] mtd: rawnand: marvell: fix the IRQ handler complete() condition Miquel Raynal
2018-10-03 12:15 ` Boris Brezillon
2018-10-05 14:39 ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.