scsi: ufs: Fix possible power drain during system suspend
authorStanley Chu <stanley.chu@mediatek.com>
Tue, 22 Dec 2020 07:29:04 +0000 (15:29 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 6 Jan 2021 02:58:30 +0000 (21:58 -0500)
commit1d53864c3617f5235f891ca0fbe9347c4cd35d46
treea9c617c12caa958a2889ba15347934065f1d62c7
parenta8f808839abe3a10011e28b46af1848dfd8c4f21
scsi: ufs: Fix possible power drain during system suspend

Currently if device needs to do flush or BKOP operations, the device VCC
power is kept during runtime-suspend period.

However, if system suspend is happening while device is runtime-suspended,
such power may not be disabled successfully.

The reasons may be,

1. If current PM level is the same as SPM level, device will keep
   runtime-suspended by ufshcd_system_suspend().

2. Flush recheck work may not be scheduled successfully during system
   suspend period. If it can wake up the system, this is also not the
   intention of the recheck work.

To fix this issue, simply runtime-resume the device if the flush is allowed
during runtime suspend period. Flush capability will be disabled while
leaving runtime suspend, and also not be allowed in system suspend period.

Link: https://lore.kernel.org/r/20201222072905.32221-2-stanley.chu@mediatek.com
Fixes: 51dd905bd2f6 ("scsi: ufs: Fix WriteBooster flush during runtime suspend")
Reviewed-by: Chaotian Jing <chaotian.jing@mediatek.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufshcd.c