Re: [PATCH v4 07/10] scsi: ufs: Simplify error handling preparation

From: Bart Van Assche
Date: Wed Jun 23 2021 - 17:30:49 EST


On 6/23/21 12:35 AM, Can Guo wrote:
> -static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
> +static int ufshcd_err_handling_prepare(struct ufs_hba *hba)
> {
> /*
> * It is not safe to perform error handling while suspend or resume is
> * in progress. Hence the lock_system_sleep() call.
> */
> lock_system_sleep();
> + /*
> + * Exclusively call pm_runtime_get_sync(hba->dev) once, in case
> + * following ufshcd_rpm_get_sync() fails.
> + */
> + pm_runtime_get_sync(hba->dev);
> + if (pm_runtime_suspended(hba->dev) || hba->is_sys_suspended) {
> + pm_runtime_put(hba->dev);
> + unlock_system_sleep();
> + return -EINVAL;
> + }

There is code present in ufshcd_queuecommand() that may trigger data
corruption to prevent that the above pm_runtime_get_sync() call triggers
a deadlock. I think we need a better solution.

Thanks,

Bart.