Skip to content

spi: spl022: fix sleeping in interrupt context

Nam Cao linux-arm-kernel linux-spi lkml 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesIn review
  2. v12 patches 3 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2spi: introduce SPI_TRANS_FAIL_IO for error reportingdrivers/spi/spi.c include/linux/spi/spi.h+11 -40 replies
2/2spi: spl022: switch to use default spi_transfer_one_message()drivers/spi/spi-pl022.c+66 -3062 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchLinus Walleij
1/2A-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] spi: spl022: fix sleeping in interrupt context

Hi,

While running the spl022, I got the following warning:

BUG: sleeping function called from invalid context at drivers/spi/spi.c:1428

This is because between spi transfers, spi_transfer_delay_exec() (who may sleep if the delay is >10us) is called in interrupt context. This is a problem for anyone who runs this driver and need more than 10us delay.

Patch 1 adds an error reporting mechanism, needed by patch 2 who switch to use the default spi_transfer_one_message(), which fix the problem.

The series is tested with polling transfer mode and interrupt transfer mode. I can't test the DMA mode, so some help testing here is very appreciated.

One question: This series is quite big for stable trees, so how can we backport this fix? We can:
- Let it be released, and get tested for some time. After a while without any reported problem, backport it.
- Have a small patch which fixes this problem. One idea I have is to switch the current interrupt handler to threaded interrupt handler, and switch from existing use of tasklet to workqueue. So that the driver can safely sleep if needed. And then add this series on top of that.
- other options that I miss?

Best regards,
Nam

v2: add some documents for the new flag. No functional change.

Nam Cao (2):
spi: introduce SPI_TRANS_FAIL_IO for error reporting
spi: spl022: switch to use default spi_transfer_one_message()

 drivers/spi/spi-pl022.c | 372 +++++++---------------------------------
 drivers/spi/spi.c       |   3 +
 include/linux/spi/spi.h |  12 +-
 3 files changed, 77 insertions(+), 310 deletions(-)
Signature · 1 line
2.39.2