From patchwork Wed Dec 11 10:54:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 849140 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp244818wry; Wed, 11 Dec 2024 02:55:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXN26C9KyvB+H0Ia7d/3lBDcg80xlPZuq/6gdJsNJyM7b906Efu78AeGel9MwQwWkNht9KKTA==@linaro.org X-Google-Smtp-Source: AGHT+IG7lP04w4cbwUnJzplvMYTmEHO6Ozdh0cGg9QKUM2jScahP2wty635tWBk9QDJz93Ofu69G X-Received: by 2002:a17:907:3a98:b0:aa6:707a:af59 with SMTP id a640c23a62f3a-aa6b13d2f91mr202716066b.50.1733914523412; Wed, 11 Dec 2024 02:55:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733914523; cv=none; d=google.com; s=arc-20240605; b=DUnCyGbxNbI3bGcMgHM6lhKc3vysJD0vLHqKrsDWFbT/dkd2NusdCOaXR6AH3nHmvT 6F7IcizfTo4grQ2q8shWaNTRJ9G97McvVTnPHBX4fJAOk72/lcCBh11q4ILxKWTWmr62 KGDwi5zpBhJIA2nqMhkgtCPlbXjmzTXHEE6GBHn3wCof0601bGKMuXDdRnAG9ExIgh3G qaWYzrdwprr0HoGDLB0Sy2j/s/pK3gLMWr8HHR1//QsMfb7d6ix8m2KzvBvN6Z6bOvTQ GSGxbfD0qk+rEZF+6+ZS0s6iVFmfkRXq/yHoJiv2O1rN/7DT1geEb78ieSb83yDGFGJz uoaQ== 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=p6KbavC+z5tRgNXbT1IqE6TtPJsFqKJYWnG08OKayQ4=; fh=Mdv60lOLCM2FVlSyb8BT3ll7ZnGvzcIYnnlQlu9dOZU=; b=ZrB3MLmLluFjESmIIpmEDUskbtoJVnL0az9wJEO79TrVbkLpb18kNNTT5/FjAmtXBd J9HryqREb6UtrQC1xf8tJQvlNl9Ww4zGoCXqFxtlMYHzC2VAhJI1hjqkBQMyJu6iBTlG n9G+XYrinxB+PysuYpuaqpLnrjyCyNvS0bk2YyKZXXkOS8Pohlpt1KNi9pMMUXZPpy2z mSik7uH7ECTvyoMub8j17wr1ssjfa78ezyy/ystN0NOtQPhstReCXob+4nGpj1uafr2F WluMSi1Tlp0ySpRPl/KOzeczzuAsdTCT2WvzVCFPXdOhx0W4SIvwcXURQZ1vDpni3U/v EVVw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qxul41gv; 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-aa669ecc788si644503066b.281.2024.12.11.02.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:23 -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=qxul41gv; 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 BB4BF801FD; Wed, 11 Dec 2024 11:55:16 +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="qxul41gv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8FAD8801BF; Wed, 11 Dec 2024 11:55:15 +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-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 979DD801FD for ; Wed, 11 Dec 2024 11:55:13 +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-x62f.google.com with SMTP id a640c23a62f3a-aa6332dde13so938675266b.1 for ; Wed, 11 Dec 2024 02:55:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733914513; x=1734519313; 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=p6KbavC+z5tRgNXbT1IqE6TtPJsFqKJYWnG08OKayQ4=; b=qxul41gv/9Zoh98m0w0cCc7dG37ZQtv2cEc6ZB23MDf++U93Ip18mrKT53QRNwlkFo Y25mKe+GvwKS9/5eajvlIrW4AeM9sKutPHTeuunxUcPMMfDDDq5dmV/rca3YnO9FlJsU /bnQLjTntF1A+o2K0pEK0TV71dBSPSnbWfMQPKGKeun9W6Jgi6tt2PRiqNioghsksobt 5PdbG04gcFKAJB2coQHTFuA806W+95GHUF1knTEk+xUYaw+9N5VVvRxdMorHLNRYtrYY xkeIbiUtYDdDAmZn47GYOgPSBii8X3yfdbqiV3ddoljw+XRXAxFXRyjKzLBH37a0r90H eyhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733914513; x=1734519313; 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=p6KbavC+z5tRgNXbT1IqE6TtPJsFqKJYWnG08OKayQ4=; b=Ly0DqGIVSCdo8TN5ljcjkE/e9YvyCGKlxqVS0B42dTJV5bX8Ho0CFRsgKVl3809722 FqR+fTg6zx47Q0t0BZivlRLBpFKZBkwei8P6S9lzESJqDemOAy2z5F3FDuyPLqSqNtdV YAlnLIXEB0Z1MEHg2q1mfwnGeZBtmyU1onyPqUBTX4vnCTdz2TvWabt0vvXE7TBTlR5R 9wxHOTUq/KEcTMHewsEfXOof3YSc67aZkT5KXvHBzFpxBzHFxEcuNXFqTYxICVuu+uMM CUs7W81NZkNuSbGu7bkClpIJGMNqlYk/x51W0cykid3jcfo24LKHaWJBBJsbgayfiTTl mamQ== X-Forwarded-Encrypted: i=1; AJvYcCXoAbqGQJHjPnXNtOY+yRDzOs5q2yxyCTdeFT7m1r7gN0WsxBtNbDQ/TQ7UaHhfCVK4BeF99Go=@lists.denx.de X-Gm-Message-State: AOJu0YxKX39mqQVQ5quuzKDCAUMvuJUQYj+1S6XtTdoj7Ra2Pids+czf aqbzX8Dy0ReunkMWmi5UmWguMfJAtv3WDLTyAtq//TxpJDtH51+khgT5ZD9r2uw= X-Gm-Gg: ASbGncvpC9gBW9xygYnWFV2aVi5ai4K1WD7LxzWn3+SH6Pu2bYAUmEGXtINQAc6KHru DzUVFIZsEwpn7GJa+aWyiQALgyrt1kmfOSHQcbnl+oTmqxgV6ojQeI4fsvG0iMajw3t0NDJjLC0 2nW0oQCcDu/JEoLjoJDBqMplx9KBTZQXHfrGT9OU/74gNG7o6NRsQCjhD8FdIHgBzYdrRltjHJl YpgxT6wmeRWjcQC1XOxDs9ja8xDPSlwplinUFqQLboC1nx9ihBRZwJ2ZzL/jU8Y3422c6+QDlhS MBSHrgSD4O18KQ9jX4IRxeo4YJqcjgw= X-Received: by 2002:a17:906:314e:b0:aa6:9eac:4b7f with SMTP id a640c23a62f3a-aa6b11418aemr229775066b.7.1733914513071; Wed, 11 Dec 2024 02:55:13 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa67e652b1dsm508006566b.172.2024.12.11.02.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:12 -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 , Nam Cao , AKASHI Takahiro , Sam Protsenko , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v1 1/8] lmb: Remove lmb_align_down() Date: Wed, 11 Dec 2024 12:54:42 +0200 Message-ID: <20241211105504.453234-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211105504.453234-1-ilias.apalodimas@linaro.org> References: <20241211105504.453234-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We already have a macro for this. Use it instead of adding yet another variant for alignment. Signed-off-by: Ilias Apalodimas --- lib/lmb.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index f9880a8dc62b..b9c26cb02e10 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -342,11 +342,6 @@ static long lmb_overlaps_region(struct alist *lmb_rgn_lst, phys_addr_t base, return (i < lmb_rgn_lst->count) ? i : -1; } -static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size) -{ - return addr & ~(size - 1); -} - /* * IOVA LMB memory maps using lmb pointers instead of the global LMB memory map. */ @@ -400,7 +395,7 @@ phys_addr_t io_lmb_alloc(struct lmb *io_lmb, phys_size_t size, ulong align) if (lmbsize < size) continue; - base = lmb_align_down(lmbbase + lmbsize - size, align); + base = ALIGN_DOWN(lmbbase + lmbsize - size, align); while (base && lmbbase <= base) { rgn = lmb_overlaps_region(&io_lmb->used_mem, base, size); @@ -416,7 +411,7 @@ phys_addr_t io_lmb_alloc(struct lmb *io_lmb, phys_size_t size, ulong align) res_base = lmb_used[rgn].base; if (res_base < size) break; - base = lmb_align_down(res_base - size, align); + base = ALIGN_DOWN(res_base - size, align); } } return 0; @@ -709,13 +704,13 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, continue; if (max_addr == LMB_ALLOC_ANYWHERE) { - base = lmb_align_down(lmbbase + lmbsize - size, align); + base = ALIGN_DOWN(lmbbase + lmbsize - size, align); } else if (lmbbase < max_addr) { base = lmbbase + lmbsize; if (base < lmbbase) base = -1; base = min(base, max_addr); - base = lmb_align_down(base - size, align); + base = ALIGN_DOWN(base - size, align); } else { continue; } @@ -740,7 +735,7 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, res_base = lmb_used[rgn].base; if (res_base < size) break; - base = lmb_align_down(res_base - size, align); + base = ALIGN_DOWN(res_base - size, align); } } return 0; From patchwork Wed Dec 11 10:54:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 849141 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp244879wry; Wed, 11 Dec 2024 02:55:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXq9byVHyiVNq9xgR+1Qv0pb6iKMHE3hTHmvTxSqsPGgbsuaaLQYhMjda9BGLuSIfLTxYr+Pg==@linaro.org X-Google-Smtp-Source: AGHT+IEgmXwkr02PmSvhukO+wywsLT/wV+zAIMIlPjpDHe+9F9Ag0X9BBF2Cb3u5TakEDGbC116f X-Received: by 2002:a17:907:9507:b0:aa6:79fa:b480 with SMTP id a640c23a62f3a-aa6b10f5f2amr187673166b.10.1733914532154; Wed, 11 Dec 2024 02:55:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733914532; cv=none; d=google.com; s=arc-20240605; b=UQv7obiP7hFLZLhoGNbPE1eUFs/hzFRA/fxD055itF9NOp0Sip0agSl7Cfl6o0pqjB Xh6amM4BFkB6Gtbn80w1OvHUKZAnckAeXkTaKT0qF3R2J0TU0wtGVpsbXE8RQcrZVTIx XYM9GCJt93whwR5DoMMFs5mJA2StX60NVItENNe7AzfhOQHNne/3hFpV1rQnmD2/OQtl r39EszJc9E7WH/hUmZOvhX/6ZqA0skEtUiNMoX69UjsAnbvRzlcNESWFCrTzgFPVAlpB ZkgRIrogkOqKOTWCHbndJ4HdwWeFOOK+ruVse1loWyZpShiU86FKCHu3d/JAEkIxmqSV qDfA== 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=YbLpubeED0aQaKkvNACnHm1nwskLRmvJIgDVU5EU9oc=; fh=n//qT7euXeDmudfqLJh1rHWa0VDcpLKe7oYhtfsoHJw=; b=SeRc19jOflw6snjJMePSitKEgZFiAsMO6N5TBsrtPAE+bgoYRU4NqflH6RYj1c9rSZ gTQQgbDnyOusyAPGVbnj4JeUOcZvdpAheP28aWl6P3EvwNWLqOK6xJQd0K70/DiZ4DzY v8tWMfph3+m4OiZLdkwCV/E9v2xTvojxjEwiRJLl208sbZ0nPr1dNpr/MmI0BYUOTWqF 2WrVaz2HKhmlkDBHXPcyiH3tF5KaXloMM2WBTqTqT6Oe+jgTvT2RpWQwbBnjLE3ktiGq MTKRSpaNP/IalGtJy0GPcBvgpNd08axFk0nYWf8TQXPbM+q/TcYrsldZHn8KhuWr+GWB +vww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ujYFMosy; 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-aa666ec6807si633300966b.849.2024.12.11.02.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:32 -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=ujYFMosy; 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 2746F801F0; Wed, 11 Dec 2024 11:55:23 +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="ujYFMosy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 34F2F80212; Wed, 11 Dec 2024 11:55:21 +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-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (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 8E213801ED for ; Wed, 11 Dec 2024 11:55:17 +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-x631.google.com with SMTP id a640c23a62f3a-aa6aee68a57so148542866b.3 for ; Wed, 11 Dec 2024 02:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733914517; x=1734519317; 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=YbLpubeED0aQaKkvNACnHm1nwskLRmvJIgDVU5EU9oc=; b=ujYFMosy2jzLfqS4FPGmrz1brpgGPhLS7lxFik0FU05Jm9MugnFig8GVsrwK3Ra3Oa sEyym4ZfEZ5fynNrvQmb/q4AEdcMZtkOAx8EEJTFNZVvwJaAoajCbbdf/hwDkFC35SG1 QV1YA6WGQa6++aFTg4O+Efqcr1lZhGt2XCHgzHqVUwt/K8kzAR4qFvhflbq2/cSpJp8Z Jywczq0371UYf73aeyWpPGkhqdeOsZBgKiw2B/r6rxcjmM/wxfWgDTDqTrYiXNUuXqvW t9Z+sDQJGb2UGPgeb/B7YIFw3i3v7Ssk8N76JYA72zPl93+cIfYVZmV84U2nI+CpEWDG kqig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733914517; x=1734519317; 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=YbLpubeED0aQaKkvNACnHm1nwskLRmvJIgDVU5EU9oc=; b=Zr2yvZKAm3Q+L5EEVYcGLY9ge6/Lp9prys9fRQdyUR0IERNMeJXz17+DYkg9wJwN/H TTkFxmALWKE9N94OPgDicXn6B5JuamPHeJ/x+G8/s7VyCEpeeAMt7tFHx1CpvBBFVMft V2A6+t+MELX9o/khsxoCpXqJV9yXtyhtd2y0Tgsl2plTPGNVPJ1w8M76ZrdqC/PuEWe8 jVCS5TKWU361NUTIOcx5jmPDL/H5x3rSOJGvtTy/7WsoPuYjH6cgYxEdeVImnWdTMC4p H33XM4ymBAnHsLUR9janZADrOWwlhJG1ZQCfi8AvC18zonsIrUdfJDYV7dC6AAegnaYe U6zA== X-Forwarded-Encrypted: i=1; AJvYcCUxYTKgrlOPU8YI1xQhTC6Nx2+uhbMr9Gk/wDlIQwK1dxliI2rxJcHlMMjTjzsW7d8/zvGzrdE=@lists.denx.de X-Gm-Message-State: AOJu0Yyv2hD81y53lNSe1iNByPuehPD4KA07r42tusgoymqTN84EKxSt C0ojiUJ7Lde7XC2E8nJYlUWWdrqkP+sHqZtew+LTMyy9+IHQLEx/kFOoYUTdYPw= X-Gm-Gg: ASbGncsNMcoPFGDCxKuD1B5zwU7W1SwI8M2wzKZ+JEsAq5Vq2sKRB/nQB2nf0ZSztkQ z+Rvr06Pn/gN2humCkcnc+1ip1qXF6Sx+Lw6EW5OrxZFc7MS+rkDWrF3tREu6g5hoC1t0hZKjr4 39sSc8a8/IWIERePvV4AVKOsOYanLtYiFcEuQ654Rp7SihIy/KaQOwk5IO/dqqLKclgglfNSeaN 6+Z9lnlQEFjR0nvrR/W54i0eAK6TGgmu7xyl9vciqxKscd6TOicjrnRnfbj2nscNw2tirL5uDcK wVujiO6VhMDIF3SLId5uaw9e+Jm/IPI= X-Received: by 2002:a17:906:2922:b0:aa6:834b:d138 with SMTP id a640c23a62f3a-aa6b1180468mr212349566b.19.1733914516737; Wed, 11 Dec 2024 02:55:16 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa67e652b1dsm508006566b.172.2024.12.11.02.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:16 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , =?utf-8?q?Marek_Beh?= =?utf-8?q?=C3=BAn?= , Simon Glass , Marek Vasut , Sughosh Ganu , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Baruch Siach , Nam Cao , AKASHI Takahiro , Sam Protsenko , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v1 2/8] lmb: Move enum lmb_flags to a u32 Date: Wed, 11 Dec 2024 12:54:43 +0200 Message-ID: <20241211105504.453234-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211105504.453234-1-ilias.apalodimas@linaro.org> References: <20241211105504.453234-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean LMB flags is not an enum anymore. It's currently used as a bitmask in various places of our code. So make it a u32 which is more appropriate when dealing with masks. Signed-off-by: Ilias Apalodimas --- boot/image-fdt.c | 4 ++-- include/lmb.h | 25 +++++++++++-------------- lib/lmb.c | 18 +++++++++--------- test/cmd/bdinfo.c | 2 +- 4 files changed, 23 insertions(+), 26 deletions(-) -- 2.45.2 diff --git a/boot/image-fdt.c b/boot/image-fdt.c index 73c43c30684f..cda7c3aa9e38 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -68,7 +68,7 @@ static const struct legacy_img_hdr *image_get_fdt(ulong fdt_addr) } #endif -static void boot_fdt_reserve_region(u64 addr, u64 size, enum lmb_flags flags) +static void boot_fdt_reserve_region(u64 addr, u64 size, u32 flags) { long ret; @@ -100,7 +100,7 @@ void boot_fdt_add_mem_rsv_regions(void *fdt_blob) int i, total, ret; int nodeoffset, subnode; struct fdt_resource res; - enum lmb_flags flags; + u32 flags; if (fdt_check_header(fdt_blob) != 0) return; diff --git a/include/lmb.h b/include/lmb.h index 03d5fac6aa79..7db9e0b62840 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -19,18 +19,15 @@ #define LMB_ALIST_INITIAL_SIZE 4 /** - * enum lmb_flags - Definition of memory region attributes - * @LMB_NONE: No special request - * @LMB_NOMAP: Don't add to MMU configuration - * @LMB_NOOVERWRITE: The memory region cannot be overwritten/re-reserved - * @LMB_NONOTIFY: Do not notify other modules of changes to this memory region - */ -enum lmb_flags { - LMB_NONE = 0, - LMB_NOMAP = BIT(1), - LMB_NOOVERWRITE = BIT(2), - LMB_NONOTIFY = BIT(3), -}; + * LMB_NONE: No special request + * LMB_NOMAP: Don't add to MMU configuration + * LMB_NOOVERWRITE: The memory region cannot be overwritten/re-reserved + * LMB_NONOTIFY: Do not notify other modules of changes to this memory region + */ +#define LMB_NONE 0 +#define LMB_NOMAP BIT(0) +#define LMB_NOOVERWRITE BIT(1) +#define LMB_NONOTIFY BIT(2) /** * struct lmb_region - Description of one region @@ -41,7 +38,7 @@ enum lmb_flags { struct lmb_region { phys_addr_t base; phys_size_t size; - enum lmb_flags flags; + u32 flags; }; /** @@ -101,7 +98,7 @@ long lmb_reserve(phys_addr_t base, phys_size_t size); * * %-1 - Failure */ long lmb_reserve_flags(phys_addr_t base, phys_size_t size, - enum lmb_flags flags); + u32 flags); phys_addr_t lmb_alloc(phys_size_t size, ulong align); phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr); diff --git a/lib/lmb.c b/lib/lmb.c index b9c26cb02e10..edecdb8e9cbf 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -188,7 +188,7 @@ static long lmb_resize_regions(struct alist *lmb_rgn_lst, * * %-1 - Failure */ static long lmb_add_region_flags(struct alist *lmb_rgn_lst, phys_addr_t base, - phys_size_t size, enum lmb_flags flags) + phys_size_t size, u32 flags) { unsigned long coalesced = 0; long ret, i; @@ -201,7 +201,7 @@ static long lmb_add_region_flags(struct alist *lmb_rgn_lst, phys_addr_t base, for (i = 0; i < lmb_rgn_lst->count; i++) { phys_addr_t rgnbase = rgn[i].base; phys_size_t rgnsize = rgn[i].size; - enum lmb_flags rgnflags = rgn[i].flags; + u32 rgnflags = rgn[i].flags; ret = lmb_addrs_adjacent(base, size, rgnbase, rgnsize); if (ret > 0) { @@ -430,14 +430,14 @@ long io_lmb_free(struct lmb *io_lmb, phys_addr_t base, phys_size_t size) static struct lmb lmb; -static bool lmb_should_notify(enum lmb_flags flags) +static bool lmb_should_notify(u32 flags) { return !lmb.test && !(flags & LMB_NONOTIFY) && CONFIG_IS_ENABLED(EFI_LOADER); } static int lmb_map_update_notify(phys_addr_t addr, phys_size_t size, u8 op, - enum lmb_flags flags) + u32 flags) { u64 efi_addr; u64 pages; @@ -470,7 +470,7 @@ static int lmb_map_update_notify(phys_addr_t addr, phys_size_t size, u8 op, return 0; } -static void lmb_print_region_flags(enum lmb_flags flags) +static void lmb_print_region_flags(u32 flags) { const char * const flag_str[] = { "none", "no-map", "no-overwrite", "no-notify" }; @@ -495,7 +495,7 @@ static void lmb_dump_region(struct alist *lmb_rgn_lst, char *name) { struct lmb_region *rgn = lmb_rgn_lst->data; unsigned long long base, size, end; - enum lmb_flags flags; + u32 flags; int i; printf(" %s.count = %#x\n", name, lmb_rgn_lst->count); @@ -669,7 +669,7 @@ long lmb_free(phys_addr_t base, phys_size_t size) return lmb_free_flags(base, size, LMB_NONE); } -long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags flags) +long lmb_reserve_flags(phys_addr_t base, phys_size_t size, u32 flags) { long ret = 0; struct alist *lmb_rgn_lst = &lmb.used_mem; @@ -687,7 +687,7 @@ long lmb_reserve(phys_addr_t base, 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) + phys_addr_t max_addr, u32 flags) { int ret; long i, rgn; @@ -774,7 +774,7 @@ phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, } static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, - enum lmb_flags flags) + u32 flags) { long rgn; struct lmb_region *lmb_memory = lmb.free_mem.data; diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index bb419ab2394e..014391b38ac0 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -104,7 +104,7 @@ static int lmb_test_dump_region(struct unit_test_state *uts, { struct lmb_region *rgn = lmb_rgn_lst->data; unsigned long long base, size, end; - enum lmb_flags flags; + u32 flags; int i; ut_assert_nextline(" %s.count = %#x", name, lmb_rgn_lst->count); From patchwork Wed Dec 11 10:54:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 849142 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp244936wry; Wed, 11 Dec 2024 02:55:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVNRF0sCk+5J7dZCnghuWmo64TjneX06uIA3hfjXCiGlgCos6uosJhLMBAKbFIPxM81mqfYUg==@linaro.org X-Google-Smtp-Source: AGHT+IFDgoeGjktxCpOEV4Qi5KitJm0ZKEGvuA6CJhkA+eDFMztSmo5IVdKFnfGohYyDNSxLRvXL X-Received: by 2002:a17:906:dc94:b0:aa6:b473:ea4c with SMTP id a640c23a62f3a-aa6b473ef03mr177659466b.10.1733914540866; Wed, 11 Dec 2024 02:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733914540; cv=none; d=google.com; s=arc-20240605; b=Fy+0WPdhPg6alpt1/QqdwqhSuISlTQdElain++oanjGU2hhhjXT52hY5YGJCe7G4wi Gj0e7vhdfWPA5e2GFgSgef1/z8pWn+caoln4gEwGLwi9OoElcs0L/e0wK+Mk/lxZih41 RrkVlVrKSjtXPqLVuMe6so+kKjI/y3bFyvLfxra4OM1ybwnKKUKpTom9nqd91FT/Hz2X AyO9rMDjwRLhX4/GkKfgkG2GwNsoL2tKEcJxp+QtbZaGC924sgmfKZRSAYpWUFfuT/dY a8cjC8DrOSXt/AwZB3WsoraZwJgF3k4mRRXSR/ZRVARrkwyuwL8x1t1sTg+dKT+F6edh HhrA== 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=ZePv0turzEJjx/RvBmyBpYP2kTWKVfhuUztW1KX614Y=; fh=YJPwk7o6VQuXl+yyRlkTWBK4MpXPTyBbrfREyh4Jcig=; b=dnvvoNkQFHS9PuVXTNABThYxMF/ONXLf+rAr4TmggHTQpaEF5RKB3nDfq3Xr4Xownu aZKGKrL0w91Fif8VL0ESqf29/Hsf0mlaNkrrndjDPMAdUk36HuzAL+OIPDCf28svN6aQ Htnn00NYEqvRfduDla3Xez+aDC9ULc+qswz5hamU06GTaHbEZ0BH7Q2t6Mn+VtTalAlD fEzNFx/jGmuCOR9oGpCThWxhZRNKdauYAl7miszqemIfgCI93Pf2NOz2qBOsq1JQeZup e8S3wi7hpFBNsBzRAX44/JlLK1CRqNI/nRNfP/naetJ8Y+FDOPYXHRBYY6b/1sTV7DHr fm4Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jgoe5qsC; 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-aa662d29880si596519266b.863.2024.12.11.02.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:40 -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=Jgoe5qsC; 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 73092801ED; Wed, 11 Dec 2024 11:55:24 +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="Jgoe5qsC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3C8380212; Wed, 11 Dec 2024 11:55:23 +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-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (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 69590801EA for ; Wed, 11 Dec 2024 11:55:21 +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-x62c.google.com with SMTP id a640c23a62f3a-a9a68480164so962402466b.3 for ; Wed, 11 Dec 2024 02:55:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733914521; x=1734519321; 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=ZePv0turzEJjx/RvBmyBpYP2kTWKVfhuUztW1KX614Y=; b=Jgoe5qsCLhTR+AQ+Uo8qxJ0V1afcDbkFTHLFeYz9u71nUorNAQg065ye0i14y9Uvgt ILJ4107eAnQZOVMQbUAYL7IUw+TmaRFLxobV5+OA+Za20p1ZTsiNheCxXelal7eZ9VED zBx+2xQAPTdgQL4LEFccx5r4yKfgci143mZJcuJwmK/0zp4F0H9Q6spyT7DijCrcSYcD 8TTDD9EeFVQa3VeumR863XwrNQ61FfiQkqqyP2uEbcfw6rxcqBO1mRsmpUwzSEZP0byd ljI1yxY9PGG6Iv3x/ukBWceiVoa0n/+5OQoBFcphiLlHCTfclqW8qqS9A/Lp9pvMND56 yp3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733914521; x=1734519321; 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=ZePv0turzEJjx/RvBmyBpYP2kTWKVfhuUztW1KX614Y=; b=EECwy+su5e3i7CBeTkG2tSg22dfnqCziPSivLep1jG3qcX0vjE5IfBPY9rmZ1cgiaG HV3BTL7T6aP69eAIftpJX6xu7X4573te94Sqzm9+8C2MQlJ/Cd3HBgWTuu9LLtmiHi7k k10z4+cMx8WNwJY63JQvgBFAGclGvZD1I8QulAKm8h7MN68Tu/2/l8EKuFoVlu7qFzZj yOhSs01VwSe8wK/Fmk14mGazqQrQb0yhT67RV4tueTaHVUxf4IqGrwxbl5bB0euCKtWq v8JR487DtTXYeAfy0S9Cp1IOa5hRW+bizCI0ok3gAuPhCxu0viNuuUYNI7T+PTcztMxr AxRg== X-Forwarded-Encrypted: i=1; AJvYcCV2CdBYLWHoH4jG7xMog/9AZb3M2LH11YUehy+D/bwOb3R9t2NP+cRiX6PnjTs/y7TqCiNEtp0=@lists.denx.de X-Gm-Message-State: AOJu0YxciL8+yyZZ4CPLiGAPa1ob+tvCwM4ToTb16B0o5NvLoj2PUQSd 3PsAUTdohmY1S92nWkCt+SoC7NgceojmNksoLdaEuQZSgZSuKHisxWJMou9bd1Y= X-Gm-Gg: ASbGncsRKIO1sIHwaZiFDRoikK3ZQ5JcJonPsOJeLZqxDQDMVp3A8d3QVtiq6omABKu neWQqhGFP2dSJyOMRSir/y5gyFXghr1119fWt6W1cT2cnNXFVVNFXu6AAsNQ/pPJwxFPvBXt/YO 79bDgwULBuKP5hl6MQa5YB+6YKpfM+74kEkKRa0GlXso3uwpOVpwyVgaIV+eLB1JSlZlSRt4p2S 3m0yw8mslGYBeZcw650rjirUwodj4AjEveKEwHj3vuyofyUnuQW+EKJmvjJ18lLtZiwSKVS4eO/ On3yQ1urjdLMqsG18t8Z8npbmH5kYw0= X-Received: by 2002:a17:906:23e1:b0:aa6:7b1e:47cc with SMTP id a640c23a62f3a-aa6b11b3e19mr228547866b.20.1733914520658; Wed, 11 Dec 2024 02:55:20 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa67e652b1dsm508006566b.172.2024.12.11.02.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:20 -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 , Mayuresh Chitale , Nam Cao , AKASHI Takahiro , Sam Protsenko , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v1 3/8] lmb: Remove lmb_reserve_flags() Date: Wed, 11 Dec 2024 12:54:44 +0200 Message-ID: <20241211105504.453234-4-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211105504.453234-1-ilias.apalodimas@linaro.org> References: <20241211105504.453234-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean lmb_reserve() is just calling lmb_reserve_flags() with LMB_NONE. There's not much we gain from this abstraction. So let's remove the latter, add the flags argument to lmb_reserve() and make the code a bit easier to follow. 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 | 6 ++--- cmd/booti.c | 2 +- cmd/bootz.c | 2 +- cmd/load.c | 2 +- include/lmb.h | 14 ++-------- lib/lmb.c | 28 ++++++++------------ test/lib/lmb.c | 48 +++++++++++++++++------------------ 11 files changed, 48 insertions(+), 63 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/mp.c b/arch/powerpc/cpu/mpc85xx/mp.c index bed465cb2cba..8918a401fac3 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(bootpg, 4096, LMB_NONE); } void setup_mp(void) diff --git a/arch/powerpc/lib/misc.c b/arch/powerpc/lib/misc.c index 4cd23b3406d1..7e303419624a 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(base, bootm_size - size, LMB_NONE); } #ifdef CONFIG_MP diff --git a/boot/bootm.c b/boot/bootm.c index 16a43d519a8a..854ac7ec7388 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(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..070ada007185 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(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 cda7c3aa9e38..d717f6690729 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -72,7 +72,7 @@ static void boot_fdt_reserve_region(u64 addr, u64 size, u32 flags) { long ret; - ret = lmb_reserve_flags(addr, size, flags); + ret = lmb_reserve(addr, size, flags); if (!ret) { debug(" reserving fdt memory region: addr=%llx size=%llx flags=%x\n", (unsigned long long)addr, @@ -184,7 +184,7 @@ 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(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 +675,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(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..1a57fe913977 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(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..99318ff213f4 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(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..899bb4f598e2 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(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 7db9e0b62840..9539cb67c3d7 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -78,16 +78,7 @@ void lmb_add_memory(void); long lmb_add(phys_addr_t base, phys_size_t size); /** - * lmb_reserve() - Reserve a memory region (with no special flags) - * @base: Base address of the memory region - * @size: Size of the memory region - * - * Return: 0 on success, negative error code on failure. - */ -long lmb_reserve(phys_addr_t base, phys_size_t size); - -/** - * lmb_reserve_flags() - Reserve one region with a specific flags bitfield + * lmb_reserve() - Reserve one region with a specific flags bitfield * @base: Base address of the memory region * @size: Size of the memory region * @flags: Flags for the memory region @@ -97,8 +88,7 @@ long lmb_reserve(phys_addr_t base, phys_size_t size); * * %-EEXIST - The region is already added, and flags != LMB_NONE * * %-1 - Failure */ -long lmb_reserve_flags(phys_addr_t base, phys_size_t size, - u32 flags); +long lmb_reserve(phys_addr_t base, phys_size_t size, u32 flags); phys_addr_t lmb_alloc(phys_size_t size, ulong align); phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr); diff --git a/lib/lmb.c b/lib/lmb.c index edecdb8e9cbf..fd0e91981ad4 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -553,12 +553,11 @@ static void lmb_reserve_uboot_region(void) if (bank_end > end) bank_end = end - 1; - lmb_reserve_flags(rsv_start, bank_end - rsv_start + 1, - LMB_NOOVERWRITE); + lmb_reserve(rsv_start, bank_end - rsv_start + 1, LMB_NOOVERWRITE); if (gd->flags & GD_FLG_SKIP_RELOC) - lmb_reserve_flags((phys_addr_t)(uintptr_t)_start, - gd->mon_len, LMB_NOOVERWRITE); + lmb_reserve((phys_addr_t)(uintptr_t)_start, + gd->mon_len, LMB_NOOVERWRITE); break; } @@ -584,7 +583,7 @@ static __maybe_unused void lmb_reserve_common_spl(void) if (IS_ENABLED(CONFIG_SPL_STACK_R_ADDR)) { rsv_start = gd->start_addr_sp - 16384; rsv_size = 16384; - lmb_reserve_flags(rsv_start, rsv_size, LMB_NOOVERWRITE); + lmb_reserve(rsv_start, rsv_size, LMB_NOOVERWRITE); } if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS)) { @@ -592,7 +591,7 @@ static __maybe_unused void lmb_reserve_common_spl(void) rsv_start = (phys_addr_t)(uintptr_t)__bss_start; rsv_size = (phys_addr_t)(uintptr_t)__bss_end - (phys_addr_t)(uintptr_t)__bss_start; - lmb_reserve_flags(rsv_start, rsv_size, LMB_NOOVERWRITE); + lmb_reserve(rsv_start, rsv_size, LMB_NOOVERWRITE); } } @@ -624,11 +623,11 @@ void lmb_add_memory(void) * allocated */ if (bd->bi_dram[i].start >= ram_top) - lmb_reserve_flags(bd->bi_dram[i].start, size, - LMB_NOOVERWRITE); + lmb_reserve(bd->bi_dram[i].start, size, + LMB_NOOVERWRITE); else if (bank_end > ram_top) - lmb_reserve_flags(ram_top, bank_end - ram_top, - LMB_NOOVERWRITE); + lmb_reserve(ram_top, bank_end - ram_top, + LMB_NOOVERWRITE); } } } @@ -669,7 +668,7 @@ long lmb_free(phys_addr_t base, phys_size_t size) return lmb_free_flags(base, size, LMB_NONE); } -long lmb_reserve_flags(phys_addr_t base, phys_size_t size, u32 flags) +long lmb_reserve(phys_addr_t base, phys_size_t size, u32 flags) { long ret = 0; struct alist *lmb_rgn_lst = &lmb.used_mem; @@ -681,11 +680,6 @@ long lmb_reserve_flags(phys_addr_t base, phys_size_t size, u32 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, u32 flags) { @@ -790,7 +784,7 @@ static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, lmb_memory[rgn].size, base + size - 1, 1)) { /* ok, reserve the memory */ - if (!lmb_reserve_flags(base, size, flags)) + if (!lmb_reserve(base, size, flags)) return base; } } diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 48c3c966f8f2..3c3e862ffa0e 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(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(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(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(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(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(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(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(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(alloc_addr_a, 0x10000, LMB_NONE); ut_asserteq(ret, 0); - ret = lmb_reserve(alloc_addr_b, 0x10000); + ret = lmb_reserve(alloc_addr_b, 0x10000, LMB_NONE); ut_asserteq(ret, 0); - ret = lmb_reserve(alloc_addr_c, 0x10000); + ret = lmb_reserve(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(alloc_addr_a, 0x10000, LMB_NONE); ut_asserteq(ret, 0); - ret = lmb_reserve(alloc_addr_b, 0x10000); + ret = lmb_reserve(alloc_addr_b, 0x10000, LMB_NONE); ut_asserteq(ret, 0); - ret = lmb_reserve(alloc_addr_c, 0x10000); + ret = lmb_reserve(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); @@ -747,19 +747,19 @@ static int lib_test_lmb_flags(struct unit_test_state *uts) ut_asserteq(ret, 0); /* reserve, same flag */ - ret = lmb_reserve_flags(0x40010000, 0x10000, LMB_NOMAP); + ret = lmb_reserve(0x40010000, 0x10000, LMB_NOMAP); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40010000, 0x10000, 0, 0, 0, 0); /* reserve again, same flag */ - ret = lmb_reserve_flags(0x40010000, 0x10000, LMB_NOMAP); + ret = lmb_reserve(0x40010000, 0x10000, LMB_NOMAP); ut_asserteq(ret, -EEXIST); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40010000, 0x10000, 0, 0, 0, 0); /* reserve again, new flag */ - ret = lmb_reserve_flags(0x40010000, 0x10000, LMB_NONE); + ret = lmb_reserve(0x40010000, 0x10000, LMB_NONE); ut_asserteq(ret, -1); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40010000, 0x10000, 0, 0, 0, 0); @@ -767,20 +767,20 @@ static int lib_test_lmb_flags(struct unit_test_state *uts) ut_asserteq(lmb_is_nomap(&used[0]), 1); /* merge after */ - ret = lmb_reserve_flags(0x40020000, 0x10000, LMB_NOMAP); + ret = lmb_reserve(0x40020000, 0x10000, LMB_NOMAP); 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); + ret = lmb_reserve(0x40000000, 0x10000, LMB_NOMAP); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, 0x40000000, 0x30000, 0, 0, 0, 0); ut_asserteq(lmb_is_nomap(&used[0]), 1); - ret = lmb_reserve_flags(0x40030000, 0x10000, LMB_NONE); + ret = lmb_reserve(0x40030000, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, 0x40000000, 0x30000, 0x40030000, 0x10000, 0, 0); @@ -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(0x40040000, 0x10000, LMB_NONE); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, 0x40000000, 0x30000, 0x40030000, 0x20000, 0, 0); @@ -797,18 +797,18 @@ static int lib_test_lmb_flags(struct unit_test_state *uts) ut_asserteq(lmb_is_nomap(&used[0]), 1); ut_asserteq(lmb_is_nomap(&used[1]), 0); - ret = lmb_reserve_flags(0x40070000, 0x10000, LMB_NOMAP); + ret = lmb_reserve(0x40070000, 0x10000, LMB_NOMAP); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 3, 0x40000000, 0x30000, 0x40030000, 0x20000, 0x40070000, 0x10000); - ret = lmb_reserve_flags(0x40050000, 0x10000, LMB_NOMAP); + ret = lmb_reserve(0x40050000, 0x10000, LMB_NOMAP); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 4, 0x40000000, 0x30000, 0x40030000, 0x20000, 0x40050000, 0x10000); /* merge with 2 adjacent regions */ - ret = lmb_reserve_flags(0x40060000, 0x10000, LMB_NOMAP); + ret = lmb_reserve(0x40060000, 0x10000, LMB_NOMAP); ut_asserteq(ret, 0); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 3, 0x40000000, 0x30000, 0x40030000, 0x20000, 0x40050000, 0x30000); From patchwork Wed Dec 11 10:54:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 849143 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp244970wry; Wed, 11 Dec 2024 02:55:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUjNR+tFoIuLtsjFd5A8wvFHHx/kP2L2KrpVfuJQC+a0cL5k+mQZiculFbe+RktBstxLE1dFg==@linaro.org X-Google-Smtp-Source: AGHT+IHB3fRPuvdzKqVb3vO7bRWewY0D2EejFzUma3zQSNhWRJBn6Gn1DwHodm5oSN60eqvf54MS X-Received: by 2002:a17:906:1ba9:b0:aa6:a228:afa9 with SMTP id a640c23a62f3a-aa6b1141c89mr185896666b.3.1733914549879; Wed, 11 Dec 2024 02:55:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733914549; cv=none; d=google.com; s=arc-20240605; b=HFpVan3Pg/8mZXZ2f+DmmdYLKE+GvLMOJEBxeVUEtOUgioAKEfcbSmIc2r7XRAzk2k aabrNRIBZnRpMNdhNdUtv7Pll8lLxd7t38VWC6ClRbSu9l9o5cXwjwHP/8uXslLNWkHU WlX6G8HBITqMaSox61eYQEPNTaVBQFna4jUtJkL61aViNZLKxfK7Ukxx6AkBTpW6fDI1 UCWD3unyzxPL/bSEvb1JF+IZqNp9P9OdbAG028yB5pUCdccpzn6DH2fQMH1bCuzeZxyY /z5fmjWb6giPcAy84LYw3JPywsTon8DJvA/UpdF1oHa73O20DSU19+WKp8xokrwKSiB+ Xvjw== 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=eQ66NDUUIlNQKPYo6heYWOWor1RBFYpFYyRBelWLCDQ=; fh=l/x0QKPzY6fKsJPf89p4KWiwu5iXL1j54RRy/KIslJ4=; b=kdFMFZH/5LC7xqyP3PSAW3fZgs9BDAW5amfLp2094sN+bPNGEBgC+DQeMMqgpgLRN0 T/GbOuQGZf5CyFpSN/zwU2NuXxZTnJXqLFgW5VGLvtM/j01A6bgRJA8LC1MFjam6vpAH YqcI16aJK93O2GNL45UQ7Lanl0Tvx39JdqH1rv1grJva9nhLxp4qodxY4gcQQq6HcwMS ov1do83YiqrYccm46lNwcrZg3mRdPz9mJIqvPsCwYDkvSb98BPs/d4yKVgdu6ebLJ5i7 Idf80t7PDuvnkmyDpYGq6tuGSVcGPt8U26bNFEjGJQogHDPdENoRz//W9KpbRgWFm0Ar 8OKw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LKTvaQT7; 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-aa6af622027si112060866b.326.2024.12.11.02.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:49 -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=LKTvaQT7; 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 B9EC88023C; Wed, 11 Dec 2024 11:55:27 +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="LKTvaQT7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 252CA80239; Wed, 11 Dec 2024 11:55:27 +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-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (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 0D5828021C for ; Wed, 11 Dec 2024 11:55:25 +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-x52b.google.com with SMTP id 4fb4d7f45d1cf-5cfa1ec3b94so8902782a12.2 for ; Wed, 11 Dec 2024 02:55:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733914524; x=1734519324; 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=eQ66NDUUIlNQKPYo6heYWOWor1RBFYpFYyRBelWLCDQ=; b=LKTvaQT7LvYs8NOQ5dVcnHeDbAZJ+4u0sq1HRU+XZYLKwTWVHtwbtNyUe+hYfI0Tw3 LLTWIPpisa+stFfmzfIqmecmx2ChhYsG7F/Wx0iFAV5R57VKr0eNfseX1dkWRzNP4xKN iJUaqs2KYUG9cnFejLI4AwdBIvefS3932BYzGWslsuxzF45TkwDOrSshuTRW7IzHyam/ EMcYMlPd70QlHXbsI1Bg2duSNa7XqDZ6aqlBQ2eXXeoZoqvOJXF3WEw9vgfI6nVW0qKf EKzra/Hd2+uaSSn1i3cN45/hSK86r9ug7wYW4LiOl/SWNA4skJ6CvReJnGBLNpLA6+lh ib9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733914524; x=1734519324; 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=eQ66NDUUIlNQKPYo6heYWOWor1RBFYpFYyRBelWLCDQ=; b=K4IRPX563Vsv6JmomV+QHD/wWBqynSSi0qJo48jBwXniIed9Gwzn7T+BDuqdmF07Oc ijFp/7eCoVfSgyd4m223yRlg3gRW3ZytnnfcIGjdBcnvAHDxrjrEqJIh77KxrBWl1I4+ EjpqhdEDfzt7ghSr66/j86gvSJNPRlIGNocggRWvc3cfuIxCEFDTLVV4zeFzR2NbIwgM Po9QizhWufinfjS2eEEVH+6GRWPyAtgj7DcKEN6lbMlB47PCjb3ka0hwLNO/7vuni+Yb DP7W7sNKOVUuU86ADvB4c0vMb3P61Cb3so9QsC3Im2RkzVLn0wosPDXZFTst23sxeyZ9 hplQ== X-Forwarded-Encrypted: i=1; AJvYcCVTWY+NAJDhKDJ5Ils5+KLBwsxnt1zHjDYogq3Nj34NtOmJJW3+cVM02P0a3vKaxL7lw9h7bEs=@lists.denx.de X-Gm-Message-State: AOJu0YwB31ospWH7Jm8/oxUyIN7sgbv9D2SUykUTcNiQ1G5p+oCfrSXU oBftXFI2ZuwkyzbrhDGVsIGxC+A1H7HsvoRr4qYoQosEMYvB16HuO9wrOQre/AA= X-Gm-Gg: ASbGncscgGZHIT6q5Xdm7MenEgj7tLMKJ6UtLtL4wInCnh24kZx8L8/r5H3qu9A0Mwp m/hAbZeH9S6JjrxVvTkgsWJAJMtjN3UKzocphx0QFq6mzW1ObEaXhbPfEW/k1mIC2atuLzfnjD1 h4dh6EyfENvC+UGZrlAYXgmPLp8wAvOkiO9IvW+U21ODfz0WcMQRicZOfelx9VCFa+zd5yYqJju Ak/ufzz9rdlWE99ei4lpzdZrF2lgDhm2YbOWKU9C36D8G1G21V/+yKELKl29u97XqUwoYtnrcvw +lL4EEViyESU+7GQJ/RV4XLLXX5w2AQ= X-Received: by 2002:a17:907:9548:b0:aa6:748e:d20d with SMTP id a640c23a62f3a-aa6b12052c1mr184988266b.32.1733914524455; Wed, 11 Dec 2024 02:55:24 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa67e652b1dsm508006566b.172.2024.12.11.02.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:23 -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 , AKASHI Takahiro , Nam Cao , Sam Protsenko , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v1 4/8] lmb: Rename free_mem to available_mem Date: Wed, 11 Dec 2024 12:54:45 +0200 Message-ID: <20241211105504.453234-5-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211105504.453234-1-ilias.apalodimas@linaro.org> References: <20241211105504.453234-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean free_mem is a misnomer. We never update it with the free memory for LMB. Instead, it describes all available memory and is checked against used_mem to decide whether an area is free or not. So let's rename this field to better match 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(-) diff --git a/include/lmb.h b/include/lmb.h index 9539cb67c3d7..3db35992df8d 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -43,12 +43,12 @@ struct lmb_region { /** * struct lmb - The LMB structure - * @free_mem: List of free memory regions + * @available_mem: List of memory available to LMB * @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 fd0e91981ad4..da960e422ada 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; @@ -515,7 +515,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"); } @@ -642,7 +642,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) @@ -688,9 +688,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; @@ -771,10 +771,10 @@ static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 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 @@ -813,10 +813,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) { @@ -830,8 +830,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; } @@ -854,7 +854,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"); @@ -914,7 +914,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 014391b38ac0..764294857082 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 3c3e862ffa0e..6e870274fedb 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 Wed Dec 11 10:54:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 849144 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp245029wry; Wed, 11 Dec 2024 02:56:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVTl+BPRHIT/x2SBrdNJY6ZMYIgBHIXg+gPnNNc9agC3DEeQk2qbgojxeIikwvWynUyodcnhA==@linaro.org X-Google-Smtp-Source: AGHT+IHnCSUnyejs9qpR7JKnjZAHqpWEJXWVo8Eq8LlbWgFRUtLGf/m3DrKfGJTau6zsCxGLXvPu X-Received: by 2002:a17:906:1da9:b0:aa6:6fa5:65b3 with SMTP id a640c23a62f3a-aa6b139de22mr187587766b.47.1733914560024; Wed, 11 Dec 2024 02:56:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733914560; cv=none; d=google.com; s=arc-20240605; b=hicJBA802tkCJiVuVGIGbTYmnrt1cRv0kJdFZeDMUaj5ytX8rb4xQ4xvzrX7/Im6gl ZUWuFyRIybT8mde/GXKqNY8hyu2FebBoXt57oy4xsXFPCdzVQoqngvnz+UOmjBzkoG50 buIYBc6MTcyh6PpuN7x2F2PN3rLokGNGlALltw9k2TuQ81+B4uIu4LU7rjnCHrJM+KS9 xRQNqtP/mrjfQ+HjP6K+6UVY/WHcedU0OwFqE4LV40l4oVfopkX3VY5COx2gS/+wlS16 GVln+b/ARdF4aEyGkBf2khRGxYEjpu+VgWL5Q9684T+8KoXNkP9X7XcpiwJmx2K69Pm6 O34w== 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=0LrJKDtfKA9ty6RP+PUQwpGRC7a/wDd2aZf4oOuSj3g=; fh=IvTrgPMTWgPRBwC0I89Yvywc4BN8uLKRqRnfqfexrFI=; b=eltcFfWzMcpeBDmqisigkegvHEk/Hoa82a+4ZGiLf6VDPtDPS8ffHbz+unXdCIyKpV Ya82NBkhV8BJfKZ0VWMI4JJKKWHCeNkQztkwL9wLoEmxycTZpbG+KIPAMiXhyqzY9OhD tEC20CC2P+vdPnH+miiwVope5jgKpu7XjtLPwHxMyEwnRK23awwwTWkRtrfKlOHVIrO2 9hiNk3af6pu7D0cnfiTW6ykUuyzzvsGYlH5G7lNMsLhBE2apTgMIuNq1lWiONYmpP/2y wP+skuFD9Wbt/zh3vXok/CUGDxH1VYGd3SUID9VUFUguvqLC0BVzkj9/W7YPb3g9Lt8N NBgg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yhng+d9X; 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-aa625ed83dcsi958189066b.145.2024.12.11.02.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:59 -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=Yhng+d9X; 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 19557801EA; Wed, 11 Dec 2024 11:55:32 +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="Yhng+d9X"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B629C801EA; Wed, 11 Dec 2024 11:55:30 +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-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (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 BC3A3801BF for ; Wed, 11 Dec 2024 11:55:28 +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-x632.google.com with SMTP id a640c23a62f3a-a9a68480164so962417966b.3 for ; Wed, 11 Dec 2024 02:55:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733914528; x=1734519328; 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=0LrJKDtfKA9ty6RP+PUQwpGRC7a/wDd2aZf4oOuSj3g=; b=Yhng+d9XtoUlt5lnJwrHWhwboV53v1J6ULmuv/2EKOCnEC1drbfQDB3y89bsDbKkpZ cEDn4fJ603jGqC05Hp5/V2M3/LqfgwolPUkU5JKoypxlI6wXBavZ+kBmmElPYBnN7Cxn 8iMnV/7SV6EV79EVe2sO7FJyOoBqq3lRpTmIW6/+8kQdksGq4ot5t238QWwdqd5JvLic vFrL0jjm8ik7CH+DLFb2Ld/l/H8adhDpF/PCcdNMyQF3FLkb+zi//tIHHdNrWlWufLp1 21QHb4xitpOpkkt05QxqOaclmTmzglKBIPPZBl8/3GTGAQgwLcB04txGvea3xzcDKtae BsAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733914528; x=1734519328; 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=0LrJKDtfKA9ty6RP+PUQwpGRC7a/wDd2aZf4oOuSj3g=; b=pTGAJ82KLSMKQRaK2/efLpmM4465yUu4dnbxU1JkHMIux0Fopn3nm6/BGR0urTg3Dr wRsElSqIBRSTXloNn4VJLL0DZ6g469wjeojEptHflWqkiGaka0Am+Zvo1tF5LXBu+ywX /XoobDfDxWQteKi/YTkRcKwJc1hZruX7SPKcuMOJMd43EO8mAvT0yhi+vVRyiVczltaF WNdtO9xZbIRzvfvaF5e9Zhrq0iDiz+V73BRahN0EM1wO6RxTCigwYUJkrK9rikHm+q0l tUVwAuz+cgjwh/9imzB8qUYe8hmY7f/MC2766W5uhxzveN5Q/OLlDoGH3jbzrpkBSoPP 1qnw== X-Forwarded-Encrypted: i=1; AJvYcCWHysDyoOtdJHCgxohj7ioSWHZ3tBeEp4KQw10FXYfucPab9L5SfzMVagq6icY6XQNzQyMQXJg=@lists.denx.de X-Gm-Message-State: AOJu0YxSx+EDJhiyUZ63gCn/0zA2LYX/ryCb22FowWGJ7W5RvTGC6u39 NH3KG6TXAAdbhJORJHKws5jbnUVuhHF5au/y8eJQ52Zu3jZ/aGvCHYbl+WxhzuY= X-Gm-Gg: ASbGnct2LaxKUa/DWpJ4Zi6IrBe4of29vz+nIFAVCQxTzZsqQ21ARFpOyc9P8sgZEf0 R7kT/tSx2+EcoAKrUFUYDiovpStIKBFx2WzyelWzZvJeP5TuvEOlYfSYe9VokNJbogonYllil/e oIxjeTX6guA5TzfOM/fdVFvza+7gEUwiSOUPo/9ARbFi+Zne7r0qlWZHJfMLk/xg3yNNW+IlXoi e+oOC3nLpD5cuS0EO7J1tOUzVOXVYQmd4B4eFRftJmrSNOroFTxWD49u1fMG6zVl4Kc4ZaowGpl RzYzIdSzSKN8nTZ/bRH7mIPSL2lTsb8= X-Received: by 2002:a17:906:1ba9:b0:aa6:995d:9ef1 with SMTP id a640c23a62f3a-aa6b115b17emr204184266b.12.1733914528150; Wed, 11 Dec 2024 02:55:28 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa67e652b1dsm508006566b.172.2024.12.11.02.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:27 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Sughosh Ganu , =?utf-8?q?Marek_Beh=C3=BAn?= , Marek Vasut , Simon Glass , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Sean Anderson , Nam Cao , AKASHI Takahiro , Sam Protsenko , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v1 5/8] lmb: Remove lmb_add_region() Date: Wed, 11 Dec 2024 12:54:46 +0200 Message-ID: <20241211105504.453234-6-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211105504.453234-1-ilias.apalodimas@linaro.org> References: <20241211105504.453234-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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(). Acked-by: Sughosh Ganu Reviewed-by: Heinrich Schuchardt Signed-off-by: Ilias Apalodimas --- lib/lmb.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index da960e422ada..659581f13f20 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -632,19 +632,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 Wed Dec 11 10:54:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 849145 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp245081wry; Wed, 11 Dec 2024 02:56:08 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWpzCy8uuCiNskyhBsaE/oP1x05X+rDA+VXXwGs4wwnnrg1wL4BeqhpeRkWZxyJ9N95NfP86Q==@linaro.org X-Google-Smtp-Source: AGHT+IGcBwk/+KPL3gjbQgRt6OSdUj4fN/Rt2pRC/bEHges4egM+BIMqMZ6LcY9hTX3yL497JwZI X-Received: by 2002:a17:907:1585:b0:aa6:b926:bfb2 with SMTP id a640c23a62f3a-aa6b926c377mr83666966b.24.1733914568224; Wed, 11 Dec 2024 02:56:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733914568; cv=none; d=google.com; s=arc-20240605; b=T0bafrM3yYQos2g+Q+a0ib/lTGaB7YkYNP9f0ka5liEk7cfqTT8flaibKH5tNryMjI Xdzg4aUqmFlgsrygtSPj3G3VzPX3ZDdSonEcSGZEL1byhKh5jVtlRv+pwxIgqdJTXEKi tQTKwrxUt2coNr9QUa45KQbawqwzJf1qEO8bVjCfC/NtJCXT00kOmNa5lK3qJlMtqx8E iHcdmSy/5D/rHyKGQ3pW66XegFaEzeC9vObAtnF/0PwQnNMmGJpliIMeG4xcvPydOJd0 KEz3MtUU8ebXn1OTnnvbC/9eXxRMm9mS2C+GSaNmdIANP1o5Xg2v/3vOrqT2iqLf1H1X Zi1g== 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=ZQsPHQ1/jdI36lyyoSKwR2ROE1TShrRikMUQaGqrphk=; fh=38/sX0PKrzNZCrw31ImZ930rXFFaL2TYl68ObxHgXRo=; b=MV9BXXgkUQfScSNkPVrPkWtYD+O819ITkEl1STrWXYr7eK4szqyr+dwTYY6gMKLiRO u3wJZXjegFd2Or7foQmzIPV3PPT94Sff7y8yWmcUlxzw7Nq8d9eylC8yCU81aHddNG+9 XwRLqe8q2Je2rIzVTEtfUK0kipBCkw2NHn3loH+1riNMfZLy7Sb0zO1e/FttDpynCkus n7yHvRETrF/XKOoyjdxvF1YxfeJrSF3tOxthtnTVzdkO7jqRwckcCYNFWj9A2LLgOj9A YiBxcoblIiM1tlkzY6eD4S5QM2iDS4ZRjGyl7sifvlSr72jKtrAV+6tCgX9BB26R16iF biGQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LGZjSiui; 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-aa66e7af73asi589886466b.917.2024.12.11.02.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:56:08 -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=LGZjSiui; 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 622488021D; Wed, 11 Dec 2024 11:55:35 +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="LGZjSiui"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8628C801BF; Wed, 11 Dec 2024 11:55:34 +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 57A618021F for ; Wed, 11 Dec 2024 11:55:32 +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-aa6aee68a57so148583666b.3 for ; Wed, 11 Dec 2024 02:55:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733914532; x=1734519332; 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=ZQsPHQ1/jdI36lyyoSKwR2ROE1TShrRikMUQaGqrphk=; b=LGZjSiuinQBXxr0bw7al75l59pL0Qk4BxbSU3Zjqrdxqk8CpdKkfXNBfgU7ThmVVtT 8O8XQ7ykdeum4HnJWPZCHI8a1x7ApRub498AH6hmYMfwT5orr+n+nw4rEVopMuU9QLx8 JPKACRMZZSkic2triigekCaCReXvumdpI0IJK+9Th5rSdE+ia+bc2+0Sx4TICv1MzEbr ldbOvuEEEPg7xcJ452vx8+W/B1TBNSBBAS6vQhuZK9tupC5/1Mao8OzGqnZop8MkRJqp Z4sK8th4v/RdjWyUTh+yz79K/Cdkrh5wYeffdZFrrBMhUIKiD/dpPOXGIc3r3GvaAvME qk4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733914532; x=1734519332; 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=ZQsPHQ1/jdI36lyyoSKwR2ROE1TShrRikMUQaGqrphk=; b=V46JmzC9xuOJeU3Lk/rfHb3DWYn/7FhEniEJ9qgtT/7r/Pc1zz/BXO+4eVHOrbTY2x XFJducKhGRdQBSrNndDncsF/ywwOASay05KSqNtlePhufe4X3TW1HihHHRxJrYh8ZmXm hu+i8slPh2AqDZ+P+1xjQF9juIJPEt7oeWVCbeROeq2uCkjoK/mdiTcNTan3LVM4Wipn xkZmATMB6/iGTZDM1PhT32c6Zb5etML6eDvRLWUG7bBn+qH7Jzb3qjR7HkN9GBc5mUQI 9YEZRYG9ddKNLIr47BCRtMSfTWJVD3wyh/5H0pzgvBQoDB58+JLhC+/DF+AeFeJx84Xl kDIQ== X-Forwarded-Encrypted: i=1; AJvYcCVe0tIWFkQr0BM54v5Fh2AuGCwpUgRci9uug3iCO7PTx1chELlQlsuWnd/Awht+1Hvn98/9aCU=@lists.denx.de X-Gm-Message-State: AOJu0YwkmFXh7aMWh9C5rctQLQPTog1Gi+tQ+eiaHNx1mxGptNbS1Fj5 Oa256X+tSYUP2FZmBrDDbki0LrY8bEJeVHs0Ulj+oE56YrDirY9WaybbZf9gLSQ= X-Gm-Gg: ASbGnctQIHI/LEds8APbOvSJ6Ta3dAa+UFRsR0DOvaYk9pqX3GlT4g7dBQQ/XdvUZFb 7/0aGEk7ff93LKvcOx/vARc2A6agavEf8qfKDFqZH7jwVMKMsquuTeFavam35xFI/3Ls5nmGm8G J8WJJ4y75cWeiBxy6F3mry6Gi4TGbIFQGYlNRGvpdfb44/HHeOwUmNa0LYnfYmK6YA6p0wmB6wI uxzoD7eSfdma6lXKnKHwJTKkqncYYY+OCzpewKhO9sYVedaaLq4GX4x08ohf/5cfxNfUqTwPRmP PmG3UAaz3rXBkaFWL81WO+xnafpw8Pw= X-Received: by 2002:a17:906:31c1:b0:aa6:9624:78f7 with SMTP id a640c23a62f3a-aa6b118234cmr216300766b.17.1733914531755; Wed, 11 Dec 2024 02:55:31 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa67e652b1dsm508006566b.172.2024.12.11.02.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:31 -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 , Sughosh Ganu , Simon Glass , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Nam Cao , AKASHI Takahiro , Sam Protsenko , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v1 6/8] lmb: Remove lmb_alloc_addr_flags() Date: Wed, 11 Dec 2024 12:54:47 +0200 Message-ID: <20241211105504.453234-7-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211105504.453234-1-ilias.apalodimas@linaro.org> References: <20241211105504.453234-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean lmb_alloc_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 latter, add a flags argument to lmb_alloc_addr() and make the code a bit easier to follow. Signed-off-by: Ilias Apalodimas --- fs/fs.c | 2 +- include/lmb.h | 10 ++++------ lib/efi_loader/efi_memory.c | 2 +- lib/lmb.c | 15 ++------------- test/lib/lmb.c | 34 +++++++++++++++++----------------- 5 files changed, 25 insertions(+), 38 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 21a23efd932d..99ddcc5e37be 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(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 3db35992df8d..5e59915340b7 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -92,7 +92,6 @@ long lmb_reserve(phys_addr_t base, phys_size_t size, u32 flags); phys_addr_t lmb_alloc(phys_size_t size, ulong align); phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr); -phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size); phys_size_t lmb_get_free_size(phys_addr_t addr); /** @@ -113,8 +112,8 @@ phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, phys_addr_t max_addr, uint flags); /** - * lmb_alloc_addr_flags() - Allocate specified memory address with specified - * attributes + * lmb_alloc_addr() - Allocate specified memory address with specified attributes + * * @base: Base Address requested * @size: Size of the region requested * @flags: Memory region attributes to be set @@ -125,8 +124,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); +phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size, uint flags); /** * lmb_is_reserved_flags() - Test if address is in reserved region with flag @@ -164,7 +162,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(addr, len, LMB_NONE) == addr ? 0 : -1; } /** diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index edd7da7d8c6e..34e2b9e18ef0 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -490,7 +490,7 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, return EFI_NOT_FOUND; addr = map_to_sysmem((void *)(uintptr_t)*memory); - addr = (u64)lmb_alloc_addr_flags(addr, len, flags); + addr = (u64)lmb_alloc_addr(addr, len, flags); if (!addr) return EFI_NOT_FOUND; break; diff --git a/lib/lmb.c b/lib/lmb.c index 659581f13f20..ffad7ec12eb5 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -761,8 +761,7 @@ 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, - u32 flags) +static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags) { long rgn; struct lmb_region *lmb_memory = lmb.available_mem.data; @@ -786,17 +785,7 @@ 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); -} - -phys_addr_t lmb_alloc_addr_flags(phys_addr_t base, phys_size_t size, - uint flags) +phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size, uint flags) { return _lmb_alloc_addr(base, size, flags); } diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 6e870274fedb..971614fd8314 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -530,21 +530,21 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) ut_asserteq(ret, 0); /* Try to allocate a page twice */ - b = lmb_alloc_addr_flags(alloc_addr_a, 0x1000, LMB_NONE); + b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NONE); ut_asserteq(b, alloc_addr_a); - b = lmb_alloc_addr_flags(alloc_addr_a, 0x1000, LMB_NOOVERWRITE); + b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NOOVERWRITE); ut_asserteq(b, 0); - b = lmb_alloc_addr_flags(alloc_addr_a, 0x1000, LMB_NONE); + b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NONE); ut_asserteq(b, alloc_addr_a); - b = lmb_alloc_addr_flags(alloc_addr_a, 0x2000, LMB_NONE); + b = lmb_alloc_addr(alloc_addr_a, 0x2000, LMB_NONE); ut_asserteq(b, alloc_addr_a); ret = lmb_free(alloc_addr_a, 0x2000); ut_asserteq(ret, 0); - b = lmb_alloc_addr_flags(alloc_addr_a, 0x1000, LMB_NOOVERWRITE); + b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NOOVERWRITE); ut_asserteq(b, alloc_addr_a); - b = lmb_alloc_addr_flags(alloc_addr_a, 0x1000, LMB_NONE); + b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NONE); ut_asserteq(b, 0); - b = lmb_alloc_addr_flags(alloc_addr_a, 0x1000, LMB_NOOVERWRITE); + b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NOOVERWRITE); ut_asserteq(b, 0); ret = lmb_free(alloc_addr_a, 0x1000); ut_asserteq(ret, 0); @@ -560,22 +560,22 @@ 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(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); + 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); + 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); + 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 +591,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(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 +600,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(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 +609,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(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 +624,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(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(ram_end, 1, LMB_NONE); ut_asserteq(ret, 0); } if (ram != 0) { - ret = lmb_alloc_addr(ram - 1, 1); + ret = lmb_alloc_addr(ram - 1, 1, LMB_NONE); ut_asserteq(ret, 0); } From patchwork Wed Dec 11 10:54:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 849146 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp245136wry; Wed, 11 Dec 2024 02:56:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVWVFKYwuR6lSzbjSwGm105LgbO9NeE1MQsTGNhx42urZl/zndc84DuKzQNpHI+FL6p6ek0SA==@linaro.org X-Google-Smtp-Source: AGHT+IH7LhVousOSTfmuVqe68qPX1BQN3VTpeOsQubN0XD2nInFm7SEFCy/o5ReFfbupU0dZVtsz X-Received: by 2002:a05:6402:348b:b0:5d3:cf89:bd3e with SMTP id 4fb4d7f45d1cf-5d4331639cbmr4996061a12.30.1733914579589; Wed, 11 Dec 2024 02:56:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733914579; cv=none; d=google.com; s=arc-20240605; b=QrGLGGAYtTpseureFEl8U/jFXlnUYgNsfmUY71bn+BgJhTXu0eQnoaL/vriNIEOwYX ZOQ9wYZ6ioZAPRGboJuZKG/1DJ8eOTDu+8Z+7ZFRJwoIp7gZte1ahhJ2Ureh0Z8+pUX7 5OKbPjjHELyKZscLKalablL9t2ga8MAipF7IQkeFpnodk9wb+iVjPlrZ5Lpflkze642G 5KmDwaSBIPFZjINvlf3jrV0A5Tbl29tgeKoVDCEkA5f+Dr3gDYkxUSGtn8n+J9Jk2ebk 3sWq7Hl95A0jiQ5fV0IZm6Mxh1POB8MaU+VOEesUiXHIi87LgRrhiF/3AGHVer0InN/9 FpXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vq7Et1+06yoU+SrfNejcP7FvAUznzZZKURsbScNxGrA=; fh=dqoIyWezwpN87+mH4dIocR3yjQuK5Awmyd9b0nFZkMg=; b=TFS2HQZGQzMC6L172+pxy+nAIcIKmmf6LxtANDYCk+feNwyPC2Q1Zya6MzQridUZ2P t6LaY6hhOM7WKkKc5tb3WtL30xSYDftCqAMK446aLleSJgGSrQxGHk/8+yBKORkNn3xp RQpM0JcbLq4hOFClvhqbpdzbBKblz3lqyhhT8O4hWsHhrxQy8PFiYKkCjZ1ZIbsphWpw RGOMubBakIK63dT3TTE9NkgvAdT8/wbJJsgcmMem7fLoW78A8pYjYTZZCcmtLxb8Hdxw EYparbJcp11tlY5Rq5zsp9OnRgkl9J06wGFMvCbGf0HBHsGU+Mbm76k6QWJ+bIsurEI2 Sj0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gjwDneBk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5d3def710f2si6678709a12.265.2024.12.11.02.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:56:19 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gjwDneBk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AE3418022B; Wed, 11 Dec 2024 11:55:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gjwDneBk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6FB0801FE; Wed, 11 Dec 2024 11:55:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 12DA480278 for ; Wed, 11 Dec 2024 11:55:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-aa6b4cc7270so78780966b.0 for ; Wed, 11 Dec 2024 02:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733914535; x=1734519335; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vq7Et1+06yoU+SrfNejcP7FvAUznzZZKURsbScNxGrA=; b=gjwDneBk5FLuX2YM0u6jecWFwP1wxirMoAF5X/42cB1Dj0izpnjAhtltpltw4cnf+M QoiOGKJGIWuNvOHAWXszzeWwnhyb6lsNwesxX5EAeT57RH1SFWhweBVLw1/q+nhSP9qI d0+yMcQpRowKBtO5f9GZ3EkZCCUMy9C/LUDfSLQV2JFl2kHtux1+TLWKJ+wuEoNp5EnF ExznIO2mjHIgNeFMlf/iplLDOZZTA9fS0C62+LTraYmN+tPFxYvJ6tdz+PX8pc07iopv 8/NWE5NlADhb+uA7saPABbqkMyxuBokaxILhv2Hd/oKkVRd9sRZzezokGidhBuP91Th9 o+FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733914535; x=1734519335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vq7Et1+06yoU+SrfNejcP7FvAUznzZZKURsbScNxGrA=; b=bx0yvQRmesmdrmV4i1+9mpr1F4396NMNebRyf55paOE+3ArLkvJljYk0BCM98HNr2w EtNfQmJGiCrb9xI4/W3u/xcI+ekS/b9Ye4sHlTMuxJA8osGMe/LdQxHmOPsViX+3s9h/ JBqQl0iIkZt4QPSl30cYL91XwisdRRHN/+hjhT43/qYEVu/uWMBifXoDpkNxmhguKze2 O3QwPqfkmmcl6DOvScLXB6PXSA4Ih57ibwyRKoozeWJy+90S8+RTE2PoS4W1s16PEVvW 6Cww8NY63pDeCay+F+1gqHlPgwhJCyHj9MELrz3LtJ1NTmm3opbqlhsy8mYo2il5HhkJ BEQA== X-Forwarded-Encrypted: i=1; AJvYcCW92S4FSxJmzJGZIeSM+Mm4gPj4dog9HNzxzmYPvizDNvkCgQtYQHkXCcNLTtrYjb6DaDb751E=@lists.denx.de X-Gm-Message-State: AOJu0Yw7njjVyAPQDzl7dLiT7P3sN5g7eyDM9j+53enywsKJXae4Gc/J A8lluauz+fPnL58V5xOAw/iTfADq3VWXRdWJtS9j8ihbJPPV4BkmEayuFB7TMwU= X-Gm-Gg: ASbGncvizmqp1ptnvlke7uxSNbWFVYndfQJ2Jgp6S5wlyKvqCgkQwglDyRseb3GThqr PgEpYA04yRqwYFc/L/uSm6+80jKdEfdVOrmZSZBtEUNslSpwqWIWQWRS/Fc8SqVbpmXDZfRgaiH xRHo68o8dGYTSfCtUKIhGfa+evwwAss2wru+Q+bSvo+4FUnchQ3vzoBD453UY2qXdrg7B33WTWw +2Dg3gFigY2YUKeT8mi2qfH54KogcBtgCaSQeWZwXwcO20kqVjqknkrXWi+YRvyyyYbj8TUsDgR Srhads+2twHXL+Lrx4Tp5YsveQvb1dM= X-Received: by 2002:a05:6402:4008:b0:5d0:ced8:d22d with SMTP id 4fb4d7f45d1cf-5d43314d119mr5792678a12.22.1733914535491; Wed, 11 Dec 2024 02:55:35 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa67e652b1dsm508006566b.172.2024.12.11.02.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:35 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , =?utf-8?q?Marek_Beh?= =?utf-8?q?=C3=BAn?= , Simon Glass , Marek Vasut , Sughosh Ganu , Mattijs Korpershoek , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Sean Anderson , Baruch Siach , Nam Cao , AKASHI Takahiro , Sam Protsenko , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v1 7/8] lmb: Remove lmb_alloc_base_flags() Date: Wed, 11 Dec 2024 12:54:48 +0200 Message-ID: <20241211105504.453234-8-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211105504.453234-1-ilias.apalodimas@linaro.org> References: <20241211105504.453234-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean lmb_alloc_base() is just calling lmb_alloc_base_flags() with LMB_NONE. There's not much we gain from this abstraction, so let's remove the former add the flags argument to lmb_alloc_base() and make the code a bit easier to follow. Signed-off-by: Ilias Apalodimas --- boot/image-board.c | 18 +++++++++++------- boot/image-fdt.c | 5 +++-- include/lmb.h | 7 +++---- lib/efi_loader/efi_memory.c | 4 ++-- lib/lmb.c | 19 +++---------------- test/lib/lmb.c | 8 ++++---- 6 files changed, 26 insertions(+), 35 deletions(-) diff --git a/boot/image-board.c b/boot/image-board.c index 070ada007185..4e86a9a22719 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -565,9 +565,11 @@ int boot_ramdisk_high(ulong rd_data, ulong rd_len, ulong *initrd_start, lmb_reserve(rd_data, rd_len, LMB_NONE); } else { if (initrd_high) - *initrd_start = (ulong)lmb_alloc_base(rd_len, - 0x1000, - initrd_high); + *initrd_start = + (ulong)lmb_alloc_base(rd_len, + 0x1000, + initrd_high, + LMB_NONE); else *initrd_start = (ulong)lmb_alloc(rd_len, 0x1000); @@ -839,7 +841,8 @@ int boot_get_cmdline(ulong *cmd_start, ulong *cmd_end) barg = IF_ENABLED_INT(CONFIG_SYS_BOOT_GET_CMDLINE, CONFIG_SYS_BARGSIZE); cmdline = (char *)(ulong)lmb_alloc_base(barg, 0xf, - env_get_bootm_mapsize() + env_get_bootm_low()); + env_get_bootm_mapsize() + env_get_bootm_low(), + LMB_NONE); if (!cmdline) return -1; @@ -872,9 +875,10 @@ int boot_get_cmdline(ulong *cmd_start, ulong *cmd_end) int boot_get_kbd(struct bd_info **kbd) { *kbd = (struct bd_info *)(ulong)lmb_alloc_base(sizeof(struct bd_info), - 0xf, - env_get_bootm_mapsize() + - env_get_bootm_low()); + 0xf, + env_get_bootm_mapsize() + + env_get_bootm_low(), + LMB_NONE); if (!*kbd) return -1; diff --git a/boot/image-fdt.c b/boot/image-fdt.c index d717f6690729..9d1598b1a93c 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -187,7 +187,8 @@ int boot_relocate_fdt(char **of_flat_tree, ulong *of_size) lmb_reserve(map_to_sysmem(of_start), of_len, LMB_NONE); disable_relocation = 1; } else if (desired_addr) { - addr = lmb_alloc_base(of_len, 0x1000, desired_addr); + addr = lmb_alloc_base(of_len, 0x1000, desired_addr, + LMB_NONE); of_start = map_sysmem(addr, of_len); if (of_start == NULL) { puts("Failed using fdt_high value for Device Tree"); @@ -216,7 +217,7 @@ int boot_relocate_fdt(char **of_flat_tree, ulong *of_size) * for LMB allocation. */ usable = min(start + size, low + mapsize); - addr = lmb_alloc_base(of_len, 0x1000, usable); + addr = lmb_alloc_base(of_len, 0x1000, usable, LMB_NONE); of_start = map_sysmem(addr, of_len); /* Allocation succeeded, use this block. */ if (of_start != NULL) diff --git a/include/lmb.h b/include/lmb.h index 5e59915340b7..d481972a6686 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -91,11 +91,10 @@ long lmb_add(phys_addr_t base, phys_size_t size); long lmb_reserve(phys_addr_t base, phys_size_t size, u32 flags); phys_addr_t lmb_alloc(phys_size_t size, ulong align); -phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr); phys_size_t lmb_get_free_size(phys_addr_t addr); /** - * lmb_alloc_base_flags() - Allocate specified memory region with specified + * lmb_alloc_base() - Allocate specified memory region with specified * attributes * @size: Size of the region requested * @align: Alignment of the memory region requested @@ -108,8 +107,8 @@ phys_size_t lmb_get_free_size(phys_addr_t addr); * * Return: Base address on success, 0 on error. */ -phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, - phys_addr_t max_addr, uint flags); +phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, + uint flags); /** * lmb_alloc_addr() - Allocate specified memory address with specified attributes diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 34e2b9e18ef0..1212772471e3 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -472,7 +472,7 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, switch (type) { case EFI_ALLOCATE_ANY_PAGES: /* Any page */ - addr = (u64)lmb_alloc_base_flags(len, EFI_PAGE_SIZE, + addr = (u64)lmb_alloc_base(len, EFI_PAGE_SIZE, LMB_ALLOC_ANYWHERE, flags); if (!addr) return EFI_OUT_OF_RESOURCES; @@ -480,7 +480,7 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, case EFI_ALLOCATE_MAX_ADDRESS: /* Max address */ addr = map_to_sysmem((void *)(uintptr_t)*memory); - addr = (u64)lmb_alloc_base_flags(len, EFI_PAGE_SIZE, addr, + addr = (u64)lmb_alloc_base(len, EFI_PAGE_SIZE, addr, flags); if (!addr) return EFI_OUT_OF_RESOURCES; diff --git a/lib/lmb.c b/lib/lmb.c index ffad7ec12eb5..bdaaa634abd1 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -731,24 +731,11 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t lmb_alloc(phys_size_t size, ulong align) { - return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE); + return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE, LMB_NONE); } -phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr) -{ - phys_addr_t alloc; - - alloc = _lmb_alloc_base(size, align, max_addr, LMB_NONE); - - if (alloc == 0) - printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", - (ulong)size, (ulong)max_addr); - - return alloc; -} - -phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, - phys_addr_t max_addr, uint flags) +phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, + uint flags) { phys_addr_t alloc; diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 971614fd8314..fcb5f1af532a 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -128,7 +128,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram, ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr, 0x10000, ram_end - 4, 4, 0, 0); /* alloc below end of reserved region -> below reserved region */ - b = lmb_alloc_base(4, 1, alloc_64k_end); + b = lmb_alloc_base(4, 1, alloc_64k_end, LMB_NONE); ut_asserteq(b, alloc_64k_addr - 4); ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr - 4, 0x10000 + 4, ram_end - 4, 4, 0, 0); @@ -138,7 +138,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram, ut_asserteq(c, ram_end - 8); ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr - 4, 0x10000 + 4, ram_end - 8, 8, 0, 0); - d = lmb_alloc_base(4, 1, alloc_64k_end); + d = lmb_alloc_base(4, 1, alloc_64k_end, LMB_NONE); ut_asserteq(d, alloc_64k_addr - 8); ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 8, 0, 0); @@ -163,7 +163,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram, alloc_64k_addr - 8, 4, alloc_64k_addr, 0x10000, ram_end - 8, 4); /* allocate again to ensure we get the same address */ - b2 = lmb_alloc_base(4, 1, alloc_64k_end); + b2 = lmb_alloc_base(4, 1, alloc_64k_end, LMB_NONE); ut_asserteq(b, b2); ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 4, 0, 0); @@ -363,7 +363,7 @@ static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram, ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 0, 0, 0, 0, 0, 0, 0); /* allocate a block with base*/ - b = lmb_alloc_base(alloc_size, align, ram_end); + b = lmb_alloc_base(alloc_size, align, ram_end, LMB_NONE); ut_assert(a == b); ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram + ram_size - alloc_size_aligned, From patchwork Wed Dec 11 10:54:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 849147 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp245193wry; Wed, 11 Dec 2024 02:56:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVb3Rsz2uRhr3j2AQTdO0v+ZC4/4D1nRhe/sBIEolzI6UiOSif5jGI4ZOV2gjoxszocllfuxg==@linaro.org X-Google-Smtp-Source: AGHT+IG1kd8KqryRYayvzlyLwYcSvefwB/at01OBk11zWXBR8rkynX6YE9WoPa7o2pVCpQpm/YeG X-Received: by 2002:a17:906:31d2:b0:aa6:7df0:b179 with SMTP id a640c23a62f3a-aa6b11b2e63mr218666666b.22.1733914589821; Wed, 11 Dec 2024 02:56:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733914589; cv=none; d=google.com; s=arc-20240605; b=DDtltZFEPg6yt9uUSGCNDj8hv8OU0Pf5PU8veAxqi/VDRQ6YqDIB5nBfE5R74MS3Hx 7/n/stZcBD3zyl7xMfauvJnFk12mU5cGjw/JoyUAxxAg+An2zC5x9m1ygcKEe3dCq3cR k9SOi8JOQIQhcD7ZD0g0kExcuGkOmzd0zNBaLoAlalw+RQb4QAOm8OStzMIWhro+Wxd2 4f2sYzDBWNE0rIPiZdUsCa8+PtUR/ZrzqycSCckZxYMY2m+1pCUsXqqm90pU07aQxVTT 5Q+po+gt9WweHXjWrtB1SA1GH7sH4s2IMlXcM9x4DV9QNo/mr9fe6ulpjVaeyakokQLI X1YQ== 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=1Pa4i6SSo0ziuImDLfRHe3DBSlYndj2von0Q32AANuI=; fh=fNJvnq8CRwjM8113ImGn/4yNvZ1pnvxrVyTqFjY3QQc=; b=RvyfUfct32kOsY9Rvyrx7CnaZQKlFN4NJdHTUDVl50ALFcxCgMPj2QiB7XGG6Xpl4Z y36w7d3O/61AJbdSxkN8TTTt3+bhIp8Uv9u6aqIMctSQGQEyp7bNXpdxu7fw/s8RwrWk 7bG5GLhn1hMSyXoUqyN7auXbDh/QLqGmjiyvpu8qREIIb0/BDQL3hhniFyJHjYNfz66E Q2GaVSTPP6KUBSZDfobk4k2knMvIuVsgdsRRzLXZbEoBsKeq1UXX2z7mX78yTrjE3DI4 a/OSKXcMyNbr9FihTJwKjNrLFM++EUen1NEx47mYoo5S9kg4qWjr4Ecl9EBG0TEsxtFa rIwg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ruovsQOQ; 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-aa66fce860esi574793566b.267.2024.12.11.02.56.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:56:29 -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=ruovsQOQ; 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 03300801FE; Wed, 11 Dec 2024 11:55:43 +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="ruovsQOQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C881080241; Wed, 11 Dec 2024 11:55:41 +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-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 CBBEE801BF for ; Wed, 11 Dec 2024 11:55:39 +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-x629.google.com with SMTP id a640c23a62f3a-aa67af4dc60so576662366b.2 for ; Wed, 11 Dec 2024 02:55:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733914539; x=1734519339; 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=1Pa4i6SSo0ziuImDLfRHe3DBSlYndj2von0Q32AANuI=; b=ruovsQOQiNJpumVdcdvmcW3SxlLGAbPQyKOLrtLuIij2RLco0+xV4iFUtAdQiGNCM6 4tvGPe6J3ymEmNAMAp2Tgj9BNtSbOKTEHNai22C7QWDl7NGcE4kObBJWXjKE9cH9YC1s X6ZuzBPeX9QFm+mRB4zya7aPMPbpBJ8o/F8HjC/DFxNF5iWM25EMUGSWlF2Q3ntYnY8D 41kZO0RQLRRE7wQVL5IehO/TUclBsQnqC7utTAwBjlVKDgq+Wfux/CIhfVZEpcxQO9kd ln2FuHhUB8xYcQpAJFjtKFFXUQt3y8Cx4s1OZdHrY8WNAVJG6q2KvKaSsSgb0bK0Ks75 9tVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733914539; x=1734519339; 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=1Pa4i6SSo0ziuImDLfRHe3DBSlYndj2von0Q32AANuI=; b=OyByVo8zxR8tNnkuaZJdR0kMN7IO/G4Wn9utdnEtHoxKVCdWLX9+k9mUE6F1HMPHOW eYGq20zK3gD1DR6wfrMYAMEi/ELNM50YnzqFuM8wOq+dx+ty/iZoXbDF3MngxFuw6No9 sQpJ4np5bvmHfwge12NmWStwLjkv1KtVBbk/kML6ECuQNm3Ibz4KajbHNmpAyOQ9Nhmw 4ZBh130BBi8vtTb9UotmcsW2kb1cI5urOfpBdNFG1lgpeQ+cCaO4JterrsgQx1/p2ltM iDXIyyRmgl0SJ7IW40/wHl+KjlgBTtayq0YL18vBTy/+lCNnSEnn9DFXdWYm+izwl67b lPPw== X-Forwarded-Encrypted: i=1; AJvYcCXBUHvudLT4kjFMYKLmNtsj5roWDQgwzpUZWJqrCfzCvQCY7x2bG27rkIPL7gNOxbcMpWxD4EE=@lists.denx.de X-Gm-Message-State: AOJu0YwnVXajgOy3zbkVLvLPmrZH3hSKoKFI9/EpzI0NcNJgWE4CDKan 9OOxpe0+MyN59t7VAUca6rd4WJq5oJZurAzHI39F1Ayf/HsLX9ZM5GurWymOoeE= X-Gm-Gg: ASbGncu4C+fANeW+BnToZGyJe2PHvCfBoUkqV9SNrwCTCFZnSWK2T1DX9H4oxR5PY3n 0bVI1If3+m8lK5y6ffnccCNvM08BYForE6hrEPrrqs/rQS5kvnKNJi64HeVPwm+a4/SThRhRDaQ StnGQjBKxUS56LtxDerktGFs3+JyVb3O9DC0o5frIJ80ahpNbRaKf79N0fKJdRPrxOAYHbx4kYr ShkHjl95lvxu3N6reNgpYFpObAUyW05L7PIKiwqnXw1o5X1X8rV5rVY3+IaJHPjdJ4Xrq3/a7u1 ZoJ7VTGnE1M/zG3Wl/YYfH5KbGVZLH0= X-Received: by 2002:a17:907:84c2:b0:aa6:824c:4ae5 with SMTP id a640c23a62f3a-aa6b1505cc2mr176234066b.56.1733914539129; Wed, 11 Dec 2024 02:55:39 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa67e652b1dsm508006566b.172.2024.12.11.02.55.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:55:38 -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 , Sean Anderson , Baruch Siach , Nam Cao , AKASHI Takahiro , Sam Protsenko , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v1 8/8] lmb: Rename _lmb_alloc_addr() to lmb_alloc_addr_flags() Date: Wed, 11 Dec 2024 12:54:49 +0200 Message-ID: <20241211105504.453234-9-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211105504.453234-1-ilias.apalodimas@linaro.org> References: <20241211105504.453234-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean lmb_alloc_addr_flags() is a wrapper for _lmb_alloc_addr() and it's the only function using it. Rename _lmb_alloc_addr() to lmb_alloc_addr_flags() and remove the wrapper. Signed-off-by: Ilias Apalodimas --- include/lmb.h | 2 +- lib/lmb.c | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/lmb.h b/include/lmb.h index d481972a6686..76fb82b197a9 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -123,7 +123,7 @@ phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, * * Return: Base address on success, 0 on error. */ -phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size, uint flags); +phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags); /** * lmb_is_reserved_flags() - Test if address is in reserved region with flag diff --git a/lib/lmb.c b/lib/lmb.c index bdaaa634abd1..7ca44591e1d7 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -748,7 +748,7 @@ phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, return alloc; } -static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags) +phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags) { long rgn; struct lmb_region *lmb_memory = lmb.available_mem.data; @@ -772,11 +772,6 @@ static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags return 0; } -phys_addr_t lmb_alloc_addr(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) {