aboutsummaryrefslogtreecommitdiff
path: root/libflash/blocklevel.h
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2017-04-06 11:38:47 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-04-07 14:51:33 +1000
commitd6a5b53f878bb422cfd2a960fff9dce5e3bb4117 (patch)
tree4dd486b661a8499ad55f506120b4bb4fb999e583 /libflash/blocklevel.h
parent6e393c989a861cac2dac359c8e6ba1d5fc952279 (diff)
downloadskiboot-d6a5b53f878bb422cfd2a960fff9dce5e3bb4117.zip
skiboot-d6a5b53f878bb422cfd2a960fff9dce5e3bb4117.tar.gz
skiboot-d6a5b53f878bb422cfd2a960fff9dce5e3bb4117.tar.bz2
libflash/blocklevel: Add blocklevel_smart_erase()
With recent changes to flash drivers in linux not all erase blocks are 4K anymore. While most level of the pflash/gard tool stacks were written to not mind, it turns out there are bugs which means not 4K erase block backing stores aren't handled all that well. Part of the problem is the FFS layout that is 4K aligned and with larger block sizes pflash and the gard tool don't check if their erase commands are erase block aligned - which they are usually not with 64K erase blocks. This patch aims to add common functionality to blocklevel so that (at least) pflash and the gard tool don't need to worry about the problem anymore. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libflash/blocklevel.h')
-rw-r--r--libflash/blocklevel.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/libflash/blocklevel.h b/libflash/blocklevel.h
index 09f0096..ba42c83 100644
--- a/libflash/blocklevel.h
+++ b/libflash/blocklevel.h
@@ -1,4 +1,4 @@
-/* Copyright 2013-2015 IBM Corp.
+/* Copyright 2013-2017 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,6 +75,14 @@ int blocklevel_get_info(struct blocklevel_device *bl, const char **name, uint64_
*/
int blocklevel_smart_write(struct blocklevel_device *bl, uint64_t pos, const void *buf, uint64_t len);
+/*
+ * blocklevel_smart_erase() will handle unaligned erases.
+ * blocklevel_erase() expects a erase_granule aligned buffer and the
+ * erase length to be an exact multiple of erase_granule,
+ * blocklevel_smart_erase() solves this requirement by performing a
+ * read erase write under the hood.
+ */
+int blocklevel_smart_erase(struct blocklevel_device *bl, uint64_t pos, uint64_t len);
/* Implemented in software at this level */
int blocklevel_ecc_protect(struct blocklevel_device *bl, uint32_t start, uint32_t len);