From e78ea98bb28b276a20ec50251e6a1dde01295c35 Mon Sep 17 00:00:00 2001 From: Yidi Lin Date: Fri, 8 Dec 2023 23:52:05 +0800 Subject: [PATCH] libpayload/arm64: Round fb_size up to a multiple of GRANULE_SIZE If a framebuffer is already configured by coreboot, we need to ensure that the framebuffer size is a multiple of GRANULE_SIZE before passing to `mmu_add_memrange`. Otherwise, we would fail to allocate memory region due to `sanity_check`. Change-Id: Ia6a6400733ca10a61220087e87022f68c28e4789 Signed-off-by: Yidi Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/79451 Reviewed-by: Julius Werner Tested-by: build bot (Jenkins) --- payloads/libpayload/arch/arm64/mmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/payloads/libpayload/arch/arm64/mmu.c b/payloads/libpayload/arch/arm64/mmu.c index bb7954473c..5865b1b9ef 100644 --- a/payloads/libpayload/arch/arm64/mmu.c +++ b/payloads/libpayload/arch/arm64/mmu.c @@ -575,8 +575,6 @@ static struct mmu_memrange *_mmu_add_fb_range( prop.type = TYPE_DMA_MEM; - /* make sure to allocate a size of multiple of GRANULE_SIZE */ - size = ALIGN_UP(size, GRANULE_SIZE); prop.size = size; prop.lim_excl = MIN_64_BIT_ADDR; prop.align = MB_SIZE; @@ -634,6 +632,9 @@ static void mmu_add_fb_range(struct mmu_ranges *mmu_ranges) if (!fb_size) return; + /* make sure to allocate a size of multiple of GRANULE_SIZE */ + fb_size = ALIGN_UP(fb_size, GRANULE_SIZE); + /* framebuffer address has been set already, so just add it as DMA */ if (framebuffer->physical_address) { if (mmu_add_memrange(mmu_ranges,