From patchwork Tue Nov 8 05:15:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 692143 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tCcvz0QlPz9t5m for ; Tue, 8 Nov 2016 16:15:43 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tCcvy6Hx5zDvd7 for ; Tue, 8 Nov 2016 16:15:42 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tCcvr6wZxzDt2W for ; Tue, 8 Nov 2016 16:15:36 +1100 (AEDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uA85DbPS120136 for ; Tue, 8 Nov 2016 00:15:35 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 26k593w2kf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 08 Nov 2016 00:15:34 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Nov 2016 22:15:34 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 7 Nov 2016 22:15:31 -0700 Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id AC1F93E4004C; Mon, 7 Nov 2016 22:15:30 -0700 (MST) Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uA85FUEh21430318; Tue, 8 Nov 2016 05:15:30 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21DFDAE03C; Tue, 8 Nov 2016 00:15:30 -0500 (EST) Received: from birb.localdomain (unknown [9.185.16.186]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 61D1DAE04B; Tue, 8 Nov 2016 00:15:29 -0500 (EST) Received: by birb.localdomain (Postfix, from userid 1000) id 0C97F229EAA2; Tue, 8 Nov 2016 16:15:25 +1100 (AEDT) From: Stewart Smith To: jk@ozlabs.org, skiboot@lists.ozlabs.org Date: Tue, 8 Nov 2016 16:15:24 +1100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478580199-5907-1-git-send-email-stewart@linux.vnet.ibm.com> References: <1478580199-5907-1-git-send-email-stewart@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16110805-0008-0000-0000-000006065FA3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006040; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000189; SDB=6.00778015; UDB=6.00374647; IPR=6.00555333; BA=6.00004862; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013247; XFM=3.00000011; UTC=2016-11-08 05:15:32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16110805-0009-0000-0000-00003CD2A708 Message-Id: <1478582124-9376-1-git-send-email-stewart@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-08_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611080093 Subject: [Skiboot] [PATCH v2] Add BMC platform to enable correct OEM IPMI commands X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 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" An out of tree platform (p8dtu) uses a different IPMI OEM command for IPMI_PARTIAL_ADD_ESEL. This exposed some assumptions about the BMC implementation in our core code. Now, with platform.bmc, each platform can dictate (or detect) the BMC that is present. We allow it to be set at runtime rather than purely statically in struct platform as it's possible to have differing BMC implementations on the one machine (e.g. AMI BMC or OpenBMC). Signed-off-by: Stewart Smith Acked-by: Jeremy Kerr --- Changes in V2: - just have the numbers in bmc_platform - have generic BMC platform, so bmc_platform always exists --- core/platform.c | 16 ++++++++++++++++ hw/ipmi/ipmi-sel.c | 21 +++++++++++++++++++-- include/ipmi.h | 4 ---- include/platform.h | 26 ++++++++++++++++++++++++++ platforms/astbmc/astbmc.h | 2 ++ platforms/astbmc/common.c | 6 ++++++ platforms/astbmc/firestone.c | 1 + platforms/astbmc/garrison.c | 1 + platforms/astbmc/habanero.c | 1 + platforms/astbmc/palmetto.c | 1 + 10 files changed, 73 insertions(+), 6 deletions(-) diff --git a/core/platform.c b/core/platform.c index 9171fa3..a7244a4 100644 --- a/core/platform.c +++ b/core/platform.c @@ -28,6 +28,7 @@ bool manufacturing_mode = false; struct platform platform; +const struct bmc_platform *bmc_platform = NULL; DEFINE_LOG_ENTRY(OPAL_RC_ABNORMAL_REBOOT, OPAL_PLATFORM_ERR_EVT, OPAL_CEC, OPAL_CEC_HARDWARE, OPAL_PREDICTIVE_ERR_FAULT_RECTIFY_REBOOT, @@ -122,12 +123,24 @@ static int64_t generic_cec_power_down(uint64_t request __unused) return OPAL_UNSUPPORTED; } +static struct bmc_platform generic_bmc = { + .name = "generic", +}; + static struct platform generic_platform = { .name = "generic", + .bmc = &generic_bmc, .init = generic_platform_init, .cec_power_down = generic_cec_power_down, }; +void set_bmc_platform(const struct bmc_platform *bmc) +{ + if (bmc) + prlog(PR_NOTICE, "PLAT: Detected BMC platform %s\n", bmc->name); + bmc_platform = bmc; +} + void probe_platform(void) { struct platform *platforms = &__platforms_start; @@ -154,8 +167,11 @@ void probe_platform(void) } prlog(PR_NOTICE, "PLAT: Detected %s platform\n", platform.name); + + set_bmc_platform(platform.bmc); } + int start_preload_resource(enum resource_id id, uint32_t subid, void *buf, size_t *len) { diff --git a/hw/ipmi/ipmi-sel.c b/hw/ipmi/ipmi-sel.c index 369cebc..b79959c 100644 --- a/hw/ipmi/ipmi-sel.c +++ b/hw/ipmi/ipmi-sel.c @@ -334,6 +334,11 @@ static void ipmi_elog_poll(struct ipmi_msg *msg) struct errorlog *elog_buf = (struct errorlog *) msg->user_data; size_t req_size; + if (bmc_platform->ipmi_oem_partial_add_esel == 0) { + prlog(PR_WARNING, "BUG: Dropping ESEL on the floor due to buggy/mising code in OPAL for this BMC"); + return; + } + ipmi_init_esel_record(); if (msg->cmd == IPMI_CMD(IPMI_RESERVE_SEL)) { first = true; @@ -386,7 +391,8 @@ static void ipmi_elog_poll(struct ipmi_msg *msg) req_size = IPMI_MAX_REQ_SIZE; } - ipmi_init_msg(msg, IPMI_DEFAULT_INTERFACE, IPMI_PARTIAL_ADD_ESEL, + ipmi_init_msg(msg, IPMI_DEFAULT_INTERFACE, + bmc_platform->ipmi_oem_partial_add_esel, ipmi_elog_poll, elog_buf, req_size, 2); msg->data[0] = reservation_id & 0xff; @@ -462,8 +468,19 @@ static void sel_pnor(uint8_t access) if (granted) occ_pnor_set_owner(PNOR_OWNER_EXTERNAL); + if (bmc_platform->ipmi_oem_pnor_access_status == 0) { + /** + * @fwts-label PNORAccessYeahButNoBut + * @fwts-advice OPAL doesn't know that the BMC supports + * PNOR access commands. This will be a bug in the OPAL + * support for this BMC. + */ + prlog(PR_ERR, "PNOR BUG: access requested but BMC doesn't support request\n"); + break; + } + /* Ack the request */ - msg = ipmi_mkmsg_simple(IPMI_PNOR_ACCESS_STATUS, &granted, 1); + msg = ipmi_mkmsg_simple(bmc_platform->ipmi_oem_pnor_access_status, &granted, 1); ipmi_queue_msg(msg); break; case RELEASE_PNOR: diff --git a/include/ipmi.h b/include/ipmi.h index a6791e4..7a30449 100644 --- a/include/ipmi.h +++ b/include/ipmi.h @@ -120,10 +120,6 @@ #define IPMI_GET_BT_CAPS IPMI_CODE(IPMI_NETFN_APP, 0x36) #define IPMI_SET_SENSOR_READING IPMI_CODE(IPMI_NETFN_SE, 0x30) -/* AMI OEM comamnds. AMI uses NETFN 0x3a and 0x32 */ -#define IPMI_PARTIAL_ADD_ESEL IPMI_CODE(0x32, 0xf0) -#define IPMI_PNOR_ACCESS_STATUS IPMI_CODE(0x3a, 0x07) - /* * IPMI response codes. */ diff --git a/include/platform.h b/include/platform.h index ff75adf..27bd66f 100644 --- a/include/platform.h +++ b/include/platform.h @@ -31,6 +31,22 @@ enum resource_id { #define RESOURCE_SUBID_NONE 0 #define RESOURCE_SUBID_SUPPORTED 1 +enum ipmi_oem_cmds { + IPMI_OEM_PARTIAL_ADD_ESEL, + IPMI_OEM_PNOR_ACCESS_STATUS +}; + +struct bmc_platform { + const char *name; + + /* + * Map IPMI_OEM_X to vendor commands for this BMC + * 0 = unimplimented + */ + uint32_t ipmi_oem_partial_add_esel; + uint32_t ipmi_oem_pnor_access_status; +}; + /* * Each platform can provide a set of hooks * that can affect the generic code @@ -39,6 +55,13 @@ struct platform { const char *name; /* + * If BMC is constant, bmc platform specified here. + * Platforms can also call set_bmc_platform() if BMC platform is + * not a constant. + */ + const struct bmc_platform *bmc; + + /* * Probe platform, return true on a match, called before * any allocation has been performed outside of the heap * so the platform can perform additional memory reservations @@ -174,6 +197,7 @@ extern struct platform __platforms_start; extern struct platform __platforms_end; extern struct platform platform; +extern const struct bmc_platform *bmc_platform; extern bool manufacturing_mode; @@ -189,4 +213,6 @@ extern int resource_loaded(enum resource_id id, uint32_t idx); extern int wait_for_resource_loaded(enum resource_id id, uint32_t idx); +extern void set_bmc_platform(const struct bmc_platform *bmc); + #endif /* __PLATFORM_H */ diff --git a/platforms/astbmc/astbmc.h b/platforms/astbmc/astbmc.h index 322282e..fbba095 100644 --- a/platforms/astbmc/astbmc.h +++ b/platforms/astbmc/astbmc.h @@ -41,6 +41,8 @@ struct slot_table_entry { const struct slot_table_entry *children; }; +extern const struct bmc_platform astbmc_ami; + extern void astbmc_early_init(void); extern int64_t astbmc_ipmi_reboot(void); extern int64_t astbmc_ipmi_power_down(uint64_t request); diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c index e1a8a4d..19dc3ca 100644 --- a/platforms/astbmc/common.c +++ b/platforms/astbmc/common.c @@ -357,3 +357,9 @@ void astbmc_early_init(void) prd_init(); } + +const struct bmc_platform astbmc_ami = { + .name = "AMI", + .ipmi_oem_partial_add_esel = IPMI_CODE(0x32, 0xf0), + .ipmi_oem_pnor_access_status = IPMI_CODE(0x3a, 0x07), +}; diff --git a/platforms/astbmc/firestone.c b/platforms/astbmc/firestone.c index c4e6b2a..3c36660 100644 --- a/platforms/astbmc/firestone.c +++ b/platforms/astbmc/firestone.c @@ -146,6 +146,7 @@ static bool firestone_probe(void) DECLARE_PLATFORM(firestone) = { .name = "Firestone", + .bmc = &astbmc_ami, .probe = firestone_probe, .init = astbmc_init, .pci_get_slot_info = slot_table_get_slot_info, diff --git a/platforms/astbmc/garrison.c b/platforms/astbmc/garrison.c index f400a51..ba7211f 100644 --- a/platforms/astbmc/garrison.c +++ b/platforms/astbmc/garrison.c @@ -293,6 +293,7 @@ static bool garrison_probe(void) DECLARE_PLATFORM(garrison) = { .name = "Garrison", + .bmc = &astbmc_ami, .probe = garrison_probe, .init = astbmc_init, .pci_get_slot_info = slot_table_get_slot_info, diff --git a/platforms/astbmc/habanero.c b/platforms/astbmc/habanero.c index 738aa63..4640e3a 100644 --- a/platforms/astbmc/habanero.c +++ b/platforms/astbmc/habanero.c @@ -141,6 +141,7 @@ static bool habanero_probe(void) DECLARE_PLATFORM(habanero) = { .name = "Habanero", + .bmc = &astbmc_ami, .probe = habanero_probe, .init = astbmc_init, .pci_get_slot_info = slot_table_get_slot_info, diff --git a/platforms/astbmc/palmetto.c b/platforms/astbmc/palmetto.c index 033f103..58ed861 100644 --- a/platforms/astbmc/palmetto.c +++ b/platforms/astbmc/palmetto.c @@ -46,6 +46,7 @@ static bool palmetto_probe(void) DECLARE_PLATFORM(palmetto) = { .name = "Palmetto", .probe = palmetto_probe, + .bmc = &astbmc_ami, .init = astbmc_init, .external_irq = astbmc_ext_irq_serirq_cpld, .cec_power_down = astbmc_ipmi_power_down,