diff options
| author | Honghui Jiang <jiang_hh2019@163.com> | 2026-08-14 11:14:17 +0800 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-08-14 16:48:51 +0100 |
| commit | af6aaacd42f74e2139391f9853d770d61ac430ce (patch) | |
| tree | 1e1e92c30ce8a761a1cb6dfcbc529152adf6a69d | |
| parent | b82b2dfc93d3c7729250e1107b7121775f5dfd40 (diff) | |
| download | linux-af6aaacd42f74e2139391f9853d770d61ac430ce.tar.gz linux-af6aaacd42f74e2139391f9853d770d61ac430ce.zip | |
spi: Clear current DMA devices when unmapping a message
The current DMA device pointers remain set after a message has been
unmapped. Existing users either check the corresponding mapped flag or
access the pointers before finalizing the message, but retaining stale
device pointers is fragile.
Clear both pointers in spi_unmap_msg() after the internal unmap
completes. Keep them intact in __spi_unmap_msg(), since that helper is
also used during partial-map unwind and the in-message DMA-to-PIO
fallback, before processing of the current message is complete.
Suggested-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Honghui Jiang <jiang_hh2019@163.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260814031419.43378-4-jiang_hh2019@163.com
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | drivers/spi/spi.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index bfb5ac93c8ee..ebda5855bba4 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1560,6 +1560,7 @@ static inline int spi_unmap_msg(struct spi_controller *ctlr, struct spi_message *msg) { struct spi_transfer *xfer; + int ret; list_for_each_entry(xfer, &msg->transfers, transfer_list) { /* @@ -1572,7 +1573,12 @@ static inline int spi_unmap_msg(struct spi_controller *ctlr, xfer->rx_buf = NULL; } - return __spi_unmap_msg(ctlr, msg); + ret = __spi_unmap_msg(ctlr, msg); + + ctlr->cur_rx_dma_dev = NULL; + ctlr->cur_tx_dma_dev = NULL; + + return ret; } static int spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg) |
