From fa06b20e434c62a9d3499ad07773617159f1365b Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 27 Jun 2019 11:19:50 -0700 Subject: [PATCH] scsi: ufs: atomic update for clkgating_enable Bug: 134949663 Bug: 137150088 Bug: 149155051 Test: test with powerhint feature Change-Id: Ie5002107a69e7d56a889138eec0e593de1bf6a61 Signed-off-by: Jaegeuk Kim Signed-off-by: Leo Liou [dereference23: Apply to msm-4.14] Signed-off-by: Alexander Winkowski --- drivers/scsi/ufs/ufshcd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 1dc6a2fd8510..13cba5f4ff02 100755 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2929,19 +2929,19 @@ static ssize_t ufshcd_clkgate_enable_store(struct device *dev, return -EINVAL; value = !!value; + + spin_lock_irqsave(hba->host->host_lock, flags); if (value == hba->clk_gating.is_enabled) goto out; - if (value) { - ufshcd_release(hba, false); - } else { - spin_lock_irqsave(hba->host->host_lock, flags); + if (value) + hba->clk_gating.active_reqs--; + else hba->clk_gating.active_reqs++; - spin_unlock_irqrestore(hba->host->host_lock, flags); - } hba->clk_gating.is_enabled = value; out: + spin_unlock_irqrestore(hba->host->host_lock, flags); return count; }