Skip to content

Commit 5e8b7b5

Browse files
committed
Merge tag 'devfreq-next-for-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux
Pull devfreq changes for v6.19 from Chanwoo Choi: "- Move governor.h under include/linux/ and rename to devfreq-governor.h in order to allow devfreq governor definitions in out of drivers/devfreq/. - Fix potential use-after-free issue of OPP handling on hisi_uncore_freq.c - Use min() to improve the readability on tegra30-devfreq.c - Fix typo in DFSO_DOWNDIFFERENTIAL macro name on governor_simpleondemand.c" * tag 'devfreq-next-for-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux: PM / devfreq: Fix typo in DFSO_DOWNDIFFERENTIAL macro name PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate PM / devfreq: hisi: Fix potential UAF in OPP handling PM / devfreq: Move governor.h to a public header location
2 parents ac3fd01 + d9600d5 commit 5e8b7b5

9 files changed

Lines changed: 45 additions & 50 deletions

drivers/devfreq/devfreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/stat.h>
2121
#include <linux/pm_opp.h>
2222
#include <linux/devfreq.h>
23+
#include <linux/devfreq-governor.h>
2324
#include <linux/workqueue.h>
2425
#include <linux/platform_device.h>
2526
#include <linux/list.h>
@@ -28,7 +29,6 @@
2829
#include <linux/of.h>
2930
#include <linux/pm_qos.h>
3031
#include <linux/units.h>
31-
#include "governor.h"
3232

3333
#define CREATE_TRACE_POINTS
3434
#include <trace/events/devfreq.h>

drivers/devfreq/governor_passive.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,33 @@
1414
#include <linux/slab.h>
1515
#include <linux/device.h>
1616
#include <linux/devfreq.h>
17+
#include <linux/devfreq-governor.h>
1718
#include <linux/units.h>
18-
#include "governor.h"
19+
20+
/**
21+
* struct devfreq_cpu_data - Hold the per-cpu data
22+
* @node: list node
23+
* @dev: reference to cpu device.
24+
* @first_cpu: the cpumask of the first cpu of a policy.
25+
* @opp_table: reference to cpu opp table.
26+
* @cur_freq: the current frequency of the cpu.
27+
* @min_freq: the min frequency of the cpu.
28+
* @max_freq: the max frequency of the cpu.
29+
*
30+
* This structure stores the required cpu_data of a cpu.
31+
* This is auto-populated by the governor.
32+
*/
33+
struct devfreq_cpu_data {
34+
struct list_head node;
35+
36+
struct device *dev;
37+
unsigned int first_cpu;
38+
39+
struct opp_table *opp_table;
40+
unsigned int cur_freq;
41+
unsigned int min_freq;
42+
unsigned int max_freq;
43+
};
1944

2045
static struct devfreq_cpu_data *
2146
get_parent_cpu_data(struct devfreq_passive_data *p_data,

drivers/devfreq/governor_performance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
#include <linux/devfreq.h>
10+
#include <linux/devfreq-governor.h>
1011
#include <linux/module.h>
11-
#include "governor.h"
1212

1313
static int devfreq_performance_func(struct devfreq *df,
1414
unsigned long *freq)

drivers/devfreq/governor_powersave.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
#include <linux/devfreq.h>
10+
#include <linux/devfreq-governor.h>
1011
#include <linux/module.h>
11-
#include "governor.h"
1212

1313
static int devfreq_powersave_func(struct devfreq *df,
1414
unsigned long *freq)

drivers/devfreq/governor_simpleondemand.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
#include <linux/errno.h>
1010
#include <linux/module.h>
1111
#include <linux/devfreq.h>
12+
#include <linux/devfreq-governor.h>
1213
#include <linux/math64.h>
13-
#include "governor.h"
1414

1515
/* Default constants for DevFreq-Simple-Ondemand (DFSO) */
1616
#define DFSO_UPTHRESHOLD (90)
17-
#define DFSO_DOWNDIFFERENCTIAL (5)
17+
#define DFSO_DOWNDIFFERENTIAL (5)
1818
static int devfreq_simple_ondemand_func(struct devfreq *df,
1919
unsigned long *freq)
2020
{
2121
int err;
2222
struct devfreq_dev_status *stat;
2323
unsigned long long a, b;
2424
unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD;
25-
unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
25+
unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENTIAL;
2626
struct devfreq_simple_ondemand_data *data = df->data;
2727

2828
err = devfreq_update_stats(df);

drivers/devfreq/governor_userspace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#include <linux/slab.h>
1010
#include <linux/device.h>
1111
#include <linux/devfreq.h>
12+
#include <linux/devfreq-governor.h>
1213
#include <linux/kstrtox.h>
1314
#include <linux/pm.h>
1415
#include <linux/mutex.h>
1516
#include <linux/module.h>
16-
#include "governor.h"
1717

1818
struct userspace_data {
1919
unsigned long user_frequency;

drivers/devfreq/hisi_uncore_freq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/bits.h>
1010
#include <linux/cleanup.h>
1111
#include <linux/devfreq.h>
12+
#include <linux/devfreq-governor.h>
1213
#include <linux/device.h>
1314
#include <linux/dev_printk.h>
1415
#include <linux/errno.h>
@@ -26,8 +27,6 @@
2627
#include <linux/units.h>
2728
#include <acpi/pcc.h>
2829

29-
#include "governor.h"
30-
3130
struct hisi_uncore_pcc_data {
3231
u16 status;
3332
u16 resv;
@@ -265,10 +264,11 @@ static int hisi_uncore_target(struct device *dev, unsigned long *freq,
265264
dev_err(dev, "Failed to get opp for freq %lu hz\n", *freq);
266265
return PTR_ERR(opp);
267266
}
268-
dev_pm_opp_put(opp);
269267

270268
data = (u32)(dev_pm_opp_get_freq(opp) / HZ_PER_MHZ);
271269

270+
dev_pm_opp_put(opp);
271+
272272
return hisi_uncore_cmd_send(uncore, HUCF_PCC_CMD_SET_FREQ, &data);
273273
}
274274

drivers/devfreq/tegra30-devfreq.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
#include <linux/clk.h>
1010
#include <linux/cpufreq.h>
1111
#include <linux/devfreq.h>
12+
#include <linux/devfreq-governor.h>
1213
#include <linux/interrupt.h>
1314
#include <linux/io.h>
1415
#include <linux/irq.h>
16+
#include <linux/minmax.h>
1517
#include <linux/module.h>
1618
#include <linux/of.h>
1719
#include <linux/platform_device.h>
@@ -21,8 +23,6 @@
2123

2224
#include <soc/tegra/fuse.h>
2325

24-
#include "governor.h"
25-
2626
#define ACTMON_GLB_STATUS 0x0
2727
#define ACTMON_GLB_PERIOD_CTRL 0x4
2828

@@ -326,14 +326,9 @@ static unsigned long actmon_cpu_to_emc_rate(struct tegra_devfreq *tegra,
326326
unsigned int i;
327327
const struct tegra_actmon_emc_ratio *ratio = actmon_emc_ratios;
328328

329-
for (i = 0; i < ARRAY_SIZE(actmon_emc_ratios); i++, ratio++) {
330-
if (cpu_freq >= ratio->cpu_freq) {
331-
if (ratio->emc_freq >= tegra->max_freq)
332-
return tegra->max_freq;
333-
else
334-
return ratio->emc_freq;
335-
}
336-
}
329+
for (i = 0; i < ARRAY_SIZE(actmon_emc_ratios); i++, ratio++)
330+
if (cpu_freq >= ratio->cpu_freq)
331+
return min(ratio->emc_freq, tegra->max_freq);
337332

338333
return 0;
339334
}
Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* Copyright (C) 2011 Samsung Electronics
66
* MyungJoo Ham <myungjoo.ham@samsung.com>
77
*
8-
* This header is for devfreq governors in drivers/devfreq/
8+
* This header is for devfreq governors
99
*/
1010

11-
#ifndef _GOVERNOR_H
12-
#define _GOVERNOR_H
11+
#ifndef __LINUX_DEVFREQ_DEVFREQ_H__
12+
#define __LINUX_DEVFREQ_DEVFREQ_H__
1313

1414
#include <linux/devfreq.h>
1515

@@ -47,31 +47,6 @@
4747
#define DEVFREQ_GOV_ATTR_POLLING_INTERVAL BIT(0)
4848
#define DEVFREQ_GOV_ATTR_TIMER BIT(1)
4949

50-
/**
51-
* struct devfreq_cpu_data - Hold the per-cpu data
52-
* @node: list node
53-
* @dev: reference to cpu device.
54-
* @first_cpu: the cpumask of the first cpu of a policy.
55-
* @opp_table: reference to cpu opp table.
56-
* @cur_freq: the current frequency of the cpu.
57-
* @min_freq: the min frequency of the cpu.
58-
* @max_freq: the max frequency of the cpu.
59-
*
60-
* This structure stores the required cpu_data of a cpu.
61-
* This is auto-populated by the governor.
62-
*/
63-
struct devfreq_cpu_data {
64-
struct list_head node;
65-
66-
struct device *dev;
67-
unsigned int first_cpu;
68-
69-
struct opp_table *opp_table;
70-
unsigned int cur_freq;
71-
unsigned int min_freq;
72-
unsigned int max_freq;
73-
};
74-
7550
/**
7651
* struct devfreq_governor - Devfreq policy governor
7752
* @node: list node - contains registered devfreq governors
@@ -124,4 +99,4 @@ static inline int devfreq_update_stats(struct devfreq *df)
12499

125100
return df->profile->get_dev_status(df->dev.parent, &df->last_status);
126101
}
127-
#endif /* _GOVERNOR_H */
102+
#endif /* __LINUX_DEVFREQ_DEVFREQ_H__ */

0 commit comments

Comments
 (0)