This is a note to let you know that I've just added the patch titled scsi: hisi_sas: Fix memory ordering in hisi_sas_task_deliver() to the 5.18-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: scsi-hisi_sas-fix-memory-ordering-in-hisi_sas_task_d.patch and it can be found in the queue-5.18 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 9d1f2c535f8af2c7070cbe1cfd1828d44e4dbce1 Author: John Garry <john.garry@xxxxxxxxxx> Date: Tue May 17 16:04:21 2022 +0800 scsi: hisi_sas: Fix memory ordering in hisi_sas_task_deliver() [ Upstream commit 6c6ac8b7773f05f93dc4e4044686e059d1f78dea ] The memories for the slot should be observed to be written prior to observing the slot as ready. Prior to commit 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR"), we had a spin_lock() + spin_unlock() immediately before marking the slot as ready. The spin_unlock() - with release semantics - caused the slot memory to be observed to be written. Now that the spin_lock() + spin_unlock() is gone, use a smp_wmb(). Link: https://lore.kernel.org/r/1652774661-12935-1-git-send-email-john.garry@xxxxxxxxxx Fixes: 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR") Reported-by: Yihang Li <liyihang6@xxxxxxxxxxxxx> Tested-by: Yihang Li <liyihang6@xxxxxxxxxxxxx> Signed-off-by: John Garry <john.garry@xxxxxxxxxx> Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 86cbfab78dfe..849cc5fc86af 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -446,6 +446,8 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba, return; } + /* Make slot memories observable before marking as ready */ + smp_wmb(); WRITE_ONCE(slot->ready, 1); spin_lock(&dq->lock);