scsi: ufs: update pm_lvl during probe only when current pm_lvl is invalid

As per current code, pm_lvl is read from DT on every probe
during system resume after suspend.

Therefore, rpm_lvl and spm_lvl updated by sysfs will be overwritten
with the pm_lvl read from DT during probe after resume from
system suspend.

To avoid this read pm_lvl from DT only when current pm_lvl
is invalid or during the first ufs probe after boot.

Change-Id: I059d574a81d0e0f7cee8b6492e495819579a2d4c
Signed-off-by: Nitin Rawat <nitirawa@codeaurora.org>
This commit is contained in:
Nitin Rawat 2020-11-12 13:26:09 +05:30
commit 3b52295bc6
2 changed files with 7 additions and 0 deletions

View file

@ -1786,16 +1786,22 @@ static void ufshcd_parse_pm_levels(struct ufs_hba *hba)
{
struct device *dev = hba->dev;
struct device_node *np = dev->of_node;
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
enum ufs_pm_level rpm_lvl = UFS_PM_LVL_MAX, spm_lvl = UFS_PM_LVL_MAX;
if (!np)
return;
if (host->is_dt_pm_level_read)
return;
if (!of_property_read_u32(np, "rpm-level", &rpm_lvl) &&
ufshcd_is_valid_pm_lvl(rpm_lvl))
hba->rpm_lvl = rpm_lvl;
if (!of_property_read_u32(np, "spm-level", &spm_lvl) &&
ufshcd_is_valid_pm_lvl(spm_lvl))
hba->spm_lvl = spm_lvl;
host->is_dt_pm_level_read = true;
}
#if defined(CONFIG_SCSI_UFSHCD_QTI)

View file

@ -376,6 +376,7 @@ struct ufs_qcom_host {
atomic_t clks_on;
struct ufs_qcom_qos_req *ufs_qos;
bool bypass_g4_cfgready;
bool is_dt_pm_level_read;
};
static inline u32