Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
bb4d5e38
K
Kernel
项目概览
openeuler
/
Kernel
大约 2 年 前同步成功
通知
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看板
提交
bb4d5e38
编写于
5月 05, 2017
作者:
Z
Zhang Rui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'backup-thermal-shutdown' into next
上级
a6128f47
ef1d87e0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
101 addition
and
1 deletion
+101
-1
Documentation/thermal/sysfs-api.txt
Documentation/thermal/sysfs-api.txt
+21
-0
drivers/thermal/Kconfig
drivers/thermal/Kconfig
+17
-0
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.c
+63
-1
未找到文件。
Documentation/thermal/sysfs-api.txt
浏览文件 @
bb4d5e38
...
@@ -582,3 +582,24 @@ platform data is provided, this uses the step_wise throttling policy.
...
@@ -582,3 +582,24 @@ platform data is provided, this uses the step_wise throttling policy.
This function serves as an arbitrator to set the state of a cooling
This function serves as an arbitrator to set the state of a cooling
device. It sets the cooling device to the deepest cooling state if
device. It sets the cooling device to the deepest cooling state if
possible.
possible.
6. thermal_emergency_poweroff:
On an event of critical trip temperature crossing. Thermal framework
allows the system to shutdown gracefully by calling orderly_poweroff().
In the event of a failure of orderly_poweroff() to shut down the system
we are in danger of keeping the system alive at undesirably high
temperatures. To mitigate this high risk scenario we program a work
queue to fire after a pre-determined number of seconds to start
an emergency shutdown of the device using the kernel_power_off()
function. In case kernel_power_off() fails then finally
emergency_restart() is called in the worst case.
The delay should be carefully profiled so as to give adequate time for
orderly_poweroff(). In case of failure of an orderly_poweroff() the
emergency poweroff kicks in after the delay has elapsed and shuts down
the system.
If set to 0 emergency poweroff will not be supported. So a carefully
profiled non-zero positive value is a must for emergerncy poweroff to be
triggered.
drivers/thermal/Kconfig
浏览文件 @
bb4d5e38
...
@@ -15,6 +15,23 @@ menuconfig THERMAL
...
@@ -15,6 +15,23 @@ menuconfig THERMAL
if THERMAL
if THERMAL
config THERMAL_EMERGENCY_POWEROFF_DELAY_MS
int "Emergency poweroff delay in milli-seconds"
depends on THERMAL
default 0
help
Thermal subsystem will issue a graceful shutdown when
critical temperatures are reached using orderly_poweroff(). In
case of failure of an orderly_poweroff(), the thermal emergency
poweroff kicks in after a delay has elapsed and shuts down the system.
This config is number of milliseconds to delay before emergency
poweroff kicks in. Similarly to the critical trip point,
the delay should be carefully profiled so as to give adequate
time for orderly_poweroff() to finish on regular execution.
If set to 0 emergency poweroff will not be supported.
In doubt, leave as 0.
config THERMAL_HWMON
config THERMAL_HWMON
bool
bool
prompt "Expose thermal sensors as hwmon device"
prompt "Expose thermal sensors as hwmon device"
...
...
drivers/thermal/thermal_core.c
浏览文件 @
bb4d5e38
...
@@ -45,8 +45,10 @@ static LIST_HEAD(thermal_governor_list);
...
@@ -45,8 +45,10 @@ static LIST_HEAD(thermal_governor_list);
static
DEFINE_MUTEX
(
thermal_list_lock
);
static
DEFINE_MUTEX
(
thermal_list_lock
);
static
DEFINE_MUTEX
(
thermal_governor_lock
);
static
DEFINE_MUTEX
(
thermal_governor_lock
);
static
DEFINE_MUTEX
(
poweroff_lock
);
static
atomic_t
in_suspend
;
static
atomic_t
in_suspend
;
static
bool
power_off_triggered
;
static
struct
thermal_governor
*
def_governor
;
static
struct
thermal_governor
*
def_governor
;
...
@@ -322,6 +324,54 @@ static void handle_non_critical_trips(struct thermal_zone_device *tz,
...
@@ -322,6 +324,54 @@ static void handle_non_critical_trips(struct thermal_zone_device *tz,
def_governor
->
throttle
(
tz
,
trip
);
def_governor
->
throttle
(
tz
,
trip
);
}
}
/**
* thermal_emergency_poweroff_func - emergency poweroff work after a known delay
* @work: work_struct associated with the emergency poweroff function
*
* This function is called in very critical situations to force
* a kernel poweroff after a configurable timeout value.
*/
static
void
thermal_emergency_poweroff_func
(
struct
work_struct
*
work
)
{
/*
* We have reached here after the emergency thermal shutdown
* Waiting period has expired. This means orderly_poweroff has
* not been able to shut off the system for some reason.
* Try to shut down the system immediately using kernel_power_off
* if populated
*/
WARN
(
1
,
"Attempting kernel_power_off: Temperature too high
\n
"
);
kernel_power_off
();
/*
* Worst of the worst case trigger emergency restart
*/
WARN
(
1
,
"Attempting emergency_restart: Temperature too high
\n
"
);
emergency_restart
();
}
static
DECLARE_DELAYED_WORK
(
thermal_emergency_poweroff_work
,
thermal_emergency_poweroff_func
);
/**
* thermal_emergency_poweroff - Trigger an emergency system poweroff
*
* This may be called from any critical situation to trigger a system shutdown
* after a known period of time. By default this is not scheduled.
*/
void
thermal_emergency_poweroff
(
void
)
{
int
poweroff_delay_ms
=
CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS
;
/*
* poweroff_delay_ms must be a carefully profiled positive value.
* Its a must for thermal_emergency_poweroff_work to be scheduled
*/
if
(
poweroff_delay_ms
<=
0
)
return
;
schedule_delayed_work
(
&
thermal_emergency_poweroff_work
,
msecs_to_jiffies
(
poweroff_delay_ms
));
}
static
void
handle_critical_trips
(
struct
thermal_zone_device
*
tz
,
static
void
handle_critical_trips
(
struct
thermal_zone_device
*
tz
,
int
trip
,
enum
thermal_trip_type
trip_type
)
int
trip
,
enum
thermal_trip_type
trip_type
)
{
{
...
@@ -342,7 +392,17 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
...
@@ -342,7 +392,17 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
dev_emerg
(
&
tz
->
device
,
dev_emerg
(
&
tz
->
device
,
"critical temperature reached(%d C),shutting down
\n
"
,
"critical temperature reached(%d C),shutting down
\n
"
,
tz
->
temperature
/
1000
);
tz
->
temperature
/
1000
);
mutex_lock
(
&
poweroff_lock
);
if
(
!
power_off_triggered
)
{
/*
* Queue a backup emergency shutdown in the event of
* orderly_poweroff failure
*/
thermal_emergency_poweroff
();
orderly_poweroff
(
true
);
orderly_poweroff
(
true
);
power_off_triggered
=
true
;
}
mutex_unlock
(
&
poweroff_lock
);
}
}
}
}
...
@@ -1463,6 +1523,7 @@ static int __init thermal_init(void)
...
@@ -1463,6 +1523,7 @@ static int __init thermal_init(void)
{
{
int
result
;
int
result
;
mutex_init
(
&
poweroff_lock
);
result
=
thermal_register_governors
();
result
=
thermal_register_governors
();
if
(
result
)
if
(
result
)
goto
error
;
goto
error
;
...
@@ -1497,6 +1558,7 @@ static int __init thermal_init(void)
...
@@ -1497,6 +1558,7 @@ static int __init thermal_init(void)
ida_destroy
(
&
thermal_cdev_ida
);
ida_destroy
(
&
thermal_cdev_ida
);
mutex_destroy
(
&
thermal_list_lock
);
mutex_destroy
(
&
thermal_list_lock
);
mutex_destroy
(
&
thermal_governor_lock
);
mutex_destroy
(
&
thermal_governor_lock
);
mutex_destroy
(
&
poweroff_lock
);
return
result
;
return
result
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录