Skip to content

spi: spi-ti-qspi: finalize message on transfer error

Joseph CT Chan linux-spi stable 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 0 repliesNew
  2. v22 patches 0 repliesSuperseded

Changes in v3 from the cover letter

- Rebased on spi/for-7.5 now that the SPI core series is applied there.
- Patch 1: fixed the commit message to state that the old code returns -EINVAL directly rather than ret.
- Patch 2: dropped the drivers/spi/Makefile change (already includes tests/) and left drivers/spi/.kunitconfig unmodified because enabling CONFIG_COMPILE_TEST=y in it would alter many unrelated options for every SPI KUnit run (pass the three options via --kconfig_add); moved logic_iomem checks out of Kconfig depends and skipped via kunit_skip() when !INDIRECT_IOMEM || HAVE_CLK; removed the stale pm_runtime_get_noresume() calls (ti_qspi_remove() no longer calls pm_runtime_put_sync() after commit 8b8678d3e894); reduced the test to one fast KUNIT_CASE checking spi_sync() == -ETIMEDOUT, !msg.optimized, and QSPI_INVAL (removed the async, recovery, and tautological m->status checks and the optional second MEM resource).

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2spi: spi-ti-qspi: finalize message on transfer errordrivers/spi/spi-ti-qspi.c+2 -20 replies
2/2spi: spi-ti-qspi: add a KUnit test for transfer error finalizationdrivers/spi/Kconfig drivers/spi/tests/Makefile drivers/spi/tests/spi-ti-qspi-kunit.c+185 -00 replies

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH v3 0/2] spi: spi-ti-qspi: finalize message on transfer error

From: Joseph CT Chan <[email protected]>

Hi Mark,

When a transfer fails in ti_qspi_start_transfer_one(), for example on a write completion timeout, the driver returns without finalizing the message and without writing QSPI_INVAL to end the frame. A queued caller then waits forever, and a spi_sync() that took the no-queue path gets -EINPROGRESS instead of the error (with the message's optimize state left unreleased). Patch 1 sends the error through the existing exit path, which ends the frame, sets the status, and finalizes the message.

Patch 2 adds a KUnit test that emulates the controller registers with logic_iomem on ARCH=um and calls kunit_skip() on configurations without CONFIG_INDIRECT_IOMEM or with CONFIG_HAVE_CLK enabled. The test is not added to drivers/spi/.kunitconfig because building SPI_TI_QSPI on UML or x86_64 requires CONFIG_COMPILE_TEST=y, which would change many unrelated options for every SPI KUnit run. Run it with:

  ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/spi \
          --kconfig_add CONFIG_COMPILE_TEST=y \
          --kconfig_add CONFIG_SPI_TI_QSPI=y \
          --kconfig_add CONFIG_SPI_TI_QSPI_KUNIT_TEST=y

Tested with KUnit:
- (a) Plain ARCH=um (./tools/testing/kunit/kunit.py run --kunitconfig=drivers/spi):
11/11 passed (spi_ti_qspi not enabled).
- (b) ARCH=um with the --kconfig_add options, patch 2 only:
11 passed, 1 failed (ti_qspi_test fails on all three checks).
- (c) ARCH=um with the --kconfig_add options, both patches:
12/12 passed.
- (d) x86_64 with the --kconfig_add options: 11 passed, 1 skipped (ti_qspi_test skipped with reason); plain x86_64: 11/11 passed.
- W=1 builds of drivers/spi/ on ARCH=um and x86_64: 0 warnings.
- Not tested on hardware.

Changes in v3:
- Rebased on spi/for-7.5 now that the SPI core series is applied there.
- Patch 1: fixed the commit message to state that the old code returns -EINVAL directly rather than ret.
- Patch 2: dropped the drivers/spi/Makefile change (already includes tests/) and left drivers/spi/.kunitconfig unmodified because enabling CONFIG_COMPILE_TEST=y in it would alter many unrelated options for every SPI KUnit run (pass the three options via --kconfig_add); moved logic_iomem checks out of Kconfig depends and skipped via kunit_skip() when !INDIRECT_IOMEM || HAVE_CLK; removed the stale pm_runtime_get_noresume() calls (ti_qspi_remove() no longer calls pm_runtime_put_sync() after commit 8b8678d3e894); reduced the test to one fast KUNIT_CASE checking spi_sync() == -ETIMEDOUT, !msg.optimized, and QSPI_INVAL (removed the async, recovery, and tautological m->status checks and the optional second MEM resource).

Changes in v2:
- Split out of the v1 14-patch series, as David suggested.
- Patch 2: trimmed the comments in the test.
- Moved the AI assistance note from an Assisted-by tag into the commit message.

v2: https://lore.kernel.org/linux-spi/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Please consider this patch series for the next merge window.

Thanks,
Joseph

Joseph CT Chan (2):
spi: spi-ti-qspi: finalize message on transfer error
spi: spi-ti-qspi: add a KUnit test for transfer error finalization

 drivers/spi/Kconfig                   |  12 ++
 drivers/spi/spi-ti-qspi.c             |   4 +-
 drivers/spi/tests/Makefile            |   1 +
 drivers/spi/tests/spi-ti-qspi-kunit.c | 172 ++++++++++++++++++++++++++
 4 files changed, 187 insertions(+), 2 deletions(-)
 create mode 100644 drivers/spi/tests/spi-ti-qspi-kunit.c

base-commit: 0877b0b54a4c186ea9acca25ae79efd8516176ba

Signature · 1 line
2.56.0.679.gc527c65306-goog