From 322317b06939befbe87397e8d26f4dfca975f763 Mon Sep 17 00:00:00 2001 From: Cyril Bur Date: Wed, 2 Nov 2016 16:43:29 +1100 Subject: platforms/mambo: Support large unaligned reads 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 [initial review and changes by Mikey Neuling] Signed-off-by: Michael Neuling Signed-off-by: Stewart Smith --- 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; } -- cgit v1.1