* [PATCH] mtd: spi-nor: sfdp: Increase SFDP data size limit to 16 KiB
@ 2026-09-17 5:02 Takahiro Kuwano via B4 Relay
2026-09-17 12:42 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Takahiro Kuwano via B4 Relay @ 2026-09-17 5:02 UTC (permalink / raw)
To: Pratyush Yadav, Michael Walle, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: linux-mtd, linux-kernel, Takahiro Kuwano
From: Takahiro Kuwano <takahiro.kuwano@infineon.com>
The size of SFDP data read and cached is limited to avoid allocating
too much memory. The current limit is PAGE_SIZE, but the Spansion S25FS256S
has parameter tables at offsets beyond 4 KiB.
Increase the limit to 16 KiB to support such devices by introducing the
SFDP_MAX_SIZE macro.
Suggested-by: Miquel Raynal <miquel.raynal@bootlin.com>
Suggested-by: Michael Walle <mwalle@kernel.org>
Signed-off-by: Takahiro Kuwano <takahiro.kuwano@infineon.com>
---
drivers/mtd/spi-nor/sfdp.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index 641f17ad51a0..5d5bb6e587bf 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -115,6 +115,12 @@ struct sfdp_bfpt_erase {
#define SFDP_4BAIT_DWORD_MAX 2
+/*
+ * Limit the total size of SFDP to a reasonable value to avoid allocating too
+ * much memory just of because the flash returned some insane values.
+ */
+#define SFDP_MAX_SIZE SZ_16K
+
struct sfdp_4bait {
/* The hardware capability. */
u32 hwcaps;
@@ -1594,14 +1600,10 @@ int spi_nor_parse_sfdp(struct spi_nor *nor)
SFDP_PARAM_HEADER_PARAM_LEN(param_header));
}
- /*
- * Limit the total size to a reasonable value to avoid allocating too
- * much memory just of because the flash returned some insane values.
- */
- if (sfdp_size > PAGE_SIZE) {
+ if (sfdp_size > SFDP_MAX_SIZE) {
dev_dbg(dev, "SFDP data (%zu) too big, truncating\n",
sfdp_size);
- sfdp_size = PAGE_SIZE;
+ sfdp_size = SFDP_MAX_SIZE;
}
sfdp = devm_kzalloc(dev, sizeof(*sfdp), GFP_KERNEL);
---
base-commit: a96edc3f0b4f036a5b6ebc9b1eca4273ef5ce2d0
change-id: 20260917-sfdp_size-f9d50cd0539d
Best regards,
--
Takahiro Kuwano <takahiro.kuwano@infineon.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: spi-nor: sfdp: Increase SFDP data size limit to 16 KiB
2026-09-17 5:02 [PATCH] mtd: spi-nor: sfdp: Increase SFDP data size limit to 16 KiB Takahiro Kuwano via B4 Relay
@ 2026-09-17 12:42 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2026-09-17 12:42 UTC (permalink / raw)
To: Takahiro Kuwano via B4 Relay
Cc: Pratyush Yadav, Michael Walle, Richard Weinberger,
Vignesh Raghavendra, takahiro.kuwano, linux-mtd, linux-kernel
On 17/09/2026 at 14:02:15 +09, Takahiro Kuwano via B4 Relay <devnull+takahiro.kuwano.infineon.com@kernel.org> wrote:
> From: Takahiro Kuwano <takahiro.kuwano@infineon.com>
>
> The size of SFDP data read and cached is limited to avoid allocating
> too much memory. The current limit is PAGE_SIZE, but the Spansion S25FS256S
> has parameter tables at offsets beyond 4 KiB.
>
> Increase the limit to 16 KiB to support such devices by introducing the
> SFDP_MAX_SIZE macro.
>
> Suggested-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Suggested-by: Michael Walle <mwalle@kernel.org>
> Signed-off-by: Takahiro Kuwano <takahiro.kuwano@infineon.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-17 12:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 5:02 [PATCH] mtd: spi-nor: sfdp: Increase SFDP data size limit to 16 KiB Takahiro Kuwano via B4 Relay
2026-09-17 12:42 ` Miquel Raynal
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®