From: Heinrich Schuchardt Date: Fri, 11 Aug 2017 18:58:53 +0200 Subject: [U-Boot] [PATCH v1 13/15] efi_loader: make pool allocations cacheline aligned In-Reply-To: <20170810182948.27653-14-robdclark@gmail.com> References: <20170810182948.27653-1-robdclark@gmail.com> <20170810182948.27653-14-robdclark@gmail.com> Message-ID: <02d079b1-d08c-9fac-eb43-bd26f3d08319@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 08/10/2017 08:29 PM, Rob Clark wrote: > This avoids printf() spam about file reads (such as loading an image) > into unaligned buffers (and the associated memcpy()). And generally > seems like a good idea. > > Signed-off-by: Rob Clark > --- > lib/efi_loader/efi_memory.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c > index 9e079f1fa3..2ba8d8b42b 100644 > --- a/lib/efi_loader/efi_memory.c > +++ b/lib/efi_loader/efi_memory.c > @@ -43,7 +43,7 @@ void *efi_bounce_buffer; > */ > struct efi_pool_allocation { > u64 num_pages; > - char data[]; > + char data[] __attribute__((aligned(ARCH_DMA_MINALIGN))); > }; > > /* > @@ -356,7 +356,8 @@ efi_status_t efi_allocate_pool(int pool_type, unsigned long size, > { > efi_status_t r; > efi_physical_addr_t t; > - u64 num_pages = (size + sizeof(u64) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; > + u64 num_pages = DIV_ROUND_UP(size + sizeof(struct efi_pool_allocation), > + EFI_PAGE_SIZE); It seems you missed my mail dated 2017-08-02T01:21Z: With DIV_ROUND_UP you introduce a 64bit division. Depending on the architecture this is only available via stdlib which is not available in U-Boot. Please, use + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; as in the original line. Best regards Heinrich > > if (size == 0) { > *buffer = NULL; >