From 607a7fb59a87a9ccfb0595a5b7168e9c884c4e00 Mon Sep 17 00:00:00 2001 From: Can Guo Date: Mon, 4 Nov 2019 22:21:06 -0800 Subject: [PATCH] FROMLIST: 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. Bug: 143632303 Change-Id: I14d200901274c2e630bf0205445c1f9c7e053f95 Link: https://lore.kernel.org/patchwork/patch/1149893/ Signed-off-by: Can Guo Signed-off-by: Asutosh Das --- 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 5cd3477f8f10..1afe3b56a738 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1569,6 +1569,11 @@ start: */ 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);