]> git.baikalelectronics.ru Git - kernel.git/commit
mtd: rawnand: gpmi: Set WAIT_FOR_READY timeout based on program/erase times
authorSascha Hauer <s.hauer@pengutronix.de>
Fri, 1 Jul 2022 11:03:41 +0000 (13:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2022 16:57:57 +0000 (17:57 +0100)
commit900c52621d6a986ee7cf26cb2735e3efead3a059
tree4f2dce9d9afbf63f1536df4f6fd17b70a2d7a845
parent821afdccb8f2912deb9aca100ffa428f8d56bcec
mtd: rawnand: gpmi: Set WAIT_FOR_READY timeout based on program/erase times

commit 91adf2833eafd54f7baed142fcededfad0290ad7 upstream.

48e40aeea1f92 Fixes the calculation of the DEVICE_BUSY_TIMEOUT register
value from busy_timeout_cycles. busy_timeout_cycles is calculated wrong
though: It is calculated based on the maximum page read time, but the
timeout is also used for page write and block erase operations which
require orders of magnitude bigger timeouts.

Fix this by calculating busy_timeout_cycles from the maximum of
tBERS_max and tPROG_max.

This is for now the easiest and most obvious way to fix the driver.
There's room for improvements though: The NAND_OP_WAITRDY_INSTR tells us
the desired timeout for the current operation, so we could program the
timeout dynamically for each operation instead of setting a fixed
timeout. Also we could wire up the interrupt handler to actually detect
and forward timeouts occurred when waiting for the chip being ready.

As a sidenote I verified that the change in 48e40aeea1f92 is really
correct. I wired up the interrupt handler in my tree and measured the
time between starting the operation and the timeout interrupt handler
coming in. The time increases 41us with each step in the timeout
register which corresponds to 4096 clock cycles with the 99MHz clock
that I have.

Fixes: 48e40aeea1f92 ("mtd: rawnand: gpmi: Fix setting busy timeout setting")
Fixes: 4941537c16932 ("mtd: rawniand: gpmi: use core timings instead of an empirical derivation")
Cc: stable@vger.kernel.org
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Han Xu <han.xu@nxp.com>
Tested-by: Tomasz Moń <tomasz.mon@camlingroup.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c