Skip to content

Commit 83c9c7e

Browse files
westeribroonie
authored andcommitted
spi: intel: Keep the BIOS partition inside the first chip
If there are two flash chips connected flash regions can refer to the second chip too. In this case we may see the following warning: mtd: partition "BIOS" extends beyond the end of device "0000:00:1f.5" -- size truncated to 0x400000 For this reason, check the BIOS partition size against the chip size and make sure it stays within the that. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Link: https://lore.kernel.org/r/20240201121638.207632-2-mika.westerberg@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent e58db3b commit 83c9c7e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/spi/spi-intel.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,13 @@ static void intel_spi_fill_partition(struct intel_spi *ispi,
12541254
if (end > part->size)
12551255
part->size = end;
12561256
}
1257+
1258+
/*
1259+
* Regions can refer to the second chip too so in this case we
1260+
* just make the BIOS partition to occupy the whole chip.
1261+
*/
1262+
if (ispi->chip0_size && part->size > ispi->chip0_size)
1263+
part->size = MTDPART_SIZ_FULL;
12571264
}
12581265

12591266
static int intel_spi_read_desc(struct intel_spi *ispi)
@@ -1350,6 +1357,10 @@ static int intel_spi_populate_chip(struct intel_spi *ispi)
13501357
struct spi_board_info chip;
13511358
int ret;
13521359

1360+
ret = intel_spi_read_desc(ispi);
1361+
if (ret)
1362+
return ret;
1363+
13531364
pdata = devm_kzalloc(ispi->dev, sizeof(*pdata), GFP_KERNEL);
13541365
if (!pdata)
13551366
return -ENOMEM;
@@ -1369,10 +1380,6 @@ static int intel_spi_populate_chip(struct intel_spi *ispi)
13691380
if (!spi_new_device(ispi->host, &chip))
13701381
return -ENODEV;
13711382

1372-
ret = intel_spi_read_desc(ispi);
1373-
if (ret)
1374-
return ret;
1375-
13761383
/* Add the second chip if present */
13771384
if (ispi->host->num_chipselect < 2)
13781385
return 0;

0 commit comments

Comments
 (0)