Skip to content

Commit b20f7db

Browse files
committed
Merge branch 'pm-devfreq'
* pm-devfreq: PM / devfreq: imx8m-ddrc: Remove unneeded of_match_ptr() PM / devfreq: imx-bus: Remove unneeded of_match_ptr() PM / devfreq: imx8m-ddrc: Remove imx8m_ddrc_get_dev_status PM / devfreq: Remove the invalid description for get_target_freq PM / devfreq: Check get_dev_status in devfreq_update_stats PM / devfreq: Fix the wrong set_freq path for userspace governor in Kconfig dt-bindings: devfreq: rk3399_dmc: Remove references of unexistant defines dt-bindings: devfreq: rk3399_dmc: Add rockchip,pmu phandle. PM / devfreq: rk3399_dmc: Simplify with dev_err_probe() PM / devfreq: Use more accurate returned new_freq as resume_freq PM / devfreq: Unlock mutex and free devfreq struct in error path PM / devfreq: Register devfreq as a cooling device on demand
2 parents 6948de3 + e9ff022 commit b20f7db

9 files changed

Lines changed: 70 additions & 78 deletions

File tree

Documentation/ABI/testing/sysfs-class-devfreq

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ Description:
9797
object. The values are represented in ms. If the value is
9898
less than 1 jiffy, it is considered to be 0, which means
9999
no polling. This value is meaningless if the governor is
100-
not polling; thus. If the governor is not using
101-
devfreq-provided central polling
102-
(/sys/class/devfreq/.../central_polling is 0), this value
103-
may be useless.
100+
not polling.
104101

105102
A list of governors that support the node:
106103
- simple_ondmenad

Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Required properties:
1212
for details.
1313
- center-supply: DMC supply node.
1414
- status: Marks the node enabled/disabled.
15+
- rockchip,pmu: Phandle to the syscon managing the "PMU general register
16+
files".
1517

1618
Optional properties:
1719
- interrupts: The CPU interrupt number. The interrupt specifier
@@ -77,24 +79,23 @@ Following properties relate to DDR timing:
7779

7880
- rockchip,ddr3_drv : When the DRAM type is DDR3, this parameter defines
7981
the DRAM side driver strength in ohms. Default
80-
value is DDR3_DS_40ohm.
82+
value is 40.
8183

8284
- rockchip,ddr3_odt : When the DRAM type is DDR3, this parameter defines
8385
the DRAM side ODT strength in ohms. Default value
84-
is DDR3_ODT_120ohm.
86+
is 120.
8587

8688
- rockchip,phy_ddr3_ca_drv : When the DRAM type is DDR3, this parameter defines
8789
the phy side CA line (incluing command line,
8890
address line and clock line) driver strength.
89-
Default value is PHY_DRV_ODT_40.
91+
Default value is 40.
9092

9193
- rockchip,phy_ddr3_dq_drv : When the DRAM type is DDR3, this parameter defines
9294
the PHY side DQ line (including DQS/DQ/DM line)
93-
driver strength. Default value is PHY_DRV_ODT_40.
95+
driver strength. Default value is 40.
9496

9597
- rockchip,phy_ddr3_odt : When the DRAM type is DDR3, this parameter defines
96-
the PHY side ODT strength. Default value is
97-
PHY_DRV_ODT_240.
98+
the PHY side ODT strength. Default value is 240.
9899

99100
- rockchip,lpddr3_odt_dis_freq : When the DRAM type is LPDDR3, this parameter defines
100101
then ODT disable frequency in MHz (Mega Hz).
@@ -104,25 +105,23 @@ Following properties relate to DDR timing:
104105

105106
- rockchip,lpddr3_drv : When the DRAM type is LPDDR3, this parameter defines
106107
the DRAM side driver strength in ohms. Default
107-
value is LP3_DS_34ohm.
108+
value is 34.
108109

109110
- rockchip,lpddr3_odt : When the DRAM type is LPDDR3, this parameter defines
110111
the DRAM side ODT strength in ohms. Default value
111-
is LP3_ODT_240ohm.
112+
is 240.
112113

113114
- rockchip,phy_lpddr3_ca_drv : When the DRAM type is LPDDR3, this parameter defines
114115
the PHY side CA line (including command line,
115116
address line and clock line) driver strength.
116-
Default value is PHY_DRV_ODT_40.
117+
Default value is 40.
117118

118119
- rockchip,phy_lpddr3_dq_drv : When the DRAM type is LPDDR3, this parameter defines
119120
the PHY side DQ line (including DQS/DQ/DM line)
120-
driver strength. Default value is
121-
PHY_DRV_ODT_40.
121+
driver strength. Default value is 40.
122122

123123
- rockchip,phy_lpddr3_odt : When dram type is LPDDR3, this parameter define
124-
the phy side odt strength, default value is
125-
PHY_DRV_ODT_240.
124+
the phy side odt strength, default value is 240.
126125

127126
- rockchip,lpddr4_odt_dis_freq : When the DRAM type is LPDDR4, this parameter
128127
defines the ODT disable frequency in
@@ -132,32 +131,30 @@ Following properties relate to DDR timing:
132131

133132
- rockchip,lpddr4_drv : When the DRAM type is LPDDR4, this parameter defines
134133
the DRAM side driver strength in ohms. Default
135-
value is LP4_PDDS_60ohm.
134+
value is 60.
136135

137136
- rockchip,lpddr4_dq_odt : When the DRAM type is LPDDR4, this parameter defines
138137
the DRAM side ODT on DQS/DQ line strength in ohms.
139-
Default value is LP4_DQ_ODT_40ohm.
138+
Default value is 40.
140139

141140
- rockchip,lpddr4_ca_odt : When the DRAM type is LPDDR4, this parameter defines
142141
the DRAM side ODT on CA line strength in ohms.
143-
Default value is LP4_CA_ODT_40ohm.
142+
Default value is 40.
144143

145144
- rockchip,phy_lpddr4_ca_drv : When the DRAM type is LPDDR4, this parameter defines
146145
the PHY side CA line (including command address
147-
line) driver strength. Default value is
148-
PHY_DRV_ODT_40.
146+
line) driver strength. Default value is 40.
149147

150148
- rockchip,phy_lpddr4_ck_cs_drv : When the DRAM type is LPDDR4, this parameter defines
151149
the PHY side clock line and CS line driver
152-
strength. Default value is PHY_DRV_ODT_80.
150+
strength. Default value is 80.
153151

154152
- rockchip,phy_lpddr4_dq_drv : When the DRAM type is LPDDR4, this parameter defines
155153
the PHY side DQ line (including DQS/DQ/DM line)
156-
driver strength. Default value is PHY_DRV_ODT_80.
154+
driver strength. Default value is 80.
157155

158156
- rockchip,phy_lpddr4_odt : When the DRAM type is LPDDR4, this parameter defines
159-
the PHY side ODT strength. Default value is
160-
PHY_DRV_ODT_60.
157+
the PHY side ODT strength. Default value is 60.
161158

162159
Example:
163160
dmc_opp_table: dmc_opp_table {
@@ -193,23 +190,23 @@ Example:
193190
rockchip,phy_dll_dis_freq = <125>;
194191
rockchip,auto_pd_dis_freq = <666>;
195192
rockchip,ddr3_odt_dis_freq = <333>;
196-
rockchip,ddr3_drv = <DDR3_DS_40ohm>;
197-
rockchip,ddr3_odt = <DDR3_ODT_120ohm>;
198-
rockchip,phy_ddr3_ca_drv = <PHY_DRV_ODT_40>;
199-
rockchip,phy_ddr3_dq_drv = <PHY_DRV_ODT_40>;
200-
rockchip,phy_ddr3_odt = <PHY_DRV_ODT_240>;
193+
rockchip,ddr3_drv = <40>;
194+
rockchip,ddr3_odt = <120>;
195+
rockchip,phy_ddr3_ca_drv = <40>;
196+
rockchip,phy_ddr3_dq_drv = <40>;
197+
rockchip,phy_ddr3_odt = <240>;
201198
rockchip,lpddr3_odt_dis_freq = <333>;
202-
rockchip,lpddr3_drv = <LP3_DS_34ohm>;
203-
rockchip,lpddr3_odt = <LP3_ODT_240ohm>;
204-
rockchip,phy_lpddr3_ca_drv = <PHY_DRV_ODT_40>;
205-
rockchip,phy_lpddr3_dq_drv = <PHY_DRV_ODT_40>;
206-
rockchip,phy_lpddr3_odt = <PHY_DRV_ODT_240>;
199+
rockchip,lpddr3_drv = <34>;
200+
rockchip,lpddr3_odt = <240>;
201+
rockchip,phy_lpddr3_ca_drv = <40>;
202+
rockchip,phy_lpddr3_dq_drv = <40>;
203+
rockchip,phy_lpddr3_odt = <240>;
207204
rockchip,lpddr4_odt_dis_freq = <333>;
208-
rockchip,lpddr4_drv = <LP4_PDDS_60ohm>;
209-
rockchip,lpddr4_dq_odt = <LP4_DQ_ODT_40ohm>;
210-
rockchip,lpddr4_ca_odt = <LP4_CA_ODT_40ohm>;
211-
rockchip,phy_lpddr4_ca_drv = <PHY_DRV_ODT_40>;
212-
rockchip,phy_lpddr4_ck_cs_drv = <PHY_DRV_ODT_80>;
213-
rockchip,phy_lpddr4_dq_drv = <PHY_DRV_ODT_80>;
214-
rockchip,phy_lpddr4_odt = <PHY_DRV_ODT_60>;
205+
rockchip,lpddr4_drv = <60>;
206+
rockchip,lpddr4_dq_odt = <40>;
207+
rockchip,lpddr4_ca_odt = <40>;
208+
rockchip,phy_lpddr4_ca_drv = <40>;
209+
rockchip,phy_lpddr4_ck_cs_drv = <80>;
210+
rockchip,phy_lpddr4_dq_drv = <80>;
211+
rockchip,phy_lpddr4_odt = <60>;
215212
};

drivers/devfreq/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ config DEVFREQ_GOV_USERSPACE
6262
help
6363
Sets the frequency at the user specified one.
6464
This governor returns the user configured frequency if there
65-
has been an input to /sys/devices/.../power/devfreq_set_freq.
65+
has been an input to /sys/devices/.../userspace/set_freq.
6666
Otherwise, the governor does not change the frequency
6767
given at the initialization.
6868

drivers/devfreq/devfreq.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/kmod.h>
1212
#include <linux/sched.h>
1313
#include <linux/debugfs.h>
14+
#include <linux/devfreq_cooling.h>
1415
#include <linux/errno.h>
1516
#include <linux/err.h>
1617
#include <linux/init.h>
@@ -387,7 +388,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
387388
devfreq->previous_freq = new_freq;
388389

389390
if (devfreq->suspend_freq)
390-
devfreq->resume_freq = cur_freq;
391+
devfreq->resume_freq = new_freq;
391392

392393
return err;
393394
}
@@ -821,7 +822,8 @@ struct devfreq *devfreq_add_device(struct device *dev,
821822

822823
if (devfreq->profile->timer < 0
823824
|| devfreq->profile->timer >= DEVFREQ_TIMER_NUM) {
824-
goto err_out;
825+
mutex_unlock(&devfreq->lock);
826+
goto err_dev;
825827
}
826828

827829
if (!devfreq->profile->max_state && !devfreq->profile->freq_table) {
@@ -935,6 +937,12 @@ struct devfreq *devfreq_add_device(struct device *dev,
935937

936938
mutex_unlock(&devfreq_list_lock);
937939

940+
if (devfreq->profile->is_cooling_device) {
941+
devfreq->cdev = devfreq_cooling_em_register(devfreq, NULL);
942+
if (IS_ERR(devfreq->cdev))
943+
devfreq->cdev = NULL;
944+
}
945+
938946
return devfreq;
939947

940948
err_init:
@@ -960,6 +968,8 @@ int devfreq_remove_device(struct devfreq *devfreq)
960968
if (!devfreq)
961969
return -EINVAL;
962970

971+
devfreq_cooling_unregister(devfreq->cdev);
972+
963973
if (devfreq->governor) {
964974
devfreq->governor->event_handler(devfreq,
965975
DEVFREQ_GOV_STOP, NULL);

drivers/devfreq/governor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
* Basically, get_target_freq will run
5858
* devfreq_dev_profile.get_dev_status() to get the
5959
* status of the device (load = busy_time / total_time).
60-
* If no_central_polling is set, this callback is called
61-
* only with update_devfreq() notified by OPP.
6260
* @event_handler: Callback for devfreq core framework to notify events
6361
* to governors. Events include per device governor
6462
* init and exit, opp changes out of devfreq, suspend
@@ -91,6 +89,9 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
9189

9290
static inline int devfreq_update_stats(struct devfreq *df)
9391
{
92+
if (!df->profile->get_dev_status)
93+
return -EINVAL;
94+
9495
return df->profile->get_dev_status(df->dev.parent, &df->last_status);
9596
}
9697
#endif /* _GOVERNOR_H */

drivers/devfreq/imx-bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static struct platform_driver imx_bus_platdrv = {
169169
.probe = imx_bus_probe,
170170
.driver = {
171171
.name = "imx-bus-devfreq",
172-
.of_match_table = of_match_ptr(imx_bus_of_match),
172+
.of_match_table = imx_bus_of_match,
173173
},
174174
};
175175
module_platform_driver(imx_bus_platdrv);

drivers/devfreq/imx8m-ddrc.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,18 +280,6 @@ static int imx8m_ddrc_get_cur_freq(struct device *dev, unsigned long *freq)
280280
return 0;
281281
}
282282

283-
static int imx8m_ddrc_get_dev_status(struct device *dev,
284-
struct devfreq_dev_status *stat)
285-
{
286-
struct imx8m_ddrc *priv = dev_get_drvdata(dev);
287-
288-
stat->busy_time = 0;
289-
stat->total_time = 0;
290-
stat->current_frequency = clk_get_rate(priv->dram_core);
291-
292-
return 0;
293-
}
294-
295283
static int imx8m_ddrc_init_freq_info(struct device *dev)
296284
{
297285
struct imx8m_ddrc *priv = dev_get_drvdata(dev);
@@ -429,9 +417,7 @@ static int imx8m_ddrc_probe(struct platform_device *pdev)
429417
if (ret < 0)
430418
goto err;
431419

432-
priv->profile.polling_ms = 1000;
433420
priv->profile.target = imx8m_ddrc_target;
434-
priv->profile.get_dev_status = imx8m_ddrc_get_dev_status;
435421
priv->profile.exit = imx8m_ddrc_exit;
436422
priv->profile.get_cur_freq = imx8m_ddrc_get_cur_freq;
437423
priv->profile.initial_freq = clk_get_rate(priv->dram_core);
@@ -461,7 +447,7 @@ static struct platform_driver imx8m_ddrc_platdrv = {
461447
.probe = imx8m_ddrc_probe,
462448
.driver = {
463449
.name = "imx8m-ddrc-devfreq",
464-
.of_match_table = of_match_ptr(imx8m_ddrc_of_match),
450+
.of_match_table = imx8m_ddrc_of_match,
465451
},
466452
};
467453
module_platform_driver(imx8m_ddrc_platdrv);

drivers/devfreq/rk3399_dmc.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -324,22 +324,14 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
324324
mutex_init(&data->lock);
325325

326326
data->vdd_center = devm_regulator_get(dev, "center");
327-
if (IS_ERR(data->vdd_center)) {
328-
if (PTR_ERR(data->vdd_center) == -EPROBE_DEFER)
329-
return -EPROBE_DEFER;
330-
331-
dev_err(dev, "Cannot get the regulator \"center\"\n");
332-
return PTR_ERR(data->vdd_center);
333-
}
327+
if (IS_ERR(data->vdd_center))
328+
return dev_err_probe(dev, PTR_ERR(data->vdd_center),
329+
"Cannot get the regulator \"center\"\n");
334330

335331
data->dmc_clk = devm_clk_get(dev, "dmc_clk");
336-
if (IS_ERR(data->dmc_clk)) {
337-
if (PTR_ERR(data->dmc_clk) == -EPROBE_DEFER)
338-
return -EPROBE_DEFER;
339-
340-
dev_err(dev, "Cannot get the clk dmc_clk\n");
341-
return PTR_ERR(data->dmc_clk);
342-
}
332+
if (IS_ERR(data->dmc_clk))
333+
return dev_err_probe(dev, PTR_ERR(data->dmc_clk),
334+
"Cannot get the clk dmc_clk\n");
343335

344336
data->edev = devfreq_event_get_edev_by_phandle(dev, "devfreq-events", 0);
345337
if (IS_ERR(data->edev))

include/linux/devfreq.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ enum devfreq_timer {
3838

3939
struct devfreq;
4040
struct devfreq_governor;
41+
struct thermal_cooling_device;
4142

4243
/**
4344
* struct devfreq_dev_status - Data given from devfreq user device to
@@ -98,11 +99,15 @@ struct devfreq_dev_status {
9899
* @freq_table: Optional list of frequencies to support statistics
99100
* and freq_table must be generated in ascending order.
100101
* @max_state: The size of freq_table.
102+
*
103+
* @is_cooling_device: A self-explanatory boolean giving the device a
104+
* cooling effect property.
101105
*/
102106
struct devfreq_dev_profile {
103107
unsigned long initial_freq;
104108
unsigned int polling_ms;
105109
enum devfreq_timer timer;
110+
bool is_cooling_device;
106111

107112
int (*target)(struct device *dev, unsigned long *freq, u32 flags);
108113
int (*get_dev_status)(struct device *dev,
@@ -156,6 +161,7 @@ struct devfreq_stats {
156161
* @suspend_count: suspend requests counter for a device.
157162
* @stats: Statistics of devfreq device behavior
158163
* @transition_notifier_list: list head of DEVFREQ_TRANSITION_NOTIFIER notifier
164+
* @cdev: Cooling device pointer if the devfreq has cooling property
159165
* @nb_min: Notifier block for DEV_PM_QOS_MIN_FREQUENCY
160166
* @nb_max: Notifier block for DEV_PM_QOS_MAX_FREQUENCY
161167
*
@@ -198,6 +204,9 @@ struct devfreq {
198204

199205
struct srcu_notifier_head transition_notifier_list;
200206

207+
/* Pointer to the cooling device if used for thermal mitigation */
208+
struct thermal_cooling_device *cdev;
209+
201210
struct notifier_block nb_min;
202211
struct notifier_block nb_max;
203212
};

0 commit comments

Comments
 (0)