Skip to contentSkip to conversation

powerpc/powernv: Poweroff (EPOW, DPO) events support for PowerNV platform

PATCH Superseded Vipin K Parashar 2 participants 5 messages Jun 4, 2015 – Jun 8, 2015 PowerPC

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 powerpc/powernv: Poweroff (EPOW, DPO) events support for PowerNV platform

This patch adds support for FSP (Flexible Service Processor) EPOW (Early Power Off Warning) and DPO (Delayed Power Off) events for the PowerNV platform. EPOW events are generated by FSP due to various critical system conditions that require system shutdown. A few examples of these conditions are high ambient temperature or system running on UPS power with low UPS battery. DPO event is generated in response to admin initiated system shutdown request. Upon receipt of EPOW and DPO events the host kernel invokes orderly_poweroff() for performing graceful system shutdown.

Changes in v6:
- Made below changes as suggested by Michael Ellerman on previous patch.
- Changed EPOW, DPO notifier blocks to use opal_power_control_event() and enhanced opal_power_control_event() to handle EPOW and DPO events.
- Reorganized code and added/changed few variable, function names removing older ones.
- Minor cleanup like removing unused headers, blank lines etc.

Changes in v5:
- Made changes to address review comments on previous patch.

Changes in v4:
- Made changes to address review comments on previous patch.

Changes in v3:
- Made changes to immediately call orderly_poweroff upon receipt of OPAL EPOW, DPO notifications.
- Made code changes to address review comments on previous patch.
- Made code changes to use existing OPAL EPOW API.
- Removed patch to extract EPOW event timeout from OPAL device-tree.

Changes in v2:
- Made code changes to improve code as per previous review comments.
- Added patch to obtain EPOW event timeout values from OPAL device-tree.

Vipin K Parashar (1):
powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV
platform

 arch/powerpc/include/asm/opal-api.h            |  40 ++++++++
 arch/powerpc/include/asm/opal.h                |   3 +-
 arch/powerpc/platforms/powernv/opal-power.c    | 125 +++++++++++++++++++++----
 arch/powerpc/platforms/powernv/opal-wrappers.S |   1 +
 4 files changed, 152 insertions(+), 17 deletions(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH v6 1/1 powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform

This patch adds support for FSP (Flexible Service Processor) EPOW (Early Power Off Warning) and DPO (Delayed Power Off) events for the PowerNV platform. EPOW events are generated by FSP due to various critical system conditions that require system shutdown. A few examples of these conditions are high ambient temperature or system running on UPS power with low UPS battery. DPO event is generated in response to admin initiated system shutdown request. Upon receipt of EPOW and DPO events the host kernel invokes orderly_poweroff() for performing graceful system shutdown.

---
 arch/powerpc/include/asm/opal-api.h            |  40 ++++++++
 arch/powerpc/include/asm/opal.h                |   3 +-
 arch/powerpc/platforms/powernv/opal-power.c    | 125 +++++++++++++++++++++----
 arch/powerpc/platforms/powernv/opal-wrappers.S |   1 +
 4 files changed, 152 insertions(+), 17 deletions(-)
arch/powerpc/include/asm/opal-api.h +40 -0
index 0321a90..f460435 100644
@@ -730,6 +730,46 @@ struct opal_i2c_request {
 	__be64 buffer_ra;		/* Buffer real address */
 };
 
+/*
+ * EPOW status sharing (OPAL and the host)
+ *
+ * The host will pass on OPAL, a buffer of length OPAL_SYSEPOW_MAX
+ * with individual elements being 16 bits wide to fetch the system
+ * wide EPOW status. Each element in the buffer will contain the
+ * EPOW status in it's bit representation for a particular EPOW sub
+ * class as defiend here. So multiple detailed EPOW status bits
+ * specific for any sub class can be represented in a single buffer
+ * element as it's bit representation.
+ */
+
+/* System EPOW type */
+enum OpalSysEpow {
+	OPAL_SYSEPOW_POWER	= 0,	/* Power EPOW */
+	OPAL_SYSEPOW_TEMP	= 1,	/* Temperature EPOW */
+	OPAL_SYSEPOW_COOLING	= 2,	/* Cooling EPOW */
+	OPAL_SYSEPOW_MAX	= 3,	/* Max EPOW categories */
+};
+
+/* Power EPOW */
+enum OpalSysPower {
+	OPAL_SYSPOWER_UPS	= 0x0001, /* System on UPS power */
+	OPAL_SYSPOWER_CHNG	= 0x0002, /* System power config change */
+	OPAL_SYSPOWER_FAIL	= 0x0004, /* System impending power failure */
+	OPAL_SYSPOWER_INCL	= 0x0008, /* System incomplete power */
+};
+
+/* Temperature EPOW */
+enum OpalSysTemp {
+	OPAL_SYSTEMP_AMB	= 0x0001, /* System over ambient temperature */
+	OPAL_SYSTEMP_INT	= 0x0002, /* System over internal temperature */
+	OPAL_SYSTEMP_HMD	= 0x0004, /* System over ambient humidity */
+};
+
+/* Cooling EPOW */
+enum OpalSysCooling {
+	OPAL_SYSCOOL_INSF	= 0x0001, /* System insufficient cooling */
+};
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __OPAL_API_H */
arch/powerpc/include/asm/opal.h +2 -1
index 042af1a..8b174f3 100644
@@ -141,7 +141,8 @@ int64_t opal_pci_fence_phb(uint64_t phb_id);
 int64_t opal_pci_reinit(uint64_t phb_id, uint64_t reinit_scope, uint64_t data);
 int64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t error_type, uint8_t mask_action);
 int64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t led_type, uint8_t led_action);
-int64_t opal_get_epow_status(__be64 *status);
+int64_t opal_get_epow_status(__be16 *epow_status, __be16 *num_epow_classes);
+int64_t opal_get_dpo_status(__be64 *dpo_timeout);
 int64_t opal_set_system_attention_led(uint8_t led_action);
 int64_t opal_pci_next_error(uint64_t phb_id, __be64 *first_frozen_pe,
 			    __be16 *pci_error_type, __be16 *severity);
arch/powerpc/platforms/powernv/opal-power.c +109 -16

163 lines not on this page · raw message

arch/powerpc/platforms/powernv/opal-wrappers.S +1 -0
index a7ade94..5d3c8e3 100644
@@ -249,6 +249,7 @@ OPAL_CALL(opal_pci_reinit,			OPAL_PCI_REINIT);
 OPAL_CALL(opal_pci_mask_pe_error,		OPAL_PCI_MASK_PE_ERROR);
 OPAL_CALL(opal_set_slot_led_status,		OPAL_SET_SLOT_LED_STATUS);
 OPAL_CALL(opal_get_epow_status,			OPAL_GET_EPOW_STATUS);
+OPAL_CALL(opal_get_dpo_status,			OPAL_GET_DPO_STATUS);
 OPAL_CALL(opal_set_system_attention_led,	OPAL_SET_SYSTEM_ATTENTION_LED);
 OPAL_CALL(opal_pci_next_error,			OPAL_PCI_NEXT_ERROR);
 OPAL_CALL(opal_pci_poll,			OPAL_PCI_POLL);
Signature · 1 line
1.9.3
#2 lore raw

Re: [v6] powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform

Quoted 10 lines · Vipin K Parashar

This patch adds support for FSP (Flexible Service Processor) EPOW (Early Power Off Warning) and DPO (Delayed Power Off) events for the PowerNV platform. EPOW events are generated by FSP due to various critical system conditions that require system shutdown. A few examples of these conditions are high ambient temperature or system running on UPS power with low UPS battery. DPO event is generated in response to admin initiated system shutdown request. Upon receipt of EPOW and DPO events the host kernel invokes orderly_poweroff() for performing graceful system shutdown.

Quoted 4 lines

Hi Vipin,

One issue, on mambo I'm seeing:

[666973573,3] OPAL: Called with bad token 105 !
opal-power: Existing DPO event detected.
reboot: Failed to start orderly shutdown: forcing the issue
reboot: Power down
[684431322,5] OPAL: Shutdown request type 0x0...

ie. at boot it shuts down immediately.

The problem is in here I think:

arch/powerpc/platforms/powernv/opal-power.c line 38

Quoted 6 lines
arch/powerpc/platforms/powernv/opal-power.c +6 -0
+	/* Check for DPO event */
+	rc = opal_get_dpo_status(&opal_dpo_timeout);
+	if (rc != OPAL_WRONG_STATE) {
+		pr_info("Existing DPO event detected.\n");
+		return true;
+	}

This also makes me think you probably haven't tested this on a BMC machine?

cheers

#3 lore raw

Re: [v6] powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform

Quoted 11 lines · Michael Ellerman
Quoted 10 lines · Vipin K Parashar

This patch adds support for FSP (Flexible Service Processor) EPOW (Early Power Off Warning) and DPO (Delayed Power Off) events for the PowerNV platform. EPOW events are generated by FSP due to various critical system conditions that require system shutdown. A few examples of these conditions are high ambient temperature or system running on UPS power with low UPS battery. DPO event is generated in response to admin initiated system shutdown request. Upon receipt of EPOW and DPO events the host kernel invokes orderly_poweroff() for performing graceful system shutdown.

Quoted 7 lines
Quoted 4 lines

Hi Vipin,

And on my Tuleta I get:

opal-power: OPAL EPOW, DPO support detected.
opal-power: Existing EPOW event detected.
reboot: Failed to start orderly shutdown: forcing the issue

------------[ cut here ]------------
WARNING: at kernel/workqueue.c:818
Modules linked in:
CPU: 3 PID: 26 Comm: migration/3 Not tainted 4.1.0-rc3-13669-g704921b #80
task: c000000ff1745440 ti: c000000ff17ac000 task.ti: c000000ff17ac000
NIP: c0000000000ba48c LR: c0000000000ba430 CTR: c0000000000dbac0
REGS: c000000ff17af7d0 TRAP: 0700   Not tainted  (4.1.0-rc3-13669-g704921b)
MSR: 9000000100029033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR: 20000044  XER: 00000000

CFAR: c0000000000ba44c SOFTE: 0
GPR00: c0000000000cec7c c000000ff17afa50 c000000000d7ce20 c000000ff160fcc0
GPR04: 0000000000000000 0000000000000000 c000000000e10468 0000000000000000
GPR08: c000000000d2ce20 c000000ff90dd400 0000000000000001 c000000ff901dc98
GPR12: 0000000040000082 c000000001dc0d80 c0000000000c0b18 c000000ff817a540
GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000ff8380000
GPR24: c000000000c9dc00 c000000000daa8e0 c000000ff901dc00 0000000000000000
GPR28: 0000000000000004 c000000ff174ae04 c000000ff901dc00 0000000000000000 NIP [c0000000000ba48c] wq_worker_waking_up+0x7c/0xa0
LR [c0000000000ba430] wq_worker_waking_up+0x20/0xa0

Call Trace:

[c000000ff17afa50] [c000000ff1749bc0] 0xc000000ff1749bc0 (unreliable) [c000000ff17afa80] [c0000000000cec7c] ttwu_do_activate.constprop.76+0x6c/0xa0 [c000000ff17afab0] [c0000000000d2958] try_to_wake_up+0x208/0x4a0 [c000000ff17afb30] [c0000000000eab94] __wake_up_common+0x84/0xf0 [c000000ff17afb90] [c0000000000eb744] complete+0x54/0x90 [c000000ff17afbd0] [c00000000014bac4] cpu_stop_signal_done+0x54/0x70 [c000000ff17afbf0] [c00000000014c324] cpu_stopper_thread+0xd4/0x1f0 [c000000ff17afd20] [c0000000000c5b20] smpboot_thread_fn+0x280/0x290 [c000000ff17afd80] [c0000000000c0c18] kthread+0x108/0x130 [c000000ff17afe30] [c00000000000956c] ret_from_kernel_thread+0x5c/0x70 Instruction dump:
7d00512d 40c2fff4 38210030 e8010010 ebe1fff8 7c0803a6 4e800020 60000000 60420000 3d02fffb 8948db7e 694a0001 <0b0a0000> 2faa0000 41feffbc 39400001

---[ end trace de25982dcf3cffd9 ]---

reboot: Power down

cheers

#4 lore raw

Re: [v6] powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform

In reply to Michael Ellerman
Quoted 28 lines · Michael Ellerman
Quoted 10 lines · Vipin K Parashar

This patch adds support for FSP (Flexible Service Processor) EPOW (Early Power Off Warning) and DPO (Delayed Power Off) events for the PowerNV platform. EPOW events are generated by FSP due to various critical system conditions that require system shutdown. A few examples of these conditions are high ambient temperature or system running on UPS power with low UPS battery. DPO event is generated in response to admin initiated system shutdown request. Upon receipt of EPOW and DPO events the host kernel invokes orderly_poweroff() for performing graceful system shutdown.

Quoted 4 lines

Hi Vipin,

One issue, on mambo I'm seeing:

[666973573,3] OPAL: Called with bad token 105 !
opal-power: Existing DPO event detected.
reboot: Failed to start orderly shutdown: forcing the issue
reboot: Power down
[684431322,5] OPAL: Shutdown request type 0x0...

ie. at boot it shuts down immediately.

Quoted 8 lines

The problem is in here I think:

arch/powerpc/platforms/powernv/opal-power.c line 38

Quoted 6 lines
arch/powerpc/platforms/powernv/opal-power.c +6 -0
+	/* Check for DPO event */
+	rc = opal_get_dpo_status(&opal_dpo_timeout);
+	if (rc != OPAL_WRONG_STATE) {
+		pr_info("Existing DPO event detected.\n");
+		return true;
+	}

Thanks for catching it. EPOW, DPO doesn't exist for BMC and thus we shouldn't be hitting this path on BMC/mambo. Bug exists below down where we check for
epow device-tree node . This bug got introduced with this version of
patch
when i renamed epow_dpo_supported flag with supported flag and re-organized code. Will send out fix for this. Above if cond is also isn't prefect so will fix it too with new patch.

For FSP systems please use below FW patch to make it avoid notifications which doesn't cause EPOW. Its already in recent skiboot tree.
Commit id 1954251ca83b8a458193e629d15da06d00643ae8

https://patchwork.ozlabs.org/patch/472303/

Quoted 5 lines

This also makes me think you probably haven't tested this on a BMC machine?

cheers