RE: [PATCH v4] scsi: ufs: core: handle PM commands timeout before SCSI EH
From: Fang Hongjie(方洪杰)
Date: Wed Jun 03 2026 - 07:09:31 EST
> From: Peter Wang (王信友) [mailto:peter.wang@xxxxxxxxxxxx]
> Sent: Wednesday, June 3, 2026 2:55 PM
> To: beanhuo@xxxxxxxxxx; James.Bottomley@xxxxxxxxxxxxxxxxxxxxx;
> Fang Hongjie(方洪杰) <hongjiefang@xxxxxxxxxxxx>;
> alim.akhtar@xxxxxxxxxxx; avri.altman@xxxxxxx;
> martin.petersen@xxxxxxxxxx; bvanassche@xxxxxxx
> Cc: linux-scsi@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v4] scsi: ufs: core: handle PM commands timeout before
> SCSI EH
>
>
> On Tue, 2026-06-02 at 20:41 +0800, Hongjie Fang wrote:
> > + /*
> > + * 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)) {
> > + if (!hba->mcq_enabled) {
> >
>
> Hi Hongjie,
>
> MCQ will complete all uncompleted scmd by setting force_compl.
> Hence, if there are still uncompleted scmd, it should be
> in legacy mode, and there is no need to check
> if (!hba->mcq_enabled), right?
>
The !hba->mcq_enabled check is only for clearing outstanding_reqs,
which is the legacy single-doorbell software bitmap.
MCQ does not use outstanding_reqs for request tracking.
>
> > + unsigned long flags;
> > + struct request *rq = scsi_cmd_to_rq(scmd);
> > +
> > + spin_lock_irqsave(&hba->outstanding_lock,
> > flags);
> > + __clear_bit(rq->tag, &hba->outstanding_reqs);
> > + spin_unlock_irqrestore(&hba-
> > >outstanding_lock, flags);
> > + }
> > +
> > + set_host_byte(scmd, DID_TIME_OUT);
> >
>
> Why does MCQ mode set DID_REQUEUE, while legacy mode sets
> DID_TIME_OUT?
>
Normal SCSI PM commands use DID_REQUEUE, matching the existing
MCQ force-completion behavior. Reserved internal device-management
commands continue to use DID_TIME_OUT, right ?
Best.