Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stanislav Nijnikov and committed by
Martin K. Petersen
114c1aa2 61c187e4

+113 -44
+67
Documentation/ABI/testing/sysfs-driver-ufs
··· 802 802 the particular logical unit. The full information about 803 803 the attribute could be found at UFS specifications 2.1. 804 804 The file is read only. 805 + 806 + 807 + What: /sys/bus/platform/drivers/ufshcd/*/rpm_lvl 808 + Date: September 2014 809 + Contact: Subhash Jadavani <subhashj@codeaurora.org> 810 + Description: 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 + 826 + What: /sys/bus/platform/drivers/ufshcd/*/rpm_target_dev_state 827 + Date: February 2018 828 + Contact: Subhash Jadavani <subhashj@codeaurora.org> 829 + Description: 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 + 833 + What: /sys/bus/platform/drivers/ufshcd/*/rpm_target_link_state 834 + Date: February 2018 835 + Contact: Subhash Jadavani <subhashj@codeaurora.org> 836 + Description: 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 + 840 + What: /sys/bus/platform/drivers/ufshcd/*/spm_lvl 841 + Date: September 2014 842 + Contact: Subhash Jadavani <subhashj@codeaurora.org> 843 + Description: 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 + 859 + What: /sys/bus/platform/drivers/ufshcd/*/spm_target_dev_state 860 + Date: February 2018 861 + Contact: Subhash Jadavani <subhashj@codeaurora.org> 862 + Description: 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 + 866 + What: /sys/bus/platform/drivers/ufshcd/*/spm_target_link_state 867 + Date: February 2018 868 + Contact: Subhash Jadavani <subhashj@codeaurora.org> 869 + Description: 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.
+46 -44
drivers/scsi/ufs/ufs-sysfs.c
··· 57 57 struct device_attribute *attr, char *buf) 58 58 { 59 59 struct ufs_hba *hba = dev_get_drvdata(dev); 60 - int curr_len; 61 - u8 lvl; 62 60 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; 61 + return sprintf(buf, "%d\n", hba->rpm_lvl); 83 62 } 84 63 85 64 static ssize_t rpm_lvl_store(struct device *dev, ··· 67 88 return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, true); 68 89 } 69 90 91 + static ssize_t rpm_target_dev_state_show(struct device *dev, 92 + struct device_attribute *attr, char *buf) 93 + { 94 + struct ufs_hba *hba = dev_get_drvdata(dev); 95 + 96 + return sprintf(buf, "%s\n", ufschd_ufs_dev_pwr_mode_to_string( 97 + ufs_pm_lvl_states[hba->rpm_lvl].dev_state)); 98 + } 99 + 100 + static ssize_t rpm_target_link_state_show(struct device *dev, 101 + struct device_attribute *attr, char *buf) 102 + { 103 + struct ufs_hba *hba = dev_get_drvdata(dev); 104 + 105 + return sprintf(buf, "%s\n", ufschd_uic_link_state_to_string( 106 + ufs_pm_lvl_states[hba->rpm_lvl].link_state)); 107 + } 108 + 70 109 static ssize_t spm_lvl_show(struct device *dev, 71 110 struct device_attribute *attr, char *buf) 72 111 { 73 112 struct ufs_hba *hba = dev_get_drvdata(dev); 74 - int curr_len; 75 - u8 lvl; 76 113 77 - curr_len = snprintf(buf, PAGE_SIZE, 78 - "\nCurrent System PM level [%d] => dev_state [%s] link_state [%s]\n", 79 - hba->spm_lvl, 80 - ufschd_ufs_dev_pwr_mode_to_string( 81 - ufs_pm_lvl_states[hba->spm_lvl].dev_state), 82 - ufschd_uic_link_state_to_string( 83 - ufs_pm_lvl_states[hba->spm_lvl].link_state)); 84 - 85 - curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len), 86 - "\nAll available System PM levels info:\n"); 87 - for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++) 88 - curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len), 89 - "\tSystem PM level [%d] => dev_state [%s] link_state [%s]\n", 90 - lvl, 91 - ufschd_ufs_dev_pwr_mode_to_string( 92 - ufs_pm_lvl_states[lvl].dev_state), 93 - ufschd_uic_link_state_to_string( 94 - ufs_pm_lvl_states[lvl].link_state)); 95 - 96 - return curr_len; 114 + return sprintf(buf, "%d\n", hba->spm_lvl); 97 115 } 98 116 99 117 static ssize_t spm_lvl_store(struct device *dev, ··· 99 123 return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, false); 100 124 } 101 125 126 + static ssize_t spm_target_dev_state_show(struct device *dev, 127 + struct device_attribute *attr, char *buf) 128 + { 129 + struct ufs_hba *hba = dev_get_drvdata(dev); 130 + 131 + return sprintf(buf, "%s\n", ufschd_ufs_dev_pwr_mode_to_string( 132 + ufs_pm_lvl_states[hba->spm_lvl].dev_state)); 133 + } 134 + 135 + static ssize_t spm_target_link_state_show(struct device *dev, 136 + struct device_attribute *attr, char *buf) 137 + { 138 + struct ufs_hba *hba = dev_get_drvdata(dev); 139 + 140 + return sprintf(buf, "%s\n", ufschd_uic_link_state_to_string( 141 + ufs_pm_lvl_states[hba->spm_lvl].link_state)); 142 + } 143 + 102 144 static DEVICE_ATTR_RW(rpm_lvl); 145 + static DEVICE_ATTR_RO(rpm_target_dev_state); 146 + static DEVICE_ATTR_RO(rpm_target_link_state); 103 147 static DEVICE_ATTR_RW(spm_lvl); 148 + static DEVICE_ATTR_RO(spm_target_dev_state); 149 + static DEVICE_ATTR_RO(spm_target_link_state); 104 150 105 151 static struct attribute *ufs_sysfs_ufshcd_attrs[] = { 106 152 &dev_attr_rpm_lvl.attr, 153 + &dev_attr_rpm_target_dev_state.attr, 154 + &dev_attr_rpm_target_link_state.attr, 107 155 &dev_attr_spm_lvl.attr, 156 + &dev_attr_spm_target_dev_state.attr, 157 + &dev_attr_spm_target_link_state.attr, 108 158 NULL 109 159 }; 110 160