From patchwork Sun Dec 8 10:52:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 848271 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1608506wrt; Sun, 8 Dec 2024 02:52:53 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXsfoHj/ajaFo1IQMAWw6nacwbhTsnp0XFS7LboZh43cmDVE30mk3O0AKE7DvScMqfGQTZsOw==@linaro.org X-Google-Smtp-Source: AGHT+IEAmEAvLA5Vp4rVJqGE1pfRIlCewYnfxwSQ6pZuzar+iGqxsMCjLtlkItyRMOhxeYr4IhBQ X-Received: by 2002:a17:906:6a20:b0:aa6:42d8:afac with SMTP id a640c23a62f3a-aa642d8b471mr834663966b.15.1733655172747; Sun, 08 Dec 2024 02:52:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733655172; cv=none; d=google.com; s=arc-20240605; b=Yk6G1DXsUWfF6I3/D0kMxY9NKDID1ZwYV2CGTVAevXs4vjWV7AXg64KPvSue3B3JWW TO6Cl0vYuu+J6oCzkFeuxMluZXKp3hk88En7kmkGjNQcmPaf65P5wzyLCBwAI36RlxtY ng9k/lK+vRF9mGkYxW4JcVrdGZvvQ4ChGtKLFLhPbbHiwAkN233tv+PZgb1GhYGB2m2P HCjN9YZhGCk4hbkLitqtcvWqJd+7cUd/v0Mxm7OTP5yBOMKvlc2SHetjdKBJw6Q9FV3Y QYfgJl+tq5G4v1b0ExDpLGU/kGdnNO+InRi4Ny9LjvOiJLOnGv7jYAlvFfwrxESgThlO +xAQ== 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=QVw6dy8ZMldI5jPWQEq00TutcGizQkvfeXKq+3IkWLs=; fh=cnResPlEE2IlfFT1eiNgzQP1O7ZRtTbJQEPsYcWuTLE=; b=SlsGp09ENutev/VTyw5NrLw7Dv9sIHVzF26770UJO7yvVHmBuvgl+TpglsbY9aWp5P gzxn6uOJba3NrFHTAmN/yyYnW+iz3nwtuFiaBHUKc/7FczNfMZogouKsgeEYGtoymRxd abTD9/2TX3QVeyaJ+6JBGMV2fB8eYQ++1BDEgVmn8BrhuYlZpmaxrt+krQgJ4DFqpNAb Z5N1/FNYNB0RZ+AolVbVl0YFrMGzis8D1wpHnKz8qFNL47SsncWE91gX42UH26kQ0WRr z9ew9wYZTw133nzgXKPqfydK+6IA533TYGhZgWmhvVi4iSiybDVKL/1OjNPUEtwoVwjJ Xidw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aF1N2bp+; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-aa62621d00esi517431166b.930.2024.12.08.02.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:52:52 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aF1N2bp+; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 16AE18952E; Sun, 8 Dec 2024 11:52:46 +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="aF1N2bp+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E15FC8954B; Sun, 8 Dec 2024 11:52:44 +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-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 A0534893BF for ; Sun, 8 Dec 2024 11:52:42 +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-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5d3e829ff44so1329216a12.0 for ; Sun, 08 Dec 2024 02:52:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733655162; x=1734259962; 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=QVw6dy8ZMldI5jPWQEq00TutcGizQkvfeXKq+3IkWLs=; b=aF1N2bp+95DnIcK7hT9wrNKzZ7Ls61AutxQNRcqUfCvtrsn9cbhfsBpxm6VnKxu7EV WxQHDH6APh8C1uk2fkKGgEYJZ11llr3dpDagKqCM8fdTc7jCeBJKyE9uhSoMium2wLiw U9cmU9Hn+c78P/gyar5hsgKJddMe7YWFEv6I2R7C62v/dcpoYvotXaLJB8nAQ0Wz3Vqf 6cToSYH7SwgLaLBp7jq41TAHuKlopNXOV8X9KsTzGAYKJOSab1LJ5MuOPrHqKLkCG6LN LSjl2P151jVrjaHKI1+8n2Xap4HgyC4RNYOrn3gXZMTXAtUcqwQZhtcVAZ8ZsCu7jzmJ 4ABA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733655162; x=1734259962; 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=QVw6dy8ZMldI5jPWQEq00TutcGizQkvfeXKq+3IkWLs=; b=B+91DP76bNmbB7CUQsrISvsZKOawSvIkb0m1fil3FnvkDl6mYZ+Tt7CjMc/HGkmgYU FhjhrM5xlmIwrLItICmWKOwvB2/Sddfsuf1ZETO1STV61dcjfJ5JJLkik5gjchxUflQO XoJECnrsck34nDF7eKbiy2fK262FPwEToDKaeRoNHQdHnNq1XbLgYIHPr+aDd5ci8D9h nknsnLZohQmnYZ7la9q+1A0co2Lud8fKO5JimTAev00pyP5yQUduWEpWaH+H66yHedbm YOG9OO6aP5QX4U9qU6wUJ0q60rzPmha13OoDxW6AfpNd3yw3E57/v8pD/qZA0FLEzaOI 6LdQ== X-Forwarded-Encrypted: i=1; AJvYcCX7nx+yMYH8FsdGRdtl9fKf9oKBxPucYE4DM+skJUzfF4PdhYwalLU33Q2F0JVB99R6JSitR3A=@lists.denx.de X-Gm-Message-State: AOJu0Yy8D7byRM78Ma8Lwc22pIOL5iqsuIvg3QH80nEXdrx7XOqsMiDR hY1vi0f2MG3g2V3+VDnTJX3pzzwOW81+biHQxq5tj/lxUG5aEVY9FrRaMMZ4V7o= X-Gm-Gg: ASbGncvw3+bAheJijvCPwDmCNbt5Jk9ButGydxqTuhVBbJ2efjHk0fAXpZXpY2fTJr6 gqff6WJRd7S1zfP2Jtlu84uqKCOjlTrKpwOqFlztkOsK47CjsGr7NcG0RVmAabsruzaN6CjqSrz Wpbyjj7lCvH24B1I1SwULF3ELGvohVVdjC4pxclIc4crZ+7mHn03LHaym6cTg6xhpXh7L1a9oGU +Yc3YE66WolZenT71uR+vxYyCeXjXx3cal+efo4tVMPQw2FrP3tuSoF/bh76DuDEM1ehzClIrb2 9gxKZfImkThaPtmwMxdQTjZhcrI= X-Received: by 2002:a17:907:96a5:b0:a9a:e0b8:5bac with SMTP id a640c23a62f3a-aa6219e170bmr1150372166b.23.1733655162046; Sun, 08 Dec 2024 02:52:42 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625e92fe3sm517768566b.51.2024.12.08.02.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:52:41 -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 , Sughosh Ganu , Marek Vasut , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , AKASHI Takahiro , Baruch Siach , Nam Cao , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [RFC PATCH 1/7] lmb: Replace lmb_reserve() with lmb_reserve_flags() Date: Sun, 8 Dec 2024 12:52:04 +0200 Message-ID: <20241208105223.2821049-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241208105223.2821049-1-ilias.apalodimas@linaro.org> References: <20241208105223.2821049-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_reserve() is just calling lmb_reserve_flags() with LMB_NONE. There's not much we gain from this abstraction, so let's remove the former and make the code a bit easier to follow. The code size increase is minimal - e.g for sandbox which includes all of the LMB tests add/remove: 0/1 grow/shrink: 12/0 up/down: 46/-4 (42) Function old new delta lib_test_lmb_overlapping_reserve 1018 1030 +12 version_string 70 76 +6 test_get_unreserved_size 1032 1038 +6 test_alloc_addr 2933 2939 +6 test_multi_alloc.constprop 3034 3036 +2 test_bigblock 911 913 +2 load_serial 946 948 +2 lib_test_lmb_flags 2101 2103 +2 do_bootz 526 528 +2 do_bootm_linux 2067 2069 +2 bootm_run_states 5275 5277 +2 boot_relocate_fdt 599 601 +2 lmb_reserve 4 - -4 Total: Before=2492742, After=2492784, chg +0.00% Signed-off-by: Ilias Apalodimas Reviewed-by: Tom Rini --- arch/powerpc/cpu/mpc85xx/mp.c | 2 +- arch/powerpc/lib/misc.c | 2 +- boot/bootm.c | 3 ++- boot/image-board.c | 2 +- boot/image-fdt.c | 5 +++-- cmd/booti.c | 2 +- cmd/bootz.c | 2 +- cmd/load.c | 2 +- include/lmb.h | 1 - lib/lmb.c | 5 ----- test/lib/lmb.c | 30 +++++++++++++++--------------- 11 files changed, 26 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/mp.c b/arch/powerpc/cpu/mpc85xx/mp.c index bed465cb2cba..22252c1448a8 100644 --- a/arch/powerpc/cpu/mpc85xx/mp.c +++ b/arch/powerpc/cpu/mpc85xx/mp.c @@ -412,7 +412,7 @@ void cpu_mp_lmb_reserve(void) { u32 bootpg = determine_mp_bootpg(NULL); - lmb_reserve(bootpg, 4096); + lmb_reserve_flags(bootpg, 4096, LMB_NONE); } void setup_mp(void) diff --git a/arch/powerpc/lib/misc.c b/arch/powerpc/lib/misc.c index 4cd23b3406d1..c08d4b35118b 100644 --- a/arch/powerpc/lib/misc.c +++ b/arch/powerpc/lib/misc.c @@ -40,7 +40,7 @@ int arch_misc_init(void) printf("WARNING: adjusting available memory from 0x%lx to 0x%llx\n", size, (unsigned long long)bootm_size); - lmb_reserve(base, bootm_size - size); + lmb_reserve_flags(base, bootm_size - size, LMB_NONE); } #ifdef CONFIG_MP diff --git a/boot/bootm.c b/boot/bootm.c index 16a43d519a8a..c8662442e403 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -696,7 +696,8 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress) } if (CONFIG_IS_ENABLED(LMB)) - lmb_reserve(images->os.load, (load_end - images->os.load)); + lmb_reserve_flags(images->os.load, (load_end - images->os.load), + LMB_NONE); return 0; } diff --git a/boot/image-board.c b/boot/image-board.c index b726bd6b3035..c4d914fd6074 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -562,7 +562,7 @@ int boot_ramdisk_high(ulong rd_data, ulong rd_len, ulong *initrd_start, debug(" in-place initrd\n"); *initrd_start = rd_data; *initrd_end = rd_data + rd_len; - lmb_reserve(rd_data, rd_len); + lmb_reserve_flags(rd_data, rd_len, LMB_NONE); } else { if (initrd_high) *initrd_start = (ulong)lmb_alloc_base(rd_len, diff --git a/boot/image-fdt.c b/boot/image-fdt.c index 3d5b6f9e2dc7..fd68b8594325 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -184,7 +184,8 @@ int boot_relocate_fdt(char **of_flat_tree, ulong *of_size) if (desired_addr == ~0UL) { /* All ones means use fdt in place */ of_start = fdt_blob; - lmb_reserve(map_to_sysmem(of_start), of_len); + lmb_reserve_flags(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); @@ -675,7 +676,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb) /* Create a new LMB reservation */ if (CONFIG_IS_ENABLED(LMB) && lmb) - lmb_reserve(map_to_sysmem(blob), of_size); + lmb_reserve_flags(map_to_sysmem(blob), of_size, LMB_NONE); #if defined(CONFIG_ARCH_KEYSTONE) if (IS_ENABLED(CONFIG_OF_BOARD_SETUP)) diff --git a/cmd/booti.c b/cmd/booti.c index 43e79e87201b..58d355726cc5 100644 --- a/cmd/booti.c +++ b/cmd/booti.c @@ -87,7 +87,7 @@ static int booti_start(struct bootm_info *bmi) images->os.start = relocated_addr; images->os.end = relocated_addr + image_size; - lmb_reserve(images->ep, le32_to_cpu(image_size)); + lmb_reserve_flags(images->ep, le32_to_cpu(image_size), LMB_NONE); /* * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not diff --git a/cmd/bootz.c b/cmd/bootz.c index 787203f5bd70..ab2bf12eb8b0 100644 --- a/cmd/bootz.c +++ b/cmd/bootz.c @@ -56,7 +56,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc, if (ret != 0) return 1; - lmb_reserve(images->ep, zi_end - zi_start); + lmb_reserve_flags(images->ep, zi_end - zi_start, LMB_NONE); /* * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not diff --git a/cmd/load.c b/cmd/load.c index 20d802502ae6..dfbb6d2db0c9 100644 --- a/cmd/load.c +++ b/cmd/load.c @@ -179,7 +179,7 @@ static ulong load_serial(long offset) { void *dst; - ret = lmb_reserve(store_addr, binlen); + ret = lmb_reserve_flags(store_addr, binlen, LMB_NONE); if (ret) { printf("\nCannot overwrite reserved area (%08lx..%08lx)\n", store_addr, store_addr + binlen); diff --git a/include/lmb.h b/include/lmb.h index f221f0cce8f7..62882464f866 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -82,7 +82,6 @@ int lmb_init(void); void lmb_add_memory(void); long lmb_add(phys_addr_t base, phys_size_t size); -long lmb_reserve(phys_addr_t base, phys_size_t size); /** * lmb_reserve_flags - Reserve one region with a specific flags bitfield. * diff --git a/lib/lmb.c b/lib/lmb.c index b03237bc06cb..a7ecbb58831f 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -698,11 +698,6 @@ long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags flags) return lmb_map_update_notify(base, size, MAP_OP_RESERVE, flags); } -long lmb_reserve(phys_addr_t base, phys_size_t size) -{ - return lmb_reserve_flags(base, size, LMB_NONE); -} - static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, enum lmb_flags flags) { diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 0bd29e2a4fe7..8af5dcad2ecc 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -117,7 +117,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram, } /* reserve 64KiB somewhere */ - ret = lmb_reserve(alloc_64k_addr, 0x10000); + ret = lmb_reserve_flags(alloc_64k_addr, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, 0, 0, 1, alloc_64k_addr, 0x10000, 0, 0, 0, 0); @@ -264,7 +264,7 @@ static int test_bigblock(struct unit_test_state *uts, const phys_addr_t ram) ut_asserteq(ret, 0); /* reserve 64KiB in the middle of RAM */ - ret = lmb_reserve(alloc_64k_addr, 0x10000); + ret = lmb_reserve_flags(alloc_64k_addr, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, alloc_64k_addr, 0x10000, 0, 0, 0, 0); @@ -466,35 +466,35 @@ static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts) ret = lmb_add(ram, ram_size); ut_asserteq(ret, 0); - ret = lmb_reserve(0x40010000, 0x10000); + ret = lmb_reserve_flags(0x40010000, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40010000, 0x10000, 0, 0, 0, 0); /* allocate overlapping region should return the coalesced count */ - ret = lmb_reserve(0x40011000, 0x10000); + ret = lmb_reserve_flags(0x40011000, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40010000, 0x11000, 0, 0, 0, 0); /* allocate 3nd region */ - ret = lmb_reserve(0x40030000, 0x10000); + ret = lmb_reserve_flags(0x40030000, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, 0x40010000, 0x11000, 0x40030000, 0x10000, 0, 0); /* allocate 2nd region , This should coalesced all region into one */ - ret = lmb_reserve(0x40020000, 0x10000); + ret = lmb_reserve_flags(0x40020000, 0x10000, LMB_NONE); ut_assert(ret >= 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40010000, 0x30000, 0, 0, 0, 0); /* allocate 2nd region, which should be added as first region */ - ret = lmb_reserve(0x40000000, 0x8000); + ret = lmb_reserve_flags(0x40000000, 0x8000, LMB_NONE); ut_assert(ret >= 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, 0x40000000, 0x8000, 0x40010000, 0x30000, 0, 0); /* allocate 3rd region, coalesce with first and overlap with second */ - ret = lmb_reserve(0x40008000, 0x10000); + ret = lmb_reserve_flags(0x40008000, 0x10000, LMB_NONE); ut_assert(ret >= 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40000000, 0x40000, 0, 0, 0, 0); @@ -550,11 +550,11 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) ut_asserteq(ret, 0); /* reserve 3 blocks */ - ret = lmb_reserve(alloc_addr_a, 0x10000); + ret = lmb_reserve_flags(alloc_addr_a, 0x10000, LMB_NONE); ut_asserteq(ret, 0); - ret = lmb_reserve(alloc_addr_b, 0x10000); + ret = lmb_reserve_flags(alloc_addr_b, 0x10000, LMB_NONE); ut_asserteq(ret, 0); - ret = lmb_reserve(alloc_addr_c, 0x10000); + ret = lmb_reserve_flags(alloc_addr_c, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 3, alloc_addr_a, 0x10000, alloc_addr_b, 0x10000, alloc_addr_c, 0x10000); @@ -680,11 +680,11 @@ static int test_get_unreserved_size(struct unit_test_state *uts, ut_asserteq(ret, 0); /* reserve 3 blocks */ - ret = lmb_reserve(alloc_addr_a, 0x10000); + ret = lmb_reserve_flags(alloc_addr_a, 0x10000, LMB_NONE); ut_asserteq(ret, 0); - ret = lmb_reserve(alloc_addr_b, 0x10000); + ret = lmb_reserve_flags(alloc_addr_b, 0x10000, LMB_NONE); ut_asserteq(ret, 0); - ret = lmb_reserve(alloc_addr_c, 0x10000); + ret = lmb_reserve_flags(alloc_addr_c, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 3, alloc_addr_a, 0x10000, alloc_addr_b, 0x10000, alloc_addr_c, 0x10000); @@ -789,7 +789,7 @@ static int lib_test_lmb_flags(struct unit_test_state *uts) ut_asserteq(lmb_is_nomap(&used[1]), 0); /* test that old API use LMB_NONE */ - ret = lmb_reserve(0x40040000, 0x10000); + ret = lmb_reserve_flags(0x40040000, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, 0x40000000, 0x30000, 0x40030000, 0x20000, 0, 0); From patchwork Sun Dec 8 10:52:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 848272 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1608528wrt; Sun, 8 Dec 2024 02:53:02 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUoM5+BXwnZHBar/XmiLZPL80agJOpgKh/9pPq9BRYnRpwYhUaNHiFwtp6qS9Ll2TY9jfkyMw==@linaro.org X-Google-Smtp-Source: AGHT+IEwxBRtcVOvYKSXaUJ3ArTTmDD9ssoL4fIIqUHEtvKgIFS5qXXjf9PDGZ3OO+CZt7WeXYKJ X-Received: by 2002:a17:907:9518:b0:aa6:552e:451e with SMTP id a640c23a62f3a-aa6552e4657mr395476366b.29.1733655181993; Sun, 08 Dec 2024 02:53:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733655181; cv=none; d=google.com; s=arc-20240605; b=CGLpk83ollcDCl0qAjaM49EyoEbJgPcisA8Ss5sXS0cwTkeJ43N0HQNUNrXfOeEx7s nEgrX3PEP/hA0RsXyv4NXTcnEhM1aoikY8r5UpfHZCtkexkiL7rRtMUQMieta0Wo7sL/ /pk60lFtDyhiZwQhU1o15qUE6sYBhbu4jMbfYEnO3TNoY3XENLz3psxkl6oZcpMcAMXM XkwWwrRWTPtVRJzwJHvaYm5yvIJOeffsVia10kuhSJayBKdplJ0jJ7/aB1IgJ5IRRo3R 8BIRBs9G43KLVZx9nTRyMCU+MRMn3+E+iQFP3IQRVmVCLSD1Ls0eiTzjPSk1fcvkNWjm BDmA== 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=iMp5c3d4w227EBQRr8iv9j9OVqGRaUTFIpDzyMLlBVk=; fh=xl4/3uN1P/aeBKVoOLNs3a6APypR8W4rzdBgEapZbkA=; b=ZgV9G2AFLwnCdfuRtCPa5x4HCX2EIOOAbFo2I9unXz3aVbxY6zc87deF6HeI7Be/og +sYtnRL3Si/pAsA56tVeUFULuN1mLTWGoJ7nuLN65oucMpSYaCp35xP7mkWcY2Yboxbd lBEgvTM/AUAQPhyixp2WaHvdvsWamBY+5P9ZiOkQOGnIv11d3gauvEn/Z6EIYxgcm91U HTpb+4V/nLzZ/533x1/tL9N9fcS7sxPwWfCHM2oLlaNveE6BdERaC2QtViNcbMvBi1SU syfBLLuj/9/DC0vlQLYDQ45/hBlI+166mY1N59ZvE681Pa1GnwAmZ4OHNVSFZyhjOHAd J7qQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FY6gCDCz; 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 a640c23a62f3a-aa67ce11b99si55292666b.360.2024.12.08.02.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:53:01 -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=FY6gCDCz; 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 70CDA89515; Sun, 8 Dec 2024 11:52:48 +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="FY6gCDCz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1BD6B89515; Sun, 8 Dec 2024 11:52:48 +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-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (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 1D2A38954B for ; Sun, 8 Dec 2024 11:52:46 +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-x62a.google.com with SMTP id a640c23a62f3a-a9a68480164so447443666b.3 for ; Sun, 08 Dec 2024 02:52:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733655165; x=1734259965; 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=iMp5c3d4w227EBQRr8iv9j9OVqGRaUTFIpDzyMLlBVk=; b=FY6gCDCzAugb3eYYtNcCGLeq2PQewYJgZngDZ4v4CbbdLF0TCm1oB51MxHZ0itFEH8 YxSklHb6mkTZo2EZOrjvYK1JqLvMKYAFZnUm5zamfsk3Y/TIbPRivCoaxS/DhUrImbKZ Oh2DP2aBI32dBDhz0fK15U+B5vCYNjqDudRRYe/UWN+9lcjubcNjKA5DJcF9NiBCov6H oY7W99pD0SxpGk/Eu7SDVs0UqjB5JbTHzEpks2L9ebGRlh6GnY2dVFbZr4XG7rIq5P2w Zen7F5M/Vi3dLEZZtleKRqJ+HnpLwEZQRaHh3YBsO69nirdbw+YQtUmK55sHYvY75JqG zCRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733655165; x=1734259965; 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=iMp5c3d4w227EBQRr8iv9j9OVqGRaUTFIpDzyMLlBVk=; b=JFZQFPtfPzAwl4/j0twjfGItZv2HWRpQ6AmDBjxXCGzCdj02kMdCqDpUa/cDM2fRJm 7yC8ll59e6O5ZUv2EvAb37F9FerjpLTKG955uUjsxxLom0VhUB3EaaEZ1V32Xeb/mWu+ 1OvWsmni95VCCvc3sEyUUwjofoGz1uGGq6rkwRaoi4M9pI5dYHEMLoOXJvzuTgARQxN6 GSoqqUhy7JqLYtlq0unImLjjcwSLO3tiiXuJ+lWEpwQcnXK7FZVZydnK+81v3EzOklIP sS2afz3ugBh+cM5FV2eUs/rNY3LaE5B/WXQgFSo9tSsNL0LZu6SiqgVMU7Iz1aelKXDi v6Og== X-Forwarded-Encrypted: i=1; AJvYcCV6qLzFjWkLA2zSX3u6kkTveXvbmPZshYQq12mpS3vHEBdgjPAn1VfCbthl1WKfOcwgnK06OlM=@lists.denx.de X-Gm-Message-State: AOJu0YxEKSaTZVVwiyCgN1vUsYM29AAUDmmdMbsJ07Mo05UCxaWDXX0j LnCz+KcGDHLDngnO86EZslfwFDCYCgUCkA4IK02d1Me4wVu2p5djaO42nnHLJvg= X-Gm-Gg: ASbGncs8Oo5tL90e9KrllVyGhehCs8LhdxI3iMIkXabjmfVVgZtLK+dqSLT0v8ACD6t hWrHZIiZ4/X4/9xJPQ7VJ0sqzCLR+WX9y30z/j71vzmvzIrsMzNRtJO1hL6QbfHSo/R4O4nCHiy NE4ca9T18zVi0T36hQ8ZOMsfpwHQdT2IVcgf6iaYk3KFUXvnb7SjBk5aq/0GLtgJgANIhMI2yKK AzqLo+xkYELbyzfrUjaQdGMMyOgulUsYpoSnlMRtESvdpA/kKULAyaPQVKUQonPh3JxMj6m2FoZ l6rSgDFzFAy/Dr5fyJuDuONvMU4= X-Received: by 2002:a17:906:1da1:b0:a9a:161:8da4 with SMTP id a640c23a62f3a-aa63a2432c6mr699458266b.55.1733655165437; Sun, 08 Dec 2024 02:52:45 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625e92fe3sm517768566b.51.2024.12.08.02.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:52:45 -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 , Sughosh Ganu , Marek Vasut , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Nam Cao , AKASHI Takahiro , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [RFC PATCH 2/7] lmb: Simplify lmb_addrs_overlap() Date: Sun, 8 Dec 2024 12:52:05 +0200 Message-ID: <20241208105223.2821049-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241208105223.2821049-1-ilias.apalodimas@linaro.org> References: <20241208105223.2821049-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 There's no point subtracting -1 from the calculated addresses and then check for a <= b. Just remove the -1 and check for a < b. Signed-off-by: Ilias Apalodimas --- lib/lmb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index a7ecbb58831f..c7bf5120696f 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -36,10 +36,10 @@ DECLARE_GLOBAL_DATA_PTR; static long lmb_addrs_overlap(phys_addr_t base1, phys_size_t size1, phys_addr_t base2, phys_size_t size2) { - const phys_addr_t base1_end = base1 + size1 - 1; - const phys_addr_t base2_end = base2 + size2 - 1; + const phys_addr_t base1_end = base1 + size1; + const phys_addr_t base2_end = base2 + size2; - return ((base1 <= base2_end) && (base2 <= base1_end)); + return ((base1 < base2_end) && (base2 < base1_end)); } static long lmb_addrs_adjacent(phys_addr_t base1, phys_size_t size1, From patchwork Sun Dec 8 10:52:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 848273 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1608552wrt; Sun, 8 Dec 2024 02:53:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV4h5/6MOFajFh+btEhg0yNaM2RgdD2lDf18JM5do3ieQNKU+dQV4xHF7EWfE2CXQcGIwywxQ==@linaro.org X-Google-Smtp-Source: AGHT+IHUlfo3LZdOraobFeyixrtB1EpVUMbrPV5pK4zhHa3GWymJ3Ba4sRhUfXCJc05aE/hghN7q X-Received: by 2002:a05:6402:458b:b0:5d2:7199:ac2 with SMTP id 4fb4d7f45d1cf-5d3be661af9mr21761394a12.2.1733655191355; Sun, 08 Dec 2024 02:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733655191; cv=none; d=google.com; s=arc-20240605; b=O0ACBLmpvdQ1ZCdE7FdTqX2oZQ+j47KVlVNoY8nk+Ns6m2UTMXFISOs6Lx5BY/Yvct keuHAwDF1YeZHz67kVwxXGKjyC4pqyheht1cMODotL29NFb5kGqJpiy8j0NTzyuF07K3 tUsVbLqZRWHuON0LBjo95BnYU00Rg1rgSWK9SXkLwDo4GlEPZyD8oWSuSJlnHYAuOjEY cGkGJrb8oWlZAxV03qW8dlv/vQJf0RVS1Rh7NF16KxpWc40hi1fY6KVS82HEFLlgHPPv vbM58UnY21CRjJxPna3vhrr/Oes3A+0BsZmOqDgVpqoDu4f+ZeOLuzqzZMZ5QFbjT9o3 Hlug== 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=3+pW5tMGIgPYQo5r7DA3jKbiS3JPJXBp8guvFqijUCI=; fh=zjMJe5+eKPkwNWbHAB9TKGerxG5196xYuEjDo23Jylw=; b=IIvrSYd3DM1Cp0JzCbKH1HoVXsvwAEgEEQURALR5bSarpQYmCLqZPViov4mR0f6M7j rQf6xled/HcbbPmYXbkRaJ+vEat63T280To7jWq2oeveXltutKFsBllAtE3erCKtSvmV 69etFe2HSfiAMKAo0+rHb7IICtkDqWWc5hYkowag694qtthr8ZvGCFenaWCG2WczqZbV dSORGZ/Bq20ZBhNdQUyHOmYvj7Tb9Uztf2y7jokD2EnxUZkiic8ffxvR2deZs1FJlKsy QrJJE7i/13W9fJGtElLW4XKv/dwB3YSJMHhj4t8MPz4ckOKw85NvAb+21kVgoEsRlksJ QPLA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fNFRNDaS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5d3c2a4fcaesi3544021a12.628.2024.12.08.02.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:53:11 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fNFRNDaS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 CA2648954B; Sun, 8 Dec 2024 11:52:52 +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="fNFRNDaS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6784893BF; Sun, 8 Dec 2024 11:52:51 +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-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 96F59895A4 for ; Sun, 8 Dec 2024 11:52:49 +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-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5d3f249f3b2so460159a12.3 for ; Sun, 08 Dec 2024 02:52:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733655169; x=1734259969; 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=3+pW5tMGIgPYQo5r7DA3jKbiS3JPJXBp8guvFqijUCI=; b=fNFRNDaSO9O5UHTLwNfzz/Y8CyisFPiG2rOnOXbTG+BIz27VxGUNhRvLuvag+BFtro YW3T9wHCFrLutXJEhUn95bTGKoAh9T0lL+q+SNCgzAnH1hMd83JUHtZv5bUcN2wFPrSl TcU3l4HsfTCGHje9tPYqGzjV0Tqdt1qqeaZJAKI2IJx74fvn/amzBw8nyJ6biTpxBlQb gUtSyJ7AUlp3ImWJ6IMQ/nQGPUJWuCd9kkf3lzaazwH6MpylqIDdwQc+RbxRbmo3rzDg LBdcWfV3ke1mwyyrtQBMjcl7RAEiiFuzG90DBia1z/m/mOmIk0xUKe9GwpWEkyiP/HZL QjLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733655169; x=1734259969; 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=3+pW5tMGIgPYQo5r7DA3jKbiS3JPJXBp8guvFqijUCI=; b=KjKYQC2xRkep7QvIaZww8W98TV2nJUejEjQT9ooxYrI1cz9cslDeobme3pEwYqVruZ UXz67okdq8n8Tn1a1Vd68FnzSunTFgi46GiVECj8M8Bu80AD2ykAK30/koeiEiTxsJu2 vasVO3CwcJ0G7+wee9wTqE38jAzqrX9C2mvuzOVBcatLw4aWH6SumapgU9DZ24a0FlJH fh1+Xiu9F5Cre9fWS79rAYmo3E0tMCA7eMUbCo4HWaPJfnVJ/bD1B46cxryBgURb2a8S 8+ksWfO88syFxQsjwFUYfwmHoxdkvce0/nX5a1WLTOP49P6gCawEiWWeV08PoC4sNFnz 8ezg== X-Forwarded-Encrypted: i=1; AJvYcCWgAJWp/zcarVMBkzde6+aw4ev28Up9X2y4TMcSHrZ6QJtEtOV7ggxfO+8RjaWrmBYpcsnj/+4=@lists.denx.de X-Gm-Message-State: AOJu0YxKRWcE12Sm94xr9/7VPpV4tTQUQqFuhYkePcKZD5sfWURhRkd4 //OafCHQXLPFV5Evv6kb+UZE9rXvfj/eA7Otjs/RWqYCUKKcqYLw1SsvMK7Y09A= X-Gm-Gg: ASbGnctrYDd6BSIGuYPdazIMd7kGOa4lgl3kMk+9bSylOB6XClqI0AzCyP6Yugkgv+2 T4ZrRNIxkrUUtD+o95gRRBWqEE1/B1Knp72i2k697iqLqC424PrC78Sq8/i7lXRJwpcLA4bZ1ro +NXXDwNWBV1ZXXFpTByydShq+tVyoDjRK3fgb5TpKFLWjD7S+G254xGU0WSVz8qupNDpMRAdfgT dFIa8YORnT1vlD2riPUaOSE6gqpcJW1V6F6hWUs3Z5jbnwU9lh1S1hipwKJ1hXNgxCMjxvzXl4d +SsMSIo1Sc1x7hzMJDDTwCvvEtg= X-Received: by 2002:a05:6402:915:b0:5d0:d818:559d with SMTP id 4fb4d7f45d1cf-5d3be6801a6mr25297877a12.11.1733655168966; Sun, 08 Dec 2024 02:52:48 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625e92fe3sm517768566b.51.2024.12.08.02.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:52:48 -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?= , Sughosh Ganu , Simon Glass , Marek Vasut , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Baruch Siach , Nam Cao , AKASHI Takahiro , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [RFC PATCH 3/7] lmb: Rename free_mem to available_mem Date: Sun, 8 Dec 2024 12:52:06 +0200 Message-ID: <20241208105223.2821049-4-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241208105223.2821049-1-ilias.apalodimas@linaro.org> References: <20241208105223.2821049-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 free_mem is a misnomer. We never update that with the actual free memory. Instead this field describes all available memory and it's checked against used_mem to decide if a memory area is free or not. So rename it to something that better describes its usage. Signed-off-by: Ilias Apalodimas --- include/lmb.h | 4 ++-- lib/lmb.c | 34 +++++++++++++++++----------------- test/cmd/bdinfo.c | 2 +- test/lib/lmb.c | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) -- 2.45.2 diff --git a/include/lmb.h b/include/lmb.h index 62882464f866..54af5b0e4b44 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -47,12 +47,12 @@ struct lmb_region { /** * struct lmb - The LMB structure * - * @free_mem: List of free memory regions + * @free_mem: List of all available memory * @used_mem: List of used/reserved memory regions * @test: Is structure being used for LMB tests */ struct lmb { - struct alist free_mem; + struct alist available_mem; struct alist used_mem; bool test; }; diff --git a/lib/lmb.c b/lib/lmb.c index c7bf5120696f..ffdd23d87b9b 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -350,7 +350,7 @@ int io_lmb_setup(struct lmb *io_lmb) { int ret; - ret = alist_init(&io_lmb->free_mem, sizeof(struct lmb_region), + ret = alist_init(&io_lmb->available_mem, sizeof(struct lmb_region), (uint)LMB_ALIST_INITIAL_SIZE); if (!ret) { log_debug("Unable to initialise the list for LMB free IOVA\n"); @@ -371,13 +371,13 @@ int io_lmb_setup(struct lmb *io_lmb) void io_lmb_teardown(struct lmb *io_lmb) { - alist_uninit(&io_lmb->free_mem); + alist_uninit(&io_lmb->available_mem); alist_uninit(&io_lmb->used_mem); } long io_lmb_add(struct lmb *io_lmb, phys_addr_t base, phys_size_t size) { - return lmb_add_region_flags(&io_lmb->free_mem, base, size, LMB_NONE); + return lmb_add_region_flags(&io_lmb->available_mem, base, size, LMB_NONE); } /* derived and simplified from _lmb_alloc_base() */ @@ -387,9 +387,9 @@ phys_addr_t io_lmb_alloc(struct lmb *io_lmb, phys_size_t size, ulong align) phys_addr_t base = 0; phys_addr_t res_base; struct lmb_region *lmb_used = io_lmb->used_mem.data; - struct lmb_region *lmb_memory = io_lmb->free_mem.data; + struct lmb_region *lmb_memory = io_lmb->available_mem.data; - for (i = io_lmb->free_mem.count - 1; i >= 0; i--) { + for (i = io_lmb->available_mem.count - 1; i >= 0; i--) { phys_addr_t lmbbase = lmb_memory[i].base; phys_size_t lmbsize = lmb_memory[i].size; @@ -514,7 +514,7 @@ static void lmb_dump_region(struct alist *lmb_rgn_lst, char *name) void lmb_dump_all_force(void) { printf("lmb_dump_all:\n"); - lmb_dump_region(&lmb.free_mem, "memory"); + lmb_dump_region(&lmb.available_mem, "memory"); lmb_dump_region(&lmb.used_mem, "reserved"); } @@ -650,7 +650,7 @@ static long lmb_add_region(struct alist *lmb_rgn_lst, phys_addr_t base, long lmb_add(phys_addr_t base, phys_size_t size) { long ret; - struct alist *lmb_rgn_lst = &lmb.free_mem; + struct alist *lmb_rgn_lst = &lmb.available_mem; ret = lmb_add_region(lmb_rgn_lst, base, size); if (ret) @@ -706,9 +706,9 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t base = 0; phys_addr_t res_base; struct lmb_region *lmb_used = lmb.used_mem.data; - struct lmb_region *lmb_memory = lmb.free_mem.data; + struct lmb_region *lmb_memory = lmb.available_mem.data; - for (i = lmb.free_mem.count - 1; i >= 0; i--) { + for (i = lmb.available_mem.count - 1; i >= 0; i--) { phys_addr_t lmbbase = lmb_memory[i].base; phys_size_t lmbsize = lmb_memory[i].size; @@ -800,10 +800,10 @@ static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, enum lmb_flags flags) { long rgn; - struct lmb_region *lmb_memory = lmb.free_mem.data; + struct lmb_region *lmb_memory = lmb.available_mem.data; /* Check if the requested address is in one of the memory regions */ - rgn = lmb_overlaps_region(&lmb.free_mem, base, size); + rgn = lmb_overlaps_region(&lmb.available_mem, base, size); if (rgn >= 0) { /* * Check if the requested end address is in the same memory @@ -854,10 +854,10 @@ phys_size_t lmb_get_free_size(phys_addr_t addr) int i; long rgn; struct lmb_region *lmb_used = lmb.used_mem.data; - struct lmb_region *lmb_memory = lmb.free_mem.data; + struct lmb_region *lmb_memory = lmb.available_mem.data; /* check if the requested address is in the memory regions */ - rgn = lmb_overlaps_region(&lmb.free_mem, addr, 1); + rgn = lmb_overlaps_region(&lmb.available_mem, addr, 1); if (rgn >= 0) { for (i = 0; i < lmb.used_mem.count; i++) { if (addr < lmb_used[i].base) { @@ -871,8 +871,8 @@ phys_size_t lmb_get_free_size(phys_addr_t addr) } } /* if we come here: no reserved ranges above requested addr */ - return lmb_memory[lmb.free_mem.count - 1].base + - lmb_memory[lmb.free_mem.count - 1].size - addr; + return lmb_memory[lmb.available_mem.count - 1].base + + lmb_memory[lmb.available_mem.count - 1].size - addr; } return 0; } @@ -895,7 +895,7 @@ static int lmb_setup(bool test) { bool ret; - ret = alist_init(&lmb.free_mem, sizeof(struct lmb_region), + ret = alist_init(&lmb.available_mem, sizeof(struct lmb_region), (uint)LMB_ALIST_INITIAL_SIZE); if (!ret) { log_debug("Unable to initialise the list for LMB free memory\n"); @@ -967,7 +967,7 @@ int lmb_push(struct lmb *store) void lmb_pop(struct lmb *store) { - alist_uninit(&lmb.free_mem); + alist_uninit(&lmb.available_mem); alist_uninit(&lmb.used_mem); lmb = *store; } diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index bb419ab2394e..e5b422ab2ba8 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -131,7 +131,7 @@ static int lmb_test_dump_all(struct unit_test_state *uts) struct lmb *lmb = lmb_get(); ut_assert_nextline("lmb_dump_all:"); - ut_assertok(lmb_test_dump_region(uts, &lmb->free_mem, "memory")); + ut_assertok(lmb_test_dump_region(uts, &lmb->available_mem, "memory")); ut_assertok(lmb_test_dump_region(uts, &lmb->used_mem, "reserved")); return 0; diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 8af5dcad2ecc..0f7052224c10 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -65,7 +65,7 @@ static int setup_lmb_test(struct unit_test_state *uts, struct lmb *store, ut_assertok(lmb_push(store)); lmb = lmb_get(); - *mem_lstp = &lmb->free_mem; + *mem_lstp = &lmb->available_mem; *used_lstp = &lmb->used_mem; return 0; From patchwork Sun Dec 8 10:52:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 848274 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1608568wrt; Sun, 8 Dec 2024 02:53:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVHsKtzUfkoerKlCPirIHONvdxKPO46hja+8flgVOurvoB0h0hGGFTuRFCkpgAjI+xDWIaARA==@linaro.org X-Google-Smtp-Source: AGHT+IE+HvONbCjxDsTYUHPWKMwlT5Zdq0N9kZfRU23MJVBeV/0KNxWEbIuXdbwp1uEB188Myypg X-Received: by 2002:a17:906:308d:b0:aa6:7c36:342d with SMTP id a640c23a62f3a-aa67c36351dmr124505566b.3.1733655200145; Sun, 08 Dec 2024 02:53:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733655200; cv=none; d=google.com; s=arc-20240605; b=abmkmqQx1Wj3MEczxShASnMRkJkT9MvomrQfICv573/RDdws1Tx+wwoQYV/1zY5Vo4 jbdY3VwoJVnUq5Xz+pE7CVJMowbCA92YHOKFTfq3HRSb1rTB2dfuv6i+NwSpnHmRHC8/ 6qKQtaHZ35J63CEMMn9ssoGpyRKR2yHG6KAxEnGSbDoAZAYzwN2w4SuXIBGO/aXfXVGI Y6u7yUcVJX8MB4m7CkdVBITOjhjmyOU4pCQEY/Pv6aKm3pvtyWb6I0bUl47rJoHfeqC9 tdJXC4n8G4yj5wY3z0iYkxEzWrj9zWg95xsT7GE+1v8A8Op9xN2x5BCqLAtcfzIkCQ7y Vxtg== 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=pAmvCUSXW6aB30F7BDwm6ua6DD8so9h99thLaEi5j+U=; fh=J0A5L2PCLN29undsJV7F9P+YDI6KZiWPqds4bfj4qNw=; b=lCjucI9p/TXuczPn38U15sEhTQ0CsfA7uUlyEeERqa9GXn7YVhORtJAqj1nu2jKAD0 brba6mZzqHuZsVw6OfG61XPdEFLZ/GDh8HsE3BxFs6nIB4ltoWO/XajSRoQPofsDvOSl nXpRWJuxClqGjhOwj4vMVZe/1+c/SQvi12Jq/vy6/vQXdcwl1Z4B1CqQJruAyDnHcs7N r6W7bnWPFV3RAGx865cHY4yAV2YsD0yXNYzO3gPYZlGgcipjFvLuA+xYJuuCr0uH7BWe KWRnNmv5XHHyCCNz+Qs5RC4xBrsPJl45tNTE98ScQG63hDvg2F0KK/Oxvl8W88XRWaIi e3Qw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fUU7oL0s; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-aa625ed84a3si525174566b.33.2024.12.08.02.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:53:20 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fUU7oL0s; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 337D8895C2; Sun, 8 Dec 2024 11:52:56 +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="fUU7oL0s"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 05BDF895A1; Sun, 8 Dec 2024 11:52:55 +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-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 0806B89589 for ; Sun, 8 Dec 2024 11:52:53 +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-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5cf6f804233so4160927a12.2 for ; Sun, 08 Dec 2024 02:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733655172; x=1734259972; 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=pAmvCUSXW6aB30F7BDwm6ua6DD8so9h99thLaEi5j+U=; b=fUU7oL0sz9UBeYYfL/ebLK4avQvYKGBH/WVzDTfS+Sb9Incp7mN9cfVWnECLSny/Fn yAlZZwo96LwWwcR707QYVQjlRmazrBPosYActwUyk4p/BKdY7lMi21jRpb4lvK2yCu+e BCE5uZKlChflM5rcCfByZsDu/Vgofwcra/s1iEKBM/AbkNHadhnd0Bg/qfVWp7JJnrMq sTcl2kNZ4yHaUOOwJ9z941yyFGZg1+qTXrw0YzNL4zarkxHDICCcC522JrCmVEdfjqtL JiYyctp88pX/mNzFD61D31yixGfoM2oBq/jcg1jwDlIaprPQZ+JoiqavD8kPBoPtL4co 3Qlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733655172; x=1734259972; 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=pAmvCUSXW6aB30F7BDwm6ua6DD8so9h99thLaEi5j+U=; b=MhfU9JVzu/xpuHEYU2xvzkhy8Bw6g9UCcCw/LGHNa6Qzm8wG/WovFZ2CA4cW44NQR3 8abGSZH5Xoxw6LqwSqV+uMQWSEsmL4Nck7GZUDCEkKokK/jVi1FXFe13M6Qn1PF7NVil 8hz3EN1xnetkmDmV9CVKbYQFvLwYUSCfD8XrHTRaejnUf+qkVzBM5UPdDBIOab05gbUZ TVp5rPlet0GAV6idr00A8o6VhmiyjUbyA5CuuRv+SZwF/dErgfksT2d8HUeUQD6+PbJQ Y8vPlXH0Q86w7KzT0oXLXryF8NgLv/CDc/+eZ42mpZw9jLpVIPA/JQMZRo9u4yan0qLJ aKoA== X-Forwarded-Encrypted: i=1; AJvYcCUpMIABAb1ClciX2jLzc12SnDlfrMan7GXa9bkvAlKd562nABthyeG9gI4tvpm8YJsKmmIodak=@lists.denx.de X-Gm-Message-State: AOJu0Yza2PcArNDhhy/nkR5L/x3JoS5ZvVHXU+PN3x3yh7FJQQokuugl 6q/TVYyZc8BLNEW09s0sYOVoDU4DikEBNFYCQ5FF+S703PsCKpe5FFkpuSvLQa4= X-Gm-Gg: ASbGncsqmxynAlz/1c0RYypM37vtreilSH6quTRr7W20xiCHRJPI1Dt1xtHO8Y1igFg HPpPNx8pLddk7C9zekVlMcmgpFwIG1nUZ+BH4NS/y4Lht6O3Bj7QHWoUSKaJDq+j10WmxRkmuqh DQcQMFY5ZcdSyacwI47E1tFaHiHGiLg/ePy1Qvj8CG5r7tvsjsbeTpoEA1UUFgkwod6KWLkNKO5 +NOB2jvLtHaavDOcFiIdsaunhZ3d5kqIMDT/yxZviXQhCWOjrm0f0N/1KY+xUHgZOcfwa2t7oEg UUyR3aGfvxDT6QXwdbtfJfXVxQg= X-Received: by 2002:a17:906:3d21:b0:aa5:44a8:9ae7 with SMTP id a640c23a62f3a-aa63a20ecb6mr886366466b.47.1733655172489; Sun, 08 Dec 2024 02:52:52 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625e92fe3sm517768566b.51.2024.12.08.02.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:52:52 -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?= , Sughosh Ganu , Marek Vasut , Simon Glass , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Nam Cao , Mayuresh Chitale , AKASHI Takahiro , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [RFC PATCH 4/7] lmb: Remove lmb_add_region() Date: Sun, 8 Dec 2024 12:52:07 +0200 Message-ID: <20241208105223.2821049-5-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241208105223.2821049-1-ilias.apalodimas@linaro.org> References: <20241208105223.2821049-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 There's no point defining a function that's called only once just to avoid passing the flags. Remove the wrapper and just call lmb_add_region_flags(). Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt Acked-by: Sughosh Ganu --- lib/lmb.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index ffdd23d87b9b..56e005308dde 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -640,19 +640,13 @@ void lmb_add_memory(void) } } -static long lmb_add_region(struct alist *lmb_rgn_lst, phys_addr_t base, - phys_size_t size) -{ - return lmb_add_region_flags(lmb_rgn_lst, base, size, LMB_NONE); -} - /* This routine may be called with relocation disabled. */ long lmb_add(phys_addr_t base, phys_size_t size) { long ret; struct alist *lmb_rgn_lst = &lmb.available_mem; - ret = lmb_add_region(lmb_rgn_lst, base, size); + ret = lmb_add_region_flags(lmb_rgn_lst, base, size, LMB_NONE); if (ret) return ret; From patchwork Sun Dec 8 10:52:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 848276 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1608641wrt; Sun, 8 Dec 2024 02:53:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW0Q2HxOttV1FNLlRd6DNobCAokoXWDwxcmVkGcWuohnC7qBoJqhJXORIxEGJ0EwHPU5jc4cg==@linaro.org X-Google-Smtp-Source: AGHT+IEYVY6+BQgja+bcombgS9e+z1HOc06f9mGzrxLfx4B6qlfqXu/BVmSCfGDdynGq9EderJVe X-Received: by 2002:a17:906:3147:b0:aa6:7f95:8501 with SMTP id a640c23a62f3a-aa67f95f122mr77756966b.23.1733655217309; Sun, 08 Dec 2024 02:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733655217; cv=none; d=google.com; s=arc-20240605; b=WzVPi2RMJxFK/jSm5Y3QCmT7gccmmQ7JyE2BOapNMvJCrjk0qCs4kE4WT4dCH/EfIe gsvtoTCnlRQTcXmElYruxMmqBYtGkzJK4QLCvOnYbxD7wrBASK+W6L43th5CKj8Uv/XL ThnOwBjIYJb535H2nSOMTEafcnVliOpgr1518cDVRIxtfoJKgKS8tvUJ0ZFU2mywXJGd U59t5To1kivv+sWEX7pCKw8S9o+3MG7omvN4gUjIQolH/6b5FzwU0eki+VROuFsi4kO4 glEN7qlTOtjr9n6LvOsox1CA+bENxZfDB2pn72GMCw4oeV1KFizye0HvCjvRNMJqmBsR UWqg== 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=rkmf/4JNVBoQ9BT6ifykdrJ3oCI8JLjeR4Q+X86P+r4=; fh=11qwqmSzCh5/uQQgFtDpANcakrCzY+o+Gc8XFjeWM8k=; b=MreXAQF6OjbQErSCrP2EWdiIsRRS5Tw5kUZU+ef8bjz7Thgq/7JQw7EVLVSqgWCQWE 7O8Q++/oh8h+AOgHP0pmj6mBDDT9CwvOo3jE1yAMnVG3mE0mM4OqkB1q17rFvojG0uBO KhQeJ7QJfHZ3yOcYVMT1heHHKoH4tllURkvaHl8znuL6ufX4OMkLnifhmrE7SrAbfC3d G4lwwgMSm776J1Is5AV6fpuXW6YPHSyS5a0d6/gGzSLJGFh1Bs8JqkTVuA57j+bZTgWw JniKyYZQ1/ukRFeZQNk7f3L9onkiRXUkW6dwlldP+Z9dGtaacS0aMCGLCUvIKrLyCF46 phfA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HwoG7VvK; 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 a640c23a62f3a-aa677968d18si81065766b.695.2024.12.08.02.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:53:37 -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=HwoG7VvK; 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 F420E895B1; Sun, 8 Dec 2024 11:53:04 +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="HwoG7VvK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0D11389589; Sun, 8 Dec 2024 11:53:04 +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-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (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 77869895DD for ; Sun, 8 Dec 2024 11:52:56 +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-x630.google.com with SMTP id a640c23a62f3a-aa63dbda904so423158266b.3 for ; Sun, 08 Dec 2024 02:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733655176; x=1734259976; 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=rkmf/4JNVBoQ9BT6ifykdrJ3oCI8JLjeR4Q+X86P+r4=; b=HwoG7VvKYr2kzEjt7ea5glDqgmX/vAwjB2ZNXLE7J6t3ahEXi6yZ2RUsssywDXbuwB V6j9A9FaZVRmYiLHhCx8Lsj4tSr872f+b+Fuo6eYVEcMiJd8nFenwZDLKX6bQG9kDjCH Lsfr0n6kKiAz4jhPLq2GNgxMimOA23OsHU7+Nc+h/AWu50m8GWzhMNvNZDqLFJKfJkp9 yKH0uI8kgVwMMwAqTDxcj5jD6fD07/RwtvnXYrjo2QZj4genHfVg4dc+ZIwVmXujNnQK V4LfsnWtywq8JzBS+rnllFBy8djB+yqjghqHIlSHGpFppPpSbhIa17gsmKFidBs7trfR VEsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733655176; x=1734259976; 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=rkmf/4JNVBoQ9BT6ifykdrJ3oCI8JLjeR4Q+X86P+r4=; b=vdS3OoXf6IE7fl8cgPutpfOABbh6pvZG+k8rcZDUyAkC45RH/b/hs9PJZVL2yYrawu 4H2eWDNol74IsqPbs1GNITux2t1ffxxgRr4Aa/sTYkA0fwLL3rHrzeMYQD6VFwiOy2hY SOR2lapvHkQ2nhYrNMVToPIHpszRPx8gcU/h18gqftNHZAmP3pAFkEAlccKrC95+52/Q Tj0Dkby87ylvfddYQdQJ8h6zfhEnxeM4zLchCNxwiVnUnJWrtCN3CmEoR6WzzOe/ud2A Ewf4cW1JTuUD+gvRLflIdJuuPYf+vvrY0saMSLCHNd7Wac1u6N25BhbYvrMoCD9VjSU9 rPvA== X-Forwarded-Encrypted: i=1; AJvYcCWMavGZa4AtIVT5tVmkFW4eharptRsnX6TaaitpHn5EXlMxoRB1+LAO7OmVGnrEnIYejuehEHs=@lists.denx.de X-Gm-Message-State: AOJu0YyiizIO0JdTEMh0RXbBwIsUI3mO785GwOw4foLWC0YVuh58TJKT wJN5JzXxa5tAV4krArtiBs2nsfvD/YILJUHVJkpkC06HQNyffUUnOFKx+CdpMkk= X-Gm-Gg: ASbGncshwrQPWStK/iDWGWBz/dyhxwXZIVSPkvCSEltZnsKOWew1uGLtUj6825phSIn Zt+Q+8rklpVbkHd7i3AiEsMeY33RVryAYqRb1iXPvsS30BpUIbH2Y095zaiYBPoUxeE1zjPu9/X ffL7RZBkXmkSVgFGTYaiA7PMcN3tMx3yUAHJXveOmBaUSDrxTkT+J7jUWgipFw2EFwLlmS/v/7g ZCG6fd4lH99UsZmJzZ9E1b0UUUx/mEJRViOhmhAwtJRA0pLkp+NMLSs1kTNMhWFEhTyqtpglh5t Np/30bIppslJWivjvzvV0fAKXJU= X-Received: by 2002:a17:906:9555:b0:aa6:423c:8514 with SMTP id a640c23a62f3a-aa6423c8842mr701631566b.40.1733655175946; Sun, 08 Dec 2024 02:52:55 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625e92fe3sm517768566b.51.2024.12.08.02.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:52:55 -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?= , Sughosh Ganu , Marek Vasut , Simon Glass , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Sean Anderson , Nam Cao , AKASHI Takahiro , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [RFC PATCH 5/7] lmb: Replace lmb_alloc_addr() with lmb_alloc_addr_flags() Date: Sun, 8 Dec 2024 12:52:08 +0200 Message-ID: <20241208105223.2821049-6-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241208105223.2821049-1-ilias.apalodimas@linaro.org> References: <20241208105223.2821049-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_addr() is just calling lmb_alloc_addr_flags() with LMB_NONE. There's not much we gain from this abstraction, so let's remove the former and make the code a bit easier to follow. The code size increase is minimal - e.g for sandbox which includes all of the LMB tests add/remove: 0/1 grow/shrink: 5/0 up/down: 33/-4 (29) Function old new delta test_alloc_addr 2939 2963 +24 wget_handler 1530 1533 +3 tftp_handler 1190 1192 +2 do_spi_flash 3150 3152 +2 _fs_read.lto_priv 331 333 +2 lmb_alloc_addr 4 - -4 Total: Before=2492734, After=2492763, chg +0.00% Signed-off-by: Ilias Apalodimas --- fs/fs.c | 2 +- include/lmb.h | 3 +-- lib/lmb.c | 9 --------- test/lib/lmb.c | 28 +++++++++++++++------------- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 21a23efd932d..b7d422eaf0d1 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -554,7 +554,7 @@ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset, lmb_dump_all(); - if (lmb_alloc_addr(addr, read_len) == addr) + if (lmb_alloc_addr_flags(addr, read_len, LMB_NONE) == addr) return 0; log_err("** Reading file would overwrite reserved memory **\n"); diff --git a/include/lmb.h b/include/lmb.h index 54af5b0e4b44..4e8e4f23e279 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -94,7 +94,6 @@ long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags 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_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size); phys_size_t lmb_get_free_size(phys_addr_t addr); phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, @@ -152,7 +151,7 @@ void lmb_pop(struct lmb *store); static inline int lmb_read_check(phys_addr_t addr, phys_size_t len) { - return lmb_alloc_addr(addr, len) == addr ? 0 : -1; + return lmb_alloc_addr_flags(addr, len, LMB_NONE) == addr ? 0 : -1; } /** diff --git a/lib/lmb.c b/lib/lmb.c index 56e005308dde..6dbdd81bd7d8 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -815,15 +815,6 @@ static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, return 0; } -/* - * Try to allocate a specific address range: must be in defined memory but not - * reserved - */ -phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size) -{ - return _lmb_alloc_addr(base, size, LMB_NONE); -} - /** * lmb_alloc_addr_flags() - Allocate specified memory address with specified attributes * @base: Base Address requested diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 0f7052224c10..49857cb3fd4b 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -560,22 +560,24 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) alloc_addr_b, 0x10000, alloc_addr_c, 0x10000); /* allocate blocks */ - a = lmb_alloc_addr(ram, alloc_addr_a - ram); + a = lmb_alloc_addr_flags(ram, alloc_addr_a - ram, LMB_NONE); ut_asserteq(a, ram); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 3, ram, 0x8010000, alloc_addr_b, 0x10000, alloc_addr_c, 0x10000); - b = lmb_alloc_addr(alloc_addr_a + 0x10000, - alloc_addr_b - alloc_addr_a - 0x10000); + b = lmb_alloc_addr_flags(alloc_addr_a + 0x10000, + alloc_addr_b - alloc_addr_a - 0x10000, + LMB_NONE); ut_asserteq(b, alloc_addr_a + 0x10000); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, ram, 0x10010000, alloc_addr_c, 0x10000, 0, 0); - c = lmb_alloc_addr(alloc_addr_b + 0x10000, - alloc_addr_c - alloc_addr_b - 0x10000); + c = lmb_alloc_addr_flags(alloc_addr_b + 0x10000, + alloc_addr_c - alloc_addr_b - 0x10000, + LMB_NONE); ut_asserteq(c, alloc_addr_b + 0x10000); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram, 0x18010000, 0, 0, 0, 0); - d = lmb_alloc_addr(alloc_addr_c + 0x10000, - ram_end - alloc_addr_c - 0x10000); + d = lmb_alloc_addr_flags(alloc_addr_c + 0x10000, + ram_end - alloc_addr_c - 0x10000, LMB_NONE); ut_asserteq(d, alloc_addr_c + 0x10000); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram, ram_size, 0, 0, 0, 0); @@ -591,7 +593,7 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) /* allocate at 3 points in free range */ - d = lmb_alloc_addr(ram_end - 4, 4); + d = lmb_alloc_addr_flags(ram_end - 4, 4, LMB_NONE); ut_asserteq(d, ram_end - 4); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, ram, 0x18010000, d, 4, 0, 0); @@ -600,7 +602,7 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram, 0x18010000, 0, 0, 0, 0); - d = lmb_alloc_addr(ram_end - 128, 4); + d = lmb_alloc_addr_flags(ram_end - 128, 4, LMB_NONE); ut_asserteq(d, ram_end - 128); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, ram, 0x18010000, d, 4, 0, 0); @@ -609,7 +611,7 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram, 0x18010000, 0, 0, 0, 0); - d = lmb_alloc_addr(alloc_addr_c + 0x10000, 4); + d = lmb_alloc_addr_flags(alloc_addr_c + 0x10000, 4, LMB_NONE); ut_asserteq(d, alloc_addr_c + 0x10000); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram, 0x18010004, 0, 0, 0, 0); @@ -624,18 +626,18 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram + 0x8000000, 0x10010000, 0, 0, 0, 0); - d = lmb_alloc_addr(ram, 4); + d = lmb_alloc_addr_flags(ram, 4, LMB_NONE); ut_asserteq(d, ram); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, d, 4, ram + 0x8000000, 0x10010000, 0, 0); /* check that allocating outside memory fails */ if (ram_end != 0) { - ret = lmb_alloc_addr(ram_end, 1); + ret = lmb_alloc_addr_flags(ram_end, 1, LMB_NONE); ut_asserteq(ret, 0); } if (ram != 0) { - ret = lmb_alloc_addr(ram - 1, 1); + ret = lmb_alloc_addr_flags(ram - 1, 1, LMB_NONE); ut_asserteq(ret, 0); } From patchwork Sun Dec 8 10:52:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 848275 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1608606wrt; Sun, 8 Dec 2024 02:53:28 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWISTQsuWxLGIJ63H7pYmNS8pjSRG2d7g8y45sJG/LakNxzwEYyHmPJtphIOm21P//dTY04sQ==@linaro.org X-Google-Smtp-Source: AGHT+IGrqQVGopqan2tIYNrp0DMfahXJkZOLJcOlNwQIMVb8loIsY0v0ngVgW2a1wNYvTeVF9Xw1 X-Received: by 2002:a17:907:2716:b0:aa5:3e46:96f6 with SMTP id a640c23a62f3a-aa63a1877ddmr642434066b.31.1733655208654; Sun, 08 Dec 2024 02:53:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733655208; cv=none; d=google.com; s=arc-20240605; b=jtlIf25NLVPYBepPg8HJksF+MDwTNdPMEJxiKYmLBFYcj+8vvfevnVc4wManEA0Szn g7of9e0LVA/svVCBa1u/rA80HcV1Y5CrzYC9h7UyR2HG2FsbpUj7WH+2O641ZHB3HEyS SwMns8h51/ZWHwG0yHdwvyzWPuIOVeoBetoXDpOMCV/haPlrTem9D10v/9Fm/siqXrnf ntx0aUI4abRyj3nNp9TeeBEG/YG3KVZ3I3/FYmdFu+GOW0uOiR/O4Eg1C1bOfgvVmxUQ wEroUsENw+bWKyFg6J39zCk2mgtQT1HpdVxWMduNw9WPqcoHSbi0d2eVNO9orAh8Gbba W0QA== 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=2Ft5M/+tzeZwzuuJMrMRIXXkC4+uiGclSrP1ntGrZHs=; fh=kyBTch0nIS4vWy1KsmZKAsdJRYFyWoYSUQkyT/sKqLA=; b=j3gLKB9gr+RI39kBO3XjG01hNg3R5lobd3BY3A8TYngB0sQ2iZRMC5RpQ3UuO2bnpN B2RCPe/fCiYq/Ot84zkDyOj//yr8BRzCY0npqxq/df7GAKBSvCyfU/DgnYpwgbwO51+a MKuaWb+4kr4ytOQZZrC7FBHZ0okDRwDNVJ9cVfsh26DcYUTBUtKVv9iq0+RY+rqP01/H 9VMoyhDErq5BLtZZM8txEm3Faw4w3ZC2MfJXF29Ax7+YuFZxW34fzjC7zr9ENy8PxFgY IdLPJTGmEBXzcBAvpVSKdPSKttr2GeNnSVfAh6a4qnzVlk0n0E7gsSQjlM45woMLn/SP dq0w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uWuQ0jqY; 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 a640c23a62f3a-aa6260ccc77si541969666b.366.2024.12.08.02.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:53:28 -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=uWuQ0jqY; 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 93E088954F; Sun, 8 Dec 2024 11:53:03 +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="uWuQ0jqY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D9BE7895A1; Sun, 8 Dec 2024 11:53:02 +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-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (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 A0BD6893BF for ; Sun, 8 Dec 2024 11:53:00 +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-x634.google.com with SMTP id a640c23a62f3a-aa67af4dc60so39040266b.2 for ; Sun, 08 Dec 2024 02:53:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733655180; x=1734259980; 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=2Ft5M/+tzeZwzuuJMrMRIXXkC4+uiGclSrP1ntGrZHs=; b=uWuQ0jqYChqABzagbrkDm2YH9SMcXHpXO+/GTlvLGFW5QQKib3WUbHyA/R5nSTBNl+ Pab/TgyQCz2IZrw+FM55rtOOIRqIXSqtphb9T7GuRmeFSXn+PO7cYTQr0BDETzHEhtM/ HMOjiLHwxiBFjvLo6u5icKYCUluvUV2h/eOXOEnGmaNw+iZaOsDg4Cp4oKcOvWXW7nCS Yb7TozUas0kKDO3r4UDYKA6u59nSxCfdyvgeBL5Vu0603b1DnNYUB8t6IHDQfXePY0sA P2sG26yffXHzcQoYTVocNKhIYWxPimmfbIWAXVQ0DpHeUDa+7hB2rnJogIVkYddxq6mZ XHvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733655180; x=1734259980; 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=2Ft5M/+tzeZwzuuJMrMRIXXkC4+uiGclSrP1ntGrZHs=; b=uuUXjK4COQAc1UIjBebtl7XaeDyNE1KpObbGUwNm1DkPWDCqekzi1xvvP2+8HKTB+D UwmDgirDfAoT/t7LD3EZjqcs9COgD1Gk2cdr8qO0gjXAeVUNsNtU6osDYnmTszJxMvNP q+xAszaB8iy9ESqkrIPddDW4u9ah3iSpkuB3JGBME1zzs5anPUn4E/jamjbzXku8IgJa 8MmbXPDQ+BFoHUSBDIFfvnVqg8F1xtYkH7myXjOR+t2FUaOEf+YFhEVV8IAfQTIq87Yx YhECPvXp/j+3US5e0OlQiR7eJUdJR2wUkjovjOsVZwMiu3fKZMfTKBzSToKMLeC/aG1a k1jg== X-Forwarded-Encrypted: i=1; AJvYcCVGOjww+D2k6Rp1MnAGZZe2fPSto07pAl9iCQPOFGadXhtSdavJDnye9bn5JP5hIThUpxp2Po0=@lists.denx.de X-Gm-Message-State: AOJu0YxlRP9HBOagqEh6DW0pBe5yyJAItkAAShHwN8kVXEVK8WqLuQt9 YxAymZ9TmAEgFqEXEX9neUDnu2ojN5N7oFHAQsVZSgvYf5igYPSC7A2pbG+SitM= X-Gm-Gg: ASbGncsMPCXVA8nfaKdjTA8Q2XlnahjtrHRJIElpgpdqaTFqaKOxYJqJwUKRWUkPrb8 /ZCDXyXAv37uEY0NaPfE3ismxOhJlFa+UQWVp+rzVqUYj9yXDJF5q0r+fPxmyWujhaBBz4y77Jj tyHXTu7bOk1YegxIFJHO7rRjNbAchpo7rSdkHBX/ZKNsEbG0GMfo787Ub8aEdX11Vm5BSDhPLzf W4SlYc10YcXP4Hk7zQ2YHuH64ef0IAmt2YJv03cFAn0np90ohDSQpWOy2OJphy4LdiFEy9hezSD pggSjJ6c27gaZsLvc0DPcUqUJRQ= X-Received: by 2002:a17:907:7714:b0:aa6:3418:d9d4 with SMTP id a640c23a62f3a-aa63a073aa6mr686966066b.17.1733655180043; Sun, 08 Dec 2024 02:53:00 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625e92fe3sm517768566b.51.2024.12.08.02.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:52:59 -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?= , Marek Vasut , Simon Glass , Sughosh Ganu , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Nam Cao , AKASHI Takahiro , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [RFC PATCH 6/7] lmb: Replace lmb_alloc_base() with lmb_alloc_base_flags() Date: Sun, 8 Dec 2024 12:52:09 +0200 Message-ID: <20241208105223.2821049-7-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241208105223.2821049-1-ilias.apalodimas@linaro.org> References: <20241208105223.2821049-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 and make the code a bit easier to follow. The code size increase is minimal - e.g for sandbox which includes all of the LMB tests add/remove: 1/2 grow/shrink: 4/1 up/down: 316/-382 (-66) Function old new delta lmb_alloc_base_flags - 299 +299 test_multi_alloc.constprop 3036 3042 +6 lmb_alloc 4 9 +5 boot_relocate_fdt 601 605 +4 test_noreserved 1207 1209 +2 lmb_alloc_base 48 - -48 efi_allocate_pages.part 303 249 -54 _lmb_alloc_base.lto_priv 280 - -280 Total: Before=2492763, After=2492697, chg -0.00% Signed-off-by: Ilias Apalodimas --- boot/image-board.c | 22 +++++++++++++--------- boot/image-fdt.c | 6 ++++-- include/lmb.h | 1 - lib/lmb.c | 15 +-------------- test/lib/lmb.c | 8 ++++---- 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/boot/image-board.c b/boot/image-board.c index c4d914fd6074..d84104ab5c9f 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_flags(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_flags(rd_len, + 0x1000, + initrd_high, + LMB_NONE); else *initrd_start = (ulong)lmb_alloc(rd_len, 0x1000); @@ -838,8 +840,9 @@ int boot_get_cmdline(ulong *cmd_start, ulong *cmd_end) return 0; 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()); + cmdline = (char *)(ulong)lmb_alloc_base_flags(barg, 0xf, + env_get_bootm_mapsize() + env_get_bootm_low(), + LMB_NONE); if (!cmdline) return -1; @@ -871,10 +874,11 @@ 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()); + *kbd = (struct bd_info *)(ulong)lmb_alloc_base_flags(sizeof(struct bd_info), + 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 fd68b8594325..a4ef01a8a470 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -188,7 +188,8 @@ int boot_relocate_fdt(char **of_flat_tree, ulong *of_size) LMB_NONE); disable_relocation = 1; } else if (desired_addr) { - addr = lmb_alloc_base(of_len, 0x1000, desired_addr); + addr = lmb_alloc_base_flags(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"); @@ -217,7 +218,8 @@ 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_flags(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 4e8e4f23e279..a35a69d69f77 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -93,7 +93,6 @@ long lmb_add(phys_addr_t base, phys_size_t size); long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags 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); phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, diff --git a/lib/lmb.c b/lib/lmb.c index 6dbdd81bd7d8..c09f1a1277ad 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -747,20 +747,7 @@ 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); -} - -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; + return lmb_alloc_base_flags(size, align, LMB_ALLOC_ANYWHERE, LMB_NONE); } /** diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 49857cb3fd4b..df61b2fd5a0c 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_flags(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_flags(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_flags(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_flags(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, From patchwork Sun Dec 8 10:52:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 848277 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1608682wrt; Sun, 8 Dec 2024 02:53:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXhMdH54iOzhV7I10zoqPcjJbtQGRIidFNpi6wuch8y0py9KO2RGlSBScqNO51c3iQ1sInKtA==@linaro.org X-Google-Smtp-Source: AGHT+IGRUDxBMHsSKBKhwQ3qqa1r2sT+k8QZ9HEnycTrTd/k4h1XhuVaj7LsBN3hx3mjPkYAm0OA X-Received: by 2002:a05:6402:5292:b0:5d0:d328:3a43 with SMTP id 4fb4d7f45d1cf-5d3bd66a55bmr9404933a12.6.1733655226034; Sun, 08 Dec 2024 02:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733655226; cv=none; d=google.com; s=arc-20240605; b=N5l6whNbZBA5Ml0o9mWT8RyLXLv8ThEtFemQpfu5x8mUG2goNmRomSH4iNAEolZ+kq V1WdYQZbDwPPl1JWh72BZjZGIBdk13w95WInSKtnYyqqAT0CJ64LaiYjHAS1XWaP4Tle uEZbnaVvmz6JMS4gWyLKbsGCZGcGuq+ERNCs6Dg6jHqV0UmaG8FHR6FheWauV6ca0sjR wMG4x0LJ6MstWixefrgoVkA1Y4jUaqXX9aIWFZye5VQy1vVfLjrn/DG7nu3nv6d+xcY0 vYyEnk8KI/EC899v427vGJTn/wqNgJrEua0/hjaFmAIMKV2gGaajQAV7t5t8EbULsAs8 EMwQ== 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=kRyP8CxyMSJR5NVN6FWTKtTSuN3cdpS5UQMXPY2mLgo=; fh=hZvqZBxbazJVHHmPuktPvsONT0CqPasY1orhqtz5Gjw=; b=Me2BGnRHw2T5Nc0pk/+6AGvXdgP3BXU0e6f7XSjHhzHvR6HsB/F4+Q4NaONqxuKBo2 nCJCh6q/3mUQsa+AzOyhtfU0XqQi1Z74BCjg9L/fbm2+WClt+/EGm/u/MF0XX4y755TZ YS5Xh6M2bUuz+am5OqRIiqfVfdOLfgZBLmvbMN5hZhtIjUG929l1QEueRR7HnmYtOIue hUvdraaJDfReHDh/MTS/YkxX/sSJ42cByNjGN/rsjpsIrhCgne8lDt8viHF8qQ3cv2Sw V1Cxrb+LXVfGbx3vNHP3ODDI57ziqHtiorGxrwKBZtUqXWjazzVi75XWz1CRyDKkiTT2 T+2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B1cyFgE2; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5d3c4ce5767si3390124a12.632.2024.12.08.02.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:53:46 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B1cyFgE2; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 6C5668960F; Sun, 8 Dec 2024 11:53:07 +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="B1cyFgE2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 28ECF893BF; Sun, 8 Dec 2024 11:53:06 +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-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (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 1F1FF895A9 for ; Sun, 8 Dec 2024 11:53:04 +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-x636.google.com with SMTP id a640c23a62f3a-aa560a65fd6so623284766b.0 for ; Sun, 08 Dec 2024 02:53:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733655183; x=1734259983; 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=kRyP8CxyMSJR5NVN6FWTKtTSuN3cdpS5UQMXPY2mLgo=; b=B1cyFgE26CjKpLPGufrlr6d46v9ZU27aj3mjFObPlZyVcWcSwD+t8SJXi6y3xYnNuw 58oqI2dZQPRO0mPhs6Na+Avsmw20TDDp4IljcpH59Y9XX60F404WGKHsoyQr8ObXF74k dGBpWqOKRSSNdZeu1d4GQ47o+VwNocmFgyk40IySP8ulKVYw113nuTFKBE5O23+RRpBp aUY+P3Xk9Zs4AOvdCrJYSoMLO444Sjl63sWevPW467/5ZueT02+ZHIBJc6gg2+4/zQ8i 2p5vhoK8z4kRQvKWrIpYevVHOai4DnQO3W1CRPRYCa3Dv1hr7HEu37+dCBaZTqZcQavl keiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733655183; x=1734259983; 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=kRyP8CxyMSJR5NVN6FWTKtTSuN3cdpS5UQMXPY2mLgo=; b=fdyz2bpIfBImnCWlQCa86YB5ios6mo4LkMJu7JbIBs5NCRkhNsV+qbJPLGtPdg+aTD oMsfbqwpSRvwWLEE5PVAVzUMgiEdGe6NWZxl6CSoQQLD8VRqfTQ5vvgL3rviH9QTyyrk +S/9QxKUnSQhzWc4mf3t5eqWJSGocsGF9/pMxg1SfL2Tq3NVkO1IYxPBTb8nCXGKrizm apwYIUMCpfgyZXD1VhU7i71Ry1k1tIw9sjOjyOMbe633qGlgNA7w8SDKRgbt0BxY15P0 IdD569EfUdqEaTDJGZ4O8grdkD7IXLfLb9sEkBQfmOaoj6RTBtg94i7aJncVpoKZ1Edd aQpg== X-Forwarded-Encrypted: i=1; AJvYcCXTXYmgaG3gPPCJCcvOBr0UPd268beYxPDNy2WSSiPMoknQ6BaJ98Id34rRVaFjaLmrNSZWGsk=@lists.denx.de X-Gm-Message-State: AOJu0YzsY7q1JH3KA9L6Mx3S5ejloHSwasBNbY2701qOwtwhVvjQvuFg rqzkGn5ETdY/BNTtPLqmI7cC9alWKfOxJ6Aa46vKr+rTMuEvxVrFLpoe5NCu6co= X-Gm-Gg: ASbGncs05Dfgvd12ORI6PcQZu1/c7Q5opQpG6NTRajUDYBjbn2LbCChzbts5jIw37Iq h6Od07ucahuJ/43/ejbXr9ynfEbeiI4VfvBRM/QYVFzd5IxhyQhxmrWWeN/hXa2zmTJyA7EOMf6 pOmeBGv1ZQ2VluVFeERsisBViMyK3w3Jj8V1OjdAlX8yM6yn5j+MFpxOLVmuH6tzt4l8/+ctgM9 wQ499qJiBh9hJpWsxfm4SQmJInudGmqFEdWzU21+5jyexI5tdgLv8yFNTNROR+RFY2gNfKNHRpD 9PWczKq3MppBfJxUbbcnFy8jm1s= X-Received: by 2002:a17:907:1c0c:b0:aa6:7867:a3d5 with SMTP id a640c23a62f3a-aa67867d7f6mr138170366b.29.1733655183593; Sun, 08 Dec 2024 02:53:03 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625e92fe3sm517768566b.51.2024.12.08.02.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:53:03 -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?= , Marek Vasut , Simon Glass , Sughosh Ganu , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , AKASHI Takahiro , Mayuresh Chitale , Nam Cao , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [RFC PATCH 7/7] lmb: Rename _lmb_alloc_addr_flags() Date: Sun, 8 Dec 2024 12:52:10 +0200 Message-ID: <20241208105223.2821049-8-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241208105223.2821049-1-ilias.apalodimas@linaro.org> References: <20241208105223.2821049-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 After all the cleanups of the previous patches there's not point anymore to define lmb_alloc_addr_flags() and _lmb_alloc_addr_flags(). Fix the incocistency of the flags type, which one function was definining as uintn and the other as an enum lmb_flags and rename _lmb_alloc_addr_flags() to lmb_alloc_addr_flags() Signed-off-by: Ilias Apalodimas --- include/lmb.h | 2 +- lib/lmb.c | 34 ++++++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/include/lmb.h b/include/lmb.h index a35a69d69f77..4f3c861b15a6 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -111,7 +111,7 @@ phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, * Return: base address on success, 0 on error */ phys_addr_t lmb_alloc_addr_flags(phys_addr_t base, phys_size_t size, - uint flags); + enum lmb_flags flags); /** * lmb_is_reserved_flags() - test if address is in reserved region with flag bits set diff --git a/lib/lmb.c b/lib/lmb.c index c09f1a1277ad..67bde60b74be 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -777,8 +777,20 @@ phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, return alloc; } -static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, - enum lmb_flags flags) +/** + * lmb_alloc_addr_flags() - Allocate specified memory address with specified attributes + * @base: Base Address requested + * @size: Size of the region requested + * @flags: Memory region attributes to be set + * + * Allocate a region of memory with the attributes specified through the + * parameter. The base parameter is used to specify the base address + * of the requested region. + * + * Return: base address on success, 0 on error + */ +phys_addr_t lmb_alloc_addr_flags(phys_addr_t base, phys_size_t size, + enum lmb_flags flags) { long rgn; struct lmb_region *lmb_memory = lmb.available_mem.data; @@ -802,24 +814,6 @@ static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, return 0; } -/** - * lmb_alloc_addr_flags() - Allocate specified memory address with specified attributes - * @base: Base Address requested - * @size: Size of the region requested - * @flags: Memory region attributes to be set - * - * Allocate a region of memory with the attributes specified through the - * parameter. The base parameter is used to specify the base address - * of the requested region. - * - * Return: base address on success, 0 on error - */ -phys_addr_t lmb_alloc_addr_flags(phys_addr_t base, phys_size_t size, - uint flags) -{ - return _lmb_alloc_addr(base, size, flags); -} - /* Return number of bytes from a given address that are free */ phys_size_t lmb_get_free_size(phys_addr_t addr) {