* [PATCH v2] spi: rockchip: restore bus_num alias lookup via dev->id
@ 2026-08-22 15:31 Stephano Cetola
2026-08-24 10:21 ` Sascha Hauer
0 siblings, 1 reply; 3+ messages in thread
From: Stephano Cetola @ 2026-08-22 15:31 UTC (permalink / raw)
To: Sascha Hauer, open list:BAREBOX
ctlr->bus_num = pdev->id was commented out when this driver was
ported from Linux. pdev doesn't exist in barebox's device model here,
only dev. The port left this line unresolved instead of translating
it. With bus_num left at its kzalloc default of 0,
spi_register_controller() only runs the alias lookup when bus_num < 0,
so it's skipped and every Rockchip SPI controller ends up on bus 0.
Any board that enables two Rockchip SPI controllers at once hits this
bug. Both end up on bus 0. Looking one up by bus number can then
return the wrong controller.
Fixes: 1efba64ba04 ("spi: add rockchip spi controller support")
Signed-off-by: Stephano Cetola <stephano@cetola.net>
---
We saw this on the MNT Pocket Reform (RK3588S). spi@feb20000 returns
the PMIC controller instead of the intended gpio-spi RP2040 bus. The
barebox spi command then does a write+read through the Rockchip SPI
driver, which programmes the hardware in XFM_RO (RX-only) mode for
the read phase. In that mode dummy TXDR writes don't generate clock
pulses, the RX FIFO never fills, and rockchip_spi_pio's while(1) loop
never exits.
---
Changes in v2:
- Updated commit message for clarity.
- Link to v1: https://patch.msgid.link/20260822-send-spi-rockchip-busnum-v1-1-bf9c183786e4@cetola.net
To: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
---
drivers/spi/spi-rockchip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 1e81e9393f..b9f43fa4d6 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -514,7 +514,7 @@ static int rockchip_spi_probe(struct device *dev)
goto err_put_ctlr;
}
-// ctlr->bus_num = pdev->id;
+ ctlr->bus_num = dev->id;
// ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP | SPI_LSB_FIRST;
/*
---
base-commit: 9bc1a26592a59919d2ee8c60c273d87d3d9f2e81
change-id: 20260821-send-spi-rockchip-busnum-a9b1116e14a5
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] spi: rockchip: restore bus_num alias lookup via dev->id
2026-08-22 15:31 [PATCH v2] spi: rockchip: restore bus_num alias lookup via dev->id Stephano Cetola
@ 2026-08-24 10:21 ` Sascha Hauer
2026-08-24 20:11 ` Stephano Cetola
0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2026-08-24 10:21 UTC (permalink / raw)
To: Stephano Cetola; +Cc: open list:BAREBOX
Hi Stephano,
On 2026-08-22 08:31, Stephano Cetola wrote:
> ctlr->bus_num = pdev->id was commented out when this driver was
> ported from Linux. pdev doesn't exist in barebox's device model here,
> only dev. The port left this line unresolved instead of translating
> it. With bus_num left at its kzalloc default of 0,
> spi_register_controller() only runs the alias lookup when bus_num < 0,
> so it's skipped and every Rockchip SPI controller ends up on bus 0.
>
> Any board that enables two Rockchip SPI controllers at once hits this
> bug. Both end up on bus 0. Looking one up by bus number can then
> return the wrong controller.
>
> Fixes: 1efba64ba04 ("spi: add rockchip spi controller support")
> Signed-off-by: Stephano Cetola <stephano@cetola.net>
> ---
> We saw this on the MNT Pocket Reform (RK3588S). spi@feb20000 returns
> the PMIC controller instead of the intended gpio-spi RP2040 bus. The
> barebox spi command then does a write+read through the Rockchip SPI
> driver, which programmes the hardware in XFM_RO (RX-only) mode for
> the read phase. In that mode dummy TXDR writes don't generate clock
> pulses, the RX FIFO never fills, and rockchip_spi_pio's while(1) loop
> never exits.
> ---
> Changes in v2:
> - Updated commit message for clarity.
> - Link to v1: https://patch.msgid.link/20260822-send-spi-rockchip-busnum-v1-1-bf9c183786e4@cetola.net
>
> To: Sascha Hauer <s.hauer@pengutronix.de>
> To: "open list:BAREBOX" <barebox@lists.infradead.org>
> ---
> drivers/spi/spi-rockchip.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> index 1e81e9393f..b9f43fa4d6 100644
> --- a/drivers/spi/spi-rockchip.c
> +++ b/drivers/spi/spi-rockchip.c
> @@ -514,7 +514,7 @@ static int rockchip_spi_probe(struct device *dev)
> goto err_put_ctlr;
> }
>
> -// ctlr->bus_num = pdev->id;
> + ctlr->bus_num = dev->id;
This should be initialized to -1 explicitly, because that's what we want
to archieve. The = dev->id we have here is only needed for the case when
the device is registered from platform code and we no longer use that
with this device tree only driver.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] spi: rockchip: restore bus_num alias lookup via dev->id
2026-08-24 10:21 ` Sascha Hauer
@ 2026-08-24 20:11 ` Stephano Cetola
0 siblings, 0 replies; 3+ messages in thread
From: Stephano Cetola @ 2026-08-24 20:11 UTC (permalink / raw)
To: Sascha Hauer; +Cc: open list:BAREBOX
On 8/24/26 3:21 AM, Sascha Hauer wrote:
> Hi Stephano,
>
>
> This should be initialized to -1 explicitly, because that's what we want
> to archieve. The = dev->id we have here is only needed for the case when
> the device is registered from platform code and we no longer use that
> with this device tree only driver.
>
Oh, I get it now. I'll send a V3. Thanks for pointing this out.
Cheers,
Stephano
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-24 20:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-22 15:31 [PATCH v2] spi: rockchip: restore bus_num alias lookup via dev->id Stephano Cetola
2026-08-24 10:21 ` Sascha Hauer
2026-08-24 20:11 ` Stephano Cetola
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox