|
Lee Duncan |
186bfc |
From: John Garry <john.garry@huawei.com>
|
|
Lee Duncan |
186bfc |
Date: Tue, 17 May 2022 16:04:21 +0800
|
|
Lee Duncan |
186bfc |
Subject: scsi: hisi_sas: Fix memory ordering in hisi_sas_task_deliver()
|
|
Lee Duncan |
186bfc |
Git-commit: 6c6ac8b7773f05f93dc4e4044686e059d1f78dea
|
|
Lee Duncan |
186bfc |
Patch-mainline: v5.19-rc1
|
|
Lee Duncan |
186bfc |
References: git-fixes
|
|
Lee Duncan |
186bfc |
|
|
Lee Duncan |
186bfc |
The memories for the slot should be observed to be written prior to
|
|
Lee Duncan |
186bfc |
observing the slot as ready.
|
|
Lee Duncan |
186bfc |
|
|
Lee Duncan |
186bfc |
Prior to commit 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR"),
|
|
Lee Duncan |
186bfc |
we had a spin_lock() + spin_unlock() immediately before marking the slot as
|
|
Lee Duncan |
186bfc |
ready. The spin_unlock() - with release semantics - caused the slot memory
|
|
Lee Duncan |
186bfc |
to be observed to be written.
|
|
Lee Duncan |
186bfc |
|
|
Lee Duncan |
186bfc |
Now that the spin_lock() + spin_unlock() is gone, use a smp_wmb().
|
|
Lee Duncan |
186bfc |
|
|
Lee Duncan |
186bfc |
Link: https://lore.kernel.org/r/1652774661-12935-1-git-send-email-john.garry@huawei.com
|
|
Lee Duncan |
186bfc |
Fixes: 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR")
|
|
Lee Duncan |
186bfc |
Reported-by: Yihang Li <liyihang6@hisilicon.com>
|
|
Lee Duncan |
186bfc |
Tested-by: Yihang Li <liyihang6@hisilicon.com>
|
|
Lee Duncan |
186bfc |
Signed-off-by: John Garry <john.garry@huawei.com>
|
|
Lee Duncan |
186bfc |
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
Lee Duncan |
186bfc |
Acked-by: Lee Duncan <lduncan@suse.com>
|
|
Lee Duncan |
186bfc |
---
|
|
Lee Duncan |
186bfc |
drivers/scsi/hisi_sas/hisi_sas_main.c | 2 ++
|
|
Lee Duncan |
186bfc |
1 file changed, 2 insertions(+)
|
|
Lee Duncan |
186bfc |
|
|
Lee Duncan |
186bfc |
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
Lee Duncan |
186bfc |
index f81e74fd6263..764e859d0106 100644
|
|
Lee Duncan |
186bfc |
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
Lee Duncan |
186bfc |
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
Lee Duncan |
186bfc |
@@ -446,6 +446,8 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba,
|
|
Lee Duncan |
186bfc |
return;
|
|
Lee Duncan |
186bfc |
}
|
|
Lee Duncan |
186bfc |
|
|
Lee Duncan |
186bfc |
+ /* Make slot memories observable before marking as ready */
|
|
Lee Duncan |
186bfc |
+ smp_wmb();
|
|
Lee Duncan |
186bfc |
WRITE_ONCE(slot->ready, 1);
|
|
Lee Duncan |
186bfc |
|
|
Lee Duncan |
186bfc |
spin_lock(&dq->lock);
|
|
Lee Duncan |
186bfc |
|