Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
3b4aff04
Commit
3b4aff04
authored
Mar 06, 2014
by
Rafael J. Wysocki
Browse files
Options
Browse Files
Download
Plain Diff
Merge back earlier 'pm-cpufreq' material.
parents
4e97b631
ad4c2302
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
97 deletions
+84
-97
arch/arm64/Kconfig
arch/arm64/Kconfig
+8
-0
drivers/cpufreq/Kconfig
drivers/cpufreq/Kconfig
+1
-1
drivers/cpufreq/cpufreq.c
drivers/cpufreq/cpufreq.c
+50
-57
drivers/cpufreq/cpufreq_stats.c
drivers/cpufreq/cpufreq_stats.c
+13
-25
drivers/cpufreq/intel_pstate.c
drivers/cpufreq/intel_pstate.c
+12
-14
No files found.
arch/arm64/Kconfig
View file @
3b4aff04
...
...
@@ -303,6 +303,14 @@ source "drivers/cpuidle/Kconfig"
endmenu
menu "Power management options"
source "kernel/power/Kconfig"
source "drivers/cpufreq/Kconfig"
endmenu
source "net/Kconfig"
source "drivers/Kconfig"
...
...
drivers/cpufreq/Kconfig
View file @
3b4aff04
...
...
@@ -200,7 +200,7 @@ source "drivers/cpufreq/Kconfig.x86"
endmenu
menu "ARM CPU frequency scaling drivers"
depends on ARM
depends on ARM
|| ARM64
source "drivers/cpufreq/Kconfig.arm"
endmenu
...
...
drivers/cpufreq/cpufreq.c
View file @
3b4aff04
...
...
@@ -352,7 +352,7 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_post_transition);
/*********************************************************************
* SYSFS INTERFACE *
*********************************************************************/
ssize_t
show_boost
(
struct
kobject
*
kobj
,
s
tatic
s
size_t
show_boost
(
struct
kobject
*
kobj
,
struct
attribute
*
attr
,
char
*
buf
)
{
return
sprintf
(
buf
,
"%d
\n
"
,
cpufreq_driver
->
boost_enabled
);
...
...
@@ -2012,22 +2012,21 @@ EXPORT_SYMBOL(cpufreq_get_policy);
static
int
cpufreq_set_policy
(
struct
cpufreq_policy
*
policy
,
struct
cpufreq_policy
*
new_policy
)
{
int
ret
=
0
,
failed
=
1
;
struct
cpufreq_governor
*
old_gov
;
int
ret
;
pr_debug
(
"setting new policy for CPU %u: %u - %u kHz
\n
"
,
new_policy
->
cpu
,
new_policy
->
min
,
new_policy
->
max
);
memcpy
(
&
new_policy
->
cpuinfo
,
&
policy
->
cpuinfo
,
sizeof
(
policy
->
cpuinfo
));
if
(
new_policy
->
min
>
policy
->
max
||
new_policy
->
max
<
policy
->
min
)
{
ret
=
-
EINVAL
;
goto
error_out
;
}
if
(
new_policy
->
min
>
policy
->
max
||
new_policy
->
max
<
policy
->
min
)
return
-
EINVAL
;
/* verify the cpu speed can be set within this limit */
ret
=
cpufreq_driver
->
verify
(
new_policy
);
if
(
ret
)
goto
error_ou
t
;
return
re
t
;
/* adjust if necessary - all reasons */
blocking_notifier_call_chain
(
&
cpufreq_policy_notifier_list
,
...
...
@@ -2043,7 +2042,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
*/
ret
=
cpufreq_driver
->
verify
(
new_policy
);
if
(
ret
)
goto
error_ou
t
;
return
re
t
;
/* notification of the new policy */
blocking_notifier_call_chain
(
&
cpufreq_policy_notifier_list
,
...
...
@@ -2058,58 +2057,48 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
if
(
cpufreq_driver
->
setpolicy
)
{
policy
->
policy
=
new_policy
->
policy
;
pr_debug
(
"setting range
\n
"
);
ret
=
cpufreq_driver
->
setpolicy
(
new_policy
);
}
else
{
if
(
new_policy
->
governor
!=
policy
->
governor
)
{
/* save old, working values */
struct
cpufreq_governor
*
old_gov
=
policy
->
governor
;
pr_debug
(
"governor switch
\n
"
);
/* end old governor */
if
(
policy
->
governor
)
{
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_STOP
);
up_write
(
&
policy
->
rwsem
);
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_POLICY_EXIT
);
down_write
(
&
policy
->
rwsem
);
}
return
cpufreq_driver
->
setpolicy
(
new_policy
);
}
/* start new governor */
policy
->
governor
=
new_policy
->
governor
;
if
(
!
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_POLICY_INIT
))
{
if
(
!
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_START
))
{
failed
=
0
;
}
else
{
up_write
(
&
policy
->
rwsem
);
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_POLICY_EXIT
);
down_write
(
&
policy
->
rwsem
);
}
}
if
(
new_policy
->
governor
==
policy
->
governor
)
goto
out
;
if
(
failed
)
{
/* new governor failed, so re-start old one */
pr_debug
(
"starting governor %s failed
\n
"
,
policy
->
governor
->
name
);
if
(
old_gov
)
{
policy
->
governor
=
old_gov
;
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_POLICY_INIT
);
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_START
);
}
ret
=
-
EINVAL
;
goto
error_out
;
}
/* might be a policy change, too, so fall through */
}
pr_debug
(
"governor: change or update limits
\n
"
);
ret
=
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_LIMITS
);
pr_debug
(
"governor switch
\n
"
);
/* save old, working values */
old_gov
=
policy
->
governor
;
/* end old governor */
if
(
old_gov
)
{
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_STOP
);
up_write
(
&
policy
->
rwsem
);
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_POLICY_EXIT
);
down_write
(
&
policy
->
rwsem
);
}
error_out:
return
ret
;
/* start new governor */
policy
->
governor
=
new_policy
->
governor
;
if
(
!
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_POLICY_INIT
))
{
if
(
!
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_START
))
goto
out
;
up_write
(
&
policy
->
rwsem
);
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_POLICY_EXIT
);
down_write
(
&
policy
->
rwsem
);
}
/* new governor failed, so re-start old one */
pr_debug
(
"starting governor %s failed
\n
"
,
policy
->
governor
->
name
);
if
(
old_gov
)
{
policy
->
governor
=
old_gov
;
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_POLICY_INIT
);
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_START
);
}
return
-
EINVAL
;
out:
pr_debug
(
"governor: change or update limits
\n
"
);
return
__cpufreq_governor
(
policy
,
CPUFREQ_GOV_LIMITS
);
}
/**
...
...
@@ -2145,6 +2134,11 @@ int cpufreq_update_policy(unsigned int cpu)
*/
if
(
cpufreq_driver
->
get
)
{
new_policy
.
cur
=
cpufreq_driver
->
get
(
cpu
);
if
(
WARN_ON
(
!
new_policy
.
cur
))
{
ret
=
-
EIO
;
goto
no_policy
;
}
if
(
!
policy
->
cur
)
{
pr_debug
(
"Driver did not initialize current freq"
);
policy
->
cur
=
new_policy
.
cur
;
...
...
@@ -2181,7 +2175,6 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
switch
(
action
&
~
CPU_TASKS_FROZEN
)
{
case
CPU_ONLINE
:
__cpufreq_add_dev
(
dev
,
NULL
,
frozen
);
cpufreq_update_policy
(
cpu
);
break
;
case
CPU_DOWN_PREPARE
:
...
...
drivers/cpufreq/cpufreq_stats.c
View file @
3b4aff04
...
...
@@ -180,27 +180,25 @@ static void cpufreq_stats_free_table(unsigned int cpu)
cpufreq_cpu_put
(
policy
);
}
static
int
__cpufreq_stats_create_table
(
struct
cpufreq_policy
*
policy
,
struct
cpufreq_frequency_table
*
table
)
static
int
__cpufreq_stats_create_table
(
struct
cpufreq_policy
*
policy
)
{
unsigned
int
i
,
j
,
count
=
0
,
ret
=
0
;
struct
cpufreq_stats
*
stat
;
struct
cpufreq_policy
*
current_policy
;
unsigned
int
alloc_size
;
unsigned
int
cpu
=
policy
->
cpu
;
struct
cpufreq_frequency_table
*
table
;
table
=
cpufreq_frequency_get_table
(
cpu
);
if
(
unlikely
(
!
table
))
return
0
;
if
(
per_cpu
(
cpufreq_stats_table
,
cpu
))
return
-
EBUSY
;
stat
=
kzalloc
(
sizeof
(
*
stat
),
GFP_KERNEL
);
if
((
stat
)
==
NULL
)
return
-
ENOMEM
;
current_policy
=
cpufreq_cpu_get
(
cpu
);
if
(
current_policy
==
NULL
)
{
ret
=
-
EINVAL
;
goto
error_get_fail
;
}
ret
=
sysfs_create_group
(
&
current_policy
->
kobj
,
&
stats_attr_group
);
ret
=
sysfs_create_group
(
&
policy
->
kobj
,
&
stats_attr_group
);
if
(
ret
)
goto
error_out
;
...
...
@@ -223,7 +221,7 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
stat
->
time_in_state
=
kzalloc
(
alloc_size
,
GFP_KERNEL
);
if
(
!
stat
->
time_in_state
)
{
ret
=
-
ENOMEM
;
goto
error_
out
;
goto
error_
alloc
;
}
stat
->
freq_table
=
(
unsigned
int
*
)(
stat
->
time_in_state
+
count
);
...
...
@@ -243,11 +241,10 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
stat
->
last_time
=
get_jiffies_64
();
stat
->
last_index
=
freq_table_get_index
(
stat
,
policy
->
cur
);
spin_unlock
(
&
cpufreq_stats_lock
);
cpufreq_cpu_put
(
current_policy
);
return
0
;
error_alloc:
sysfs_remove_group
(
&
policy
->
kobj
,
&
stats_attr_group
);
error_out:
cpufreq_cpu_put
(
current_policy
);
error_get_fail:
kfree
(
stat
);
per_cpu
(
cpufreq_stats_table
,
cpu
)
=
NULL
;
return
ret
;
...
...
@@ -256,7 +253,6 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
static
void
cpufreq_stats_create_table
(
unsigned
int
cpu
)
{
struct
cpufreq_policy
*
policy
;
struct
cpufreq_frequency_table
*
table
;
/*
* "likely(!policy)" because normally cpufreq_stats will be registered
...
...
@@ -266,9 +262,7 @@ static void cpufreq_stats_create_table(unsigned int cpu)
if
(
likely
(
!
policy
))
return
;
table
=
cpufreq_frequency_get_table
(
policy
->
cpu
);
if
(
likely
(
table
))
__cpufreq_stats_create_table
(
policy
,
table
);
__cpufreq_stats_create_table
(
policy
);
cpufreq_cpu_put
(
policy
);
}
...
...
@@ -291,20 +285,14 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
{
int
ret
=
0
;
struct
cpufreq_policy
*
policy
=
data
;
struct
cpufreq_frequency_table
*
table
;
unsigned
int
cpu
=
policy
->
cpu
;
if
(
val
==
CPUFREQ_UPDATE_POLICY_CPU
)
{
cpufreq_stats_update_policy_cpu
(
policy
);
return
0
;
}
table
=
cpufreq_frequency_get_table
(
cpu
);
if
(
!
table
)
return
0
;
if
(
val
==
CPUFREQ_CREATE_POLICY
)
ret
=
__cpufreq_stats_create_table
(
policy
,
table
);
ret
=
__cpufreq_stats_create_table
(
policy
);
else
if
(
val
==
CPUFREQ_REMOVE_POLICY
)
__cpufreq_stats_free_table
(
policy
);
...
...
drivers/cpufreq/intel_pstate.c
View file @
3b4aff04
...
...
@@ -99,8 +99,7 @@ struct cpudata {
u64
prev_aperf
;
u64
prev_mperf
;
unsigned
long
long
prev_tsc
;
int
sample_ptr
;
struct
sample
samples
[
SAMPLE_COUNT
];
struct
sample
sample
;
};
static
struct
cpudata
**
all_cpu_data
;
...
...
@@ -154,7 +153,7 @@ static inline void pid_reset(struct _pid *pid, int setpoint, int busy,
pid
->
setpoint
=
setpoint
;
pid
->
deadband
=
deadband
;
pid
->
integral
=
int_tofp
(
integral
);
pid
->
last_err
=
setpoint
-
busy
;
pid
->
last_err
=
int_tofp
(
setpoint
)
-
int_tofp
(
busy
)
;
}
static
inline
void
pid_p_gain_set
(
struct
_pid
*
pid
,
int
percent
)
...
...
@@ -586,15 +585,14 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
mperf
=
mperf
>>
FRAC_BITS
;
tsc
=
tsc
>>
FRAC_BITS
;
cpu
->
sample_ptr
=
(
cpu
->
sample_ptr
+
1
)
%
SAMPLE_COUNT
;
cpu
->
samples
[
cpu
->
sample_ptr
].
aperf
=
aperf
;
cpu
->
samples
[
cpu
->
sample_ptr
].
mperf
=
mperf
;
cpu
->
samples
[
cpu
->
sample_ptr
].
tsc
=
tsc
;
cpu
->
samples
[
cpu
->
sample_ptr
].
aperf
-=
cpu
->
prev_aperf
;
cpu
->
samples
[
cpu
->
sample_ptr
].
mperf
-=
cpu
->
prev_mperf
;
cpu
->
samples
[
cpu
->
sample_ptr
].
tsc
-=
cpu
->
prev_tsc
;
cpu
->
sample
.
aperf
=
aperf
;
cpu
->
sample
.
mperf
=
mperf
;
cpu
->
sample
.
tsc
=
tsc
;
cpu
->
sample
.
aperf
-=
cpu
->
prev_aperf
;
cpu
->
sample
.
mperf
-=
cpu
->
prev_mperf
;
cpu
->
sample
.
tsc
-=
cpu
->
prev_tsc
;
intel_pstate_calc_busy
(
cpu
,
&
cpu
->
sample
s
[
cpu
->
sample_ptr
]
);
intel_pstate_calc_busy
(
cpu
,
&
cpu
->
sample
);
cpu
->
prev_aperf
=
aperf
;
cpu
->
prev_mperf
=
mperf
;
...
...
@@ -614,7 +612,7 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
{
int32_t
core_busy
,
max_pstate
,
current_pstate
;
core_busy
=
cpu
->
sample
s
[
cpu
->
sample_ptr
]
.
core_pct_busy
;
core_busy
=
cpu
->
sample
.
core_pct_busy
;
max_pstate
=
int_tofp
(
cpu
->
pstate
.
max_pstate
);
current_pstate
=
int_tofp
(
cpu
->
pstate
.
current_pstate
);
core_busy
=
mul_fp
(
core_busy
,
div_fp
(
max_pstate
,
current_pstate
));
...
...
@@ -648,7 +646,7 @@ static void intel_pstate_timer_func(unsigned long __data)
intel_pstate_sample
(
cpu
);
sample
=
&
cpu
->
sample
s
[
cpu
->
sample_ptr
]
;
sample
=
&
cpu
->
sample
;
intel_pstate_adjust_busy_pstate
(
cpu
);
...
...
@@ -729,7 +727,7 @@ static unsigned int intel_pstate_get(unsigned int cpu_num)
cpu
=
all_cpu_data
[
cpu_num
];
if
(
!
cpu
)
return
0
;
sample
=
&
cpu
->
sample
s
[
cpu
->
sample_ptr
]
;
sample
=
&
cpu
->
sample
;
return
sample
->
freq
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment