Skip to content

Commit 26c06d0

Browse files
ram-dwivedimartinkpetersen
authored andcommitted
scsi: ufs: core: Enforce minimum PM level for sysfs configuration
Some UFS platforms only support a limited subset of power levels. Currently, the sysfs interface allows users to set any PM level without validating the minimum supported value. If an unsupported level is selected, suspend may fail. Introduce an pm_lvl_min field in the ufs_hba structure and use it to clamp the PM level requested via sysfs so that only supported levels are accepted. Platforms that require a minimum PM level can set this field during probe. Signed-off-by: Ram Kumar Dwivedi <ram.dwivedi@oss.qualcomm.com> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Link: https://patch.msgid.link/20260113080046.284089-4-ram.dwivedi@oss.qualcomm.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent e2725ed commit 26c06d0

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/ufs/core/ufs-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static inline ssize_t ufs_sysfs_pm_lvl_store(struct device *dev,
141141
if (kstrtoul(buf, 0, &value))
142142
return -EINVAL;
143143

144-
if (value >= UFS_PM_LVL_MAX)
144+
if (value >= UFS_PM_LVL_MAX || value < hba->pm_lvl_min)
145145
return -EINVAL;
146146

147147
if (ufs_pm_lvl_states[value].dev_state == UFS_DEEPSLEEP_PWR_MODE &&

include/ufs/ufshcd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ enum ufshcd_mcq_opr {
834834
* @uic_link_state: active state of the link to the UFS device.
835835
* @rpm_lvl: desired UFS power management level during runtime PM.
836836
* @spm_lvl: desired UFS power management level during system PM.
837+
* @pm_lvl_min: minimum supported power management level.
837838
* @pm_op_in_progress: whether or not a PM operation is in progress.
838839
* @ahit: value of Auto-Hibernate Idle Timer register.
839840
* @outstanding_tasks: Bits representing outstanding task requests
@@ -972,6 +973,7 @@ struct ufs_hba {
972973
enum ufs_pm_level rpm_lvl;
973974
/* Desired UFS power management level during system PM */
974975
enum ufs_pm_level spm_lvl;
976+
enum ufs_pm_level pm_lvl_min;
975977
int pm_op_in_progress;
976978

977979
/* Auto-Hibernate Idle Timer register value */

0 commit comments

Comments
 (0)