From: Joseph CT Chan <jctchan@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, David Lechner <dlechner@baylibre.com>,
Bart Van Assche <bvanassche@acm.org>,
Joseph CT Chan <josephctchan@google.com>
Subject: [PATCH v3 0/5] spi: spi-mux: error handling and delay fixes
Date: Thu, 3 Dec 2026 23:56:20 +0000 [thread overview]
Message-ID: <20261203235626.1437609-1-jctchan@gmail.com> (raw)
From: Joseph CT Chan <josephctchan@google.com>
Hi Mark,
This series fixes four bugs in the generic SPI multiplexer (spi-mux)
and adds a KUnit test suite covering them:
- Patch 1 releases the mux and resets current_cs to SPI_MUX_NO_CS when
spi_setup() on the parent controller fails, preventing permanent mux
deadlocks and stale settings on subsequent transfers.
- Patch 2 resets current_cs to SPI_MUX_NO_CS in spi_mux_setup() so that
setting changes on an already-selected child take effect on its next
transfer.
- Patch 3 finalizes the child's spi_message with m->status set and
restores message fields when spi_mux_select() or parent spi_async()
fails, instead of hanging callers forever or leaving the mux locked.
- Patch 4 saves the spi-mux device's own cs_setup, cs_hold, cs_inactive,
and word_delay at probe time, merges them with the active child's
delays before parent spi_setup(), and restores them on unbind.
- Patch 5 adds a KUnit test suite (spi_mux) with a Device Tree overlay
and enables it in drivers/spi/.kunitconfig (alongside CONFIG_OF=y,
CONFIG_OF_OVERLAY=y, and CONFIG_SPI_MUX=y, without CONFIG_COMPILE_TEST).
Run the suite on ARCH=um or x86_64 with:
./tools/testing/kunit/kunit.py run --kunitconfig=drivers/spi
./tools/testing/kunit/kunit.py run --arch=x86_64 --kunitconfig=drivers/spi
Tested with KUnit:
- ARCH=um (full series): 20/20 passed (spi_dma: 4, spi_core_optimize: 7,
spi_mux: 9).
- x86_64 (full series): 20/20 passed (spi_dma: 4, spi_core_optimize: 7,
spi_mux: 9).
- ARCH=um (full series + CONFIG_SPI_TI_QSPI_KUNIT_TEST=y): 21/21 passed.
- ARCH=um and x86_64 (full series + CONFIG_OF_KUNIT_TEST=y and
CONFIG_OF_OVERLAY_KUNIT_TEST=y): 35/35 passed on both architectures.
- ARCH=um (default kunit.py run): 924 tests: 894 passed, 30 skipped,
0 failed.
- Before fixes, ARCH=um (patch 5 only): 20 tests: 11 passed, 9 failed
(all 9 spi_mux cases fail).
- Before fixes, x86_64 (patch 5 only): 20 tests: 11 passed, 9 failed
(all 9 spi_mux cases fail).
- Before patch 1, ARCH=um (patches 3 and 5 without patch 1):
spi_mux_error_test 3 passed, 1 failed (parent_setup_fails fails with
-EBUSY on mux_control_try_select).
- W=1 builds of drivers/spi/ on ARCH=um, x86_64 built-in, x86_64 modular
(with MODPOST), and x86_64 KUNIT=n: 0 warnings.
- Not tested on hardware.
Changes in v3:
- Rebased on spi/for-7.5, which already includes commit 91db5febb159
("spi: unoptimize message when queuing it fails").
- Patch 1: clarified in the commit message why current_cs is also reset
to SPI_MUX_NO_CS on failure (priv->spi already holds the failing
child's settings).
- Patch 3: updated the commit message to reference commit 91db5febb159
directly instead of a separate unmerged SPI core series.
- Patch 5: dropped the drivers/spi/Makefile change (already includes
tests/); added CONFIG_OF=y, CONFIG_OF_OVERLAY=y, CONFIG_SPI_MUX=y, and
CONFIG_SPI_MUX_KUNIT_TEST=y to drivers/spi/.kunitconfig; dropped the
redundant "select DTC" from SPI_MUX_KUNIT_TEST; added
MODULE_SOFTDEP("pre: spi-mux") to spi-mux-kunit.c; used "{ }" for
zero-initialized structs and sentinels; corrected the SCK delay test
description in the commit message.
Changes in v2:
- Split out of the v1 14-patch series, as David suggested, and split the
four spi-mux fixes into four separate patches.
- Patch 5: used designated initializers for the test tables and trimmed
the comments.
- Moved the AI assistance note from an Assisted-by tag into the commit
messages.
v2: https://lore.kernel.org/linux-spi/20261103225308.3633046-1-jctchan@gmail.com/
v1: https://lore.kernel.org/all/20261102163023.2574632-1-jctchan@gmail.com/
Please consider this patch series for the next merge window.
Thanks,
Joseph
Joseph CT Chan (5):
spi: spi-mux: release mux when parent setup fails
spi: spi-mux: re-apply settings after child calls spi_setup()
spi: spi-mux: finalize message when forwarding fails
spi: spi-mux: pass child CS and word delays to the parent
spi: spi-mux: add KUnit tests for forwarding errors and settings
drivers/spi/.kunitconfig | 4 +
drivers/spi/Kconfig | 13 +
drivers/spi/spi-mux.c | 124 ++++++-
drivers/spi/tests/Makefile | 2 +
drivers/spi/tests/kunit_spi_mux.dtso | 42 +++
drivers/spi/tests/spi-mux-kunit.c | 507 +++++++++++++++++++++++++++
6 files changed, 688 insertions(+), 4 deletions(-)
create mode 100644 drivers/spi/tests/kunit_spi_mux.dtso
create mode 100644 drivers/spi/tests/spi-mux-kunit.c
base-commit: 7ab8f46f497dfc470973192f77cb226f4964ff87
--
2.56.1.915.g69d5ec7298-goog
next reply other threads:[~2026-12-03 23:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 23:56 Joseph CT Chan [this message]
2026-12-03 23:56 ` [PATCH v3 1/5] spi: spi-mux: release mux when parent setup fails Joseph CT Chan
2026-12-03 23:56 ` [PATCH v3 2/5] spi: spi-mux: re-apply settings after child calls spi_setup() Joseph CT Chan
2026-12-03 23:56 ` [PATCH v3 3/5] spi: spi-mux: finalize message when forwarding fails Joseph CT Chan
2026-12-03 23:56 ` [PATCH v3 4/5] spi: spi-mux: pass child CS and word delays to the parent Joseph CT Chan
2026-12-03 23:56 ` [PATCH v3 5/5] spi: spi-mux: add KUnit tests for forwarding errors and settings Joseph CT Chan
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=20261203235626.1437609-1-jctchan@gmail.com \
--to=jctchan@gmail.com \
--cc=broonie@kernel.org \
--cc=bvanassche@acm.org \
--cc=dlechner@baylibre.com \
--cc=josephctchan@google.com \
--cc=linux-spi@vger.kernel.org \
/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