* [PATCH -next] spi: stm32-qspi: Simpify resource lookup
@ 2024-08-20 12:37 Jinjie Ruan
2024-08-22 14:58 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Jinjie Ruan @ 2024-08-20 12:37 UTC (permalink / raw)
To: broonie, mcoquelin.stm32, alexandre.torgue, linux-spi,
linux-stm32, linux-arm-kernel, linux-kernel
Cc: ruanjinjie
Use the devm_platform_ioremap_resource_byname() helper instead of
calling platform_get_resource_byname() and devm_ioremap_resource()
separately.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
drivers/spi/spi-stm32-qspi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index 955c920c4b63..46081df73cb0 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -780,15 +780,13 @@ static int stm32_qspi_probe(struct platform_device *pdev)
qspi = spi_controller_get_devdata(ctrl);
qspi->ctrl = ctrl;
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi");
- qspi->io_base = devm_ioremap_resource(dev, res);
+ qspi->io_base = devm_platform_ioremap_resource_byname(pdev, "qspi");
if (IS_ERR(qspi->io_base))
return PTR_ERR(qspi->io_base);
qspi->phys_base = res->start;
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi_mm");
- qspi->mm_base = devm_ioremap_resource(dev, res);
+ qspi->mm_base = devm_platform_ioremap_resource_byname(pdev, "qspi_mm");
if (IS_ERR(qspi->mm_base))
return PTR_ERR(qspi->mm_base);
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] spi: stm32-qspi: Simpify resource lookup
2024-08-20 12:37 [PATCH -next] spi: stm32-qspi: Simpify resource lookup Jinjie Ruan
@ 2024-08-22 14:58 ` Mark Brown
2024-08-23 2:31 ` Jinjie Ruan
2024-08-23 6:22 ` Jinjie Ruan
0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2024-08-22 14:58 UTC (permalink / raw)
To: Jinjie Ruan
Cc: mcoquelin.stm32, alexandre.torgue, linux-spi, linux-stm32,
linux-arm-kernel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1604 bytes --]
On Tue, Aug 20, 2024 at 08:37:07PM +0800, Jinjie Ruan wrote:
> Use the devm_platform_ioremap_resource_byname() helper instead of
> calling platform_get_resource_byname() and devm_ioremap_resource()
> separately.
This breaks boot on the Avenger96 board, it causes a NULL pointer
dereference:
[ 2.350480] Unable to handle kernel NULL pointer dereference at virtual address 00000000 when read
...
[ 2.695787] Call trace:
[ 2.695807] stm32_qspi_probe from platform_probe+0x5c/0xb0
[ 2.703914] platform_probe from really_probe+0xc8/0x2c8
[ 2.709284] really_probe from __driver_probe_device+0x88/0x19c
[ 2.715145] __driver_probe_device from driver_probe_device+0x30/0x104
https://lava.sirena.org.uk/scheduler/job/650792
> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi");
> - qspi->io_base = devm_ioremap_resource(dev, res);
> + qspi->io_base = devm_platform_ioremap_resource_byname(pdev, "qspi");
> if (IS_ERR(qspi->io_base))
> return PTR_ERR(qspi->io_base);
>
> qspi->phys_base = res->start;
>
> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi_mm");
> - qspi->mm_base = devm_ioremap_resource(dev, res);
> + qspi->mm_base = devm_platform_ioremap_resource_byname(pdev, "qspi_mm");
> if (IS_ERR(qspi->mm_base))
> return PTR_ERR(qspi->mm_base);
I can't identify any obvious error here, these look like a direct
subsitution - the implementation of devm_platform_ioremap_resource_byname()
looks to be the same as the replaced code and dev is set to &pdev->dev
but I'm seeing the above behaviour.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] spi: stm32-qspi: Simpify resource lookup
2024-08-22 14:58 ` Mark Brown
@ 2024-08-23 2:31 ` Jinjie Ruan
2024-08-23 6:22 ` Jinjie Ruan
1 sibling, 0 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-08-23 2:31 UTC (permalink / raw)
To: Mark Brown
Cc: mcoquelin.stm32, alexandre.torgue, linux-spi, linux-stm32,
linux-arm-kernel, linux-kernel
On 2024/8/22 22:58, Mark Brown wrote:
> On Tue, Aug 20, 2024 at 08:37:07PM +0800, Jinjie Ruan wrote:
>> Use the devm_platform_ioremap_resource_byname() helper instead of
>> calling platform_get_resource_byname() and devm_ioremap_resource()
>> separately.
>
> This breaks boot on the Avenger96 board, it causes a NULL pointer
> dereference:
>
> [ 2.350480] Unable to handle kernel NULL pointer dereference at virtual address 00000000 when read
>
> ...
>
> [ 2.695787] Call trace:
> [ 2.695807] stm32_qspi_probe from platform_probe+0x5c/0xb0
> [ 2.703914] platform_probe from really_probe+0xc8/0x2c8
> [ 2.709284] really_probe from __driver_probe_device+0x88/0x19c
> [ 2.715145] __driver_probe_device from driver_probe_device+0x30/0x104
>
> https://lava.sirena.org.uk/scheduler/job/650792
>
>> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi");
>> - qspi->io_base = devm_ioremap_resource(dev, res);
>> + qspi->io_base = devm_platform_ioremap_resource_byname(pdev, "qspi");
>> if (IS_ERR(qspi->io_base))
>> return PTR_ERR(qspi->io_base);
>>
>> qspi->phys_base = res->start;
>>
>> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi_mm");
>> - qspi->mm_base = devm_ioremap_resource(dev, res);
>> + qspi->mm_base = devm_platform_ioremap_resource_byname(pdev, "qspi_mm");
>> if (IS_ERR(qspi->mm_base))
>> return PTR_ERR(qspi->mm_base);
>
> I can't identify any obvious error here, these look like a direct
> subsitution - the implementation of devm_platform_ioremap_resource_byname()
> looks to be the same as the replaced code and dev is set to &pdev->dev
> but I'm seeing the above behaviour.
Mark, thank you very much, I can't identify the error here too. This bug
may be easy to locate if have a reproduction environment, but it's good
to keep it the way it is.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] spi: stm32-qspi: Simpify resource lookup
2024-08-22 14:58 ` Mark Brown
2024-08-23 2:31 ` Jinjie Ruan
@ 2024-08-23 6:22 ` Jinjie Ruan
1 sibling, 0 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-08-23 6:22 UTC (permalink / raw)
To: Mark Brown
Cc: mcoquelin.stm32, alexandre.torgue, linux-spi, linux-stm32,
linux-arm-kernel, linux-kernel
On 2024/8/22 22:58, Mark Brown wrote:
> On Tue, Aug 20, 2024 at 08:37:07PM +0800, Jinjie Ruan wrote:
>> Use the devm_platform_ioremap_resource_byname() helper instead of
>> calling platform_get_resource_byname() and devm_ioremap_resource()
>> separately.
>
> This breaks boot on the Avenger96 board, it causes a NULL pointer
> dereference:
>
> [ 2.350480] Unable to handle kernel NULL pointer dereference at virtual address 00000000 when read
>
> ...
>
> [ 2.695787] Call trace:
> [ 2.695807] stm32_qspi_probe from platform_probe+0x5c/0xb0
> [ 2.703914] platform_probe from really_probe+0xc8/0x2c8
> [ 2.709284] really_probe from __driver_probe_device+0x88/0x19c
> [ 2.715145] __driver_probe_device from driver_probe_device+0x30/0x104
>
> https://lava.sirena.org.uk/scheduler/job/650792
>
>> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi");
>> - qspi->io_base = devm_ioremap_resource(dev, res);
>> + qspi->io_base = devm_platform_ioremap_resource_byname(pdev, "qspi");
>> if (IS_ERR(qspi->io_base))
>> return PTR_ERR(qspi->io_base);
>>
>> qspi->phys_base = res->start;
>>
>> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi_mm");
>> - qspi->mm_base = devm_ioremap_resource(dev, res);
>> + qspi->mm_base = devm_platform_ioremap_resource_byname(pdev, "qspi_mm");
>> if (IS_ERR(qspi->mm_base))
>> return PTR_ERR(qspi->mm_base);
>
> I can't identify any obvious error here, these look like a direct
> subsitution - the implementation of devm_platform_ioremap_resource_byname()
> looks to be the same as the replaced code and dev is set to &pdev->dev
> but I'm seeing the above behaviour.
Sorry, from lkp@intel.com,I identify that the "res" returned by
platform_get_resource_byname() is used by "qspi->phys_base =
res->start;" later,so the devm_platform_ioremap_resource_byname() is not
inapplicable here.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-23 6:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-20 12:37 [PATCH -next] spi: stm32-qspi: Simpify resource lookup Jinjie Ruan
2024-08-22 14:58 ` Mark Brown
2024-08-23 2:31 ` Jinjie Ruan
2024-08-23 6:22 ` Jinjie Ruan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®