On 3/12/25 12:40 AM, Peter Wang (王信友) wrote:
On Tue, 2025-03-11 at 12:53 -0700, Bart Van Assche wrote:
@@ -3272,13 +3261,10 @@ static void ufshcd_dev_man_unlock(struct
ufs_hba *hba)
static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct
ufshcd_lrb *lrbp,
const u32 tag, int timeout)
{
- DECLARE_COMPLETION_ONSTACK(wait);
int err;
- hba->dev_cmd.complete = &wait;
-
ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp-
ucd_req_ptr);
-
+ init_completion(&hba->dev_cmd.complete);
ufshcd_send_command(hba, tag, hba->dev_cmd_queue);
err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout);
Hi Bart,
This could calling init_completion on the same completion twice?
Hi Peter,
My patch will cause init_completion() to be called as many times as
device management commands are submitted. As far as I know the following
sequence is allowed and does not trigger any race conditions:
Thread 1 Thread 2
-------- --------
init_completion()
wait_for_completion_timeout() is called
complete()
wait_for_completion_timeout() returns
init_completion()
wait_for_completion_timeout() is called
complete()
wait_for_completion_timeout() returns
[ ... ]
Thanks,
Bart.