From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Br=FCns=2C_Stefan?= Date: Wed, 2 Aug 2017 15:24:42 +0000 Subject: [U-Boot] [PATCH] efi_loader: make pool allocations cacheline aligned In-Reply-To: References: <20170801200036.32041-1-robdclark@gmail.com> Message-ID: <4572767.ryYN3EvPXv@sbruens-linux> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mittwoch, 2. August 2017 11:28:37 CEST Rob Clark wrote: > On Tue, Aug 1, 2017 at 9:10 PM, Heinrich Schuchardt [...] > >> > >> @@ -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); > >> > >> if (size == 0) { > >> > >> *buffer = NULL; > > > > NAK > > > > 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. > > The divisor is a constant power of two so compiler should turn this into a > shift > > Please, use > > + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; > > as in the original line. > > This was actually incorrect (missing a "- 1"), which is why I decided > to stop open-coding DIV_ROUND_UP(). EFI_PAGE_MASK == EFI_PAGE_SIZE - 1 Kind regards, Stefan