diff options
author | Taeyang Choi <taeyang.choi@samsung.com> | 2024-01-24 15:25:13 +0900 |
---|---|---|
committer | Will McVicker <willmcvicker@google.com> | 2024-04-16 11:58:50 -0700 |
commit | 9c51f92afe3cabc954ee22e4b4026fb430b49800 (patch) | |
tree | aadebe88428555875f11774b920920b189786919 | |
parent | 1c105b993aa96e0d1f137f14f0ae1ab5ef12aa9f (diff) | |
download | raviole-device-9c51f92afe3cabc954ee22e4b4026fb430b49800.tar.gz |
spi: s3c64xx: reject transfer request if suspended
Due to the changes of spi.c, spi controller is in danger
to lost its message by ->resume() callback.
[Resume path]
s3c64xx_spi_resume_operation
pm_runtime_force_resume
spi_master_resume
spi_start_queue
controller->cur_msg = NULL;
[Transfer path]
__spi_sync
__spi_transfer_message_noqueue
ctlr->cur_msg = msg
__spi_pump_transfer_message
s3c64xx_spi_transfer_one_message
spi_finalize_current_message
//access controller->cur_msg
ctlr->cur_msg = NULL
As two paths could run in parallel, the cur_msg
can be NULL while doing transfer.
Reject request if the controller is in suspend,
and don't call the finalize function if we lost cur_msg already.
** change of spi.c **
https://lore.kernel.org/linux-spi/YrYfFiiYuvazKBtu@sirena.org.uk/T/
BUG: 319405160
Signed-off-by: Taeyang Choi <taeyang.choi@samsung.com>
(cherry picked from https://partner-android-review.googlesource.com/q/commit:43016e70f6cd49ea3a6ce78dc266a295ddaad06b)
Merged-In: I4d5940b9ae789ed7b1b5f5656c078624df279f34
Change-Id: I4d5940b9ae789ed7b1b5f5656c078624df279f34
Signed-off-by: Will McVicker <willmcvicker@google.com>
-rw-r--r-- | drivers/spi/spi-s3c64xx.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 0281d1cf4..01119af0e 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -959,6 +959,11 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, u32 speed; u8 bpw; + if (!master->running) { + dev_err(&spi->dev, "Controller is in suspend state.\n"); + return -EACCES; + } + /* If Master's(controller) state differs from that needed by Slave */ if (sdd->cur_speed != spi->max_speed_hz || sdd->cur_mode != spi->mode || sdd->cur_bpw != spi->bits_per_word) { @@ -1159,7 +1164,12 @@ out: msg->status = status; - spi_finalize_current_message(master); + if(master->cur_msg) + spi_finalize_current_message(master); + else { + dev_err(&master->dev, "Controller lost cur_msg!\n"); + return -EINVAL; + } return 0; } |