mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Michael Olbrich <m.olbrich@pengutronix.de>
Subject: [PATCH 1/7] efi: improve malloc pool allocation
Date: Thu, 16 Jul 2015 10:43:50 +0200	[thread overview]
Message-ID: <1437036236-19096-2-git-send-email-m.olbrich@pengutronix.de> (raw)
In-Reply-To: <1437036236-19096-1-git-send-email-m.olbrich@pengutronix.de>

Use allocate_pages() instead of allocate_pool(). With allocate_pages() we
can specify the address. This way, any address passed to the kernel will
never exceed the lower 32 bit.
If possible, try to allocate a larger pool.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 arch/efi/efi/efi.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/arch/efi/efi/efi.c b/arch/efi/efi/efi.c
index d351775a2868..c05d183c02fa 100644
--- a/arch/efi/efi/efi.c
+++ b/arch/efi/efi/efi.c
@@ -310,7 +310,8 @@ device_initcall(efi_init);
  */
 efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table)
 {
-	void *mem;
+	efi_physical_addr_t mem;
+	size_t memsize;
 	efi_status_t efiret;
 
 #ifdef DEBUG
@@ -332,8 +333,21 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table)
 
 	fixup_tables();
 
-	BS->allocate_pool(efi_loaded_image->image_data_type, SZ_16M, &mem);
-	mem_malloc_init(mem, mem + SZ_16M);
+	mem = 0x3fffffff;
+	for (memsize = SZ_256M; memsize >= SZ_8M; memsize /= 2) {
+		efiret  = BS->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+					     EFI_LOADER_DATA,
+					     memsize/PAGE_SIZE, &mem);
+		if (!EFI_ERROR(efiret))
+			break;
+		if (efiret != EFI_OUT_OF_RESOURCES)
+			panic("failed to allocate malloc pool: %s\n",
+			      efi_strerror(efiret));
+	}
+	if (EFI_ERROR(efiret))
+		panic("failed to allocate malloc pool: %s\n",
+		      efi_strerror(efiret));
+	mem_malloc_init((void *)mem, (void *)mem + memsize);
 
 	efi_clocksource_init();
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-07-16  8:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  8:43 [PATCH 0/7] EFI updates Michael Olbrich
2015-07-16  8:43 ` Michael Olbrich [this message]
2015-07-16  8:43 ` [PATCH 2/7] efi: refactor & improve application loading code Michael Olbrich
2015-07-16  8:43 ` [PATCH 3/7] efi: add support for initrd loading Michael Olbrich
2015-07-16  8:43 ` [PATCH 4/7] efi: add helper to get the GPT partition UUID for a device Michael Olbrich
2015-07-16  9:34   ` Marc Kleine-Budde
2015-07-16  9:43     ` Michael Olbrich
2015-07-16  8:43 ` [PATCH 5/7] efi: export device_path_from_handle() Michael Olbrich
2015-07-16  8:43 ` [PATCH 6/7] efi: add helper functions to write EFI variables Michael Olbrich
2015-07-16  8:43 ` [PATCH 7/7] efi: write volatile EFI variables used by systemd Michael Olbrich
2015-07-16 20:08   ` Sascha Hauer
2015-07-17  7:05     ` Michael Olbrich
2015-07-17  7:19       ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437036236-19096-2-git-send-email-m.olbrich@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox