From: Stephano Cetola <stephano@cetola.net>
To: Sascha Hauer <s.hauer@pengutronix.de>,
"open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH v3] spi: rockchip: initialize bus_num to -1
Date: Mon, 24 Aug 2026 18:21:05 -0700 [thread overview]
Message-ID: <20260824-send-spi-rockchip-busnum-v3-1-96ef89a157f7@cetola.net> (raw)
spi_register_controller() only runs the OF alias lookup when
ctrl->bus_num is negative. This driver's kzalloc'd ctlr leaves
bus_num at 0. The lookup gets skipped. 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.
Use -1 here to trigger the lookup from the device tree. No board board
file deliberately sets the id.
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 v3:
- Initialize bus_num to -1 directly. Copying dev->id worked by
coincidence, not by design.
- Rewrote the commit message to explain why -1 is correct, per
Sascha's review.
- Link to v2: https://patch.msgid.link/20260822-send-spi-rockchip-busnum-v2-1-0f43376cb391@cetola.net
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..0ee31c1f55 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 = -1;
// ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP | SPI_LSB_FIRST;
/*
---
base-commit: 9bc1a26592a59919d2ee8c60c273d87d3d9f2e81
change-id: 20260821-send-spi-rockchip-busnum-a9b1116e14a5
next reply other threads:[~2026-08-25 1:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 1:21 Stephano Cetola [this message]
2026-08-25 13:49 ` Sascha Hauer
[not found] <202608272006258002394@armdesigner.com>
2026-08-27 12:55 ` Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260824-send-spi-rockchip-busnum-v3-1-96ef89a157f7@cetola.net \
--to=stephano@cetola.net \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox