Skip to content

Commit fc9e18f

Browse files
committed
mtd: rawnand: arasan: Prevent an unsupported configuration
Under the following conditions: * after rounding up by 4 the number of bytes to transfer (this is related to the controller's internal constraints), * if this (rounded) amount of data is situated beyond the end of the device, * and only in NV-DDR mode, the Arasan NAND controller timeouts. This currently can happen in a particular helper used when picking software ECC algorithms. Let's prevent this situation by refusing to use the NV-DDR interface with software engines. Fixes: 4edde60 ("mtd: rawnand: arasan: Support NV-DDR interface") Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 73e197d commit fc9e18f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/mtd/nand/raw/arasan-nand-controller.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,21 @@ static int anfc_setup_interface(struct nand_chip *chip, int target,
973973
nvddr = nand_get_nvddr_timings(conf);
974974
if (IS_ERR(nvddr))
975975
return PTR_ERR(nvddr);
976+
977+
/*
978+
* The controller only supports data payload requests which are
979+
* a multiple of 4. In practice, most data accesses are 4-byte
980+
* aligned and this is not an issue. However, rounding up will
981+
* simply be refused by the controller if we reached the end of
982+
* the device *and* we are using the NV-DDR interface(!). In
983+
* this situation, unaligned data requests ending at the device
984+
* boundary will confuse the controller and cannot be performed.
985+
*
986+
* This is something that happens in nand_read_subpage() when
987+
* selecting software ECC support and must be avoided.
988+
*/
989+
if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT)
990+
return -ENOTSUPP;
976991
} else {
977992
sdr = nand_get_sdr_timings(conf);
978993
if (IS_ERR(sdr))

0 commit comments

Comments
 (0)