Skip to contentSkip to conversation

FAILED: patch "[PATCH] mtd: parsers: bcm47xxpart: Fix halfblock reads" failed to apply to 4.19-stable tree

PATCH [email protected] 1 participant 1 message Oct 31, 2022

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Possible dependencies:

05e258c6ec66 ("mtd: parsers: bcm47xxpart: Fix halfblock reads") 4c38eded8070 ("mtd: parsers: bcm47xxpart: print correct offset on read error")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 05e258c6ec669d6d18c494ea03d35962d6f5b545 Mon Sep 17 00:00:00 2001
From: Linus Walleij <[email protected]>
Date: Tue, 18 Oct 2022 11:11:29 +0200
Subject: [PATCH] mtd: parsers: bcm47xxpart: Fix halfblock reads
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There is some code in the parser that tries to read 0x8000 bytes into a block to "read in the middle" of the block. Well that only works if the block is also 0x10000 bytes all the time, else we get these parse errors as we reach the end of the flash:

spi-nor spi0.0: mx25l1606e (2048 Kbytes) mtd_read error while parsing (offset: 0x200000): -22 mtd_read error while parsing (offset: 0x201000): -22 (...)

Fix the code to do what I think was intended.

Fixes f0501e81fbaa ("mtd: bcm47xxpart: alternative MAGIC for board_data partition")
Cc Rafał Miłecki <[email protected]>
Cc Florian Fainelli <[email protected]>
drivers/mtd/parsers/bcm47xxpart.c +2 -2
index 50fcf4c2174b..13daf9bffd08 100644
@@ -233,11 +233,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 		}
 
 		/* Read middle of the block */
-		err = mtd_read(master, offset + 0x8000, 0x4, &bytes_read,
+		err = mtd_read(master, offset + (blocksize / 2), 0x4, &bytes_read,
 			       (uint8_t *)buf);
 		if (err && !mtd_is_bitflip(err)) {
 			pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
-			       offset + 0x8000, err);
+			       offset + (blocksize / 2), err);
 			continue;
 		}