2020-02-03 10:48:47

by Can Guo

[permalink] [raw]
Subject: [PATCH v5 5/8] scsi: ufs: Fix ufshcd_hold() caused scheduling while atomic

The async version of ufshcd_hold(async == true), which is only called
in queuecommand path as for now, is expected to work in atomic context,
thus it should not sleep or schedule out. When it runs into the condition
that clocks are ON but link is still in hibern8 state, it should bail out
without flushing the clock ungate work.

Signed-off-by: Can Guo <[email protected]>
Reviewed-by: Hongwu Su <[email protected]>
Reviewed-by: Asutosh Das <[email protected]>
---
drivers/scsi/ufs/ufshcd.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index bbc2607..e8f7f9d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1518,6 +1518,11 @@ int ufshcd_hold(struct ufs_hba *hba, bool async)
*/
if (ufshcd_can_hibern8_during_gating(hba) &&
ufshcd_is_link_hibern8(hba)) {
+ if (async) {
+ rc = -EAGAIN;
+ hba->clk_gating.active_reqs--;
+ break;
+ }
spin_unlock_irqrestore(hba->host->host_lock, flags);
flush_work(&hba->clk_gating.ungate_work);
spin_lock_irqsave(hba->host->host_lock, flags);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


2020-02-03 22:09:22

by Bean Huo (beanhuo)

[permalink] [raw]
Subject: RE: [EXT] [PATCH v5 5/8] scsi: ufs: Fix ufshcd_hold() caused scheduling while atomic

> Signed-off-by: Can Guo <[email protected]>
> Reviewed-by: Hongwu Su <[email protected]>
> Reviewed-by: Asutosh Das <[email protected]>
Reviewed-by: Bean Huo <[email protected]>

2020-02-04 06:27:59

by Stanley Chu

[permalink] [raw]
Subject: Re: [PATCH v5 5/8] scsi: ufs: Fix ufshcd_hold() caused scheduling while atomic

On Mon, 2020-02-03 at 01:17 -0800, Can Guo wrote:
> The async version of ufshcd_hold(async == true), which is only called
> in queuecommand path as for now, is expected to work in atomic context,
> thus it should not sleep or schedule out. When it runs into the condition
> that clocks are ON but link is still in hibern8 state, it should bail out
> without flushing the clock ungate work.
>
> Signed-off-by: Can Guo <[email protected]>
> Reviewed-by: Hongwu Su <[email protected]>
> Reviewed-by: Asutosh Das <[email protected]>

Reviewed-by: Stanley Chu <[email protected]>