app: aboot: Correct invalidate cache actions
When invalidate cache, address and size must be aligned
to CACHE_LINE, if not, the arch_invalidate_cache_range
api itself will do the alignment, that may cause valid
data lost which is not yet cleaned to cache.
So correct invalidate cache actions by use CACHE_LINE
aligned address and size explicitly. Use memalign,
STACKBUF_DMA_ALIGN or BUF_DMA_ALIGN to alloc space
which will used for cache invalidate and have the size
alloc Round to CACHE_LINE.
Change-Id: If51ba42e59c98d95ba9568b0478ec027d109c2ed
diff --git a/app/aboot/fastboot.c b/app/aboot/fastboot.c
index d605efb..cac7f8f 100644
--- a/app/aboot/fastboot.c
+++ b/app/aboot/fastboot.c
@@ -2,7 +2,7 @@
* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
- * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2015, 2018, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -247,7 +247,7 @@
}
/* invalidate any cached buf data (controller updates main memory) */
- arch_invalidate_cache_range((addr_t) _buf, count);
+ arch_invalidate_cache_range((addr_t) _buf, ROUNDUP(count, CACHE_LINE));
return count;
@@ -340,7 +340,7 @@
* Force reload of buffer from memory
* since transaction is complete now.
*/
- arch_invalidate_cache_range((addr_t)_buf, count);
+ arch_invalidate_cache_range((addr_t)_buf, ROUNDUP(count, CACHE_LINE));
return count;
oops:
@@ -489,7 +489,7 @@
/*
* Discard the cache contents before starting the download
*/
- arch_invalidate_cache_range((addr_t) download_base, len);
+ arch_invalidate_cache_range((addr_t) download_base, ROUNDUP(len, CACHE_LINE));
r = usb_if.usb_read(download_base, len);
if ((r < 0) || ((unsigned) r != len)) {