[Skiboot] [PATCH 2/2] platforms/mambo: Support large unaligned reads

Cyril Bur cyril.bur at au1.ibm.com
Wed Nov 2 16:43:29 AEDT 2016


Recent changes to the skiboot resource loading code means that reads for
BOOTKERNEL and ROOTFS partitions will be exactly the number of bytes
required and no longer the (inaccurate) partition total size which
happened to be block size aligned.

Error when booting in mambo:
1140078: (1140078): [    0.001132323,3] FLASH: failed to read content
size 14252376 BOOTKERNEL partition, rc -1

Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
[initial review and changes by Mikey Neuling]
Signed-off-by: Michael Neuling <mikey at neuling.org>

---
 platforms/mambo/mambo.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/platforms/mambo/mambo.c b/platforms/mambo/mambo.c
index bd151ed..7f910b2 100644
--- a/platforms/mambo/mambo.c
+++ b/platforms/mambo/mambo.c
@@ -131,22 +131,29 @@ static int bogus_disk_read(struct blocklevel_device *bl, uint64_t pos, void *buf
 			  uint64_t len)
 {
 	struct bogus_disk_info *bdi = bl->priv;
-	int rc;
+	int rc, read_sectors = 0;
 	char b[BD_SECT_SZ];
 
-	if ((len % BD_SECT_SZ) == 0)
-		return callthru_disk_read(bdi->id, buf, pos/BD_SECT_SZ,
+	if (len >= BD_SECT_SZ) {
+		rc = callthru_disk_read(bdi->id, buf, pos/BD_SECT_SZ,
 					  len/BD_SECT_SZ);
+		if (rc)
+			return rc;
+		read_sectors = (len / BD_SECT_SZ);
+	}
 
-	/* We don't support block reads > BD_SECT_SZ */
-	if (len > BD_SECT_SZ)
-		return OPAL_PARAMETER;
+	if ((len % BD_SECT_SZ) == 0)
+		return 0;
 
-	/* Skiboot does small reads for system flash header checking */
-	rc =  callthru_disk_read(bdi->id, b, pos/BD_SECT_SZ, 1);
+	/*
+	 * Read any unaligned data into a temporaty buffer b, then copy
+	 * to buf
+	 */
+	rc =  callthru_disk_read(bdi->id, b, (pos/BD_SECT_SZ) + read_sectors, 1);
 	if (rc)
 		return rc;
-	memcpy(buf, &b[pos % BD_SECT_SZ], len);
+	memcpy(buf + (read_sectors * BD_SECT_SZ) , &b[pos % BD_SECT_SZ],
+			len - (read_sectors * BD_SECT_SZ));
 	return rc;
 }
 
-- 
2.10.1



More information about the Skiboot mailing list