Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
ecf7e461
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
ecf7e461
编写于
7月 08, 2009
作者:
D
Dave Jones
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CPUFREQ] Factor out policy setting from cpufreq_add_dev
Signed-off-by:
N
Dave Jones
<
davej@redhat.com
>
上级
909a694e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
90 addition
and
76 deletion
+90
-76
drivers/cpufreq/cpufreq.c
drivers/cpufreq/cpufreq.c
+90
-76
未找到文件。
drivers/cpufreq/cpufreq.c
浏览文件 @
ecf7e461
...
...
@@ -756,6 +756,75 @@ static struct kobj_type ktype_cpufreq = {
.
release
=
cpufreq_sysfs_release
,
};
int
cpufreq_add_dev_policy
(
unsigned
int
cpu
,
struct
cpufreq_policy
*
policy
,
struct
sys_device
*
sys_dev
)
{
int
ret
=
0
;
#ifdef CONFIG_SMP
unsigned
long
flags
;
unsigned
int
j
;
#ifdef CONFIG_HOTPLUG_CPU
if
(
per_cpu
(
cpufreq_cpu_governor
,
cpu
))
{
policy
->
governor
=
per_cpu
(
cpufreq_cpu_governor
,
cpu
);
dprintk
(
"Restoring governor %s for cpu %d
\n
"
,
policy
->
governor
->
name
,
cpu
);
}
#endif
for_each_cpu
(
j
,
policy
->
cpus
)
{
struct
cpufreq_policy
*
managed_policy
;
if
(
cpu
==
j
)
continue
;
/* Check for existing affected CPUs.
* They may not be aware of it due to CPU Hotplug.
* cpufreq_cpu_put is called when the device is removed
* in __cpufreq_remove_dev()
*/
managed_policy
=
cpufreq_cpu_get
(
j
);
if
(
unlikely
(
managed_policy
))
{
/* Set proper policy_cpu */
unlock_policy_rwsem_write
(
cpu
);
per_cpu
(
policy_cpu
,
cpu
)
=
managed_policy
->
cpu
;
if
(
lock_policy_rwsem_write
(
cpu
)
<
0
)
{
/* Should not go through policy unlock path */
if
(
cpufreq_driver
->
exit
)
cpufreq_driver
->
exit
(
policy
);
cpufreq_cpu_put
(
managed_policy
);
return
-
EBUSY
;
}
spin_lock_irqsave
(
&
cpufreq_driver_lock
,
flags
);
cpumask_copy
(
managed_policy
->
cpus
,
policy
->
cpus
);
per_cpu
(
cpufreq_cpu_data
,
cpu
)
=
managed_policy
;
spin_unlock_irqrestore
(
&
cpufreq_driver_lock
,
flags
);
dprintk
(
"CPU already managed, adding link
\n
"
);
ret
=
sysfs_create_link
(
&
sys_dev
->
kobj
,
&
managed_policy
->
kobj
,
"cpufreq"
);
if
(
ret
)
cpufreq_cpu_put
(
managed_policy
);
/*
* Success. We only needed to be added to the mask.
* Call driver->exit() because only the cpu parent of
* the kobj needed to call init().
*/
if
(
cpufreq_driver
->
exit
)
cpufreq_driver
->
exit
(
policy
);
return
ret
;
}
}
#endif
return
ret
;
}
/* symlink affected CPUs */
int
cpufreq_add_dev_symlink
(
unsigned
int
cpu
,
struct
cpufreq_policy
*
policy
)
{
...
...
@@ -787,6 +856,7 @@ int cpufreq_add_dev_symlink(unsigned int cpu, struct cpufreq_policy *policy)
int
cpufreq_add_dev_interface
(
unsigned
int
cpu
,
struct
cpufreq_policy
*
policy
,
struct
sys_device
*
sys_dev
)
{
struct
cpufreq_policy
new_policy
;
struct
freq_attr
**
drv_attr
;
unsigned
long
flags
;
int
ret
=
0
;
...
...
@@ -827,6 +897,23 @@ int cpufreq_add_dev_interface(unsigned int cpu, struct cpufreq_policy *policy,
spin_unlock_irqrestore
(
&
cpufreq_driver_lock
,
flags
);
ret
=
cpufreq_add_dev_symlink
(
cpu
,
policy
);
if
(
ret
)
goto
err_out_kobj_put
;
memcpy
(
&
new_policy
,
policy
,
sizeof
(
struct
cpufreq_policy
));
/* assure that the starting sequence is run in __cpufreq_set_policy */
policy
->
governor
=
NULL
;
/* set default policy */
ret
=
__cpufreq_set_policy
(
policy
,
&
new_policy
);
policy
->
user_policy
.
policy
=
policy
->
policy
;
policy
->
user_policy
.
governor
=
policy
->
governor
;
if
(
ret
)
{
dprintk
(
"setting policy failed
\n
"
);
if
(
cpufreq_driver
->
exit
)
cpufreq_driver
->
exit
(
policy
);
}
return
ret
;
err_out_kobj_put:
...
...
@@ -849,7 +936,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
{
unsigned
int
cpu
=
sys_dev
->
id
;
int
ret
=
0
;
struct
cpufreq_policy
new_policy
;
struct
cpufreq_policy
*
policy
;
unsigned
long
flags
;
unsigned
int
j
;
...
...
@@ -914,82 +1000,14 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
blocking_notifier_call_chain
(
&
cpufreq_policy_notifier_list
,
CPUFREQ_START
,
policy
);
#ifdef CONFIG_SMP
#ifdef CONFIG_HOTPLUG_CPU
if
(
per_cpu
(
cpufreq_cpu_governor
,
cpu
))
{
policy
->
governor
=
per_cpu
(
cpufreq_cpu_governor
,
cpu
);
dprintk
(
"Restoring governor %s for cpu %d
\n
"
,
policy
->
governor
->
name
,
cpu
);
}
#endif
for_each_cpu
(
j
,
policy
->
cpus
)
{
struct
cpufreq_policy
*
managed_policy
;
if
(
cpu
==
j
)
continue
;
/* Check for existing affected CPUs.
* They may not be aware of it due to CPU Hotplug.
* cpufreq_cpu_put is called when the device is removed
* in __cpufreq_remove_dev()
*/
managed_policy
=
cpufreq_cpu_get
(
j
);
if
(
unlikely
(
managed_policy
))
{
/* Set proper policy_cpu */
unlock_policy_rwsem_write
(
cpu
);
per_cpu
(
policy_cpu
,
cpu
)
=
managed_policy
->
cpu
;
if
(
lock_policy_rwsem_write
(
cpu
)
<
0
)
{
/* Should not go through policy unlock path */
if
(
cpufreq_driver
->
exit
)
cpufreq_driver
->
exit
(
policy
);
ret
=
-
EBUSY
;
cpufreq_cpu_put
(
managed_policy
);
goto
err_free_cpumask
;
}
spin_lock_irqsave
(
&
cpufreq_driver_lock
,
flags
);
cpumask_copy
(
managed_policy
->
cpus
,
policy
->
cpus
);
per_cpu
(
cpufreq_cpu_data
,
cpu
)
=
managed_policy
;
spin_unlock_irqrestore
(
&
cpufreq_driver_lock
,
flags
);
dprintk
(
"CPU already managed, adding link
\n
"
);
ret
=
sysfs_create_link
(
&
sys_dev
->
kobj
,
&
managed_policy
->
kobj
,
"cpufreq"
);
if
(
ret
)
cpufreq_cpu_put
(
managed_policy
);
/*
* Success. We only needed to be added to the mask.
* Call driver->exit() because only the cpu parent of
* the kobj needed to call init().
*/
goto
out_driver_exit
;
/* call driver->exit() */
}
}
#endif
memcpy
(
&
new_policy
,
policy
,
sizeof
(
struct
cpufreq_policy
));
ret
=
cpufreq_add_dev_policy
(
cpu
,
policy
,
sys_dev
);
if
(
ret
)
goto
err_unlock_policy
;
ret
=
cpufreq_add_dev_interface
(
cpu
,
policy
,
sys_dev
);
if
(
ret
)
goto
err_out_unregister
;
policy
->
governor
=
NULL
;
/* to assure that the starting sequence is
* run in cpufreq_set_policy */
/* set default policy */
ret
=
__cpufreq_set_policy
(
policy
,
&
new_policy
);
policy
->
user_policy
.
policy
=
policy
->
policy
;
policy
->
user_policy
.
governor
=
policy
->
governor
;
if
(
ret
)
{
dprintk
(
"setting policy failed
\n
"
);
goto
err_out_unregister
;
}
unlock_policy_rwsem_write
(
cpu
);
kobject_uevent
(
&
policy
->
kobj
,
KOBJ_ADD
);
...
...
@@ -1009,10 +1027,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
kobject_put
(
&
policy
->
kobj
);
wait_for_completion
(
&
policy
->
kobj_unregister
);
out_driver_exit:
if
(
cpufreq_driver
->
exit
)
cpufreq_driver
->
exit
(
policy
);
err_unlock_policy:
unlock_policy_rwsem_write
(
cpu
);
err_free_cpumask:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录