]> git.baikalelectronics.ru Git - kernel.git/commit
mtd: rawnand: gpmi: Fix setting busy timeout setting
authorSascha Hauer <s.hauer@pengutronix.de>
Tue, 14 Jun 2022 08:31:38 +0000 (10:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jun 2022 06:58:45 +0000 (08:58 +0200)
commita64593269c3c982cb7e1b38d95a8177981915627
tree599f8dfcc0c07e6b4d07ac43ba6d4ee7250ee18a
parent4c7d524e4476e8d8ad5e68d7829bcf6176bd8548
mtd: rawnand: gpmi: Fix setting busy timeout setting

commit 48e40aeea1f924d979691278fcef7ccd02a71aae upstream.

The DEVICE_BUSY_TIMEOUT value is described in the Reference Manual as:

| Timeout waiting for NAND Ready/Busy or ATA IRQ. Used in WAIT_FOR_READY
| mode. This value is the number of GPMI_CLK cycles multiplied by 4096.

So instead of multiplying the value in cycles with 4096, we have to
divide it by that value. Use DIV_ROUND_UP to make sure we are on the
safe side, especially when the calculated value in cycles is smaller
than 4096 as typically the case.

This bug likely never triggered because any timeout != 0 usually will
do. In my case the busy timeout in cycles was originally calculated as
2408, which multiplied with 4096 is 0x968000. The lower 16 bits were
taken for the 16 bit wide register field, so the register value was
0x8000. With f0263ceb9e2c ("mtd: rawnand: gpmi: fix controller timings
setting") however the value in cycles became 2384, which multiplied
with 4096 is 0x950000. The lower 16 bit are 0x0 now resulting in an
intermediate timeout when reading from NAND.

Fixes: 4941537c16932 ("mtd: rawnand: gpmi: use core timings instead of an empirical derivation")
Cc: stable@vger.kernel.org
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220614083138.3455683-1-s.hauer@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c