linuxsequencepower-off

Android Linux kernel power-off sequence


I'm working with Linux kernel of Android and I have a problem. I'm trying to make a flow chart of my Android phone's kernel power-off code sequence.

If I press the power button on my phone and choose "Power off" to turn off my device. I wonder what's going on inside the system. Which kernel module will be the initial module of power-off sequence? Which kernel modules call which system calls during the whole power-off process?

I got the log file of my device as below..

...
ghost[362]: [Ghost] Now, 50th boot.
[  119.307156] msm_hsl_power: Unknown PM state 1
[  129.966017] pil-q6v5-mss fc880000.qcom,mss: PBL returned unexpected status -284491765
[  129.972866] pil-q6v5-mss fc880000.qcom,mss: mba: Failed to bring out of reset
[  129.992102] modem_notifier_cb: sysmon_send_event error -19
[  129.996628] M-Notify: General: 5
[  129.999825] msm_ipc_load_default_node: Failed to load modem
[  131.336799] pil-q6v5-mss fc880000.qcom,mss: PBL returned unexpected status -284491765
[  131.343844] pil-q6v5-mss fc880000.qcom,mss: mba: Failed to bring out of reset
[  131.351708] modem_notifier_cb: sysmon_send_event error -19
[  131.356216] M-Notify: General: 5
[  131.359430] smd_pkt_open failed on smd_pkt_dev id:0 - subsystem_get failed for modem
[  132.385289] param_sec_operation FAIL LLSEEK
[  132.388448] sec_open_param PARAM OPEN FAIL
[  132.392715] set_dload_mode <0> ( c01882a0 )
[  132.397069] (sec_debug_set_upload_magic) 0
[  132.496318] Power down.
[  132.497733] Powering off the SoC
[  132.500972] set_dload_mode <0> ( c0188348 )
[  132.505717] Calling SCM to disable SPMI PMIC

I wonder if restart.c in "arch\arm\mach-msm" is the first module which initial the power-off sequence after I press the "Power off" soft button?

I'm a newbie in Linux. I will be very grateful for your help!


Solution

  • I'm assuming this is an Android phone?

    There is a difference between the shutdown sequence for Linux and for Android, even though Android is based on the Linux kernel. What the Linux shutdown sequence does is to start by setting the runlevel to 0; this will cause any services to shut down, before allowing for a clean halt and poweroff.

    But Android doesn't have runlevels, because they're not a feature of the Linux kernel, but of initd.

    Hopefully this will give you something to start with for the Linux shutdown sequence. You should start by learning about runlevels.

    Details of the kernel shutdown sequence are in this question.