Commit 0fef6bb
scsi: ufs: core: mcq: Fix the incorrect OCS value for the device command
In MCQ mode, when a device command uses a hardware queue shared with other
commands, a race condition may occur in the following scenario:
1. A device command is completed in CQx with CQE entry "e".
2. The interrupt handler copies the "cqe" pointer to "hba->dev_cmd.cqe"
and completes "hba->dev_cmd.complete".
3. The "ufshcd_wait_for_dev_cmd()" function is awakened and retrieves the
OCS value from "hba->dev_cmd.cqe".
However, there is a possibility that the CQE entry "e" will be overwritten
by newly completed commands in CQx, resulting in an incorrect OCS value
being received by "ufshcd_wait_for_dev_cmd()".
To avoid this race condition, the OCS value should be immediately copied to
the struct "lrb" of the device command. Then "ufshcd_wait_for_dev_cmd()"
can retrieve the OCS value from the struct "lrb".
Fixes: 57b1c0e ("scsi: ufs: core: mcq: Add support to allocate multiple queues")
Suggested-by: Can Guo <[email protected]>
Signed-off-by: Stanley Chu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Tested-by: Po-Wen Kao <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>1 parent e246514 commit 0fef6bb
2 files changed
+7
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3086 | 3086 | | |
3087 | 3087 | | |
3088 | 3088 | | |
3089 | | - | |
| 3089 | + | |
3090 | 3090 | | |
3091 | 3091 | | |
3092 | 3092 | | |
| |||
3182 | 3182 | | |
3183 | 3183 | | |
3184 | 3184 | | |
3185 | | - | |
3186 | 3185 | | |
3187 | 3186 | | |
3188 | 3187 | | |
| |||
5431 | 5430 | | |
5432 | 5431 | | |
5433 | 5432 | | |
| 5433 | + | |
5434 | 5434 | | |
5435 | 5435 | | |
5436 | 5436 | | |
| |||
5446 | 5446 | | |
5447 | 5447 | | |
5448 | 5448 | | |
5449 | | - | |
| 5449 | + | |
| 5450 | + | |
| 5451 | + | |
| 5452 | + | |
| 5453 | + | |
5450 | 5454 | | |
5451 | 5455 | | |
5452 | 5456 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
229 | 228 | | |
230 | 229 | | |
231 | 230 | | |
| |||
0 commit comments