From patchwork Wed Dec 11 10:54:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 849146 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp245136wry; Wed, 11 Dec 2024 02:56:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVWVFKYwuR6lSzbjSwGm105LgbO9NeE1MQsTGNhx42urZl/zndc84DuKzQNpHI+FL6p6ek0SA==@linaro.org X-Google-Smtp-Source: AGHT+IH7LhVousOSTfmuVqe68qPX1BQN3VTpeOsQubN0XD2nInFm7SEFCy/o5ReFfbupU0dZVtsz X-Received: by 2002:a05:6402:348b:b0:5d3:cf89:bd3e with SMTP id 4fb4d7f45d1cf-5d4331639cbmr4996061a12.30.1733914579589; Wed, 11 Dec 2024 02:56:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733914579; cv=none; d=google.com; s=arc-20240605; b=QrGLGGAYtTpseureFEl8U/jFXlnUYgNsfmUY71bn+BgJhTXu0eQnoaL/vriNIEOwYX ZOQ9wYZ6ioZAPRGboJuZKG/1DJ8eOTDu+8Z+7ZFRJwoIp7gZte1ahhJ2Ureh0Z8+pUX7 5OKbPjjHELyKZscLKalablL9t2ga8MAipF7IQkeFpnodk9wb+iVjPlrZ5Lpflkze642G 5KmDwaSBIPFZjINvlf3jrV0A5Tbl29tgeKoVDCEkA5f+Dr3gDYkxUSGtn8n+J9Jk2ebk 3sWq7Hl95A0jiQ5fV0IZm6Mxh1POB8MaU+VOEesUiXHIi87LgRrhiF/3AGHVer0InN/9 FpXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vq7Et1+06yoU+SrfNejcP7FvAUznzZZKURsbScNxGrA=; fh=dqoIyWezwpN87+mH4dIocR3yjQuK5Awmyd9b0nFZkMg=; b=TFS2HQZGQzMC6L172+pxy+nAIcIKmmf6LxtANDYCk+feNwyPC2Q1Zya6MzQridUZ2P t6LaY6hhOM7WKkKc5tb3WtL30xSYDftCqAMK446aLleSJgGSrQxGHk/8+yBKORkNn3xp RQpM0JcbLq4hOFClvhqbpdzbBKblz3lqyhhT8O4hWsHhrxQy8PFiYKkCjZ1ZIbsphWpw RGOMubBakIK63dT3TTE9NkgvAdT8/wbJJsgcmMem7fLoW78A8pYjYTZZCcmtLxb8Hdxw EYparbJcp11tlY5Rq5zsp9OnRgkl9J06wGFMvCbGf0HBHsGU+Mbm76k6QWJ+bIsurEI2 Sj0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gjwDneBk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5d3def710f2si6678709a12.265.2024.12.11.02.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:56:19 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gjwDneBk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AE3418022B; Wed, 11 Dec 2024 11:55:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gjwDneBk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6FB0801FE; Wed, 11 Dec 2024 11:55:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 12DA480278 for ; Wed, 11 Dec 2024 11:55:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-aa6b4cc7270so78780966b.0 for ; Wed, 11 Dec 2024 02:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733914535; x=1734519335; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vq7Et1+06yoU+SrfNejcP7FvAUznzZZKURsbScNxGrA=; b=gjwDneBk5FLuX2YM0u6jecWFwP1wxirMoAF5X/42cB1Dj0izpnjAhtltpltw4cnf+M QoiOGKJGIWuNvOHAWXszzeWwnhyb6lsNwesxX5EAeT57RH1SFWhweBVLw1/q+nhSP9qI d0+yMcQpRowKBtO5f9GZ3EkZCCUMy9C/LUDfSLQV2JFl2kHtux1+TLWKJ+wuEoNp5EnF ExznIO2mjHIgNeFMlf/iplLDOZZTA9fS0C62+LTraYmN+tPFxYvJ6tdz+PX8pc07iopv 8/NWE5NlADhb+uA7saPABbqkMyxuBokaxILhv2Hd/oKkVRd9sRZzezokGidhBuP91Th9 o+FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733914535; x=1734519335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vq7Et1+06yoU+SrfNejcP7FvAUznzZZKURsbScNxGrA=; b=bx0yvQRmesmdrmV4i1+9mpr1F4396NMNebRyf55paOE+3ArLkvJljYk0BCM98HNr2w EtNfQmJGiCrb9xI4/W3u/xcI+ekS/b9Ye4sHlTMuxJA8osGMe/LdQxHmOPsViX+3s9h/ JBqQl0iIkZt4QPSl30cYL91XwisdRRHN/+hjhT43/qYEVu/uWMBifXoDpkNxmhguKze2 O3QwPqfkmmcl6DOvScLXB6PXSA4Ih57ibwyRKoozeWJy+90S8+RTE2PoS4W1s16PEVvW 6Cww8NY63pDeCay+F+1gqHlPgwhJCyHj9MELrz3LtJ1NTmm3opbqlhsy8mYo2il5HhkJ BEQA== X-Forwarded-Encrypted: i=1; AJvYcCW92S4FSxJmzJGZIeSM+Mm4gPj4dog9HNzxzmYPvizDNvkCgQtYQHkXCcNLTtrYjb6DaDb751E=@lists.denx.de X-Gm-Message-State: AOJu0Yw7njjVyAPQDzl7dLiT7P3sN5g7eyDM9j+53enywsKJXae4Gc/J A8lluauz+fPnL58V5xOAw/iTfADq3VWXRdWJtS9j8ihbJPPV4BkmEayuFB7TMwU= X-Gm-Gg: ASbGncvizmqp1ptnvlke7uxSNbWFVYndfQJ2Jgp6S5wlyKvqCgkQwglDyRseb3GThqr PgEpYA04yRqwYFc/L/uSm6+80jKdEfdVOrmZSZBtEUNslSpwqWIWQWRS/Fc8SqVbpmXDZfRgaiH xRHo68o8dGYTSfCtUKIhGfa+evwwAss2wru+Q+bSvo+4FUnchQ3vzoBD453UY2qXdrg7B33WTWw +2Dg3gFigY2YUKeT8mi2qfH54KogcBtgCaSQeWZwXwcO20kqVjqknkrXWi+YRvyyyYbj8TUsDgR Srhads+2twHXL+Lrx4Tp5YsveQvb1dM= X-Received: by 2002:a05:6402:4008:b0:5d0:ced8:d22d with SMTP id 4fb4d7f45d1cf-5d43314d119mr5792678a12.22.1733914535491; Wed, 11 Dec 2024 02:55:35 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa67e652b1dsm508006566b.172.2024.12.11.02.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:35 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , =?utf-8?q?Marek_Beh?= =?utf-8?q?=C3=BAn?= , Simon Glass , Marek Vasut , Sughosh Ganu , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Sean Anderson , Baruch Siach , Nam Cao , AKASHI Takahiro , Sam Protsenko , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v1 7/8] lmb: Remove lmb_alloc_base_flags() Date: Wed, 11 Dec 2024 12:54:48 +0200 Message-ID: <20241211105504.453234-8-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211105504.453234-1-ilias.apalodimas@linaro.org> References: <20241211105504.453234-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean lmb_alloc_base() is just calling lmb_alloc_base_flags() with LMB_NONE. There's not much we gain from this abstraction, so let's remove the former add the flags argument to lmb_alloc_base() and make the code a bit easier to follow. Signed-off-by: Ilias Apalodimas Reviewed-by: Sam Protsenko --- boot/image-board.c | 18 +++++++++++------- boot/image-fdt.c | 5 +++-- include/lmb.h | 7 +++---- lib/efi_loader/efi_memory.c | 4 ++-- lib/lmb.c | 19 +++---------------- test/lib/lmb.c | 8 ++++---- 6 files changed, 26 insertions(+), 35 deletions(-) diff --git a/boot/image-board.c b/boot/image-board.c index 070ada007185..4e86a9a22719 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -565,9 +565,11 @@ int boot_ramdisk_high(ulong rd_data, ulong rd_len, ulong *initrd_start, lmb_reserve(rd_data, rd_len, LMB_NONE); } else { if (initrd_high) - *initrd_start = (ulong)lmb_alloc_base(rd_len, - 0x1000, - initrd_high); + *initrd_start = + (ulong)lmb_alloc_base(rd_len, + 0x1000, + initrd_high, + LMB_NONE); else *initrd_start = (ulong)lmb_alloc(rd_len, 0x1000); @@ -839,7 +841,8 @@ int boot_get_cmdline(ulong *cmd_start, ulong *cmd_end) barg = IF_ENABLED_INT(CONFIG_SYS_BOOT_GET_CMDLINE, CONFIG_SYS_BARGSIZE); cmdline = (char *)(ulong)lmb_alloc_base(barg, 0xf, - env_get_bootm_mapsize() + env_get_bootm_low()); + env_get_bootm_mapsize() + env_get_bootm_low(), + LMB_NONE); if (!cmdline) return -1; @@ -872,9 +875,10 @@ int boot_get_cmdline(ulong *cmd_start, ulong *cmd_end) int boot_get_kbd(struct bd_info **kbd) { *kbd = (struct bd_info *)(ulong)lmb_alloc_base(sizeof(struct bd_info), - 0xf, - env_get_bootm_mapsize() + - env_get_bootm_low()); + 0xf, + env_get_bootm_mapsize() + + env_get_bootm_low(), + LMB_NONE); if (!*kbd) return -1; diff --git a/boot/image-fdt.c b/boot/image-fdt.c index d717f6690729..9d1598b1a93c 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -187,7 +187,8 @@ int boot_relocate_fdt(char **of_flat_tree, ulong *of_size) lmb_reserve(map_to_sysmem(of_start), of_len, LMB_NONE); disable_relocation = 1; } else if (desired_addr) { - addr = lmb_alloc_base(of_len, 0x1000, desired_addr); + addr = lmb_alloc_base(of_len, 0x1000, desired_addr, + LMB_NONE); of_start = map_sysmem(addr, of_len); if (of_start == NULL) { puts("Failed using fdt_high value for Device Tree"); @@ -216,7 +217,7 @@ int boot_relocate_fdt(char **of_flat_tree, ulong *of_size) * for LMB allocation. */ usable = min(start + size, low + mapsize); - addr = lmb_alloc_base(of_len, 0x1000, usable); + addr = lmb_alloc_base(of_len, 0x1000, usable, LMB_NONE); of_start = map_sysmem(addr, of_len); /* Allocation succeeded, use this block. */ if (of_start != NULL) diff --git a/include/lmb.h b/include/lmb.h index 5e59915340b7..d481972a6686 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -91,11 +91,10 @@ long lmb_add(phys_addr_t base, phys_size_t size); long lmb_reserve(phys_addr_t base, phys_size_t size, u32 flags); phys_addr_t lmb_alloc(phys_size_t size, ulong align); -phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr); phys_size_t lmb_get_free_size(phys_addr_t addr); /** - * lmb_alloc_base_flags() - Allocate specified memory region with specified + * lmb_alloc_base() - Allocate specified memory region with specified * attributes * @size: Size of the region requested * @align: Alignment of the memory region requested @@ -108,8 +107,8 @@ phys_size_t lmb_get_free_size(phys_addr_t addr); * * Return: Base address on success, 0 on error. */ -phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, - phys_addr_t max_addr, uint flags); +phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, + uint flags); /** * lmb_alloc_addr() - Allocate specified memory address with specified attributes diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 34e2b9e18ef0..1212772471e3 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -472,7 +472,7 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, switch (type) { case EFI_ALLOCATE_ANY_PAGES: /* Any page */ - addr = (u64)lmb_alloc_base_flags(len, EFI_PAGE_SIZE, + addr = (u64)lmb_alloc_base(len, EFI_PAGE_SIZE, LMB_ALLOC_ANYWHERE, flags); if (!addr) return EFI_OUT_OF_RESOURCES; @@ -480,7 +480,7 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, case EFI_ALLOCATE_MAX_ADDRESS: /* Max address */ addr = map_to_sysmem((void *)(uintptr_t)*memory); - addr = (u64)lmb_alloc_base_flags(len, EFI_PAGE_SIZE, addr, + addr = (u64)lmb_alloc_base(len, EFI_PAGE_SIZE, addr, flags); if (!addr) return EFI_OUT_OF_RESOURCES; diff --git a/lib/lmb.c b/lib/lmb.c index ffad7ec12eb5..bdaaa634abd1 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -731,24 +731,11 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t lmb_alloc(phys_size_t size, ulong align) { - return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE); + return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE, LMB_NONE); } -phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr) -{ - phys_addr_t alloc; - - alloc = _lmb_alloc_base(size, align, max_addr, LMB_NONE); - - if (alloc == 0) - printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", - (ulong)size, (ulong)max_addr); - - return alloc; -} - -phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, - phys_addr_t max_addr, uint flags) +phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, + uint flags) { phys_addr_t alloc; diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 971614fd8314..fcb5f1af532a 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -128,7 +128,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram, ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr, 0x10000, ram_end - 4, 4, 0, 0); /* alloc below end of reserved region -> below reserved region */ - b = lmb_alloc_base(4, 1, alloc_64k_end); + b = lmb_alloc_base(4, 1, alloc_64k_end, LMB_NONE); ut_asserteq(b, alloc_64k_addr - 4); ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr - 4, 0x10000 + 4, ram_end - 4, 4, 0, 0); @@ -138,7 +138,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram, ut_asserteq(c, ram_end - 8); ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr - 4, 0x10000 + 4, ram_end - 8, 8, 0, 0); - d = lmb_alloc_base(4, 1, alloc_64k_end); + d = lmb_alloc_base(4, 1, alloc_64k_end, LMB_NONE); ut_asserteq(d, alloc_64k_addr - 8); ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 8, 0, 0); @@ -163,7 +163,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram, alloc_64k_addr - 8, 4, alloc_64k_addr, 0x10000, ram_end - 8, 4); /* allocate again to ensure we get the same address */ - b2 = lmb_alloc_base(4, 1, alloc_64k_end); + b2 = lmb_alloc_base(4, 1, alloc_64k_end, LMB_NONE); ut_asserteq(b, b2); ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 4, 0, 0); @@ -363,7 +363,7 @@ static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram, ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 0, 0, 0, 0, 0, 0, 0); /* allocate a block with base*/ - b = lmb_alloc_base(alloc_size, align, ram_end); + b = lmb_alloc_base(alloc_size, align, ram_end, LMB_NONE); ut_assert(a == b); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram + ram_size - alloc_size_aligned,