Skip to content

spi: spi-mux: error handling and delay fixes

Joseph CT Chan linux-spi stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest5 patches 2 repliesIn review

Changes in v2 from the cover letter

- Split out of the v1 14-patch series, as David suggested.
- Patches 3 and 4: updated the patch references in the commit messages.
- Patch 5: designated initializers, trimmed the comments.
- Moved the AI assistance note from an Assisted-by tag into the commit message.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5spi: spi-mux: release mux when parent setup failsdrivers/spi/spi-mux.c+8 -10 replies
2/5spi: spi-mux: re-apply settings after child calls spi_setup()drivers/spi/spi-mux.c+6 -00 replies
3/5spi: spi-mux: finalize message when forwarding failsdrivers/spi/spi-mux.c+23 -30 replies
4/5spi: spi-mux: pass child CS and word delays to the parentdrivers/spi/spi-mux.c+83 -00 replies
5/5spi: spi-mux: add KUnit tests for forwarding errors and settingsdrivers/spi/Kconfig drivers/spi/Makefile drivers/spi/tests/.kunitconfig +3 more+569 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/5] spi: spi-mux: error handling and delay fixes

From: Joseph CT Chan <[email protected]>

Hi Mark,

This series fixes four problems in spi-mux:
- If spi_setup() on the parent fails, the mux stays locked and every later message on that mux blocks.
- When the selected child changes its settings and calls spi_setup(), the new settings never reach the parent.
- If selecting the mux or spi_async() on the parent fails, the message is never finalized and spi_sync() on the child waits forever. -EBUSY while mmc_spi holds the parent bus lock is one easy way to hit this.
- The child's CS setup, hold, inactive and word delays are not passed to the parent.
Patch 5 adds KUnit tests for all four. Tested with KUnit on ARCH=um:
the 9 spi_mux cases pass with patches 1-4 and fail without them. Not tested on hardware.

Changes in v2:
- Split out of the v1 14-patch series, as David suggested.
- Patches 3 and 4: updated the patch references in the commit messages.
- Patch 5: designated initializers, trimmed the comments.
- Moved the AI assistance note from an Assisted-by tag into the commit message.

v1: https://lore.kernel.org/all/[email protected]/

This series depends on the SPI core series v2: without "spi: unoptimize message when queuing it fails", a failed spi_async() on the parent leaves the message optimized. It is also based on the spi-ti-qspi series v2, because both add lines at the end of the same KUnit Makefile and .kunitconfig. Patches 1-4 apply on their own.

SPI core series v2: https://lore.kernel.org/linux-spi/[email protected]/
spi-ti-qspi series v2: https://lore.kernel.org/linux-spi/[email protected]/

Walkthrough: https://gist.github.com/joectchan/9a14b5e6facb75058ebc5a6ff1757131

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/Kconfig                  |  14 +
 drivers/spi/Makefile                 |   1 +
 drivers/spi/spi-mux.c                | 124 ++++++-
 drivers/spi/tests/.kunitconfig       |   4 +
 drivers/spi/tests/Makefile           |   2 +
 drivers/spi/tests/kunit_spi_mux.dtso |  42 +++
 drivers/spi/tests/spi-mux-kunit.c    | 506 +++++++++++++++++++++++++++
 7 files changed, 689 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: c339f4010dea8b0d754f84ace70cd1b089878ef8
prerequisite-patch-id: 6999a3baa2d32de8fa42f2626a845fe3cb63b0b2
prerequisite-patch-id: 686a62b9223209bf1e83740a0874e20d7607f69a
prerequisite-patch-id: 616b18b757805a6f1520177e1a3e572ac95be582
prerequisite-patch-id: 0d46943b5bec4900701286d93b8b3e975701fb3d

Signature · 1 line
2.56.0.385.gac671c819a-goog