Skip to contentSkip to conversation

spi: aspeed: Fix window offset of CE1

PATCH In review Cédric Le Goater 3 participants 4 messages Oct 16, 2022 – Oct 19, 2022

Subsystems (3)
lore
Share & tools
lore

Cédric Le Goater

author maintainer
#0 lore raw

PATCH 1/1 spi: aspeed: Fix window offset of CE1

The offset value of the mapping window in the kernel structure is calculated using the value of the previous window offset. This doesn't reflect how the HW is configured and can lead to erroneous setting of the second flash device (CE1).

Cc Chin-Ting Kuo <[email protected]>
Fixes e3228ed92893 ("spi: spi-mem: Convert Aspeed SMC driver to spi-mem")
---
 drivers/spi/spi-aspeed-smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-aspeed-smc.c +1 -1
index 33cefcf18392..b90571396a60 100644
@@ -398,7 +398,7 @@ static void aspeed_spi_get_windows(struct aspeed_spi *aspi,
 		windows[cs].cs = cs;
 		windows[cs].size = data->segment_end(aspi, reg_val) -
 			data->segment_start(aspi, reg_val);
-		windows[cs].offset = cs ? windows[cs - 1].offset + windows[cs - 1].size : 0;
+		windows[cs].offset = data->segment_start(aspi, reg_val) - aspi->ahb_base_phy;
 		dev_vdbg(aspi->dev, "CE%d offset=0x%.8x size=0x%x\n", cs,
 			 windows[cs].offset, windows[cs].size);
 	}
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · C?dric Le Goater

The offset value of the mapping window in the kernel structure is calculated using the value of the previous window offset. This doesn't reflect how the HW is configured and can lead to erroneous setting of the second flash device (CE1).

So .offset is expected to be the absolute address of the window, and this was okay for the 2400/2500 but was broken on the 2600?

Quoted 24 lines
Cc Chin-Ting Kuo <[email protected]>
Fixes e3228ed92893 ("spi: spi-mem: Convert Aspeed SMC driver to spi-mem")
---
 drivers/spi/spi-aspeed-smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-aspeed-smc.c +1 -2
index 33cefcf18392..b90571396a60 100644
@@ -398,7 +398,7 @@ static void aspeed_spi_get_windows(struct aspeed_spi *aspi,
                windows[cs].cs = cs;
                windows[cs].size = data->segment_end(aspi, reg_val) -
                        data->segment_start(aspi, reg_val);
-               windows[cs].offset = cs ? windows[cs - 1].offset + windows[cs - 1].size : 0;
+               windows[cs].offset = data->segment_start(aspi, reg_val) - aspi->ahb_base_phy;
                dev_vdbg(aspi->dev, "CE%d offset=0x%.8x size=0x%x\n", cs,
                         windows[cs].offset, windows[cs].size);
        }
--

2.37.3

author maintainer
#2 lore raw
Quoted 9 lines · Joel Stanley
Quoted 5 lines · C?dric Le Goater

The offset value of the mapping window in the kernel structure is calculated using the value of the previous window offset. This doesn't reflect how the HW is configured and can lead to erroneous setting of the second flash device (CE1).

So .offset is expected to be the absolute address of the window, and this was okay for the 2400/2500 but was broken on the 2600?

the aspeed_spi_get_windows() routine collects in an array the window/decoding range setting for each CS, and the offset for CS1 and above is computed from the offset/size of the previous CS. But this makes an assumption on the fact ranges are contiguous, which is not necessarily how the HW is configured.

C.

Quoted 27 lines
Quoted 24 lines
Cc Chin-Ting Kuo <[email protected]>
Fixes e3228ed92893 ("spi: spi-mem: Convert Aspeed SMC driver to spi-mem")
---
  drivers/spi/spi-aspeed-smc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-aspeed-smc.c +1 -2
index 33cefcf18392..b90571396a60 100644
@@ -398,7 +398,7 @@ static void aspeed_spi_get_windows(struct aspeed_spi *aspi,
                 windows[cs].cs = cs;
                 windows[cs].size = data->segment_end(aspi, reg_val) -
                         data->segment_start(aspi, reg_val);
-               windows[cs].offset = cs ? windows[cs - 1].offset + windows[cs - 1].size : 0;
+               windows[cs].offset = data->segment_start(aspi, reg_val) - aspi->ahb_base_phy;
                 dev_vdbg(aspi->dev, "CE%d offset=0x%.8x size=0x%x\n", cs,
                          windows[cs].offset, windows[cs].size);
         }
--

2.37.3

maintainer
#3 lore raw
In reply to Cédric Le Goater
Quoted 6 lines · C?dric Le Goater

The offset value of the mapping window in the kernel structure is calculated using the value of the previous window offset. This doesn't reflect how the HW is configured and can lead to erroneous setting of the second flash device (CE1).

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: aspeed: Fix window offset of CE1

      commit: f8aa6c895d482847c9b799dcdac8bbdb56cb8e04

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark