mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Hilliard <james.hilliard1@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
	 Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>,
	 Boris Brezillon <bbrezillon@kernel.org>,
	 Brian Norris <computersforpeace@gmail.com>,
	linux-mtd@lists.infradead.org,  linux-kernel@vger.kernel.org,
	James Hilliard <james.hilliard1@gmail.com>,
	 stable@vger.kernel.org
Subject: [PATCH 1/4] mtd: rawnand: sm_common: restore the first ECC region offset
Date: Sun, 08 Nov 2026 18:29:20 -0700	[thread overview]
Message-ID: <20261108-submit-r852-smartmedia-attach-v1-v1-1-56d08c0571a2@gmail.com> (raw)
In-Reply-To: <20261108-submit-r852-smartmedia-attach-v1-v1-0-56d08c0571a2@gmail.com>

The conversion to mtd_ooblayout_ops moved the first ECC region from bytes
8-10 to bytes 5-7. Those bytes contain the bad-block marker and the first
logical-block address, so software ECC writes can overwrite them and ECC
reads use the wrong bytes.

Derive both ECC region offsets from struct sm_oob, restoring the original
8-10 and 13-15 layout without overlapping the metadata.

Fixes: 987b913c2b7e ("mtd: nand: sm_common: switch to mtd_ooblayout_ops")
Cc: stable@vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 drivers/mtd/nand/raw/sm_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/sm_common.c b/drivers/mtd/nand/raw/sm_common.c
index e238784c8c3e..a3a3a05cc5a4 100644
--- a/drivers/mtd/nand/raw/sm_common.c
+++ b/drivers/mtd/nand/raw/sm_common.c
@@ -16,7 +16,8 @@ static int oob_sm_ooblayout_ecc(struct mtd_info *mtd, int section,
 		return -ERANGE;
 
 	oobregion->length = 3;
-	oobregion->offset = ((section + 1) * 8) - 3;
+	oobregion->offset = section ? offsetof(struct sm_oob, ecc1) :
+				      offsetof(struct sm_oob, ecc2);
 
 	return 0;
 }

-- 
2.53.0


  reply	other threads:[~2026-11-09  1:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09  1:29 [PATCH 0/4] mtd: rawnand: restore SmartMedia setup in r852 James Hilliard
2026-11-09  1:29 ` James Hilliard [this message]
2026-11-09  1:29 ` [PATCH 2/4] mtd: rawnand: sm_common: avoid recursive locking when marking bad blocks James Hilliard
2026-11-09  1:29 ` [PATCH 3/4] mtd: rawnand: r852: use the standard OOB write operation James Hilliard
2026-11-09  1:29 ` [PATCH 4/4] mtd: rawnand: r852: restore SmartMedia and ECC initialization James Hilliard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261108-submit-r852-smartmedia-attach-v1-v1-1-56d08c0571a2@gmail.com \
    --to=james.hilliard1@gmail.com \
    --cc=bbrezillon@kernel.org \
    --cc=computersforpeace@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=maximlevitsky@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®