RE: [PATCH v4] scsi: ufs: core: handle PM commands timeout before SCSI EH

From: Fang Hongjie(方洪杰)

Date: Wed Jun 03 2026 - 01:18:11 EST



> From: Bart Van Assche [mailto:bvanassche@xxxxxxx]
> Sent: Wednesday, June 3, 2026 1:32 AM
> To: Fang Hongjie(方洪杰) <hongjiefang@xxxxxxxxxxxx>;
> alim.akhtar@xxxxxxxxxxx; avri.altman@xxxxxxx;
> James.Bottomley@xxxxxxxxxxxxxxxxxxxxx; martin.petersen@xxxxxxxxxx;
> peter.wang@xxxxxxxxxxxx; beanhuo@xxxxxxxxxx
> Cc: linux-scsi@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v4] scsi: ufs: core: handle PM commands timeout before
> SCSI EH
>
> On 6/2/26 5:41 AM, Hongjie Fang wrote:
> > - return scsi_host_busy(hba->host) ? SCSI_EH_RESET_TIMER :
> SCSI_EH_DONE;
> > + /*
> > + * ufshcd_link_recovery() may already have completed @scmd, e.g.
> via
> > + * the existing MCQ force-completion path.
> > + */
> > + if (!test_bit(SCMD_STATE_COMPLETE, &scmd->state)) {
>
> The above test can be left out if scsi_done() would be called before
> ufshcd_link_recovery(), isn't it? Otherwise this patch looks good to me.

I think scsi_done() has to stay after ufshcd_link_recovery().
The reason is that scsi_done() wakes the blk_execute_rq()/scsi_execute_cmd()
waiter. If that happens before link recovery finishes, scsi_check_passthrough()
may retry the PM command while the host is still in recovery / reset state,
which would bring back the original retry-vs-recovery race this patch is
trying to avoid.



Best.