[PATCH v4 1/1] scsi: ufs: core: fix device management cmd timeout flow

Bart Van Assche bvanassche at acm.org
Wed Jan 18 13:59:36 PST 2023


On 12/15/22 19:25, Mason Zhang wrote:
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index b1f59a5fe632..fa86ce80f350 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -3008,6 +3008,22 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
>   		} else {
>   			dev_err(hba->dev, "%s: failed to clear tag %d\n",
>   				__func__, lrbp->task_tag);
> +
> +			spin_lock_irqsave(&hba->outstanding_lock, flags);
> +			pending = test_bit(lrbp->task_tag,
> +					   &hba->outstanding_reqs);
> +			if (pending)
> +				hba->dev_cmd.complete = NULL;
> +			spin_unlock_irqrestore(&hba->outstanding_lock, flags);
> +
> +			if (!pending) {
> +				/*
> +				 * The completion handler ran while we tried to
> +				 * clear the command.
> +				 */
> +				time_left = 1;
> +				goto retry;
> +			}
>   		}
>   	}

Reviewed-by: Bart Van Assche <bvanassche at acm.org>



More information about the Linux-mediatek mailing list