]> git.itanic.dy.fi Git - linux-stable/commitdiff
mtd: spi-nor: drop .parse_sfdp
authorMichael Walle <mwalle@kernel.org>
Fri, 8 Sep 2023 10:16:29 +0000 (12:16 +0200)
committerTudor Ambarus <tudor.ambarus@linaro.org>
Tue, 19 Sep 2023 15:57:49 +0000 (18:57 +0300)
Drop the size parameter to indicate we need to do SFDP, we can do that
because it is guaranteed that the size will be set by SFDP and because
PARSE_SFDP forced the SFDP parsing it must be overwritten.

There is a (very tiny) chance that this might break block protection
support: we now rely on the SFDP reported size of the flash for the
BP calculation. OTOH, if the flash reports its size wrong, we are
in bigger trouble than just having the BP calculation wrong.

Signed-off-by: Michael Walle <mwalle@kernel.org>
Link: https://lore.kernel.org/r/20230807-mtd-flash-info-db-rework-v3-11-e60548861b10@kernel.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
drivers/mtd/spi-nor/core.c
drivers/mtd/spi-nor/core.h
drivers/mtd/spi-nor/eon.c
drivers/mtd/spi-nor/gigadevice.c
drivers/mtd/spi-nor/issi.c
drivers/mtd/spi-nor/macronix.c
drivers/mtd/spi-nor/spansion.c
drivers/mtd/spi-nor/sst.c
drivers/mtd/spi-nor/winbond.c

index 368851ff9f40b5320e36b1b318d51d54b99e2957..4ba1778eda4bab21af8c46d75d5ce4b9a41652be 100644 (file)
@@ -2017,7 +2017,6 @@ static const struct spi_nor_manufacturer *manufacturers[] = {
 
 static const struct flash_info spi_nor_generic_flash = {
        .name = "spi-nor-generic",
-       .parse_sfdp = true,
 };
 
 static const struct flash_info *spi_nor_match_id(struct spi_nor *nor,
@@ -3069,7 +3068,7 @@ static int spi_nor_init_params(struct spi_nor *nor)
 
        spi_nor_init_default_params(nor);
 
-       if (nor->info->parse_sfdp) {
+       if (spi_nor_needs_sfdp(nor)) {
                ret = spi_nor_parse_sfdp(nor);
                if (ret) {
                        dev_err(nor->dev, "BFPT parsing failed. Please consider using SPI_NOR_SKIP_SFDP when declaring the flash\n");
index fba3ea8536a5ac8bbeb0c67fefbc985fdb0ea4a1..5f7cfdf1e8348483d167be65b21a3bac8c9e7267 100644 (file)
@@ -460,9 +460,6 @@ struct spi_nor_fixups {
  * @page_size:      (optional) the flash's page size. Defaults to 256.
  * @addr_nbytes:    number of address bytes to send.
  *
- * @parse_sfdp:     true when flash supports SFDP tables. The false value has no
- *                  meaning. If one wants to skip the SFDP tables, one should
- *                  instead use the SPI_NOR_SKIP_SFDP sfdp_flag.
  * @flags:          flags that indicate support that is not defined by the
  *                  JESD216 standard in its SFDP tables. Flag meanings:
  *   SPI_NOR_HAS_LOCK:        flash supports lock/unlock via SR
@@ -521,7 +518,6 @@ struct flash_info {
        u8 n_banks;
        u8 addr_nbytes;
 
-       bool parse_sfdp;
        u16 flags;
 #define SPI_NOR_HAS_LOCK               BIT(0)
 #define SPI_NOR_HAS_TB                 BIT(1)
@@ -598,9 +594,6 @@ struct flash_info {
                        .n_regions = (_n_regions),                      \
                },
 
-#define PARSE_SFDP                                                     \
-       .parse_sfdp = true,                                             \
-
 #define FLAGS(_flags)                                                  \
                .flags = (_flags),                                      \
 
@@ -740,6 +733,22 @@ static inline struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd)
        return container_of(mtd, struct spi_nor, mtd);
 }
 
+/**
+ * spi_nor_needs_sfdp() - returns true if SFDP parsing is used for this flash.
+ *
+ * Return: true if SFDP parsing is needed
+ */
+static inline bool spi_nor_needs_sfdp(const struct spi_nor *nor)
+{
+       /*
+        * The flash size is one property parsed by the SFDP. We use it as an
+        * indicator whether we need SFDP parsing for a particular flash. I.e.
+        * non-legacy flash entries in flash_info will have a size of zero iff
+        * SFDP should be used.
+        */
+       return !nor->info->size;
+}
+
 #ifdef CONFIG_DEBUG_FS
 void spi_nor_debugfs_register(struct spi_nor *nor);
 void spi_nor_debugfs_shutdown(void);
index 50a11053711f7bcd467f740f46bdeb1ad3d816b1..434aaf1558562d5b35169a39d1eb84f8d32bb838 100644 (file)
@@ -25,8 +25,7 @@ static const struct flash_info eon_nor_parts[] = {
        { "en25qh64",   INFO(0x1c7017, 0, 64 * 1024,  128)
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
        { "en25qh128",  INFO(0x1c7018, 0, 64 * 1024,  256) },
-       { "en25qh256",  INFO(0x1c7019, 0, 64 * 1024,  512)
-               PARSE_SFDP },
+       { "en25qh256",  INFO(0x1c7019, 0, 64 * 1024,  0) },
        { "en25s64",    INFO(0x1c3817, 0, 64 * 1024,  128)
                NO_SFDP_FLAGS(SECT_4K) },
 };
index d57ddaf1525b3605174be1fc614f100bd94d3adf..7cf142c7552930722507b2ab95918bba3b427392 100644 (file)
@@ -62,8 +62,7 @@ static const struct flash_info gigadevice_nor_parts[] = {
                FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
                              SPI_NOR_QUAD_READ) },
-       { "gd25q256", INFO(0xc84019, 0, 64 * 1024, 512)
-               PARSE_SFDP
+       { "gd25q256", INFO(0xc84019, 0, 64 * 1024, 0)
                FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6)
                FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
                .fixups = &gd25q256_fixups },
index accdf7aa2bfdea90dab2c1cb3a5b92cc564ddb90..9d22b799ce94dc7bc17ef73353f37ba87aa7405e 100644 (file)
@@ -62,8 +62,7 @@ static const struct flash_info issi_nor_parts[] = {
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
        { "is25lp128",  INFO(0x9d6018, 0, 64 * 1024, 256)
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
-       { "is25lp256",  INFO(0x9d6019, 0, 64 * 1024, 512)
-               PARSE_SFDP
+       { "is25lp256",  INFO(0x9d6019, 0, 64 * 1024, 0)
                FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
                .fixups = &is25lp256_fixups },
        { "is25wp032",  INFO(0x9d7016, 0, 64 * 1024,  64)
@@ -73,7 +72,6 @@ static const struct flash_info issi_nor_parts[] = {
        { "is25wp128",  INFO(0x9d7018, 0, 64 * 1024, 256)
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
        { "is25wp256", INFO(0x9d7019, 0, 0, 0)
-               PARSE_SFDP
                FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
                FLAGS(SPI_NOR_QUAD_PP)
                .fixups = &is25lp256_fixups },
index eb149e517c1fe7ac458db1f2f08a58d556fd1f8f..0f3bd3ed8eff53a6a455b0ba5fd86d0ef97b6e61 100644 (file)
@@ -83,7 +83,6 @@ static const struct flash_info macronix_nor_parts[] = {
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
                FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
        { "mx25uw51245g", INFOB(0xc2813a, 0, 0, 0, 4)
-               PARSE_SFDP
                FLAGS(SPI_NOR_RWW) },
        { "mx25v8035f",  INFO(0xc22314, 0, 64 * 1024,  16)
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
index ec3172ff5baf9c6aaa031c1e9d3a65e982929226..b6fcd56e270eb4fc43d76e8096231eb7756c3b28 100644 (file)
@@ -849,59 +849,47 @@ static const struct flash_info spansion_nor_parts[] = {
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
                FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
        { "s25fs256t",  INFO6(0x342b19, 0x0f0890, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s25fs256t_fixups },
        { "s25hl512t",  INFO6(0x342a1a, 0x0f0390, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s25hx_t_fixups },
        { "s25hl01gt",  INFO6(0x342a1b, 0x0f0390, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s25hx_t_fixups },
        { "s25hl02gt",  INFO6(0x342a1c, 0x0f0090, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                FLAGS(NO_CHIP_ERASE)
                .fixups = &s25hx_t_fixups },
        { "s25hs512t",  INFO6(0x342b1a, 0x0f0390, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s25hx_t_fixups },
        { "s25hs01gt",  INFO6(0x342b1b, 0x0f0390, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s25hx_t_fixups },
        { "s25hs02gt",  INFO6(0x342b1c, 0x0f0090, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                FLAGS(NO_CHIP_ERASE)
                .fixups = &s25hx_t_fixups },
        { "cy15x104q",  INFO6(0x042cc2, 0x7f7f7f, 512 * 1024, 1)
                FLAGS(SPI_NOR_NO_ERASE) },
        { "s28hl512t",   INFO(0x345a1a,      0, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s28hx_t_fixups,
        },
        { "s28hl01gt",   INFO(0x345a1b,      0, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s28hx_t_fixups,
        },
        { "s28hs512t",   INFO(0x345b1a,      0, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s28hx_t_fixups,
        },
        { "s28hs01gt",   INFO(0x345b1b,      0, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s28hx_t_fixups,
        },
        { "s28hs02gt",   INFO(0x345b1c,      0, 0, 0)
-               PARSE_SFDP
                MFR_FLAGS(USE_CLPEF)
                .fixups = &s28hx_t_fixups,
        },
index 197d2c1101ed5e37e3556edd3d2b8768e99b0040..57df68eab6aa542d05fc802af7ac0f7ec371316a 100644 (file)
@@ -115,7 +115,6 @@ static const struct flash_info sst_nor_parts[] = {
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
        { "sst26vf032b", INFO(0xbf2642, 0, 0, 0)
                FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
-               PARSE_SFDP
                .fixups = &sst26vf_nor_fixups },
        { "sst26vf064b", INFO(0xbf2643, 0, 64 * 1024, 128)
                FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
index cd99c9a1c568844ca6ef3f307928fe116c448899..7873cc394f07ec0408479c4d2303d31284f2bcca 100644 (file)
@@ -121,13 +121,11 @@ static const struct flash_info winbond_nor_parts[] = {
        { "w25q80bl", INFO(0xef4014, 0, 64 * 1024,  16)
                NO_SFDP_FLAGS(SECT_4K) },
        { "w25q128", INFO(0xef4018, 0, 0, 0)
-               PARSE_SFDP
                FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) },
        { "w25q256", INFO(0xef4019, 0, 64 * 1024, 512)
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
                .fixups = &w25q256_fixups },
-       { "w25q256jvm", INFO(0xef7019, 0, 64 * 1024, 512)
-               PARSE_SFDP },
+       { "w25q256jvm", INFO(0xef7019, 0, 64 * 1024, 0) },
        { "w25q256jw", INFO(0xef6019, 0, 64 * 1024, 512)
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
                              SPI_NOR_QUAD_READ) },
@@ -135,10 +133,8 @@ static const struct flash_info winbond_nor_parts[] = {
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ |
                              SPI_NOR_DUAL_READ) },
        { "w25q512nwq", INFO(0xef6020, 0, 0, 0)
-               PARSE_SFDP
                OTP_INFO(256, 3, 0x1000, 0x1000) },
-       { "w25q512nwm", INFO(0xef8020, 0, 64 * 1024, 1024)
-               PARSE_SFDP
+       { "w25q512nwm", INFO(0xef8020, 0, 64 * 1024, 0)
                OTP_INFO(256, 3, 0x1000, 0x1000) },
        { "w25q512jvq", INFO(0xef4020, 0, 64 * 1024, 1024)
                NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |