diff mbox series

[RFC,v1] ufs: relocate flush of exceptional event

Message ID 1608360039-16390-1-git-send-email-kwmad.kim@samsung.com
State New
Headers show
Series [RFC,v1] ufs: relocate flush of exceptional event | expand

Commit Message

Kiwoong Kim Dec. 19, 2020, 6:40 a.m. UTC
I found one case as follows and the current flush
location doesn't guarantee disabling BKOPS in the
case of requsting device power off.
1) The exceptional event handler is queued.
2) ufs suspend starts with a request of device power off
3) BKOPS is disabled in ufs suspend
4) The queued work for the handler is done and BKOPS
is enabled again.

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Can Guo Dec. 20, 2020, 5:48 a.m. UTC | #1
On 2020-12-19 14:40, Kiwoong Kim wrote:
> I found one case as follows and the current flush

> location doesn't guarantee disabling BKOPS in the

> case of requsting device power off.

> 1) The exceptional event handler is queued.

> 2) ufs suspend starts with a request of device power off

> 3) BKOPS is disabled in ufs suspend

> 4) The queued work for the handler is done and BKOPS

> is enabled again.

> 

> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>

> ---

>  drivers/scsi/ufs/ufshcd.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c

> index 92d433d..414025c 100644

> --- a/drivers/scsi/ufs/ufshcd.c

> +++ b/drivers/scsi/ufs/ufshcd.c

> @@ -8608,6 +8608,8 @@ static int ufshcd_suspend(struct ufs_hba *hba,

> enum ufs_pm_op pm_op)

>  			ufshcd_wb_need_flush(hba));

>  	}

> 

> +	flush_work(&hba->eeh_work);

> +

>  	if (req_dev_pwr_mode != hba->curr_dev_pwr_mode) {

>  		if ((ufshcd_is_runtime_pm(pm_op) && !hba->auto_bkops_enabled) ||

>  		    !ufshcd_is_runtime_pm(pm_op)) {

> @@ -8622,8 +8624,6 @@ static int ufshcd_suspend(struct ufs_hba *hba,

> enum ufs_pm_op pm_op)

>  		}

>  	}

> 

> -	flush_work(&hba->eeh_work);

> -

>  	/*

>  	 * In the case of DeepSleep, the device is expected to remain powered

>  	 * with the link off, so do not check for bkops.


Reviewed-by: Can Guo <cang@codeaurora.org>
Stanley Chu Dec. 20, 2020, 2:09 p.m. UTC | #2
On Sat, 2020-12-19 at 15:40 +0900, Kiwoong Kim wrote:
> I found one case as follows and the current flush

> location doesn't guarantee disabling BKOPS in the

> case of requsting device power off.

> 1) The exceptional event handler is queued.

> 2) ufs suspend starts with a request of device power off

> 3) BKOPS is disabled in ufs suspend

> 4) The queued work for the handler is done and BKOPS

> is enabled again.

> 

> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>


Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Martin K. Petersen Jan. 8, 2021, 4:19 a.m. UTC | #3
On Sat, 19 Dec 2020 15:40:39 +0900, Kiwoong Kim wrote:

> I found one case as follows and the current flush

> location doesn't guarantee disabling BKOPS in the

> case of requsting device power off.

> 1) The exceptional event handler is queued.

> 2) ufs suspend starts with a request of device power off

> 3) BKOPS is disabled in ufs suspend

> 4) The queued work for the handler is done and BKOPS

> is enabled again.


Applied to 5.11/scsi-fixes, thanks!

[1/1] ufs: relocate flush of exceptional event
      https://git.kernel.org/mkp/scsi/c/6948a96a0d69

-- 
Martin K. Petersen	Oracle Linux Engineering
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 92d433d..414025c 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8608,6 +8608,8 @@  static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 			ufshcd_wb_need_flush(hba));
 	}
 
+	flush_work(&hba->eeh_work);
+
 	if (req_dev_pwr_mode != hba->curr_dev_pwr_mode) {
 		if ((ufshcd_is_runtime_pm(pm_op) && !hba->auto_bkops_enabled) ||
 		    !ufshcd_is_runtime_pm(pm_op)) {
@@ -8622,8 +8624,6 @@  static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 		}
 	}
 
-	flush_work(&hba->eeh_work);
-
 	/*
 	 * In the case of DeepSleep, the device is expected to remain powered
 	 * with the link off, so do not check for bkops.