All of lore.kernel.org
 help / color / mirror / Atom feed
* how softpoweroff works for openbmc
@ 2020-02-13 15:17 =?gb18030?B?xM/SsKXgpeult6WopemltA==?=
  2020-02-14  2:40 ` Lei YU
  0 siblings, 1 reply; 3+ messages in thread
From: =?gb18030?B?xM/SsKXgpeult6WopemltA==?= @ 2020-02-13 15:17 UTC (permalink / raw)
  To: =?gb18030?B?b3BlbmJtYw==?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1499 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1777 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: how softpoweroff works for openbmc
  2020-02-13 15:17 how softpoweroff works for openbmc =?gb18030?B?xM/SsKXgpeult6WopemltA==?=
@ 2020-02-14  2:40 ` Lei YU
  2020-02-14  8:06   ` =?gb18030?B?u9i4tKO6IGhvdyBzb2Z0cG93ZXJvZmYgd29ya3MgZm9yIG9wZW5ibWM=?= =?gb18030?B?xM/SsKXgpeult6WopemltA==?=
  0 siblings, 1 reply; 3+ messages in thread
From: Lei YU @ 2020-02-14  2:40 UTC (permalink / raw)
  To: 南野ムルシエラゴ; +Cc: openbmc

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@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@.target, which shutdowns the chassis power.


On Thu, Feb 13, 2020 at 11:20 PM 南野ムルシエラゴ <1181052146@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* =?gb18030?B?u9i4tKO6IGhvdyBzb2Z0cG93ZXJvZmYgd29ya3MgZm9yIG9wZW5ibWM=?=
  2020-02-14  2:40 ` Lei YU
@ 2020-02-14  8:06   ` =?gb18030?B?xM/SsKXgpeult6WopemltA==?=
  0 siblings, 0 replies; 3+ messages in thread
From: =?gb18030?B?xM/SsKXgpeult6WopemltA==?= @ 2020-02-14  8:06 UTC (permalink / raw)
  To: =?gb18030?B?bWluZTI2MDMwOQ==?=; +Cc: =?gb18030?B?b3BlbmJtYw==?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 5361 bytes --]

Hi, Lei YU

Thanks a lot for your advices! The steps are very clear and helps me very much!

Best Regards!
Liu Hongwei

------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"mine260309"<mine260309@gmail.com&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê2ÔÂ14ÈÕ(ÐÇÆÚÎå) ÉÏÎç10:40
ÊÕ¼þÈË:&nbsp;"ÄÏÒ°¥à¥ë¥·¥¨¥é¥´"<1181052146@qq.com&gt;;
³­ËÍ:&nbsp;"openbmc"<openbmc@lists.ozlabs.org&gt;;
Ö÷Ìâ:&nbsp;Re: how softpoweroff works for openbmc



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&nbsp; RequestedHostTransition
to Off implemented by phosphor-host-state-manager.
&nbsp;&nbsp; https://github.com/openbmc/phosphor-state-manager/blob/c101157e5b138f36044a2a3aaf15ad8ac16501fc/host_state_manager.cpp#L316
2. phosphor-host-state-manager starts obmc-host-shutdown@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".
&nbsp;&nbsp; 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".
&nbsp;&nbsp; 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.
&nbsp;&nbsp; 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.
&nbsp;&nbsp; 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).
&nbsp;&nbsp; When it times out, the BMC will shutdown the chassis power.
&nbsp;&nbsp; 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".
&nbsp;&nbsp; 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.
&nbsp;&nbsp;&nbsp; https://github.com/openbmc/phosphor-host-ipmid/blob/51f781418013b993f4b3d5c1572ce19a5b93edf0/softoff/softoff.cpp#L118
13. Then systemd will execute the other dependent
obmc-chassis-poweroff@.target, which shutdowns the chassis power.


On Thu, Feb 13, 2020 at 11:20 PM ÄÏÒ°¥à¥ë¥·¥¨¥é¥´ <1181052146@qq.com&gt; wrote:
&gt;
&gt; Greetings:
&gt; 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".
&gt; 1. for "poweroff", I found the call path:
&gt; ipmiChassisControl()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //phosphor-host-ipmid
&gt; initiate_state_transition()
&gt; ...
&gt; d-bus
&gt; ...
&gt; requestedHostTransition()&nbsp;&nbsp; //phosphor-state-manager
&gt; ...
&gt; dbus
&gt; ...
&gt; on_set_power_state()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //skeleton
&gt; and finally write some gpio pin to power down.
&gt; 2. for "softpoweroff", I found the call path:
&gt; ipmiChassisControl()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //phosphor-host-ipmid
&gt; stop_soft_off_timer()
&gt; sendHostShutDownCmd()
&gt; ipmid_send_cmd_to_host()
&gt; checkQueueAndAlertHost()
&gt; ...
&gt; d-bus(setAttention)
&gt; ...
&gt; method_send_sms_atn()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //btbridge
&gt; and finally send some message to host via BT, or in case of KCS via KCS.
&gt; My question is:
&gt; 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?
&gt; 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?
&gt; 3. I am a learner of openbmc, I know there must be errors in my mail.
&gt; Can anyone help tell me?
&gt;
&gt; Best Regards!
&gt; Liu Hongwei

[-- Attachment #2: Type: text/html, Size: 5817 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-14  8:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13 15:17 how softpoweroff works for openbmc =?gb18030?B?xM/SsKXgpeult6WopemltA==?=
2020-02-14  2:40 ` Lei YU
2020-02-14  8:06   ` =?gb18030?B?u9i4tKO6IGhvdyBzb2Z0cG93ZXJvZmYgd29ya3MgZm9yIG9wZW5ibWM=?= =?gb18030?B?xM/SsKXgpeult6WopemltA==?=

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.