mtd: rawnand: arasan: Ensure program page operations are successful
authorMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 17 Jul 2023 19:42:20 +0000 (21:42 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 22 Sep 2023 14:43:57 +0000 (16:43 +0200)
commit3a4a893dbb19e229db3b753f0462520b561dee98
treef5808160888cdce0a1e0eb067cbcd30fe40a1bce
parent9836a987860e33943945d4b257729a4f94eae576
mtd: rawnand: arasan: Ensure program page operations are successful

The NAND core complies with the ONFI specification, which itself
mentions that after any program or erase operation, a status check
should be performed to see whether the operation was finished *and*
successful.

The NAND core offers helpers to finish a page write (sending the
"PAGE PROG" command, waiting for the NAND chip to be ready again, and
checking the operation status). But in some cases, advanced controller
drivers might want to optimize this and craft their own page write
helper to leverage additional hardware capabilities, thus not always
using the core facilities.

Some drivers, like this one, do not use the core helper to finish a page
write because the final cycles are automatically managed by the
hardware. In this case, the additional care must be taken to manually
perform the final status check.

Let's read the NAND chip status at the end of the page write helper and
return -EIO upon error.

Cc: Michal Simek <michal.simek@amd.com>
Cc: stable@vger.kernel.org
Fixes: 88ffef1b65cf ("mtd: rawnand: arasan: Support the hardware BCH ECC engine")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/linux-mtd/20230717194221.229778-2-miquel.raynal@bootlin.com
drivers/mtd/nand/raw/arasan-nand-controller.c