From patchwork Thu Feb 5 03:10:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 436572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6FD82140216 for ; Thu, 5 Feb 2015 14:10:40 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 5ED501A0C04 for ; Thu, 5 Feb 2015 14:10:40 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id AEFF51A0BDA for ; Thu, 5 Feb 2015 14:10:37 +1100 (AEDT) Received: by pdjy10 with SMTP id y10so4813809pdj.7 for ; Wed, 04 Feb 2015 19:10:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=S+7L92p8Y1Ov3VjiMWVHEzwFiylFBmaBoI7u8QMkYCY=; b=M3XQ5H2dGXdTBQ66RSaOxCKYQGXsH2xVjZpKVx0fRHcrGo38Sw6kGEOpv/OqNX+UBn H4djUsUTlebvXmXfC0zKti8GIonUC8XrI0iZVf+ajJZmG7kID63XUgW7B3O1HowLC74o G50N5vXEbPWykGhe3X7UFhRhYiKUHCRKwsm1o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=S+7L92p8Y1Ov3VjiMWVHEzwFiylFBmaBoI7u8QMkYCY=; b=L9iihBZlHyqPQcLzuFtuprHlYLW+k/9Y9ZqNxSrILn6ZSKugmaa9hK6TgGEAd1la9T FExig3etjoZxoQHiLr7qsHLBxy2zDqGSODZL5JfdJub4Du2m7Nl2K64VHvClfzHTJgle L9nNHBJQG/E2PRQARzVRbaBgJozaT024hrbtt3NmJIVmlrrCc6YodXf4dQZ6ImXG+NdC BwAsz5Ola8KzucCk6KyKrcnH6pf6yIx+Azzv3QQI1GYK2pZ0xITXxX/OKuK3ysXuAoDY gTHBt2x+BPThrsYWWZvTnnIaTZ/UdMgjK3jWWUobRX+HLF7JEN1rBLou1VQ14JNr/+0e hJrA== X-Gm-Message-State: ALoCoQkWLKDmHITbBm3zr5UtzunyKt4nlJwFMJxqbTrcUz8UyPo+8maj5wnjjJovgYEhqKXb4cTO X-Received: by 10.70.140.44 with SMTP id rd12mr2381459pdb.64.1423105835911; Wed, 04 Feb 2015 19:10:35 -0800 (PST) Received: from icarus.au.ibm.com (220-244-113-206.static.tpgi.com.au. [220.244.113.206]) by mx.google.com with ESMTPSA id zo7sm3435594pab.8.2015.02.04.19.10.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Feb 2015 19:10:35 -0800 (PST) From: Joel Stanley To: skiboot@lists.ozlabs.org Date: Thu, 5 Feb 2015 13:40:05 +1030 Message-Id: <1423105805-3816-5-git-send-email-joel@jms.id.au> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1423105805-3816-1-git-send-email-joel@jms.id.au> References: <1423105805-3816-1-git-send-email-joel@jms.id.au> In-Reply-To: <1422577911-18394-1-git-send-email-joel@jms.id.au> References: <1422577911-18394-1-git-send-email-joel@jms.id.au> Subject: [Skiboot] [PATCH 4/4] ipmi: Message Linux to perform graceful shutdown X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This sends the previously unused OPAL_MSG_SHUTDOWN using opal_queue_msg to initiate a graceful shutdown. The message provides a single parameter indicating weather the shutdown is will result in a power-off, or a reboot. Signed-off-by: Joel Stanley --- doc/opal-api/opal-messages.txt | 57 ++++++++++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi-sel.c | 22 ++++++++++++++++ include/opal.h | 2 +- 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 doc/opal-api/opal-messages.txt diff --git a/doc/opal-api/opal-messages.txt b/doc/opal-api/opal-messages.txt new file mode 100644 index 0000000..df10236 --- /dev/null +++ b/doc/opal-api/opal-messages.txt @@ -0,0 +1,57 @@ +OAPL_MESSAGE +============ + +The host OS can use OPAL_GET_MSG to retrive messages queued by OPAL. The +messages are defined by enum OpalMessageType. + +OPAL_MSG_ASYNC_COMP +------------------- + +params[0] = token +params[1] = rc + +Additional parameters are function-specific. + +OPAL_MSG_MEM_ERR +---------------- + +OPAL_MSG_EPOW +------------- + +OPAL_MSG_SHUTDOWN +----------------- + +Used by OPAL to inform the host OS it must imitate a graceful shutdown. Uses +the first parameter to indicate weather the system is going down for shutdown +or a reboot. + +params[0] = 0x01 reboot, 0x00 shutdown + +OPAL_MSG_HMI_EVT +---------------- + +Sends the OPAL HMI Event to the host OS + +TODO: Describe what HMI is + +struct OpalHMIEvent { + uint8_t version; /* 0x00 */ + uint8_t severity; /* 0x01 */ + uint8_t type; /* 0x02 */ + uint8_t disposition; /* 0x03 */ + uint8_t reserved_1[4]; /* 0x04 */ + + uint64_t hmer; + /* TFMR register. Valid only for TFAC and TFMR_PARITY error type. */ + uint64_t tfmr; +}; + + +OPAL_MSG_DPO +------------ + +Used for delayed power off, where OPAL can inform a host OS that it intends to +perform a shutdown in the future. + +The host OS can use the separate API OPAL_GET_DPO_STATUS to query OPAL for the +number of seconds before a forced shutdown will occur. diff --git a/hw/ipmi/ipmi-sel.c b/hw/ipmi/ipmi-sel.c index 3d4fbf7..1f4ad11 100644 --- a/hw/ipmi/ipmi-sel.c +++ b/hw/ipmi/ipmi-sel.c @@ -21,6 +21,7 @@ #include #include #include +#include /* OEM SEL fields */ #define SEL_OEM_ID_0 0x55 @@ -34,6 +35,9 @@ #define CMD_AMI_POWER 0x04 #define CMD_AMI_PNOR_ACCESS 0x07 +#define SOFT_OFF 0x00 +#define SOFT_REBOOT 0x01 + struct oem_sel { /* SEL header */ uint8_t id[2]; @@ -173,6 +177,23 @@ int ipmi_elog_commit(struct errorlog *elog_buf) return 0; } +static void sel_power(uint8_t power) +{ + switch (power) { + case SOFT_OFF: + prlog(PR_NOTICE, "IPMI: soft shutdown requested\n"); + opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, SOFT_OFF); + break; + case SOFT_REBOOT: + prlog(PR_NOTICE, "IPMI: soft reboot rqeuested\n"); + opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, SOFT_REBOOT); + break; + default: + prlog(PR_WARNING, "IPMI: requested bad power state: %02x\n", + power); + } +} + static void dump_sel(struct oem_sel *sel) { const int level = PR_DEBUG; @@ -218,6 +239,7 @@ void ipmi_parse_sel(struct ipmi_msg *msg) switch (sel.cmd) { case CMD_AMI_POWER: + sel_power(sel.data[0]); break; case CMD_AMI_PNOR_ACCESS: break; diff --git a/include/opal.h b/include/opal.h index 6c9b13a..679a0d9 100644 --- a/include/opal.h +++ b/include/opal.h @@ -395,7 +395,7 @@ enum OpalMessageType { */ OPAL_MSG_MEM_ERR, OPAL_MSG_EPOW, - OPAL_MSG_SHUTDOWN, + OPAL_MSG_SHUTDOWN, /* params[0] = 1 reboot, 0 shutdown */ OPAL_MSG_HMI_EVT, OPAL_MSG_DPO, OPAL_MSG_TYPE_MAX,