All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mtd: rawnand: arasan: Prevent an unsupported configuration
@ 2021-10-08 16:36 Miquel Raynal
  2021-10-15 10:31 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Miquel Raynal @ 2021-10-08 16:36 UTC (permalink / raw)
  To: Naga Sureshkumar Relli, Michal Simek, Amit Kumar Mahapatra,
	Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, Thomas Petazzoni, Boris Brezillon, Miquel Raynal

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: 4edde6031458 ("mtd: rawnand: arasan: Support NV-DDR interface")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---

Changes in v2:
As v1 was too invasive Boris suggested to adopt a much simpler approach:
let's just avoid the situation. That's what I am doing here.

 drivers/mtd/nand/raw/arasan-nand-controller.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/mtd/nand/raw/arasan-nand-controller.c b/drivers/mtd/nand/raw/arasan-nand-controller.c
index 9cbcc698c64d..53bd10738418 100644
--- a/drivers/mtd/nand/raw/arasan-nand-controller.c
+++ b/drivers/mtd/nand/raw/arasan-nand-controller.c
@@ -973,6 +973,21 @@ static int anfc_setup_interface(struct nand_chip *chip, int target,
 		nvddr = nand_get_nvddr_timings(conf);
 		if (IS_ERR(nvddr))
 			return PTR_ERR(nvddr);
+
+		/*
+		 * The controller only supports data payload requests which are
+		 * a multiple of 4. In practice, most data accesses are 4-byte
+		 * aligned and this is not an issue. However, rounding up will
+		 * simply be refused by the controller if we reached the end of
+		 * the device *and* we are using the NV-DDR interface(!). In
+		 * this situation, unaligned data requests ending at the device
+		 * boundary will confuse the controller and cannot be performed.
+		 *
+		 * This is something that happens in nand_read_subpage() when
+		 * selecting software ECC support and must be avoided.
+		 */
+		if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT)
+			return -ENOTSUPP;
 	} else {
 		sdr = nand_get_sdr_timings(conf);
 		if (IS_ERR(sdr))
-- 
2.27.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mtd: rawnand: arasan: Prevent an unsupported configuration
  2021-10-08 16:36 [PATCH v2] mtd: rawnand: arasan: Prevent an unsupported configuration Miquel Raynal
@ 2021-10-15 10:31 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:31 UTC (permalink / raw)
  To: Miquel Raynal, Naga Sureshkumar Relli, Michal Simek,
	Amit Kumar Mahapatra, Richard Weinberger, Vignesh Raghavendra,
	Tudor Ambarus
  Cc: linux-mtd, Thomas Petazzoni, Boris Brezillon

On Fri, 2021-10-08 at 16:36:40 UTC, Miquel Raynal wrote:
> 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: 4edde6031458 ("mtd: rawnand: arasan: Support NV-DDR interface")
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-15 10:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08 16:36 [PATCH v2] mtd: rawnand: arasan: Prevent an unsupported configuration Miquel Raynal
2021-10-15 10:31 ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.