how softpoweroff works for openbmc

Lei YU mine260309 at gmail.com
Fri Feb 14 13:40:11 AEDT 2020


I had a summary of how the soft-off works, please see below.

---

On OpenPOWER systems, the soft-off is implemented by
phosphor-softpoweroff in phosphor-host-ipmid/softoff.
The whole steps are described as below:

1. To power off the host gracefully, BMC sets  RequestedHostTransition
to Off implemented by phosphor-host-state-manager.
   https://github.com/openbmc/phosphor-state-manager/blob/c101157e5b138f36044a2a3aaf15ad8ac16501fc/host_state_manager.cpp#L316
2. phosphor-host-state-manager starts obmc-host-shutdown at 0.target
3. The target depends on
xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service, and it comes
to phosphor-softpoweroff.
4. phosphor-softpoweroff invokes sendHostShutDownCmd(), that calls the
"Execute" method of "xyz.openbmc_project.Control.Host".
   https://github.com/openbmc/phosphor-host-ipmid/blob/51f781418013b993f4b3d5c1572ce19a5b93edf0/softoff/softoff.cpp#L32
5. The host control service (implemented in host-cmd-manager.cpp) puts
the command in a queue and invokes checkQueueAndAlertHost(), which
invokes "setAttention" method of "org.openbmc.HostIpmi".
   https://github.com/openbmc/phosphor-host-ipmid/blob/51f781418013b993f4b3d5c1572ce19a5b93edf0/host-cmd-manager.cpp#L112
6. btbridged implements setAttention(), and it sends SMS ATN message
to host via IPMI BT.
   https://github.com/openbmc/btbridge/blob/aa5511d28ff9acee4a404c6397d09f5187812ed8/btbridged.c#L261
7. Then the Host received the attention, so it reads messages from BMC.
8. BMC's ipmid's ipmi_app_read_event() is invoked, and the queued SOFT
OFF command is sent to the Host, and sends a CommandComplete signal on
DBus.
   https://github.com/openbmc/phosphor-host-ipmid/blob/51f781418013b993f4b3d5c1572ce19a5b93edf0/systemintfcmds.cpp#L23
9. phosphor-softpoweroff registers the signal, so the callback
hostControlEvent() is invoked, which starts a timer (configurable by
IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS).
   When it times out, the BMC will shutdown the chassis power.
   https://github.com/openbmc/phosphor-host-ipmid/blob/51f781418013b993f4b3d5c1572ce19a5b93edf0/softoff/softoff.cpp#L75
10. When the Host OS is shutdown, it sends the chassis control's
CMD_POWER_OFF message via IPMI.
11. The ipmid invokes stop_soft_off_timer(),and sets the property
"ResponseReceived" to "SoftPowerOff.HostResponse.HostShutdown".
   https://github.com/openbmc/phosphor-host-ipmid/blob/51f781418013b993f4b3d5c1572ce19a5b93edf0/chassishandler.cpp#L1159
12. In phosphor-softpoweroff, responseReceived() is invoked, stops the
timer, and the process exits normally.
    https://github.com/openbmc/phosphor-host-ipmid/blob/51f781418013b993f4b3d5c1572ce19a5b93edf0/softoff/softoff.cpp#L118
13. Then systemd will execute the other dependent
obmc-chassis-poweroff at .target, which shutdowns the chassis power.


On Thu, Feb 13, 2020 at 11:20 PM 南野ムルシエラゴ <1181052146 at qq.com> wrote:
>
> Greetings:
> I am learning how power control works in openbmc system. It comes to poweroff sequence. I found that for poweroff there are "poweroff" and "softpoweroff".
> 1. for "poweroff", I found the call path:
> ipmiChassisControl()             //phosphor-host-ipmid
> initiate_state_transition()
> ...
> d-bus
> ...
> requestedHostTransition()   //phosphor-state-manager
> ...
> dbus
> ...
> on_set_power_state()            //skeleton
> and finally write some gpio pin to power down.
> 2. for "softpoweroff", I found the call path:
> ipmiChassisControl()             //phosphor-host-ipmid
> stop_soft_off_timer()
> sendHostShutDownCmd()
> ipmid_send_cmd_to_host()
> checkQueueAndAlertHost()
> ...
> d-bus(setAttention)
> ...
> method_send_sms_atn()      //btbridge
> and finally send some message to host via BT, or in case of KCS via KCS.
> My question is:
> 1. In case of softpoweroff I found in code that the openbmc system just send setAttention to host and return? Does that mean letting the host system to powerdown and openbmc system does not write any power related gpio anymore?
> 2. If host system can handle the softpoweroff request sent by openbmc, How can host system handle it? I know there is a module called ipmi_si.ko which may communicate with openbmc. But I do not find and code in ipmi_si related with softpoweroff, or any other module in host system to control softpoweroff?
> 3. I am a learner of openbmc, I know there must be errors in my mail.
> Can anyone help tell me?
>
> Best Regards!
> Liu Hongwei


More information about the openbmc mailing list