Skip to contentSkip to conversation

mtd: rawnand: mtk: Fix WAITRDY break condition and timeout

PATCH Applied Hauke Mehrtens 3 participants 3 messages Mar 9, 2021 – Mar 11, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: mtk: Fix WAITRDY break condition and timeout

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()")
---
 drivers/mtd/nand/raw/mtk_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/mtk_nand.c +2 -2
index 57f1f1708994..5c5c92132287 100644
@@ -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;
 	}
Signature · 7 lines
2.30.1


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Tue, 9 Mar 2021 01:01:07 +0100 Hauke Mehrtens <[email protected]> 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.

Quoted 5 lines

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()")
Quoted 9 lines
---
 drivers/mtd/nand/raw/mtk_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/mtk_nand.c +0 -0
index 57f1f1708994..5c5c92132287 100644

drivers/mtd/nand/raw/mtk_nand.c static int mtk_nfc_exec_instr(struct nand_chip *chip, · line 495

Quoted 10 lines
drivers/mtd/nand/raw/mtk_nand.c +2 -2
@@ -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-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

maintainer Applied
#2 lore raw
In reply to Hauke Mehrtens

Hi Hauke,

Hauke Mehrtens <[email protected]> wrote on Tue, 9 Mar 2021 01:01:07 +0100:

Quoted 23 lines

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()")
---
 drivers/mtd/nand/raw/mtk_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/mtk_nand.c +0 -0
index 57f1f1708994..5c5c92132287 100644

drivers/mtd/nand/raw/mtk_nand.c static int mtk_nfc_exec_instr(struct nand_chip *chip, · line 495

Quoted 10 lines
drivers/mtd/nand/raw/mtk_nand.c +2 -2
@@ -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-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek