[Skiboot] [PATCH 12/13] gard: Always use MTD to access flash

Oliver O'Halloran oohall at gmail.com
Wed Nov 8 19:59:17 AEDT 2017


Direct mode is generally either unsafe or unsupported. We should always
access the PNOR via an MTD device so make that the default. If someone
really needs direct mode, then they can use pflash.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 external/gard/gard.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/external/gard/gard.c b/external/gard/gard.c
index 1ee54e6b3d99..815243457cf5 100644
--- a/external/gard/gard.c
+++ b/external/gard/gard.c
@@ -879,6 +879,14 @@ int main(int argc, char **argv)
 #endif
 	}
 
+	/*
+	 * Force libflash to do flash accesses via the MTD. Direct mode is
+	 * generally unsafe since it fiddles with the flash controller state
+	 * underneath the kernel. Anyone who needs direct mode can use pflash
+	 * instead.
+	 */
+	arch_flash_access(ctx->bl, PNOR_MTD);
+
 	if (arch_flash_init(&(ctx->bl), filename, true)) {
 		/* Can fail for a few ways, most likely couldn't open MTD device */
 		fprintf(stderr, "Can't open %s\n", filename ? filename : "MTD Device. Are you root?");
-- 
2.9.5



More information about the Skiboot mailing list