summaryrefslogtreecommitdiff
path: root/src/lib/cbfs_core.c
diff options
context:
space:
mode:
authorVladimir Serbinenko <phcoder@gmail.com>2014-02-05 17:00:40 +0100
committerVladimir Serbinenko <phcoder@gmail.com>2014-02-05 23:04:53 +0100
commit3d6ffe76f8a505c2dff5d5c6146da3d63dad6e82 (patch)
treea6a9aafffb24fb903df8ef5f9fbaee94b8df748f /src/lib/cbfs_core.c
parent79c712cb9e35ea9c0f383c047b4aa9590b64496d (diff)
load_payload: Use 32-bit accesses to speed up decompression.
Flash prefers 32-bit sequential access. On some platforms ROM is not cached due to i.a. MTRR shortage. Moreover ROM caching is not currently enabled by default. With this patch payload decompression is sped up by theoretical factor of 4. Test on X201, with caching disabled: Before: 90:load payload 4,470,841 (24,505) 99:selfboot jump 6,073,812 (1,602,971) After: 90:load payload 4,530,979 (17,728) 99:selfboot jump 5,103,408 (572,429) Change-Id: Id17e61316dbbf73f4a837bf173f88bf26c01c62b Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com> Reviewed-on: http://review.coreboot.org/5144 Reviewed-by: Aaron Durbin <adurbin@google.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/lib/cbfs_core.c')
-rw-r--r--src/lib/cbfs_core.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/cbfs_core.c b/src/lib/cbfs_core.c
index 839b994cf3..50c037e573 100644
--- a/src/lib/cbfs_core.c
+++ b/src/lib/cbfs_core.c
@@ -202,6 +202,12 @@ int cbfs_decompress(int algo, void *src, void *dst, int len)
{
switch (algo) {
case CBFS_COMPRESS_NONE:
+ /* Reads need to be aligned at 4 bytes to avoid
+ poor flash performance. */
+ while (len && ((u32)src & 3)) {
+ *(u8*)dst++ = *(u8*)src++;
+ len--;
+ }
memmove(dst, src, len);
return len;
#ifdef CBFS_CORE_WITH_LZMA