From patchwork Fri Jan 30 00:31:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 434694 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 363A814007D for ; Fri, 30 Jan 2015 11:32:39 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 1E45E1A0D8B for ; Fri, 30 Jan 2015 11:32:39 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pa0-x22d.google.com (mail-pa0-x22d.google.com [IPv6:2607:f8b0:400e:c03::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 6BD8E1A0D30 for ; Fri, 30 Jan 2015 11:32:36 +1100 (AEDT) Received: by mail-pa0-f45.google.com with SMTP id et14so45109088pad.4 for ; Thu, 29 Jan 2015 16:32:34 -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; bh=E0KO66JwPqNfaeWWPRr4qqdEy5y0QQUcdB8fg43BPEY=; b=I2/Th5Gj5jdiMn2uaS1UE0rCBvmWNsOzZ5wepevkHZL4o4sPWHPVSnCekABcTj8x1/ Zeje1FjoVakXhEoXDoQhShE0eFetzwkuBi3CzVhb0PVvmEX4UvW/gBzdgU5fU7ztQt6s Ufkj4bHjij6VCVrbWdR19wzEl2+8FAfWECuOY= 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; bh=E0KO66JwPqNfaeWWPRr4qqdEy5y0QQUcdB8fg43BPEY=; b=Tnoi53fct9ANdEO6pvySDF1e89iZQFrFkgaYDQPUKL56bSfEQCz6HFkInxp0IA1uf5 GcPtp/lNqUZ3Z4cBoFk5z+50YGS8xVDCw40c9u532538cidL9mno4FNX8INHcJqnDA+H y36Q+8bcWymLbYb50Gh+SU5XdYHUZiMRoCSXWzb5j8HSMOCHd5FTGRY7rrNCXjvMbB+d 5P7+MaEeDmSxUQsllBdp6X/ocl6oyKiM+l0sRh9DctIFHEI2iSAVQMDxSpOktsI8ZQLf Y2Gg/vfa7nmrpJJ3t8zkf+YD+uPBtUcvEwsWZ882BuaJ6g8WrR7I8QqsSonLGOLKeeIC bWGQ== X-Gm-Message-State: ALoCoQmvfje9C7S1m8wCQN1ZflrC6gdfcP8lHbwOHU9jjXIdKBtt4eQvsC3ofWIUItv5tkdUL0K/ X-Received: by 10.66.119.172 with SMTP id kv12mr3423819pab.72.1422577954743; Thu, 29 Jan 2015 16:32:34 -0800 (PST) Received: from icarus.au.ibm.com (ppp121-45-7-169.lns20.adl2.internode.on.net. [121.45.7.169]) by mx.google.com with ESMTPSA id ca2sm8864916pbc.68.2015.01.29.16.32.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 16:32:34 -0800 (PST) From: Joel Stanley To: skiboot@lists.ozlabs.org Date: Fri, 30 Jan 2015 11:01:51 +1030 Message-Id: <1422577911-18394-6-git-send-email-joel@jms.id.au> X-Mailer: git-send-email 2.1.4 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 5/5] ipmi: Disable nvram accesses when requested 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" BMC based systems contain a PNOR to provide nvram storage. The host normally has exclusive access to the PNOR, however the BMC may use IPMI to request access to perform functions such as update the firmware. Indicate to users of the opal_vmram_{read,write} functions that the device is busy. Signed-off-by: Joel Stanley --- core/nvram.c | 7 +++++++ hw/ipmi/ipmi-sel.c | 22 ++++++++++++++++++++++ include/skiboot.h | 1 + 3 files changed, 30 insertions(+) diff --git a/core/nvram.c b/core/nvram.c index f25d6aa..bd69737 100644 --- a/core/nvram.c +++ b/core/nvram.c @@ -25,6 +25,13 @@ static void *nvram_image; static uint32_t nvram_size; static bool nvram_ready; +/* If another device (eg. BMC) is touching the nvram, we can mark it as busy + * to stop access */ +void nvram_set_ready(bool state) +{ + nvram_ready = state; +} + static int64_t opal_read_nvram(uint64_t buffer, uint64_t size, uint64_t offset) { if (!nvram_ready) diff --git a/hw/ipmi/ipmi-sel.c b/hw/ipmi/ipmi-sel.c index 291f279..f25d004 100644 --- a/hw/ipmi/ipmi-sel.c +++ b/hw/ipmi/ipmi-sel.c @@ -41,6 +41,9 @@ #define SOFT_OFF 0x00 #define SOFT_REBOOT 0x01 +#define RELEASE_PNOR 0x00 +#define REQUEST_PNOR 0x01 + struct oem_sel { /* SEL header */ uint8_t id[2]; @@ -180,6 +183,24 @@ int ipmi_elog_commit(struct errorlog *elog_buf) return 0; } +static void sel_pnor(uint8_t access) +{ + switch (access) { + case REQUEST_PNOR: + prlog(PR_NOTICE, "IPMI: PNOR access requested\n"); + nvram_set_ready(false); + /* TODO: Ack the request */ + break; + case RELEASE_PNOR: + prlog(PR_NOTICE, "IPMI: PNOR access released\n"); + nvram_set_ready(true); + break; + default: + prlog(PR_ERR, "IPMI: invalid PNOR access requested: %02x\n", + access); + } +} + static void sel_power(uint8_t power) { switch (power) { @@ -248,6 +269,7 @@ void ipmi_parse_sel(struct ipmi_msg *msg) sel_power(sel.data[0]); break; case CMD_AMI_PNOR_ACCESS: + sel_pnor(sel.data[0]); break; default: printf("IPMI: unknown OEM SEL command %02x received\n", diff --git a/include/skiboot.h b/include/skiboot.h index 1b55638..8a38758 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -199,6 +199,7 @@ extern void occ_fsp_init(void); /* NVRAM support */ extern void nvram_init(void); extern void nvram_read_complete(bool success); +extern void nvram_set_ready(bool state); /* NVRAM on flash helper */ struct flash_chip;