powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform
PATCH v9 1/1 powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform
This patch adds support for OPAL EPOW (Environmental and Power Warnings) and DPO (Delayed Power Off) events for the PowerNV platform. These events are generated on FSP (Flexible Service Processor) based systems. EPOW events are generated 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 v9:
- Edited commit log for EPOW acronym expansion and reviewers list.
Changes in v8:
- Added logic to filter events which doesn't require system shutdown for EPOW scenario.
- Re-phrased patch description.
Changes in v7:
- Fixed logic to check epow support to avoid EPOW, DPO handling path for BMC systems.
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 | 147 ++++++++++++++++++++++--- arch/powerpc/platforms/powernv/opal-wrappers.S | 1 + 4 files changed, 173 insertions(+), 18 deletions(-)
Signature · 1 line
1.9.3
PATCH v9 1/1 powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform
This patch adds support for OPAL EPOW (Environmental and Power Warnings) and DPO (Delayed Power Off) events for the PowerNV platform. These events are generated on FSP (Flexible Service Processor) based systems. EPOW events are generated 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 | 147 ++++++++++++++++++++++--- arch/powerpc/platforms/powernv/opal-wrappers.S | 1 + 4 files changed, 173 insertions(+), 18 deletions(-)
arch/powerpc/include/asm/opal-api.h +40 -0
@@ -756,6 +756,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
@@ -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 +130 -17
185 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-wrappers.S +1 -0
@@ -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
Quoted 10 lines · Vipin K Parashar
This patch adds support for OPAL EPOW (Environmental and Power Warnings) and DPO (Delayed Power Off) events for the PowerNV platform. These events are generated on FSP (Flexible Service Processor) based systems. EPOW events are generated 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 2 lines
Signed-off-by Vipin K Parashar <[email protected]>Acked-by Vaibhav Jain <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/3b476aadbc1409fef6be
cheers