Commit 499f7a96 authored by Bao D. Nguyen's avatar Bao D. Nguyen Committed by Martin K. Petersen

scsi: ufshcd: Allow specifying an Auto-Hibernate Timer value of zero

Setting the Auto-Hibernate Timer to zero is a valid setting which indicates
the Auto-Hibernate feature being disabled. Correctly support this setting.

In addition, when the timer value is queried from sysfs, read from the host
controller's register and return that value instead of using the RAM value.

Link: https://lore.kernel.org/r/b141cfcd7998b8933635828b56fbb64f8ad4d175.1598661071.git.nguyenb@codeaurora.orgAcked-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Signed-off-by: default avatarBao D. Nguyen <nguyenb@codeaurora.org>
Signed-off-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
Signed-off-by: default avatarCan Guo <cang@codeaurora.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 8c657235
...@@ -146,12 +146,19 @@ static u32 ufshcd_us_to_ahit(unsigned int timer) ...@@ -146,12 +146,19 @@ static u32 ufshcd_us_to_ahit(unsigned int timer)
static ssize_t auto_hibern8_show(struct device *dev, static ssize_t auto_hibern8_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
u32 ahit;
struct ufs_hba *hba = dev_get_drvdata(dev); struct ufs_hba *hba = dev_get_drvdata(dev);
if (!ufshcd_is_auto_hibern8_supported(hba)) if (!ufshcd_is_auto_hibern8_supported(hba))
return -EOPNOTSUPP; return -EOPNOTSUPP;
return snprintf(buf, PAGE_SIZE, "%d\n", ufshcd_ahit_to_us(hba->ahit)); pm_runtime_get_sync(hba->dev);
ufshcd_hold(hba, false);
ahit = ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER);
ufshcd_release(hba);
pm_runtime_put_sync(hba->dev);
return scnprintf(buf, PAGE_SIZE, "%d\n", ufshcd_ahit_to_us(ahit));
} }
static ssize_t auto_hibern8_store(struct device *dev, static ssize_t auto_hibern8_store(struct device *dev,
......
...@@ -3980,7 +3980,7 @@ void ufshcd_auto_hibern8_enable(struct ufs_hba *hba) ...@@ -3980,7 +3980,7 @@ void ufshcd_auto_hibern8_enable(struct ufs_hba *hba)
{ {
unsigned long flags; unsigned long flags;
if (!ufshcd_is_auto_hibern8_supported(hba) || !hba->ahit) if (!ufshcd_is_auto_hibern8_supported(hba))
return; return;
spin_lock_irqsave(hba->host->host_lock, flags); spin_lock_irqsave(hba->host->host_lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment