FROMLIST: scsi: ufs: atomic update for clkgating_enable

Powerhints enables/disables clkgating so frequently which leads wrong UFS
status resulting in timeout.

Bug: 158050260
Bug: 134949663
Bug: 166641672
Change-Id: Ie5002107a69e7d56a889138eec0e593de1bf6a61
Link: https://lore.kernel.org/linux-scsi/20200915204532.1672300-1-jaegeuk@kernel.org/T/#t
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
This commit is contained in:
Jaegeuk Kim
2019-06-27 11:19:50 -07:00
parent c0391ecb55
commit b78d30deb3

View File

@@ -1791,19 +1791,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);
} 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;
}