-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path0023-scsi-ufs-Make-clk-scaling-governor-params-configurab.patch
130 lines (125 loc) · 4.29 KB
/
0023-scsi-ufs-Make-clk-scaling-governor-params-configurab.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
From b4df0c5ed308f50f92d9958e8f1a1c3816596c06 Mon Sep 17 00:00:00 2001
From: Avri Altman <[email protected]>
Date: Sat, 6 Apr 2019 17:15:19 +0300
Subject: [PATCH 23/25] scsi: ufs: Make clk scaling governor params
configurable
Add sysfs entries for upthreshold and downdifferential.
Not sure that those are even needed, as devfreq has its own buit-in
entries: /sys/devices/platform/soc/1d84000.ufshc/devfreq/1d84000.ufshc.
Change-Id: I18b432c7d40cc3c32b27161d998a61ee3c5f03e0
Signed-off-by: Avri Altman <[email protected]>
---
drivers/scsi/ufs/ufshcd.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++
drivers/scsi/ufs/ufshcd.h | 4 +++
2 files changed, 81 insertions(+)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 77739a3..bf9c3ba 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2402,6 +2402,67 @@ out:
return count;
}
+#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
+static ssize_t clk_scaling_upthreshold_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%d\n",
+ ufshcd_ondemand_data.upthreshold);
+}
+
+static ssize_t clk_scaling_upthreshold_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct ufs_hba *hba = dev_get_drvdata(dev);
+ unsigned int upthreshold;
+ unsigned long flags;
+
+ if (kstrtouint(buf, 0, &upthreshold))
+ return -EINVAL;
+
+ if (upthreshold > 100)
+ return -EINVAL;
+
+ spin_lock_irqsave(hba->host->host_lock, flags);
+ ufshcd_ondemand_data.upthreshold = upthreshold;
+ spin_unlock_irqrestore(hba->host->host_lock, flags);
+
+ return count;
+}
+
+static ssize_t clk_scaling_downdifferential_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%d\n",
+ ufshcd_ondemand_data.downdifferential);
+}
+
+static ssize_t
+clk_scaling_downdifferential_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct ufs_hba *hba = dev_get_drvdata(dev);
+ unsigned int downdifferential;
+ unsigned long flags;
+
+ if (kstrtouint(buf, 0, &downdifferential))
+ return -EINVAL;
+
+ if (downdifferential > ufshcd_ondemand_data.upthreshold)
+ return -EINVAL;
+
+ spin_lock_irqsave(hba->host->host_lock, flags);
+ ufshcd_ondemand_data.downdifferential = downdifferential;
+ spin_unlock_irqrestore(hba->host->host_lock, flags);
+
+ return count;
+}
+#endif
+
static void ufshcd_clkscaling_init_sysfs(struct ufs_hba *hba)
{
hba->clk_scaling.enable_attr.show = ufshcd_clkscale_enable_show;
@@ -2409,6 +2470,22 @@ static void ufshcd_clkscaling_init_sysfs(struct ufs_hba *hba)
sysfs_attr_init(&hba->clk_scaling.enable_attr.attr);
hba->clk_scaling.enable_attr.attr.name = "clkscale_enable";
hba->clk_scaling.enable_attr.attr.mode = 0644;
+#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
+ hba->clk_scaling.upthreshold_attr.show = clk_scaling_upthreshold_show;
+ hba->clk_scaling.upthreshold_attr.store =
+ clk_scaling_upthreshold_store;
+ sysfs_attr_init(&hba->clk_scaling.upthreshold_attr.attr);
+ hba->clk_scaling.upthreshold_attr.attr.name = "clkscale_upthreshold";
+ hba->clk_scaling.upthreshold_attr.attr.mode = 0644;
+ hba->clk_scaling.upthreshold_attr.show =
+ clk_scaling_downdifferential_show;
+ hba->clk_scaling.upthreshold_attr.store =
+ clk_scaling_downdifferential_store;
+ sysfs_attr_init(&hba->clk_scaling.downdifferential_attr.attr);
+ hba->clk_scaling.downdifferential_attr.attr.name =
+ "clkscale_downdifferential";
+ hba->clk_scaling.downdifferential_attr.attr.mode = 0644;
+#endif
if (device_create_file(hba->dev, &hba->clk_scaling.enable_attr))
dev_err(hba->dev, "Failed to create sysfs for clkscale_enable\n");
}
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 56115b4..d39e5d3 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -534,6 +534,10 @@ struct ufs_clk_scaling {
unsigned long window_start_t;
ktime_t busy_start_t;
struct device_attribute enable_attr;
+#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
+ struct device_attribute upthreshold_attr;
+ struct device_attribute downdifferential_attr;
+#endif
struct ufs_saved_pwr_info saved_pwr_info;
struct workqueue_struct *workq;
struct work_struct suspend_work;
--
2.7.4