aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislav Nijnikov <stanislav.nijnikov@wdc.com>2018-03-01 05:48:06 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2018-03-21 21:21:25 -0400
commit114c1aa210494a02c26aa33f793e5b641df01989 (patch)
treed9b9faa8e0e970b33bf4f10a0c4c5349680dad99
parent61c187e46ebb27f51b52bd0eb68b7f534a300184 (diff)
scsi: ufs: sysfs: reworking of the rpm_lvl and spm_lvl entries
Read from these files will return the integer value of the chosen power management level now. Separate entries were added to show the target UFS device and UIC link states. The description of the possible power managements levels was added to the ABI file. The on-write behaviour of these entries wasn't changed. [mkp: typo] Signed-off-by: Stanislav Nijnikov <stanislav.nijnikov@wdc.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--Documentation/ABI/testing/sysfs-driver-ufs67
-rw-r--r--drivers/scsi/ufs/ufs-sysfs.c92
2 files changed, 114 insertions, 45 deletions
diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs
index 07f1c2f8dbfc..83735f79e572 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -802,3 +802,70 @@ Description: This file shows the The amount of physical memory needed
802 the particular logical unit. The full information about 802 the particular logical unit. The full information about
803 the attribute could be found at UFS specifications 2.1. 803 the attribute could be found at UFS specifications 2.1.
804 The file is read only. 804 The file is read only.
805
806
807What: /sys/bus/platform/drivers/ufshcd/*/rpm_lvl
808Date: September 2014
809Contact: Subhash Jadavani <subhashj@codeaurora.org>
810Description: This entry could be used to set or show the UFS device
811 runtime power management level. The current driver
812 implementation supports 6 levels with next target states:
813 0 - an UFS device will stay active, an UIC link will
814 stay active
815 1 - an UFS device will stay active, an UIC link will
816 hibernate
817 2 - an UFS device will moved to sleep, an UIC link will
818 stay active
819 3 - an UFS device will moved to sleep, an UIC link will
820 hibernate
821 4 - an UFS device will be powered off, an UIC link will
822 hibernate
823 5 - an UFS device will be powered off, an UIC link will
824 be powered off
825
826What: /sys/bus/platform/drivers/ufshcd/*/rpm_target_dev_state
827Date: February 2018
828Contact: Subhash Jadavani <subhashj@codeaurora.org>
829Description: This entry shows the target power mode of an UFS device
830 for the chosen runtime power management level.
831 The file is read only.
832
833What: /sys/bus/platform/drivers/ufshcd/*/rpm_target_link_state
834Date: February 2018
835Contact: Subhash Jadavani <subhashj@codeaurora.org>
836Description: This entry shows the target state of an UFS UIC link
837 for the chosen runtime power management level.
838 The file is read only.
839
840What: /sys/bus/platform/drivers/ufshcd/*/spm_lvl
841Date: September 2014
842Contact: Subhash Jadavani <subhashj@codeaurora.org>
843Description: This entry could be used to set or show the UFS device
844 system power management level. The current driver
845 implementation supports 6 levels with next target states:
846 0 - an UFS device will stay active, an UIC link will
847 stay active
848 1 - an UFS device will stay active, an UIC link will
849 hibernate
850 2 - an UFS device will moved to sleep, an UIC link will
851 stay active
852 3 - an UFS device will moved to sleep, an UIC link will
853 hibernate
854 4 - an UFS device will be powered off, an UIC link will
855 hibernate
856 5 - an UFS device will be powered off, an UIC link will
857 be powered off
858
859What: /sys/bus/platform/drivers/ufshcd/*/spm_target_dev_state
860Date: February 2018
861Contact: Subhash Jadavani <subhashj@codeaurora.org>
862Description: This entry shows the target power mode of an UFS device
863 for the chosen system power management level.
864 The file is read only.
865
866What: /sys/bus/platform/drivers/ufshcd/*/spm_target_link_state
867Date: February 2018
868Contact: Subhash Jadavani <subhashj@codeaurora.org>
869Description: This entry shows the target state of an UFS UIC link
870 for the chosen system power management level.
871 The file is read only.
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index cd7174d2d225..4ff9e0b7eba1 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -57,29 +57,8 @@ static ssize_t rpm_lvl_show(struct device *dev,
57 struct device_attribute *attr, char *buf) 57 struct device_attribute *attr, char *buf)
58{ 58{
59 struct ufs_hba *hba = dev_get_drvdata(dev); 59 struct ufs_hba *hba = dev_get_drvdata(dev);
60 int curr_len; 60
61 u8 lvl; 61 return sprintf(buf, "%d\n", hba->rpm_lvl);
62
63 curr_len = snprintf(buf, PAGE_SIZE,
64 "\nCurrent Runtime PM level [%d] => dev_state [%s] link_state [%s]\n",
65 hba->rpm_lvl,
66 ufschd_ufs_dev_pwr_mode_to_string(
67 ufs_pm_lvl_states[hba->rpm_lvl].dev_state),
68 ufschd_uic_link_state_to_string(
69 ufs_pm_lvl_states[hba->rpm_lvl].link_state));
70
71 curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
72 "\nAll available Runtime PM levels info:\n");
73 for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++)
74 curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
75 "\tRuntime PM level [%d] => dev_state [%s] link_state [%s]\n",
76 lvl,
77 ufschd_ufs_dev_pwr_mode_to_string(
78 ufs_pm_lvl_states[lvl].dev_state),
79 ufschd_uic_link_state_to_string(
80 ufs_pm_lvl_states[lvl].link_state));
81
82 return curr_len;
83} 62}
84 63
85static ssize_t rpm_lvl_store(struct device *dev, 64static ssize_t rpm_lvl_store(struct device *dev,
@@ -88,33 +67,30 @@ static ssize_t rpm_lvl_store(struct device *dev,
88 return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, true); 67 return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, true);
89} 68}
90 69
70static ssize_t rpm_target_dev_state_show(struct device *dev,
71 struct device_attribute *attr, char *buf)
72{
73 struct ufs_hba *hba = dev_get_drvdata(dev);
74
75 return sprintf(buf, "%s\n", ufschd_ufs_dev_pwr_mode_to_string(
76 ufs_pm_lvl_states[hba->rpm_lvl].dev_state));
77}
78
79static ssize_t rpm_target_link_state_show(struct device *dev,
80 struct device_attribute *attr, char *buf)
81{
82 struct ufs_hba *hba = dev_get_drvdata(dev);
83
84 return sprintf(buf, "%s\n", ufschd_uic_link_state_to_string(
85 ufs_pm_lvl_states[hba->rpm_lvl].link_state));
86}
87
91static ssize_t spm_lvl_show(struct device *dev, 88static ssize_t spm_lvl_show(struct device *dev,
92 struct device_attribute *attr, char *buf) 89 struct device_attribute *attr, char *buf)
93{ 90{
94 struct ufs_hba *hba = dev_get_drvdata(dev); 91 struct ufs_hba *hba = dev_get_drvdata(dev);
95 int curr_len;
96 u8 lvl;
97
98 curr_len = snprintf(buf, PAGE_SIZE,
99 "\nCurrent System PM level [%d] => dev_state [%s] link_state [%s]\n",
100 hba->spm_lvl,
101 ufschd_ufs_dev_pwr_mode_to_string(
102 ufs_pm_lvl_states[hba->spm_lvl].dev_state),
103 ufschd_uic_link_state_to_string(
104 ufs_pm_lvl_states[hba->spm_lvl].link_state));
105 92
106 curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len), 93 return sprintf(buf, "%d\n", hba->spm_lvl);
107 "\nAll available System PM levels info:\n");
108 for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++)
109 curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
110 "\tSystem PM level [%d] => dev_state [%s] link_state [%s]\n",
111 lvl,
112 ufschd_ufs_dev_pwr_mode_to_string(
113 ufs_pm_lvl_states[lvl].dev_state),
114 ufschd_uic_link_state_to_string(
115 ufs_pm_lvl_states[lvl].link_state));
116
117 return curr_len;
118} 94}
119 95
120static ssize_t spm_lvl_store(struct device *dev, 96static ssize_t spm_lvl_store(struct device *dev,
@@ -123,12 +99,38 @@ static ssize_t spm_lvl_store(struct device *dev,
123 return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, false); 99 return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, false);
124} 100}
125 101
102static ssize_t spm_target_dev_state_show(struct device *dev,
103 struct device_attribute *attr, char *buf)
104{
105 struct ufs_hba *hba = dev_get_drvdata(dev);
106
107 return sprintf(buf, "%s\n", ufschd_ufs_dev_pwr_mode_to_string(
108 ufs_pm_lvl_states[hba->spm_lvl].dev_state));
109}
110
111static ssize_t spm_target_link_state_show(struct device *dev,
112 struct device_attribute *attr, char *buf)
113{
114 struct ufs_hba *hba = dev_get_drvdata(dev);
115
116 return sprintf(buf, "%s\n", ufschd_uic_link_state_to_string(
117 ufs_pm_lvl_states[hba->spm_lvl].link_state));
118}
119
126static DEVICE_ATTR_RW(rpm_lvl); 120static DEVICE_ATTR_RW(rpm_lvl);
121static DEVICE_ATTR_RO(rpm_target_dev_state);
122static DEVICE_ATTR_RO(rpm_target_link_state);
127static DEVICE_ATTR_RW(spm_lvl); 123static DEVICE_ATTR_RW(spm_lvl);
124static DEVICE_ATTR_RO(spm_target_dev_state);
125static DEVICE_ATTR_RO(spm_target_link_state);
128 126
129static struct attribute *ufs_sysfs_ufshcd_attrs[] = { 127static struct attribute *ufs_sysfs_ufshcd_attrs[] = {
130 &dev_attr_rpm_lvl.attr, 128 &dev_attr_rpm_lvl.attr,
129 &dev_attr_rpm_target_dev_state.attr,
130 &dev_attr_rpm_target_link_state.attr,
131 &dev_attr_spm_lvl.attr, 131 &dev_attr_spm_lvl.attr,
132 &dev_attr_spm_target_dev_state.attr,
133 &dev_attr_spm_target_link_state.attr,
132 NULL 134 NULL
133}; 135};
134 136