赞
踩
1.问题描述:
最近做项目遇到一个很奇怪的问题,就是安卓系统待机一会就进入了深度睡眠,连终端都没响应。调试信息如下:
- ] request_suspend_state: sleep (0->3) at 175730206087 (2017-09-27 01:28:31.556133562 UTC)
- [ 175.738202] s3cfb_early_suspend is called
- [ 175.741885] (s3cfb_backlight_off, 546): LCD_PWM_OFF
- [ 175.756345] (s3cfb_backlight_off, 588): VGA_EN_OFF
- [ 175.764283] (s3cfb_backlight_off, 603): BK_VDD_OFF
- [ 176.004117] <<-GTP-INFO->> Esd suspended!
- [ 176.038412] PM: Syncing filesystems ... done.
- [ 176.065360] Freezing user space processes ... (elapsed 0.01 seconds) done.
- [ 176.086237] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
- [ 176.106202] Suspending console(s) (use no_console_suspend to debug)
- int enter_state(suspend_state_t state)
- {
- int error;
-
- if (!valid_state(state))
- return -ENODEV;
-
- if (!mutex_trylock(&pm_mutex))
- return -EBUSY;
-
- printk(KERN_INFO "PM: Syncing filesystems ... ");
- sys_sync();
- printk("done.\n");
-
- pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
- error = suspend_prepare();
- if (error)
- goto Unlock;
-
- if (suspend_test(TEST_FREEZER))
- goto Finish;
-
- pr_debug("PM: Entering %s sleep\n", pm_states[state]);
- error = suspend_devices_and_enter(state);
-
- Finish:
- pr_debug("PM: Finishing wakeup.\n");
- suspend_finish();
- Unlock:
- mutex_unlock(&pm_mutex);
- return error;
- }
2.问题分析
android系统有earlysuspend和suspend两种休眠,earlysuspend是浅度睡眠,suspend是深度休眠。这个是由linux电源管理控制的,电源管理的接口是“/sys/power/state”和"/sys/power/wake_lock","/sys/power/wake_unlock",这个是linux是否休眠和是否进入深度休眠的关键点。只有wake_lock上锁了,linux系统就不会进入深度休眠。
3.问题解决
从上分析可知,只要linux保持有一个唤醒锁,系统就不会进入深度休眠。那么解决问题的思路是在linux启动的时候添加一个唤醒锁就行了。在init.rc文件里面添加一个初始化项:
echo "PowerManagerService.noSuspend" > /sys/power/wake_lock
问题至此完美解决。
参考资料:
1.Android 内核驱动——电源管理 :http://blog.sina.com.cn/s/blog_67d955460100xlyh.html
2.Android后台的linux一直保持唤醒状态,不进入睡眠:http://www.cnblogs.com/yajing-zh/p/4891780.html
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。