Skip to contentSkip to conversation

sf: remove spi-flash chip names from SPL binary

PATCH Superseded Simon Goldschmidt 2 participants 3 messages Oct 7, 2018 – Oct 31, 2018 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sf: remove spi-flash chip names from SPL binary

The table of spi flash chips 'spi_flash_ids' currently includes chip names. The only usage of these is to print the name when the chip is probed.

Since this message is not shown in SPL, we can remove the names from the SPL binary.

Removing the chip names saves ~890 Byte from the SPL binary in my configuration (socfpga_socrates_defconfig, MACRONIX, SPANSION and STMICRO enabled).

---
Changes in v2:
- use CONFIG_SPL_BUILD directly instead of SPI_FLASH_INCLUDE_NAME
- iterate spi_flash_ids list until info->sector_size == 0, remove the extra global 'const size_t spi_flash_ids_size'

 drivers/mtd/spi/sf_internal.h   |   3 +
 drivers/mtd/spi/spi_flash.c     |   6 +-
 drivers/mtd/spi/spi_flash_ids.c | 269 +++++++++++++++++---------------
 3 files changed, 147 insertions(+), 131 deletions(-)
drivers/mtd/spi/sf_internal.h +3 -0
index 4f63cacc64..dab3a5bfbc 100644
@@ -114,8 +114,11 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
 #define SPI_FLASH_MAX_ID_LEN	6
 
 struct spi_flash_info {
+/* Exclude chip names for SPL to save space */
+#ifndef CONFIG_SPL_BUILD
 	/* Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO]) */
 	const char	*name;
+#endif
 
 	/*
 	 * This array stores the ID bytes.
drivers/mtd/spi/spi_flash.c +5 -1
index c159124259..e6d0fa5fcf 100644
@@ -1069,7 +1069,7 @@ static const struct spi_flash_info *spi_flash_read_id(struct spi_flash *flash)
 	}
 
 	info = spi_flash_ids;
-	for (; info->name != NULL; info++) {
+	for (; info->sector_size != 0; info++) {
 		if (info->id_len) {
 			if (!memcmp(info->id, id, info->id_len))
 				return info;
@@ -1160,7 +1160,11 @@ int spi_flash_scan(struct spi_flash *flash)
 		write_sr(flash, sr);
 	}
 
+#ifndef CONFIG_SPL_BUILD
 	flash->name = info->name;
+#else
+	flash->name = "spi-flash";
+#endif
 	flash->memory_map = spi->memory_map;
 
 	if (info->flags & SST_WR)
drivers/mtd/spi/spi_flash_ids.c +139 -130

304 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 sf: remove spi-flash chip names from SPL binary

Quoted 11 lines · Simon Goldschmidt

The table of spi flash chips 'spi_flash_ids' currently includes chip names. The only usage of these is to print the name when the chip is probed.

Since this message is not shown in SPL, we can remove the names from the SPL binary.

Removing the chip names saves ~890 Byte from the SPL binary in my configuration (socfpga_socrates_defconfig, MACRONIX, SPANSION and STMICRO enabled).

I'm not still quite happy with this change, other than reducing the size which introduces many ifdef's what would you benefits with this 890bytes? do you have any room to add any key features in SPL?

#2 lore raw

PATCH v2 1/1 sf: remove spi-flash chip names from SPL binary

Quoted 11 lines · Jagan Teki
Quoted 8 lines · Simon Goldschmidt

The table of spi flash chips 'spi_flash_ids' currently includes chip names. The only usage of these is to print the name when the chip is probed.

Since this message is not shown in SPL, we can remove the names from the SPL binary.

Quoted 7 lines
Quoted 3 lines

Removing the chip names saves ~890 Byte from the SPL binary in my configuration (socfpga_socrates_defconfig, MACRONIX, SPANSION and STMICRO enabled).

I'm not still quite happy with this change, other than reducing the size which introduces many ifdef's what would you benefits with this 890bytes? do you have any room to add any key features in SPL?

Well, SPL is always tight, isn't it? Currently, I have ~7.5 kB free on my socfpga gen5 board. And to get the features required by management, I will have to add suppport for loading U-Boot from a FIT image and checking its signature.

Because of that, I figured saving RAM in SPL would be good. I don't know my required features fit in after applying this patch, though.

But if you don't like it, feel free to drop it. I don't have an immediate need to apply this.

Simon