[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0367b612-b6a5-8fb1-9cee-28de04b7ce81@acm.org>
Date: Sun, 11 Jun 2023 06:59:24 -0700
From: Bart Van Assche <bvanassche@....org>
To: Po-Wen Kao <powen.kao@...iatek.com>, linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
Alim Akhtar <alim.akhtar@...sung.com>,
Avri Altman <avri.altman@....com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
Cc: wsd_upstream@...iatek.com, peter.wang@...iatek.com,
stanley.chu@...iatek.com, alice.chao@...iatek.com,
naomi.chu@...iatek.com, chun-hung.wu@...iatek.com,
cc.chou@...iatek.com, eddie.huang@...iatek.com
Subject: Re: [PATCH v2 1/2] scsi: ufs: mcq: Fix the incorrect OCS value for
the device command
On 6/9/23 19:15, Po-Wen Kao wrote:
> From: Stanley Chu <stanley.chu@...iatek.com>
>
> 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".
Since with this patch applied ufs_dev_cmd.cqe is always NULL, please
remove the 'cqe' member from struct ufs_dev_cmd.
Thanks,
Bart.
Powered by blists - more mailing lists