diff mbox series

[v3,02/13] core/flash: Make flash_reserve() and flash_release() use any flash

Message ID 1578338508-13424-3-git-send-email-debmc@linux.ibm.com
State New, archived
Headers show
Series ipmi-hiomap: Enablement for Async opal_flash_op's | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d75e82dbfbb9443efeb3f9a5921ac23605aab469)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Deb McLemore Jan. 6, 2020, 7:21 p.m. UTC
From: Cyril Bur <cyril.bur@au1.ibm.com>

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 <cyril.bur@au1.ibm.com>
Reviewed-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
---
 core/flash.c       | 20 +++++++++++++++-----
 hw/ipmi/ipmi-sel.c |  4 ++--
 include/skiboot.h  |  4 ++--
 3 files changed, 19 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/core/flash.c b/core/flash.c
index 2f041db..78e0023 100644
--- a/core/flash.c
+++ b/core/flash.c
@@ -60,15 +60,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);
@@ -76,10 +76,10 @@  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);
 }
 
@@ -94,6 +94,16 @@  bool flash_unregister(void)
 	return true;
 }
 
+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 794aa38..ec4a318 100644
--- a/hw/ipmi/ipmi-sel.c
+++ b/hw/ipmi/ipmi-sel.c
@@ -463,7 +463,7 @@  static void sel_pnor(uint8_t access, void *context __unused)
 			break;
 		}
 
-		granted = flash_reserve();
+		granted = system_flash_reserve();
 		if (granted)
 			occ_pnor_set_owner(PNOR_OWNER_EXTERNAL);
 		/* Ack the request */
@@ -472,7 +472,7 @@  static void sel_pnor(uint8_t access, void *context __unused)
 		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 e9d57de..2cb4160 100644
--- a/include/skiboot.h
+++ b/include/skiboot.h
@@ -217,8 +217,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);
 extern bool flash_unregister(void);
 #define FLASH_SUBPART_ALIGNMENT 0x1000
 #define FLASH_SUBPART_HEADER_SIZE FLASH_SUBPART_ALIGNMENT