diff mbox series

[2/2] mtd: rawnand: Ensure continuous reads are well disabled

Message ID 20240307115315.1942678-2-miquel.raynal@bootlin.com
State Accepted
Headers show
Series [1/2] mtd: rawnand: Constrain even more when continuous reads are enabled | expand

Commit Message

Miquel Raynal March 7, 2024, 11:53 a.m. UTC
The cont_read.ongoing flag should only be enabled at the beginning of a
read operation, and also disabled at its end, so we never end up
triggering nasty side effects outside of this scope. The mtd core being
highly serialized, we should not be bothered by parallel accesses
anyway.

In case we reach the end of a read operation and the boolean was not
properly disabled, it's a bug, but it's totally manageable. So warn, and
then fix the boolean state.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/nand_base.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Miquel Raynal March 11, 2024, 8:24 a.m. UTC | #1
On Thu, 2024-03-07 at 11:53:15 UTC, Miquel Raynal wrote:
> The cont_read.ongoing flag should only be enabled at the beginning of a
> read operation, and also disabled at its end, so we never end up
> triggering nasty side effects outside of this scope. The mtd core being
> highly serialized, we should not be bothered by parallel accesses
> anyway.
> 
> In case we reach the end of a read operation and the boolean was not
> properly disabled, it's a bug, but it's totally manageable. So warn, and
> then fix the boolean state.
> 
> 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
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 2479fa98f991..d7dbbd469b89 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -3728,6 +3728,9 @@  static int nand_do_read_ops(struct nand_chip *chip, loff_t from,
 	}
 	nand_deselect_target(chip);
 
+	if (WARN_ON_ONCE(chip->cont_read.ongoing))
+		chip->cont_read.ongoing = false;
+
 	ops->retlen = ops->len - (size_t) readlen;
 	if (oob)
 		ops->oobretlen = ops->ooblen - oobreadlen;