From patchwork Wed Oct 23 15:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 837818 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1f12:b0:37d:45d0:187 with SMTP id hh18csp527878wrb; Wed, 23 Oct 2024 08:22:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUkkK5cNAT6ENiqVt0vikq1ckwkraeqGNvDPqH9mn64Q9Wi3Fs4O6KxWHX58j0nPUoItY68HQ==@linaro.org X-Google-Smtp-Source: AGHT+IGXcMFGgXW9rDE7WD3L7Hw5TghykDdlfVlSc+XJOF33Vq6r0/JJnu3lor00Qjxbyxb5rMOO X-Received: by 2002:a05:651c:198c:b0:2fc:97a8:48f9 with SMTP id 38308e7fff4ca-2fc9d35a491mr16872601fa.19.1729696942302; Wed, 23 Oct 2024 08:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729696942; cv=none; d=google.com; s=arc-20240605; b=ZIRjjDFBz8nyYZYHAT27riLUya7XdJuu5WacN01rxHF1w06Pd44fiDFk7xL+kBDx9M kGEfoAQSjVBDw53uyglUiHEmKKRQqonq/Ckh1Bwiffq+5VXHDzh2AiWyrm3c28wb3U7K zxfWEGeWZMLJsMhkE5IUSsig/kA7TRqc2OWTorN0m1E3Lp8ClHIwbRZEMpyYb5WsIYvE bjkJMD2QNGcgb+urA91qn94W95IM1/C32+XA2yT/kvOuRpKczsdaMYHaFUH/nIDwfs/q wMN8pzBY6oME+kw+CHfoJ43AgXtQFDrnf9Hi0KqNRJJPELh+rAEHmOmg47zcOvmOAyrU Ze6w== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=Pm6+7/NsXinpSFKOdnca6MFUdCL8mHEX4HacqC709XQ=; fh=yIUJoiYHJ2Rv//1uDN4b9/eqWKw3usoIEvzVeFp4aBE=; b=DhMXRQvcT0uo7Mr52TvY5Psrnd4LMM93QL3UJAxO/IxbqnOSIaxn6C6EP7G+bWK6hr Uaz1dYiO5LD+u0OMe2ePTK1/v6OvdY2XNPSn0fnkCWYUd67NQrW/b8RSMlMwkYiUYKYs ZhXRApRf369zj7nzSxFo9NxLoI86RrpSCDqjEVYlO7dmY1e5lcyu1mvCzoDBapij0NCc wgxZ83fa2GUF9mlURx+7Lc90gDesQjSVHdgwehEZDYOb/WJUbw3hcsq7kGrEbl3SeRjo ZMEvPPnMHiidkQCWF7jhpFmPBr4DXWIlMgaK8EQrMzr/zMJV4OrTD+w0tmsR/dobxVSL qAlA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=syTJZXG3; 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 38308e7fff4ca-2fb9ade6c8fsi23518871fa.194.2024.10.23.08.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 08:22:22 -0700 (PDT) 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=syTJZXG3; 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 16CE3892D5; Wed, 23 Oct 2024 17:22:16 +0200 (CEST) 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="syTJZXG3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 025F4892CF; Wed, 23 Oct 2024 17:22:15 +0200 (CEST) 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=unavailable autolearn_force=no version=3.4.2 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (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 2E9F6892DE for ; Wed, 23 Oct 2024 17:22:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a99f1fd20c4so937509766b.0 for ; Wed, 23 Oct 2024 08:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729696927; x=1730301727; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Pm6+7/NsXinpSFKOdnca6MFUdCL8mHEX4HacqC709XQ=; b=syTJZXG3SA/qWZ/IFXrEDgJRQwtCkkJJTB8sSLwOwpHu63QjtSoOX23WF0sXi+rV9D rWAmWE4wZ8VaN3ArDW7USteUMKsBSXFnNLmRGriKASSinR4yx5Pt3u+xK8IX8DtJJxqR VqiPE/yncRlVzXQxZ1Bxw7Jyak7siEs0LgLHdN6G9i7jl3M5BKKa2rnCRE1AyH5KFL3g MWZM2guSkrc5/ReSQG7xAda7bk8A4RVjQVjfph4CdnPIb6SuViBmN8L5WvcTzS/mNQWg xDcwdLk9mUAulpF6z/HOLpkshlQu116K+L9dBpSjzyvdFwp+Thq2F/KqFPaWSd7C9bPR Usgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729696927; x=1730301727; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Pm6+7/NsXinpSFKOdnca6MFUdCL8mHEX4HacqC709XQ=; b=MRMJmA7xWaug0y2w9wvGTYprLr0MPaCI6IgxbV3XjM28UPlCOrdTxXzkYTn69hk/QA PrWhFsrGbIB6KnYf5pDmZlONoq9NbKI1ZsAW8VVelqUZQ04Guu77Z9nlyRTu+xdmIjRb +H9Wuvt0mjH+QUqYXiCsvK6155nd8MxDWsu3C3DUxTkUnoRpwa+h9xB6zm0AXG9FB61x uO8BfbmO94imB3frM8SfCWdPWjeTnz8a6+uPsns8xg/+n8HimgOtfeIlskK0VrunZG3l NX2uOkghPZGPRAyXiCJiItqsDryBCx8uBYU1vkTLfkAHxUVSghCNe99tik7atkefpabn dnPQ== X-Forwarded-Encrypted: i=1; AJvYcCUSMgOwbWP45Hiz1Wv5bV2hErXTCXYyyEwCV+rfbwePNqgnj4T7tylUItSziKGXAUu0Fcmh/l0=@lists.denx.de X-Gm-Message-State: AOJu0YzjGCkEaWMohHSgSxKvdS7kJXAfU/FrywzwbtorV2FOtU/G15Tw t7io69rZPhAdz338X1IOCkUQe/YwVbp+WG+1XgZjaLUoSXW+oGqW9QydRdzUHLc= X-Received: by 2002:a17:906:c154:b0:a9a:12c9:41d1 with SMTP id a640c23a62f3a-a9abf8a2083mr305822766b.28.1729696927511; Wed, 23 Oct 2024 08:22:07 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a912edfedsm489242766b.72.2024.10.23.08.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 08:22:07 -0700 (PDT) From: Ilias Apalodimas To: sughosh.ganu@linaro.org Cc: Ilias Apalodimas , Tom Rini , Simon Glass , Marek Vasut , Laurent Pinchart , Guillaume La Roque , Matthias Schiffer , Mattijs Korpershoek , u-boot@lists.denx.de Subject: [PATCH 1/2] lmb: Fix lmb_add_region_flags() return codes and testing Date: Wed, 23 Oct 2024 18:22:00 +0300 Message-ID: <20241023152203.1218242-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 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 The function description says this should return 0 or -1 on failures. When regions coalesce though this returns the number of coalescedregions which is confusing and requires special handling of the return code. On top of that no one is using the number of coalesced regions. So let's just return 0 on success and adjust our selftests accordingly Signed-off-by: Ilias Apalodimas Reviewed-by: Caleb Connolly --- boot/image-fdt.c | 2 +- lib/lmb.c | 10 +++++----- test/lib/lmb.c | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/boot/image-fdt.c b/boot/image-fdt.c index 8eda521693dc..eac09059d955 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -73,7 +73,7 @@ static void boot_fdt_reserve_region(u64 addr, u64 size, enum lmb_flags flags) long ret; ret = lmb_reserve_flags(addr, size, flags); - if (ret >= 0) { + if (!ret) { debug(" reserving fdt memory region: addr=%llx size=%llx flags=%x\n", (unsigned long long)addr, (unsigned long long)size, flags); diff --git a/lib/lmb.c b/lib/lmb.c index 7e90f178763b..8ce58fcb9224 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -450,7 +450,7 @@ static long lmb_add_region_flags(struct alist *lmb_rgn_lst, phys_addr_t base, } if (coalesced) - return coalesced; + return 0; if (alist_full(lmb_rgn_lst) && !alist_expand_by(lmb_rgn_lst, lmb_rgn_lst->alloc)) @@ -487,7 +487,7 @@ long lmb_add(phys_addr_t base, phys_size_t size) struct alist *lmb_rgn_lst = &lmb.free_mem; ret = lmb_add_region(lmb_rgn_lst, base, size); - if (ret < 0) + if (ret) return ret; if (lmb_should_notify(LMB_NONE)) @@ -583,8 +583,8 @@ long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags flags) struct alist *lmb_rgn_lst = &lmb.used_mem; ret = lmb_add_region_flags(lmb_rgn_lst, base, size, flags); - if (ret < 0) - return -1; + if (ret) + return ret; if (lmb_should_notify(flags)) return lmb_map_update_notify(base, size, MAP_OP_RESERVE); @@ -651,7 +651,7 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, if (rgn < 0) { /* This area isn't reserved, take it */ if (lmb_add_region_flags(&lmb.used_mem, base, - size, flags) < 0) + size, flags)) return 0; if (lmb_should_notify(flags)) { diff --git a/test/lib/lmb.c b/test/lib/lmb.c index b2c54fb4bcb8..c917115b7b66 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -473,7 +473,7 @@ static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts) /* allocate overlapping region should return the coalesced count */ ret = lmb_reserve(0x40011000, 0x10000); - ut_asserteq(ret, 1); + ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40010000, 0x11000, 0, 0, 0, 0); /* allocate 3nd region */ @@ -748,13 +748,13 @@ static int lib_test_lmb_flags(struct unit_test_state *uts) /* merge after */ ret = lmb_reserve_flags(0x40020000, 0x10000, LMB_NOMAP); - ut_asserteq(ret, 1); + ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40010000, 0x20000, 0, 0, 0, 0); /* merge before */ ret = lmb_reserve_flags(0x40000000, 0x10000, LMB_NOMAP); - ut_asserteq(ret, 1); + ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40000000, 0x30000, 0, 0, 0, 0); @@ -770,7 +770,7 @@ static int lib_test_lmb_flags(struct unit_test_state *uts) /* test that old API use LMB_NONE */ ret = lmb_reserve(0x40040000, 0x10000); - ut_asserteq(ret, 1); + ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, 0x40000000, 0x30000, 0x40030000, 0x20000, 0, 0); @@ -789,7 +789,7 @@ static int lib_test_lmb_flags(struct unit_test_state *uts) /* merge with 2 adjacent regions */ ret = lmb_reserve_flags(0x40060000, 0x10000, LMB_NOMAP); - ut_asserteq(ret, 2); + ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 3, 0x40000000, 0x30000, 0x40030000, 0x20000, 0x40050000, 0x30000); From patchwork Wed Oct 23 15:22:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 837819 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1f12:b0:37d:45d0:187 with SMTP id hh18csp527975wrb; Wed, 23 Oct 2024 08:22:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXZiXIL8WPKssOoWFACqsUboXrXMrrVswrfY6oyOX7bwJ3UiQEHVXHWYDeQ+0wsc3hF7n5hRw==@linaro.org X-Google-Smtp-Source: AGHT+IGMS7f1bDW/eCC1sESb1uDOulDM1DnuWmcHiyUtK7hwHG6V4JGTOoKzKoJTmMFbxJEjjAnG X-Received: by 2002:a05:6512:2807:b0:539:eb82:d45b with SMTP id 2adb3069b0e04-53b1a36e099mr1789903e87.56.1729696949359; Wed, 23 Oct 2024 08:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729696949; cv=none; d=google.com; s=arc-20240605; b=epLmEZ9pj8E/z1RWhGRxk9k8NcEtS+MO8JYwTeEejNBhCZibgl30nRUqmFWfZUoM5Z dSUCbhDBUNwieiPCRZ2YsVJT9dkT5tdlbXX8UX7MjSiAPxY1kIuBhjLeev+ASMH6HuwG RjOAWvpC6srvTnNdFx+ddldJp5HMxO6dPE05am1ZM+Dh3/FCJgF7biuhp0Dopql80JL0 5Q9RrrcrrlumDut2SNrhmMqdIth73VnDdHaOxr1mdTYB7Oa13mdf8yhsSD7ntOImi2rH BdY8nL7KpADCBvAutJ1usAS6w6lnEdQZNj3wrxkUj4Izgz5M27AyhafhQKt2XM3JjYkz 9N3w== 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=yi5zxJzn0EZ8cZJYy+huwu4x2mZWmwvGL6NSdSIM8xQ=; fh=Vsi50gmnwzRUUgnfgcbL78rgNdpVy2Is5Y2mM2LVZI0=; b=aXRKjW0uxM+alkpKIyN7f1TavmkdVUFEVBADKWs+Wri5K/wEep2RRih/3m7oHPNR63 uLORczwTeXr5WGh8Cw/ulfHwuBXBIdIXiVM+iCKON4qmvID3CI5xmFk/gaad9IrMggHH 7FAV7f6DuZ43mtJlasbhyCT4On37bB47vGRrtLyKY3nRKgyCUy6Qg1JpCS+9+HN8/whN ZK2Z4ezBMRMGNQ1n/USWiajcAetiqj9ygUorZOAKeaWW0q9wa7ImIPleGtrXUZhQgRbY Ii7YsZfxic9V4RIUoYrg7oQvSMnUoyf+p4plYHJpod0zQkArmJLyHfWJ3Z2UJLe1JarH uSLw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ObN5ukY8; 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 2adb3069b0e04-53a22426249si2739875e87.268.2024.10.23.08.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 08:22:29 -0700 (PDT) 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=ObN5ukY8; 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 75E238919C; Wed, 23 Oct 2024 17:22:25 +0200 (CEST) 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="ObN5ukY8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1A2CE892CF; Wed, 23 Oct 2024 17:22:19 +0200 (CEST) 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=unavailable 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 4BC87892CF for ; Wed, 23 Oct 2024 17:22:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a9abe139088so153479566b.1 for ; Wed, 23 Oct 2024 08:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729696930; x=1730301730; 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=yi5zxJzn0EZ8cZJYy+huwu4x2mZWmwvGL6NSdSIM8xQ=; b=ObN5ukY8Y1rKtzxMclPt+M3gdP7ziqztrrjo3XbtyLy8TbDQySo1r8VEuEyGccLxYP yPoxAwhuJdrygi5cqVAO9oIaelRVqOPUEKbmGPZGfCzKShJY2hmhlt4fCtupu5Tu9Rty 915wMqoqkZeSN+gep4tDry8URAd5VcdZyI/l6I0hp7vkMuJAYJdAMUWZ5gyqcsmDBpGt xOU2nlZ0lIkqN8diOkqCg11laCxI/t8CNDmFluaLa/oDKv1C6bbb/vcbUYkZ3dIyy/qj o5NycIKZ4rVwlSDqK1YJ8xrUt0eqr/KVC3DOpk4HxZbWflaa0uc90MHiBlvwMiuozq42 fqUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729696930; x=1730301730; 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=yi5zxJzn0EZ8cZJYy+huwu4x2mZWmwvGL6NSdSIM8xQ=; b=YZy8btdF9PHAErsbxYI6HNHGS+7oXZa2ts9WOOcGJxnSCV3zQe8xUvTy1ZnnHz0ebc PRrOXfOH9d3+/Gw2lwVEaDIJ8DY+nrEaaXuD+Kuw+mF8aYfqhUrghOHqnnaar6UT0OFw CBqZoXLOGy/Udbt9fjcBt2POzeMk4wkWJARnBrvsoxG5pWPlsVwcjXjiEXsbJU79oN6Y DI0DQjAZ1u81V8BvCUNGn1VRUvAijB/V8vhwJBiSX7OQAdx6w9kFCkaIa4yw/B1DRVdW Lu3Jz+tUv8g/JPTbcD1XEI5Lvq0PZXTMkmnDXMy72RRYStj6sPR7Jadbia8l9LtjmajN 9S3A== X-Forwarded-Encrypted: i=1; AJvYcCUWpwxM0Kyd97vZ6hLrD2IwHtUCBMD6d966BLJ4SuWYtqxWQMpUrw/Oi5NXcbZJ+48/50BNEz4=@lists.denx.de X-Gm-Message-State: AOJu0YxPA3O+N3s8PNjegFSE4HBD5JHnPzhdD2/QTNg+zgT/Fns7gM8C /RkWpk2hHBblVt+BNALJl4OPrBeTRCDWEXbNFxVEc3byMeMXhdBhhaphQ3RAE4o= X-Received: by 2002:a17:907:2ce1:b0:a99:f29a:bc9a with SMTP id a640c23a62f3a-a9abf8491c3mr276344266b.7.1729696929568; Wed, 23 Oct 2024 08:22:09 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a912edfedsm489242766b.72.2024.10.23.08.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 08:22:09 -0700 (PDT) From: Ilias Apalodimas To: sughosh.ganu@linaro.org Cc: Ilias Apalodimas , Tom Rini , Simon Glass , Marek Vasut , Laurent Pinchart , Julien Masson , Guillaume La Roque , Mattijs Korpershoek , Matthias Schiffer , u-boot@lists.denx.de Subject: [PATCH 2/2] lmb: Simplify lmb_should_notify usage Date: Wed, 23 Oct 2024 18:22:01 +0300 Message-ID: <20241023152203.1218242-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023152203.1218242-1-ilias.apalodimas@linaro.org> References: <20241023152203.1218242-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 We never call lmb_map_update_notify() without checking the result of lmb_should_notify(). Instead of running that function everytime fold it in there and add the additional flags parameter Signed-off-by: Ilias Apalodimas --- lib/lmb.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index 8ce58fcb9224..69001ad57373 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -40,7 +40,7 @@ static bool lmb_should_notify(enum lmb_flags flags) static int __maybe_unused lmb_map_update_notify(phys_addr_t addr, phys_size_t size, - u8 op) + u8 op, enum lmb_flags flags) { u64 efi_addr; u64 pages; @@ -51,6 +51,9 @@ static int __maybe_unused lmb_map_update_notify(phys_addr_t addr, return -1; } + if (!lmb_should_notify(flags)) + return 0; + efi_addr = (uintptr_t)map_sysmem(addr, 0); pages = efi_size_in_pages(size + (efi_addr & EFI_PAGE_MASK)); efi_addr &= ~EFI_PAGE_MASK; @@ -64,9 +67,9 @@ static int __maybe_unused lmb_map_update_notify(phys_addr_t addr, log_err("%s: LMB Map notify failure %lu\n", __func__, status & ~EFI_ERROR_MASK); return -1; - } else { - return 0; } + + return 0; } static void lmb_print_region_flags(enum lmb_flags flags) @@ -490,10 +493,7 @@ long lmb_add(phys_addr_t base, phys_size_t size) if (ret) return ret; - if (lmb_should_notify(LMB_NONE)) - return lmb_map_update_notify(base, size, MAP_OP_ADD); - - return 0; + return lmb_map_update_notify(base, size, MAP_OP_ADD, LMB_NONE); } static long _lmb_free(phys_addr_t base, phys_size_t size) @@ -566,10 +566,7 @@ long lmb_free_flags(phys_addr_t base, phys_size_t size, if (ret < 0) return ret; - if (lmb_should_notify(flags)) - return lmb_map_update_notify(base, size, MAP_OP_FREE); - - return ret; + return lmb_map_update_notify(base, size, MAP_OP_FREE, flags); } long lmb_free(phys_addr_t base, phys_size_t size) @@ -586,10 +583,7 @@ long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags flags) if (ret) return ret; - if (lmb_should_notify(flags)) - return lmb_map_update_notify(base, size, MAP_OP_RESERVE); - - return ret; + return lmb_map_update_notify(base, size, MAP_OP_RESERVE, flags); } long lmb_reserve(phys_addr_t base, phys_size_t size) @@ -621,7 +615,6 @@ static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size) static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, enum lmb_flags flags) { - u8 op; int ret; long i, rgn; phys_addr_t base = 0; @@ -654,13 +647,11 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, size, flags)) return 0; - if (lmb_should_notify(flags)) { - op = MAP_OP_RESERVE; - ret = lmb_map_update_notify(base, size, - op); - if (ret) - return ret; - } + ret = lmb_map_update_notify(base, size, + MAP_OP_RESERVE, + flags); + if (ret) + return ret; return base; }