Re: [PATCH v1 1/2] scsi: ufs: set device as default active power mode during initialization only

From: asutoshd
Date: Mon Dec 30 2019 - 18:25:00 EST


Hi Stanley,

On 2019-12-30 00:12, Stanley Chu wrote:
Currently ufshcd_probe_hba() always sets device status as "active".
This shall be by an assumption that device is already in active state
during the boot stage before kernel.

However, if link is configured as "off" state and device is requested
to enter "sleep" or "powerdown" power mode during suspend flow, device
will NOT be waken up to "active" power mode during resume flow because
device is already set as "active" power mode in ufhcd_probe_hba().

Fix it by setting device as default active power mode during
initialization only, and skipping changing mode during PM flow
in ufshcd_probe_hba().

Fixes: 7caf489b99a4 (scsi: ufs: issue link starup 2 times if device
isn't active)
Cc: Alim Akhtar <alim.akhtar@xxxxxxxxxxx>
Cc: Avri Altman <avri.altman@xxxxxxx>
Cc: Bart Van Assche <bvanassche@xxxxxxx>
Cc: Bean Huo <beanhuo@xxxxxxxxxx>
Cc: Can Guo <cang@xxxxxxxxxxxxxx>
Cc: Matthias Brugger <matthias.bgg@xxxxxxxxx>
Cc: Subhash Jadavani <subhashj@xxxxxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Stanley Chu <stanley.chu@xxxxxxxxxxxx>
---
drivers/scsi/ufs/ufshcd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ed02a704c1c2..9abb7085a5d0 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6986,7 +6986,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
ufshcd_tune_unipro_params(hba);

/* UFS device is also active now */
- ufshcd_set_ufs_dev_active(hba);
+ if (!hba->pm_op_in_progress)
+ ufshcd_set_ufs_dev_active(hba);
ufshcd_force_reset_auto_bkops(hba);
hba->wlun_dev_clr_ua = true;

I see that there's a get_sync done before.
So, how would the suspend be triggered in that case?

Thanks,
asd