From patchwork Wed Jun 28 23:38:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 781966 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wyfQ64c1Lz9s74 for ; Thu, 29 Jun 2017 09:39:10 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wyfQ63sy3zDr5j for ; Thu, 29 Jun 2017 09:39:10 +1000 (AEST) 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 3wyfPY1X5HzDr1f for ; Thu, 29 Jun 2017 09:38:41 +1000 (AEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5SNTxV5013446 for ; Wed, 28 Jun 2017 19:38:39 -0400 Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bcp2t8c8b-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 28 Jun 2017 19:38:38 -0400 Received: from localhost by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 29 Jun 2017 09:38:36 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 29 Jun 2017 09:38:34 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v5SNcXYB4063710 for ; Thu, 29 Jun 2017 09:38:33 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v5SNcV42008815 for ; Thu, 29 Jun 2017 09:38:31 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v5SNcVie008809; Thu, 29 Jun 2017 09:38:31 +1000 Received: from camb691.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id A085FA01B5; Thu, 29 Jun 2017 09:38:32 +1000 (AEST) From: Cyril Bur To: skiboot@lists.ozlabs.org Date: Thu, 29 Jun 2017 09:38:02 +1000 X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170628233804.18412-1-cyril.bur@au1.ibm.com> References: <20170628233804.18412-1-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable x-cbid: 17062823-0012-0000-0000-0000024EDF8C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17062823-0013-0000-0000-00000767A10C Message-Id: <20170628233804.18412-2-cyril.bur@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-28_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706280375 Subject: [Skiboot] [PATCH 2/4] core/flash: Make flash_reserve() and flash_release() use any flash 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: , Cc: alistair@popple.id.au, sam@mendozajonas.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Now that skiboot can have multiple flashes it doesn't make sense for flash_reserve() and flash_release() to only operate on system_flash. New functions system_flash_reserve() and system_flash_release() preserve the current functionality of flash_reserve() and flash_release() and flash_reserve() and flash_releasei() can now be used to mark any flash as busy. Signed-off-by: Cyril Bur Reviewed-by: Alistair Popple --- core/flash.c | 20 +++++++++++++++----- hw/ipmi/ipmi-sel.c | 4 ++-- include/skiboot.h | 4 ++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/core/flash.c b/core/flash.c index f0390394..a905e986 100644 --- a/core/flash.c +++ b/core/flash.c @@ -48,15 +48,15 @@ static struct lock flash_lock; static struct flash *nvram_flash; static u32 nvram_offset, nvram_size; -bool flash_reserve(void) +static bool flash_reserve(struct flash *flash) { bool rc = false; if (!try_lock(&flash_lock)) return false; - if (!system_flash->busy) { - system_flash->busy = true; + if (!flash->busy) { + flash->busy = true; rc = true; } unlock(&flash_lock); @@ -64,13 +64,23 @@ bool flash_reserve(void) return rc; } -void flash_release(void) +static void flash_release(struct flash *flash) { lock(&flash_lock); - system_flash->busy = false; + flash->busy = false; unlock(&flash_lock); } +bool system_flash_reserve(void) +{ + return flash_reserve(system_flash); +} + +void system_flash_release(void) +{ + flash_release(system_flash); +} + static int flash_nvram_info(uint32_t *total_size) { int rc; diff --git a/hw/ipmi/ipmi-sel.c b/hw/ipmi/ipmi-sel.c index 5c766472..14d10db2 100644 --- a/hw/ipmi/ipmi-sel.c +++ b/hw/ipmi/ipmi-sel.c @@ -475,7 +475,7 @@ static void sel_pnor(uint8_t access) break; } - granted = flash_reserve(); + granted = system_flash_reserve(); if (granted) occ_pnor_set_owner(PNOR_OWNER_EXTERNAL); /* Ack the request */ @@ -484,7 +484,7 @@ static void sel_pnor(uint8_t access) break; case RELEASE_PNOR: prlog(PR_NOTICE, "PNOR access released\n"); - flash_release(); + system_flash_release(); occ_pnor_set_owner(PNOR_OWNER_HOST); break; default: diff --git a/include/skiboot.h b/include/skiboot.h index 1a153b02..785986cf 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -235,8 +235,8 @@ extern int flash_register(struct blocklevel_device *bl); extern int flash_start_preload_resource(enum resource_id id, uint32_t subid, void *buf, size_t *len); extern int flash_resource_loaded(enum resource_id id, uint32_t idx); -extern bool flash_reserve(void); -extern void flash_release(void); +extern bool system_flash_reserve(void); +extern void system_flash_release(void); #define FLASH_SUBPART_ALIGNMENT 0x1000 #define FLASH_SUBPART_HEADER_SIZE FLASH_SUBPART_ALIGNMENT extern int flash_subpart_info(void *part_header, uint32_t header_len,