Skip to contentSkip to conversation

bootm: Align cache flush begin address

PATCH New Bryan O'Donoghue 2 participants 3 messages Apr 13, 2018 – Apr 14, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bootm: Align cache flush begin address

commit b4d956f6bc0f ("bootm: Align cache flush end address correctly") aligns the end address of the cache flush operation to a cache-line size to ensure lower-layers in the code accept the range provided and flush.

A similar action should be taken for the begin address of a cache flush operation. The load address may not be aligned to a cache-line boundary, so ensure the passed address is aligned.

---
 common/bootm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
common/bootm.c +2 -1
index adb1213..45d140c 100644
@@ -447,7 +447,8 @@ static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end,
 		bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
 		return err;
 	}
-	flush_cache(load, ALIGN(*load_end - load, ARCH_DMA_MINALIGN));
+	flush_cache(ALIGN(load, ARCH_DMA_MINALIGN),
+		    ALIGN(*load_end - load, ARCH_DMA_MINALIGN));
 
 	debug("   kernel loaded at 0x%08lx, end = 0x%08lx\n", load, *load_end);
 	bootstage_mark(BOOTSTAGE_ID_KERNEL_LOADED);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 bootm: Align cache flush begin address

Quoted 20 lines · Bryan O'Donoghue

commit b4d956f6bc0f ("bootm: Align cache flush end address correctly") aligns the end address of the cache flush operation to a cache-line size to ensure lower-layers in the code accept the range provided and flush.

A similar action should be taken for the begin address of a cache flush operation. The load address may not be aligned to a cache-line boundary, so ensure the passed address is aligned.

---
 common/bootm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
common/bootm.c +0 -0
index adb1213..45d140c 100644

common/bootm.c static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end, · line 451

Quoted 6 lines
common/bootm.c +2 -1
@@ -447,7 +447,8 @@ static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end,
 		bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
 		return err;
 	}
-	flush_cache(load, ALIGN(*load_end - load, ARCH_DMA_MINALIGN));
+	flush_cache(ALIGN(load, ARCH_DMA_MINALIGN),
+		    ALIGN(*load_end - load, ARCH_DMA_MINALIGN));

Am I wrong in thinking that we would want ALIGN_DOWN for load here?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180413/77af8ccb/attachment.sig>
#2 lore raw

PATCH 1/1 bootm: Align cache flush begin address

Quoted 4 lines · Tom Rini

common/bootm.c static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end, · line 451

Quoted 3 lines
common/bootm.c +2 -1
-	flush_cache(load, ALIGN(*load_end - load, ARCH_DMA_MINALIGN));
+	flush_cache(ALIGN(load, ARCH_DMA_MINALIGN),
+		    ALIGN(*load_end - load, ARCH_DMA_MINALIGN));

Am I wrong in thinking that we would want ALIGN_DOWN for load here?

No, we'll need to increase the length of the flush too.

I'll change this to an analog of

if (load != ALIGN_DOWN(load)) {
     load_flush = ALIGN_DOWN(load);
     load_flush_len += load - load_flush;
}

etc