From: "Bao D. Nguyen" <quic_nguyenb@quicinc.com>
To: Can Guo <quic_cang@quicinc.com>, <bvanassche@acm.org>,
<mani@kernel.org>, <adrian.hunter@intel.com>,
<beanhuo@micron.com>, <avri.altman@wdc.com>,
<junwoo80.lee@samsung.com>, <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
Stanley Chu <stanley.chu@mediatek.com>,
Asutosh Das <quic_asutoshd@quicinc.com>,
Peter Wang <peter.wang@mediatek.com>,
"Arthur Simchaev" <Arthur.Simchaev@wdc.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scsi: ufs: core: Let the sq_lock protect sq_tail_slot access
Date: Tue, 2 Jan 2024 12:33:20 -0800 [thread overview]
Message-ID: <76fb76cc-70d6-7a5f-7fcd-e8161ae72299@quicinc.com> (raw)
In-Reply-To: <1702913550-20631-1-git-send-email-quic_cang@quicinc.com>
On 12/18/2023 7:32 AM, Can Guo wrote:
> If access sq_tail_slot without the protection from the sq_lock, race
> condition can have multiple SQEs copied to duplicate SQE slot(s), which can
> lead to multiple incredible stability issues. Fix it by moving the *dest
> initialization, in ufshcd_send_command(), back under protection from the
> sq_lock.
>
> Fixes: 3c85f087faec ("scsi: ufs: mcq: Use pointer arithmetic in ufshcd_send_command()")
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index ae9936f..2994aac 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2274,9 +2274,10 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag,
> if (is_mcq_enabled(hba)) {
> int utrd_size = sizeof(struct utp_transfer_req_desc);
> struct utp_transfer_req_desc *src = lrbp->utr_descriptor_ptr;
> - struct utp_transfer_req_desc *dest = hwq->sqe_base_addr + hwq->sq_tail_slot;
> + struct utp_transfer_req_desc *dest;
>
> spin_lock(&hwq->sq_lock);
> + dest = hwq->sqe_base_addr + hwq->sq_tail_slot;
> memcpy(dest, src, utrd_size);
> ufshcd_inc_sq_tail(hwq);
> spin_unlock(&hwq->sq_lock);
Reviewed and Tested-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
prev parent reply other threads:[~2024-01-02 20:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-18 15:32 [PATCH] scsi: ufs: core: Let the sq_lock protect sq_tail_slot access Can Guo
2023-12-18 21:41 ` Bart Van Assche
2023-12-20 14:50 ` Manivannan Sadhasivam
2023-12-20 16:35 ` Bart Van Assche
2023-12-20 17:00 ` Manivannan Sadhasivam
2024-01-02 20:33 ` Bao D. Nguyen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=76fb76cc-70d6-7a5f-7fcd-e8161ae72299@quicinc.com \
--to=quic_nguyenb@quicinc.com \
--cc=Arthur.Simchaev@wdc.com \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=jejb@linux.ibm.com \
--cc=junwoo80.lee@samsung.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mani@kernel.org \
--cc=martin.petersen@oracle.com \
--cc=peter.wang@mediatek.com \
--cc=quic_asutoshd@quicinc.com \
--cc=quic_cang@quicinc.com \
--cc=stanley.chu@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox