linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: aspeed: Fix window offset of CE1
@ 2022-10-16 15:57 Cédric Le Goater
  2022-10-16 22:43 ` Joel Stanley
  0 siblings, 1 reply; 3+ messages in thread
From: Cédric Le Goater @ 2022-10-16 15:57 UTC (permalink / raw)
  To: linux-spi
  Cc: Mark Brown, linux-aspeed, openbmc, Joel Stanley, Andrew Jeffery,
	linux-arm-kernel, linux-kernel, Cédric Le Goater,
	Chin-Ting Kuo

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 <chin-ting_kuo@aspeedtech.com> 
Fixes: e3228ed92893 ("spi: spi-mem: Convert Aspeed SMC driver to spi-mem")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/spi/spi-aspeed-smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index 33cefcf18392..b90571396a60 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: aspeed: Fix window offset of CE1
  2022-10-16 15:57 [PATCH] spi: aspeed: Fix window offset of CE1 Cédric Le Goater
@ 2022-10-16 22:43 ` Joel Stanley
  2022-10-17  9:39   ` Cédric Le Goater
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Stanley @ 2022-10-16 22:43 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-spi, Mark Brown, linux-aspeed, openbmc, Andrew Jeffery,
	linux-arm-kernel, linux-kernel, Chin-Ting Kuo

On Sun, 16 Oct 2022 at 15:57, Cédric Le Goater <clg@kaod.org> wrote:
>
> 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?

Reviewed-by: Joel Stanley <joel@jms.id.au>


>
> Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
> Fixes: e3228ed92893 ("spi: spi-mem: Convert Aspeed SMC driver to spi-mem")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  drivers/spi/spi-aspeed-smc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index 33cefcf18392..b90571396a60 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: aspeed: Fix window offset of CE1
  2022-10-16 22:43 ` Joel Stanley
@ 2022-10-17  9:39   ` Cédric Le Goater
  0 siblings, 0 replies; 3+ messages in thread
From: Cédric Le Goater @ 2022-10-17  9:39 UTC (permalink / raw)
  To: Joel Stanley
  Cc: linux-spi, Mark Brown, linux-aspeed, openbmc, Andrew Jeffery,
	linux-arm-kernel, linux-kernel, Chin-Ting Kuo

On 10/17/22 00:43, Joel Stanley wrote:
> On Sun, 16 Oct 2022 at 15:57, Cédric Le Goater <clg@kaod.org> wrote:
>>
>> 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.

> Reviewed-by: Joel Stanley <joel@jms.id.au>
> 
> 
>>
>> Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
>> Fixes: e3228ed92893 ("spi: spi-mem: Convert Aspeed SMC driver to spi-mem")
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   drivers/spi/spi-aspeed-smc.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
>> index 33cefcf18392..b90571396a60 100644
>> --- a/drivers/spi/spi-aspeed-smc.c
>> +++ b/drivers/spi/spi-aspeed-smc.c
>> @@ -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
>>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-17 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16 15:57 [PATCH] spi: aspeed: Fix window offset of CE1 Cédric Le Goater
2022-10-16 22:43 ` Joel Stanley
2022-10-17  9:39   ` Cédric Le Goater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).