linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: mtk: Fix WAITRDY break condition and timeout
@ 2021-03-09  0:01 Hauke Mehrtens
  2021-03-09  7:06 ` Boris Brezillon
  2021-03-11 11:39 ` Miquel Raynal
  0 siblings, 2 replies; 3+ messages in thread
From: Hauke Mehrtens @ 2021-03-09  0:01 UTC (permalink / raw)
  To: miquel.raynal, richard, boris.brezillon
  Cc: vigneshr, matthias.bgg, linux-mtd, linux-mediatek, Hauke Mehrtens

This fixes NAND_OP_WAITRDY_INSTR operation in the driver. Without this
change the driver waits till the system is busy, but we should wait till
the busy flag is cleared. The readl_poll_timeout() function gets a break
condition, not a wait condition.

In addition fix the timeout. The timeout_ms is given in ms, but the
readl_poll_timeout() function takes the timeout in us. Multiple the
given timeout by 1000 to convert it.

Without this change, the driver does not work at all, it doesn't even
identify the NAND chip.

Fixes: 5197360f9e09 ("mtd: rawnand: mtk: Convert the driver to exec_op()")
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/mtd/nand/raw/mtk_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c
index 57f1f1708994..5c5c92132287 100644
--- a/drivers/mtd/nand/raw/mtk_nand.c
+++ b/drivers/mtd/nand/raw/mtk_nand.c
@@ -488,8 +488,8 @@ static int mtk_nfc_exec_instr(struct nand_chip *chip,
 		return 0;
 	case NAND_OP_WAITRDY_INSTR:
 		return readl_poll_timeout(nfc->regs + NFI_STA, status,
-					  status & STA_BUSY, 20,
-					  instr->ctx.waitrdy.timeout_ms);
+					  !(status & STA_BUSY), 20,
+					  instr->ctx.waitrdy.timeout_ms * 1000);
 	default:
 		break;
 	}
-- 
2.30.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: mtk: Fix WAITRDY break condition and timeout
  2021-03-09  0:01 [PATCH] mtd: rawnand: mtk: Fix WAITRDY break condition and timeout Hauke Mehrtens
@ 2021-03-09  7:06 ` Boris Brezillon
  2021-03-11 11:39 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Boris Brezillon @ 2021-03-09  7:06 UTC (permalink / raw)
  To: Hauke Mehrtens
  Cc: miquel.raynal, richard, vigneshr, matthias.bgg, linux-mtd,
	linux-mediatek

On Tue,  9 Mar 2021 01:01:07 +0100
Hauke Mehrtens <hauke@hauke-m.de> wrote:

> This fixes NAND_OP_WAITRDY_INSTR operation in the driver. Without this
> change the driver waits till the system is busy, but we should wait till
> the busy flag is cleared. The readl_poll_timeout() function gets a break
> condition, not a wait condition.
> 
> In addition fix the timeout. The timeout_ms is given in ms, but the
> readl_poll_timeout() function takes the timeout in us. Multiple the
> given timeout by 1000 to convert it.
> 
> Without this change, the driver does not work at all, it doesn't even
> identify the NAND chip.
> 
> Fixes: 5197360f9e09 ("mtd: rawnand: mtk: Convert the driver to exec_op()")
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

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

> ---
>  drivers/mtd/nand/raw/mtk_nand.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c
> index 57f1f1708994..5c5c92132287 100644
> --- a/drivers/mtd/nand/raw/mtk_nand.c
> +++ b/drivers/mtd/nand/raw/mtk_nand.c
> @@ -488,8 +488,8 @@ static int mtk_nfc_exec_instr(struct nand_chip *chip,
>  		return 0;
>  	case NAND_OP_WAITRDY_INSTR:
>  		return readl_poll_timeout(nfc->regs + NFI_STA, status,
> -					  status & STA_BUSY, 20,
> -					  instr->ctx.waitrdy.timeout_ms);
> +					  !(status & STA_BUSY), 20,
> +					  instr->ctx.waitrdy.timeout_ms * 1000);
>  	default:
>  		break;
>  	}


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: mtk: Fix WAITRDY break condition and timeout
  2021-03-09  0:01 [PATCH] mtd: rawnand: mtk: Fix WAITRDY break condition and timeout Hauke Mehrtens
  2021-03-09  7:06 ` Boris Brezillon
@ 2021-03-11 11:39 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2021-03-11 11:39 UTC (permalink / raw)
  To: Hauke Mehrtens
  Cc: richard, boris.brezillon, vigneshr, matthias.bgg, linux-mtd,
	linux-mediatek

Hi Hauke,

Hauke Mehrtens <hauke@hauke-m.de> wrote on Tue,  9 Mar 2021 01:01:07
+0100:

> This fixes NAND_OP_WAITRDY_INSTR operation in the driver. Without this
> change the driver waits till the system is busy, but we should wait till
> the busy flag is cleared. The readl_poll_timeout() function gets a break
> condition, not a wait condition.
> 
> In addition fix the timeout. The timeout_ms is given in ms, but the
> readl_poll_timeout() function takes the timeout in us. Multiple the
> given timeout by 1000 to convert it.
> 
> Without this change, the driver does not work at all, it doesn't even
> identify the NAND chip.
> 
> Fixes: 5197360f9e09 ("mtd: rawnand: mtk: Convert the driver to exec_op()")
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> ---
>  drivers/mtd/nand/raw/mtk_nand.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c
> index 57f1f1708994..5c5c92132287 100644
> --- a/drivers/mtd/nand/raw/mtk_nand.c
> +++ b/drivers/mtd/nand/raw/mtk_nand.c
> @@ -488,8 +488,8 @@ static int mtk_nfc_exec_instr(struct nand_chip *chip,
>  		return 0;
>  	case NAND_OP_WAITRDY_INSTR:
>  		return readl_poll_timeout(nfc->regs + NFI_STA, status,
> -					  status & STA_BUSY, 20,
> -					  instr->ctx.waitrdy.timeout_ms);
> +					  !(status & STA_BUSY), 20,
> +					  instr->ctx.waitrdy.timeout_ms * 1000);
>  	default:
>  		break;
>  	}

Applied to mtd/fixes.

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2021-03-11 11:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09  0:01 [PATCH] mtd: rawnand: mtk: Fix WAITRDY break condition and timeout Hauke Mehrtens
2021-03-09  7:06 ` Boris Brezillon
2021-03-11 11:39 ` Miquel Raynal

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).