From patchwork Wed Dec 18 07:02:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 851663 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp768367wrq; Tue, 17 Dec 2024 23:03:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUg0DSGX01fU4nkHwlQEXd50hf6Zgvcbiaj5y0yoeOe89eKHVIsjDsA/SVluTktfJbQ2E2qIQ==@linaro.org X-Google-Smtp-Source: AGHT+IEOEs6l003WTBdP6y5U5qsy4ERXn1aKeYV3baRSRlUy1EwckDnKdAvAkCeLXWnNMG9YqA8J X-Received: by 2002:a17:906:31d4:b0:aa6:9c08:cd3 with SMTP id a640c23a62f3a-aabf48b984amr132058066b.48.1734505391122; Tue, 17 Dec 2024 23:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734505391; cv=none; d=google.com; s=arc-20240605; b=UlCJIw2Gt+FBk8+Ql3prDpjBUchoZ7UL4JZsYEavoWYsiFAhSvehTv9P714b7TmtLx yrU0XXkTe6SW/+PUyRufNj3Tn7aNGo7jxIdhU84law+ojhigOzI4pQz+ICNy6iDyvLD4 Qxo7xSM8uBWszQ3JF6T1DkdeGx0k7++B/KUeO/k1UlYeCAU4uxc5E2HYbtjF3BQFO+9K CQ+n5wPYvMqrebWozwr5JZDZDA2GAJ1jd4NdVauR05lwrSWRcPzs0GshH4CtMFxAg4lz 9K4PegHnXUPohVSkb66qUL9BCkqaXYf5IOUlOFRkqkgkOAwxLtjlCCf7IxNOury4aj/l RxaA== 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=6p+WKkDxcIxCTA8AyvnO/iqGzs5mT4zUYn8AC5G7hWc=; fh=NGMT63Wrj65eLrHYiRQXkL376snZ+eBG0DKADNfePmE=; b=kf+51Zq5BU4mWMaIbC1/5Y8TyIRl+ON21Zp9e9LDiZJbK1MZmOfXLIT4mPVR+c0HNM TX5qgiobmFWGZyjUUYK2KyMGVmIvtjTfNDB4IgY36krBzR3n1WM2M0KVFwhV90+Ud10j VzZuBQVa0DY0lo3jPkZ4kKRDmbKMjYult//Kzc8tmaXepikoJ1woqvJQ/oQn6Q596PCk qfw2NW91/SWsdIHcRqhQUw9lKWfE5nQMYxuXxT4fYwjMhOdBE5VMc+Mt1jps7pT6kzl8 LKkMoMNccF/TmBSljYfkmnWlRcP0fv3ivVngGSqJUBXW2tAnpgLD0ve3+ubyu4u2eaV/ sMjA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wnpYIjFM; 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-aab962c3447si562861966b.429.2024.12.17.23.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:11 -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=wnpYIjFM; 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 B187680241; Wed, 18 Dec 2024 08:03:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wnpYIjFM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A911580269; Wed, 18 Dec 2024 08:03:03 +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-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (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 A64D280241 for ; Wed, 18 Dec 2024 08:03:01 +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-wr1-x434.google.com with SMTP id ffacd0b85a97d-386329da1d9so2855702f8f.1 for ; Tue, 17 Dec 2024 23:03:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734505381; x=1735110181; 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=6p+WKkDxcIxCTA8AyvnO/iqGzs5mT4zUYn8AC5G7hWc=; b=wnpYIjFMvNTNOl5Ouy7Wqan1hS9E4hbpLceO3KIG7Hgr7yJpmbEHU10GZlwAaXr0QG 8LtMEoFi3HFCZLoGYm1R9SD4JFwIQHoDepvmgn1j2kH3bw2vvRQ6HvJ1dimXivOSEswB 1gEvBAcwS2VrjmAxpDjWAMoSNxQ2cJM8LnnniMqxslIEXg+B3+7L5hrTZINZ3rGryVAE rGKUH/J6ccR8vNFOSrRLKZGovI38RT7sf6kfnPI18uvsJxitwHPWBlA1M7CnAYPCBVXv hCZErwxA3FGIC++OZJzvr4NiqeNwaZK/88ZlQnXp9/0f909LWMWh+LA+/LE69PHWDPR9 CxTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734505381; x=1735110181; 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=6p+WKkDxcIxCTA8AyvnO/iqGzs5mT4zUYn8AC5G7hWc=; b=N0pX6e/jGF7B0zpaWguaNPMMS9mkB9aVMsF/9Zg7nIduugDdgp+OoXVnIiX2IvU3R/ uSlf0yjgkHFO5o45CfJXfDnq3Un71oX/nUk+7GWEvDlcBT9vtdCU7Y//K7z6PbX5fzt8 06f7mr5Ma5EWmc5JKgcPAcYY+Gn8pCxKdA0FfdwH566xE/ibZYZ23fQdN7vgqXFnvEJ4 Se4+w3jbbVY62DXH1RHABLvOS+dijR4hdJ2R2mRfb3cLU+/s1lp+wAamFIIThwDgl9g4 5nrVRwzG23LlHyubK8lYiHech5W5TuRJkQnY2/gKmSJ1hrcf4tP5X8ue1kJvgnq0Grmn L8FQ== X-Forwarded-Encrypted: i=1; AJvYcCXM0a3+YNCOrdeK8+gEJw5wnqvokU0ZhaKmMXtYSRf+fzrcIUXKtoAYNRxu23+waP6ZIbI3jQw=@lists.denx.de X-Gm-Message-State: AOJu0Yw/3FAG8b1rithbNbFH1bkezb4EpfHbFuyeSMyD+70xn7m+5FAB m+FCekC7ZDNl2HxDoSWQgQMn2gdV/WYzXJNDkO40yBVc1zx4FhNN5dCotmMOoFU= X-Gm-Gg: ASbGncvv668v7AXhXE+asigxyHAsS0bSdYQNo6747q1Mtvc5ISGM/xbmr5H4Ynk4krM scN/WcusjUUZXGwf0HwbR7v9c2ahCvsozHg0EbbM5e+hyJ4cJ227M8zYQUvDdNhJuMR/mTP6ABR SYbYw9NuGfaTd/8ax0JVL2wPCiTz5KOxLSjmRgVwn0D3XzTCa7ev17ACnTu+wlETNCu9Y5FUJ7n 1cUtKB1ezIkgYxwwSl4eUQi3qJjKck0Xe96wve68fJBRALiluxd6apCJQ9EuUTYNIhUz+KHDSYC 6qCSldSOaa1iJB7ao7daRbtiuKZsMKjDlw== X-Received: by 2002:a5d:5f4d:0:b0:388:caf4:e909 with SMTP id ffacd0b85a97d-388e4d56a4amr1396488f8f.25.1734505380965; Tue, 17 Dec 2024 23:03:00 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c8060592sm12971612f8f.98.2024.12.17.23.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:00 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Sam Protsenko , =?utf-8?q?Marek_Beh=C3=BAn?= , Sughosh Ganu , Simon Glass , Marek Vasut , Mattijs Korpershoek , Michal Simek , Peter Korsgaard , Michael Walle , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , AKASHI Takahiro , Nam Cao , Janne Grunau , Prasad Kummari , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v2 1/8] lmb: Remove lmb_align_down() Date: Wed, 18 Dec 2024 09:02:30 +0200 Message-ID: <20241218070251.686383-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241218070251.686383-1-ilias.apalodimas@linaro.org> References: <20241218070251.686383-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. Reviewed-by: Sam Protsenko Tested-by: Sam Protsenko 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 18 07:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 851664 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp768437wrq; Tue, 17 Dec 2024 23:03:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUUCEtHW9+SU5brxoWWF2e26yO9ITywSESEu4tdtqxYQBwcx9HvQAbK2WOVkQyG1zCl7aNvsQ==@linaro.org X-Google-Smtp-Source: AGHT+IFZYJI/FfWS+4jQroT4zxdG8DPbQwDoMJvHDmSNpXhkjG4rR1ZYOaKIWl2CobiUjwKVDXwc X-Received: by 2002:a05:6402:5306:b0:5d3:ec6e:64bf with SMTP id 4fb4d7f45d1cf-5d7ee4093a2mr1616120a12.34.1734505400178; Tue, 17 Dec 2024 23:03:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734505400; cv=none; d=google.com; s=arc-20240605; b=Mxu90ErBiBopaG6xKCGZyGywIlNl33CNdDKz8UWdr2BIXfAtMaLuEiO2JYrbMVcDdL 195lLQXjfnpaDK+rJNydjsXtmeGYTyhdXF0WQShHh6r+h7FJAMTbTk+0Ud2WnZh7Z/8u HlYjOKhZCS1AbFov+Qe3c/dIKaLY68xhijT5u30aaXQ6cQ54wDU08Az/As5W0g2NCJIQ 5XPOeBR0oEls130Mr0x85KzsIQKLwzkD/V3whq3HQME8pEhthi5AbHspRSA1gI1s5VZn OqdxVCAn2AVaJq5OSmKqLfO+r6O3tiC4pl25AyHv941eNuEpaxZLz2tJ+kz3IZ1PPrTF jfRw== 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=kmxL27mFCIVKJbTFnHm6/Ljivpz1TZT5CVJfvULBZkM=; fh=eU7e/mmsP/zbfa/gVrKggmfGExKMuDgIYowQVpghVFA=; b=MeSXpQR+RrHzNE8RkIodVWWbZjF94AbQYmvtnFacEzrmqbJ8GGo71+gd1fTu2c8JED ZX/VI9gkF5K2mMFgP+BU9aPbjqgq5sApxpl+eyUTzUyzR+CTqSOF8/1TsBtvS0paHxh1 WPGMpKuEla8W4PxHOboAqUX4yfVrLrE6oyLWnPFHeYvrXc9oZ0hsuXgslCKil7sc1ezX FG8Gx7GfyGAjaALzn49LqdyDBcy++ED1BcJyoWVX7U8/hZcGhIe+k4Mc79PVf58M+cIO DJCeMRKxtXvVq/Xv6nvlkjESQzaJOrI6vY4y/gIhsTKI5igYvQKtG7VcaZV2IIpk9n/7 gaew==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x6NTuU4M; 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-5d652f81ccbsi5851462a12.506.2024.12.17.23.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:20 -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=x6NTuU4M; 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 12DFF8027E; Wed, 18 Dec 2024 08:03:11 +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="x6NTuU4M"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9CBD680243; Wed, 18 Dec 2024 08:03:09 +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-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 802FE802EF for ; Wed, 18 Dec 2024 08:03:05 +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-wr1-x435.google.com with SMTP id ffacd0b85a97d-382610c7116so3186062f8f.0 for ; Tue, 17 Dec 2024 23:03:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734505385; x=1735110185; 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=kmxL27mFCIVKJbTFnHm6/Ljivpz1TZT5CVJfvULBZkM=; b=x6NTuU4M4I/zvujmQyFziztQsnu01dG9atukNpUR03RTZrwFYeu1trrVzKvwRE8R0q YwrMNorPodZNMydwVX9nATgHHh604IvLVQXoHqWo5vJ3iJ00Qft47GT1PH9BWV6i39CK p/1/Yh8G43iC6l7qfv9zLhXe8rwNfJeXTJ62UM5LzPDx+pr22KCQU+gZGd2fZ5jBjx8S RpT3dYC5K5ynfucRRlSt269aYckKk8KB6GAmJNbO1trM3EfLd425KLRAVWEiR2peo9h3 zftVEn5EhuLRps6AMriZLtIJUomo6yC5bRE9JsXCKPgzY5lhnB9UB7b6Z2D6JifKK0Gr e5Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734505385; x=1735110185; 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=kmxL27mFCIVKJbTFnHm6/Ljivpz1TZT5CVJfvULBZkM=; b=OFnfHEPQolKAj52CgfBl4p3+F5mNAcfm9W/EP7rcE34psT2EgjDWples8pIcIkNEBF AuCXEYaUISbI7Z4SOevtB3cwRmzVcG/oDB6//r9qnuXy7BKsdbiYGJHmEF4B/Qjac6ci neuhfXolP9lQ5hS2X0Dm1OVnNUC+tVMWVERmoBd4tv26HtWbOGInXQoRwa3wZeYBeIHx e4L8GHadjtA+dAvLXycyk0dsd4L6Wo1DJ1t/LP4v4UC7esbrzmdDIVZ/3MnBoT38Zzur RzhbnNQd/TDEUxRG/4jkQ7dCmyiqSbERWJJQaaPjPe8c5zyAgvpA4TAAODR0XINtqCMi NY6g== X-Forwarded-Encrypted: i=1; AJvYcCVODM+TuQIcrhKhaYkkQJff2oSME/DivGCnLhaKv/YT030ZL+2ZQLygNXZZ2Rhpra02cnMewTo=@lists.denx.de X-Gm-Message-State: AOJu0YxN4nZmZALOQg6TyUtrDAVJzebTGpZp2lc48DVeAp+cFA7eU8ug c5Em80s5IZR4JgNgKQDurx9Dv3qgA6Uc8JAyjunWH0j3rsh7wRcqhYZGdoYwDzw= X-Gm-Gg: ASbGncvgJY1KiDJc3yEwXqjTKknqCAzN+gxCPbavf44LuV737MTiZrnStJ3kij0DAT7 zHzauWzx8JVixo66PzVcXYEFgOTUAChLb4ximBFBizwedzmYAb+kV0TnGHEIx56oHzg4wFBsgck jLNrTLAaiP5Yj5u/9KCgCNw3lUHYoUh2YOuPOOCUdr7XpwK1i+3Nm91sz0G73Og/6Czc1G4ILaa h+1SP1eRxXkWU488PwK0nIvFkFKu9LC9Sq4bIZLppROoq5lwtxykXNifXffmhq9cV1yvsn2K8Xn g0NZZPhJNFuu9cdkTkyCqHBsbcDd5fix8w== X-Received: by 2002:a05:6000:186f:b0:385:f69a:7e5f with SMTP id ffacd0b85a97d-388e4d8df8bmr1282346f8f.38.1734505384949; Tue, 17 Dec 2024 23:03:04 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c8060592sm12971612f8f.98.2024.12.17.23.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:04 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Sam Protsenko , =?utf-8?q?Marek_Beh=C3=BAn?= , Marek Vasut , Simon Glass , Sughosh Ganu , Mattijs Korpershoek , Michael Walle , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Nam Cao , Mayuresh Chitale , AKASHI Takahiro , Janne Grunau , Prasad Kummari , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v2 2/8] lmb: Move enum lmb_flags to a u32 Date: Wed, 18 Dec 2024 09:02:31 +0200 Message-ID: <20241218070251.686383-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241218070251.686383-1-ilias.apalodimas@linaro.org> References: <20241218070251.686383-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. Reviewed-by: Sam Protsenko Tested-by: Sam Protsenko Signed-off-by: Ilias Apalodimas --- boot/image-fdt.c | 4 ++-- include/lmb.h | 27 +++++++++++++-------------- lib/lmb.c | 18 +++++++++--------- test/cmd/bdinfo.c | 2 +- 4 files changed, 25 insertions(+), 26 deletions(-) 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..3b911d5d8391 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -19,18 +19,17 @@ #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), -}; + * DOC: Memory region attribute flags. + * + * %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 +40,7 @@ enum lmb_flags { struct lmb_region { phys_addr_t base; phys_size_t size; - enum lmb_flags flags; + u32 flags; }; /** @@ -101,7 +100,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 18 07:02:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 851665 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp768513wrq; Tue, 17 Dec 2024 23:03:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWqlyWu0vNfmoh2YDRqJOzldsqRvFpwo+7WXlZ5uwsm4RaIWkrqG0K1Mi/RSd2tU2ZazYh1NQ==@linaro.org X-Google-Smtp-Source: AGHT+IFGMIWIpcyUaHUm9gnq9IQOrvm9X1IgVkaHt58WKx8FCaT7TpzeYCKqGZsNpNeiHdWMYzHn X-Received: by 2002:a17:907:c22:b0:aa6:375d:b96a with SMTP id a640c23a62f3a-aabf493267bmr121103266b.53.1734505409680; Tue, 17 Dec 2024 23:03:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734505409; cv=none; d=google.com; s=arc-20240605; b=EqfJtac+iUuq//FeEOTaPNZ75lZMOv24emnoGLl6CVDAbmz2e0V5YeQ34mzkdwgwoC 9cs7Z/tFYlKbNd2Pzw57wplvfkWr+zrk1NgbBH3j79Od1u6l6cQeFjPb0K+RVTefugXZ IGpgL5jEUx0QW6KOS4ML3pC37P/NMBf9J/Iq8WEQODuTRCjRv2MSdNgyrHZ8KOKo+2be 86Cokibu95HQO4V6RTNqw7PdyPWLHJCYPfMxnA8wc8dVrrP0urCwsofMT4SHuoNVBaBh vaAEv+BfKh5OdysinP9aLOBH6sSUtP7EYWj3ESc/trPsUA17skF2eZa9tQv3NILUguL4 ob1A== 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=y7XIpF0RcmNHSw9YLYK7Opl+/eMYWDy3q85wIJRpPx0=; fh=nbqFyCsxNH33kGPajgrff4dRQvtr4ECDXHOixtT32Ss=; b=WA7QPAUiqdtmgLD3zIywBQa8UW87yRyP5F4NP7vhzc++cUE46QvBaF5Xt8az+WumeY CWkV4ihWuzFMNvQJGd1/XaqC6Ny9feSy8GiTK5BE5rw844CUyTG/Qv5FXUFvZBtsuBq+ zhmEBsJxfrVRoB8DPDQNJtNqXp5eWnj7gGtalvyddUPoAfxEsyhTer/5roYDeQHn5749 Iah7RWp/EDiGMcktF0ugv2a3nhgmUCoGKjgXOlKoCL3lF1JCl2HUy4gGj01RU1p/rH9E HX9A2ZZg3xkBeqwqLIM1xmSffCyZXwsrIOC5vaRataeMjI42LCaTrChNEitQlU78tZ7a 0UPQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ql9+Nk+G; 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-aabbdccb2a4si396902266b.643.2024.12.17.23.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:29 -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=Ql9+Nk+G; 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 7EEEB8021D; Wed, 18 Dec 2024 08:03:12 +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="Ql9+Nk+G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CA144802B4; Wed, 18 Dec 2024 08:03:11 +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-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (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 4CC4980214 for ; Wed, 18 Dec 2024 08:03:09 +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-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4361815b96cso40598685e9.1 for ; Tue, 17 Dec 2024 23:03:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734505389; x=1735110189; 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=y7XIpF0RcmNHSw9YLYK7Opl+/eMYWDy3q85wIJRpPx0=; b=Ql9+Nk+G4yO4jHUdLgyGuPn+PMP36C2ZJIzzLD7MDM0OmwUoQZofDNjVS4L2UAIQ8g JGoQuoM326tg2PITHWp7vMm4iySF0Z3l/ulReZVb31REdUGDL5eN3UeR3Un0bfGIn4B9 aOKAiTeE1zpE0tCUCjPFXV/24dYQ8oJ9I5iZx3rzOeU8yBaLe9J9UCsBYia6Fgv7KwRP eEXKufpBh1p1M2E/RWFSHaVzTL3TbvHAb6Q/bFxobXOjb8WVyDjmCt9G4RJE77mBIkvy LPiPAsijp6+YOA2NLdQjUDDdaSBv8h4TBgvgmHFT1ezAS2tLv3ESLw95TrAm3CwyAo7l fZoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734505389; x=1735110189; 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=y7XIpF0RcmNHSw9YLYK7Opl+/eMYWDy3q85wIJRpPx0=; b=Cp/ikKrPTvgxatgTcpvBTAb4SBgpCKRpkaiHIqkHu+J7Uu4XSJSh3u4DrZPQyygraK VFKRFftdH6MwRbhavOTF5gvHM+Umx1UGPdLPO7XZ0MfkV5lm4X5IEEvYMp+lqEAmC4mt xkm9OzeRhKeV388YJ450JvDE2axWmw3YrartbUGKFirDmLUIlZbmcOj1VfazqvGlUyh2 azc89vj9FbNSzXoUEMiLyVPd5rQXOPf7+C/u7VGMVgxHW+lZyUeMILNqIXHbHrPuQ0mY mkhJeMcr5o2Ke3W+/l13gGtLH8XT/orjRDIcMAS99x8mCyFe33pt3UZwUhcA5PY81AN+ vLTg== X-Forwarded-Encrypted: i=1; AJvYcCX3SIURQUjCN87esizpn9wfk7H9khmUQf9UtUgHXQ8o5PhGjYN2IQxrQSkYiAAtCvpm5F0Ujic=@lists.denx.de X-Gm-Message-State: AOJu0Yz5D1AO/fjqROW21Spb94kEf86dAOmkCyXR1/uuyu/fLPlajEZf SIEB53htmwJNFXbpffebnuJSlxk7Dm6dWSZiuEwlEW+e50Q8v2cLe9AmD1wXZwQ= X-Gm-Gg: ASbGncu+nrTCxPB7NDLZL0sAZccnyW1V1rwCqIFDCDra2NC81fwLgjU9xrNiMQ9MdUz wGnt6PJ6xHEToA4gQHTPh6Cy1utFL/vkPLBcwsPmSMpR0D7EREzf2ST2DgwB7EhLhntb8g6pHWl PHKhIhcOl8kPngfxWVAbSGXJEvpmX5/+XKYCsK1NMQAKjtBRzPFoPF78t96jOaZb7EnaRvBs1Wu sLl/DRL/9SpKMljX785TgybD2arRWnTDUFnDfsH2S58TiIn3jZuuNX8Ymj3TA2EwkaqYe+qvlhS fEbeITIFtYtjK3rLkWg8EqqPDAFCxhnJ5A== X-Received: by 2002:a05:600c:3109:b0:434:ff25:1988 with SMTP id 5b1f17b1804b1-4365540cfd4mr10314195e9.32.1734505388615; Tue, 17 Dec 2024 23:03:08 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c8060592sm12971612f8f.98.2024.12.17.23.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:08 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Sam Protsenko , =?utf-8?q?Marek_Beh=C3=BAn?= , Sughosh Ganu , Marek Vasut , Simon Glass , Mattijs Korpershoek , Roman Stratiienko , Peter Korsgaard , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Nam Cao , AKASHI Takahiro , Prasad Kummari , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v2 3/8] lmb: Remove lmb_reserve_flags() Date: Wed, 18 Dec 2024 09:02:32 +0200 Message-ID: <20241218070251.686383-4-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241218070251.686383-1-ilias.apalodimas@linaro.org> References: <20241218070251.686383-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. Reviewed-by: Tom Rini Reviewed-by: Sam Protsenko Tested-by: Sam Protsenko Signed-off-by: Ilias Apalodimas --- 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 3b911d5d8391..3abe24deb56e 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -80,16 +80,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 @@ -99,8 +90,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 18 07:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 851666 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp768585wrq; Tue, 17 Dec 2024 23:03:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXYHnpltmobMx/I2gEiYt5Z23xRu5dD8+iVjI1WCuKrmR734CLt5wfEfRJtYftIEPcYNxwz1w==@linaro.org X-Google-Smtp-Source: AGHT+IEfdr49gRFHliAIWEZziGs2vqz9KhQml52TR8LAccs/iQV02vNc8ZYZSm8tr1fyZUwo7R9t X-Received: by 2002:a17:907:2d12:b0:aa6:8d51:8fe2 with SMTP id a640c23a62f3a-aabf48f9900mr114063166b.42.1734505418918; Tue, 17 Dec 2024 23:03:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734505418; cv=none; d=google.com; s=arc-20240605; b=f2wRxRMGlBxlPdUl0z34oEMAKY8iydpR+sqrF64jYKvlexR1LeMLNLsREUV4bLdI3/ LSaAmU+2iKsYInt1OE4XtfbNsrRvFR+DJZhkBPHr5/HB4Q/wrVR6eL4DHAUIy0yE9UJi x+Pgv5NTrAaguKLmugKUnYXgVoxbuqmESiURTdmZ9/Bi/cdBRzabGRzeFOyhoesE/pB1 EKsQjW7ScaI8TvlY5vuMFiBO+SZNdvjgLuBIfcM5xWE1usQqXpC1tXqJ3FlBt/8M9XAz VObhWXotKdQSjCs8iYtB83XKalyiLQaw8+3KacS5VFoZ+ps470hSwCOh4LuDt27MVkE0 m6ZA== 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=Frs6vrbQJHED/fo6teOSZmwleAgDavwt09hNJjrKkqQ=; fh=lKFSc2aYeNQkIKpSIdI29tHqREq8v0ZgoCF79JLaPBM=; b=i9X1l6ki4Jc1x7cdhCuoZrpBaY/SVfOTCjviMgYEpWLNaG41/JSjhyw3cmcuc/JW6h +ZA65Y9P30CHdgxP6K1wj02RBvn090+T4szTwdKZ6B7fnx/B8iMgZYbShbpQvnwr3klb ju5uKCOxZ2PAzJJ7aamFdHH33gP8SvMt88/vOwa9xSd6exZ+557DVJ4x67HxrUkeL0q3 Yy6aKehXM3UWjNe7mRfonyD6X0HzoDc4Z0F0CtWjs37TMP/Qj410pXKcB6DgTP732HD9 4e1q0Bn1k9N6zHO+/rbYqJP6gU9QXnU8j+EcLfxKYyiIIacq6+dlvU158jphG35/vgL1 wOWw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=znQFZu8T; 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-aab9632a6b5si591472866b.612.2024.12.17.23.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:38 -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=znQFZu8T; 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 D89FC80283; Wed, 18 Dec 2024 08:03:15 +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="znQFZu8T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2649680214; Wed, 18 Dec 2024 08:03: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-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 F22F4802D5 for ; Wed, 18 Dec 2024 08:03:12 +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-wm1-x334.google.com with SMTP id 5b1f17b1804b1-43618283dedso59196435e9.3 for ; Tue, 17 Dec 2024 23:03:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734505392; x=1735110192; 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=Frs6vrbQJHED/fo6teOSZmwleAgDavwt09hNJjrKkqQ=; b=znQFZu8TVTsGalB4XxygqGdl+jwgQe2lCfEQe57QuF6Eoli7UAoNFBrj12q5+y+2Ke CrBf9sdXCSNXOyZnkw0FJCYjEoJQ9gMuzGogtqyRsy1Kli4vJgRdLOef5u8pCBgxE1TM 5IzFsddBeLArvYGAqR3GAIM3dFLD5pa0yc/jlS6D/ieeED2KldgmXFCbBU2ETGD+6BOK RXyrB43zAWjBQblamq73w6Pi1DJnIiLAIC8N9fIsay0UXDO4fkEyG2lFy/LHRZX3Selb JUcZ7+GIZT9s5m0Q6vPoBIm1xxMKRRbryCUnvWjj2f8JtWlTkopFbQJjvdyyz2WTxEIi cDOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734505392; x=1735110192; 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=Frs6vrbQJHED/fo6teOSZmwleAgDavwt09hNJjrKkqQ=; b=HsfYYAWGOiyZpyGzJSZ5Ekq7wgSQx+8OL3UBuJp/sEfFqUYzcCZZgCi9Pyxdg9/sLl +TA4oPac07X9KLJU6bt0Lv7frj1O088q37tc23lxJDISUgO+prnwjytLulhta4OJz/VX OvvCSh9U3rGKQiK9920IZMNMCulWpB+tVOXuLxs1LIUJzeuxQKfZ3MZ1hoseUsoJ7rPg bM93cxX8mnHxQK04KAIzUSxaU9wYQ0B43Eh6nSBAarow3zEEGLyigOfo6U/q3g6tVXnu ZQIrNS1sICpKaqEvx1Gm4tIBjonnVSRXglo0xzeM+ibKlIGj/BF+893I9+C2YPTSSpBR N7+g== X-Forwarded-Encrypted: i=1; AJvYcCX+s+fm/vpLEf4Xlbzt7Xh7mLdrovlfMFFflAnH8pwne9nyvNH4D7efpd3qJx3vqMPDpJNPYOo=@lists.denx.de X-Gm-Message-State: AOJu0Yx+sTzS/xWCvLly3MOD8wEuxW5y0mcCBPVL9vBZLkadxBynddCt NrxHsVie6gErBR12rNO+5mbBYHltYEH2M6ks2NWd0/UCiizbBw2XIvA0YjQ4cZM= X-Gm-Gg: ASbGncvdRKaFg9e1HwCO3yayagWV6UdRLy3vF0Fy7pSRHQ3+6QI4eHfT9cq69azSCoe 90QUgRobXJA+pOue4sgMQ1/aYrvDwzL8HYg8w35+nGExhHG8MpvM02ysP2e0MfT+bW/Jo/eUwX8 Pla1Vcn3B4IMiY6zzNqEZHYHxPWnYxXysuKKUy4A8P+OECs6Rogrxyz55Eph6bB1siNv/71nzfv BgMwYaNZOdqgBSxDz+lhW87MwDeFg0AKayFSLl8iSc+fxhoMV/WJPALzWM+eQhBN0abi3iDIsXL vduXFY10E2sjYp98aDM+1GZCDB6xHWO+zQ== X-Received: by 2002:a05:600c:511c:b0:434:a815:2b57 with SMTP id 5b1f17b1804b1-436553ea6d7mr9714915e9.20.1734505392378; Tue, 17 Dec 2024 23:03:12 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c8060592sm12971612f8f.98.2024.12.17.23.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:11 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Sam Protsenko , =?utf-8?q?Marek_Beh=C3=BAn?= , Simon Glass , Sughosh Ganu , Marek Vasut , Mattijs Korpershoek , Laurent Pinchart , Roman Stratiienko , Peter Korsgaard , Matthias Schiffer , Dario Binacchi , Sean Anderson , AKASHI Takahiro , Nam Cao , Prasad Kummari , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v2 4/8] lmb: Rename free_mem to available_mem Date: Wed, 18 Dec 2024 09:02:33 +0200 Message-ID: <20241218070251.686383-5-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241218070251.686383-1-ilias.apalodimas@linaro.org> References: <20241218070251.686383-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. Reviewed-by: Sam Protsenko Tested-by: Sam Protsenko 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 3abe24deb56e..18030c610ab2 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -45,12 +45,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 18 07:02:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 851667 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp768644wrq; Tue, 17 Dec 2024 23:03:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUE3IyEiOKuDfzx5/ZJbigLlIZossNTrC3cphURhB7HEwmG7Avt9XPyCW3yHlT6Q8DqmLAq5Q==@linaro.org X-Google-Smtp-Source: AGHT+IECyaFPKJ8CpK8U9PcqPcowxtiWX6mSkKJBTBUzxe45wjpH6pqejCYRMFDDQI/EvIABvL5D X-Received: by 2002:a17:906:309b:b0:aab:9145:30a8 with SMTP id a640c23a62f3a-aabf490fc62mr128980266b.50.1734505427508; Tue, 17 Dec 2024 23:03:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734505427; cv=none; d=google.com; s=arc-20240605; b=NOjAI2zShlxgvYLDGgjuIb4Jaa9VCRoY3m2a/ojLX2aPISltS37nkYIiPpPGtHScLb MS2bBhufqXFezfD28MscLRxjYE8igF+JtSvhg5NICSgXJcbkd8Hoos3GFBTBsCm53XhR RI0w6lnIm3BzK4fRZJ/QrMADWFhWimsUYT6qodlJpiByH9X4LUOwzWxHUyhXSRHnQHLp dUxNDpCSkOyRMazhS5AOXq21VV7BPFaTBsyI4yq9CR6cylgGKeJamHY/Qs/Uy0nTAU37 fhZzg7ixzGGhF+MrL127oUXCk2L9o/JB6d8OfJsWI2PXNnLGdZwvNSovoxKdFy9crSmH nEXQ== 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=i5tM+ThIP7Ggd12PDma8fzMMV0s1w8rhwzRtsjrdIs0=; fh=6rUU3ohHu+tqBUsGhHPpWbB8D7gWEhno47IV119oOhc=; b=dSiqeGDR4nynggR0IsQD07O1nFFjsmlsawpO27RI4mSUzyjmbyUnAgj9jUF3KNms+b nf/kWc8D1wcR47WLyKfGuEk3j5FCA1EVvSR1EbqTs0SOsPkIhydlIkjJNG7oeBKWpKeC uzs4rHGvHN7jJ5wmVBEvQJfGBJv7+pZsZT1Zgu6C819CCXd8elfpchlddcNV6Mm5J0gr YComH6f9DzA5MsCukmC3cwhF0D2+r0IaMKteKfaXfhlsD328o2ra/7KE71HurRXg/1vl hhFsT4N9Yze6Hx9ga2WjJAB7nk8r5eP7PcHahhPgF/nvTOQJ0R2bIKGC6B3ji89F/qor zSDw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UeRraT5X; 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-aab9635ed62si597154166b.771.2024.12.17.23.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:47 -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=UeRraT5X; 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 3A717802D5; Wed, 18 Dec 2024 08:03: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=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="UeRraT5X"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6D20680214; Wed, 18 Dec 2024 08:03:19 +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-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 6AAFA80243 for ; Wed, 18 Dec 2024 08:03: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-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361fe642ddso63773045e9.2 for ; Tue, 17 Dec 2024 23:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734505397; x=1735110197; 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=i5tM+ThIP7Ggd12PDma8fzMMV0s1w8rhwzRtsjrdIs0=; b=UeRraT5X7OZZspyF8N/QkEas9roiZhhVQFgzxmTKXLkg26Fa3TB8hbMdq+NGuiUg2r kC3Vt2PBrlagib07Uh56YhqNh+MFDMvLUKs87Pm35goNBNQwH3PpJq1uAJmOT9U/pzWe F9403/jHxxShJAZug+yaxAXoBIuGRFvFr271vwfVPxa/WXhFSkwTw4idDNMLU7DY9vek zOcvgRXTH64cqygeTOpUjizcAf//vSMoTCOOnuOcuxVPBqZlM5rCtNMB6u8TnqOBXy87 jQANF9Mbi4uPPlgYzJueg1EAzjBf5jr1XVqLnlGjq9xBu01Ty8sKuOrSQ0DUdn/8rGfw tqJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734505397; x=1735110197; 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=i5tM+ThIP7Ggd12PDma8fzMMV0s1w8rhwzRtsjrdIs0=; b=YcKwN7gSWAo1nf2XyA12oClqALOvtK+4Yu9sbXWOScsRyr6yglh4VyhR3RHfbYXXu3 9ejHvWmgj82SZOeCRGWuJnfQxDiUCrov+WeUyRmHQ7Q96cFpHgJHRPjrmY7FJxMReC/I aorlmGoW86jodZ247U+F3U89QjR3efLIxe9ADuWXeG5lt95bRaZIaShksiWRgJUAwzUF 6xg44rbXdIBVp4FkIsDYSAHqMd9pQ2kfCj+Mjf7lIHvHS7mYg7MLKWablmOwP8c8vxD1 j2QTAC+QlGaTDcpYOlz1tehGfVDGc/UMf7OSmIH5Vv97gd3XXLTW+8CS+K32YKpwj9WU WESA== X-Forwarded-Encrypted: i=1; AJvYcCWk/ZdwgmApad2DZrOfBBsyGexnBc2+j1wFkHZJBKiOwJ8XV4AOIlrrzci5FTMSOGUVEr/n8wc=@lists.denx.de X-Gm-Message-State: AOJu0Yw4+KvJVPOpuI6pEWO3m0wtk/PW/iDqIZcesT36wzItJwr5WuH4 tRHGjX5YSQgANC36CPtRNE1qETaNqcUSexv+y3IIXwBgpEK47shVq0MeBRInQ0M= X-Gm-Gg: ASbGncv1Q9uiyRtlrZ8sUAclstzs9jyCJNsV2psm2eT/jc9SNnTaCY46KGMwUZog+wz BNlS1dGe6twIqww48JRFtazpvNNHvAr01y+UOyGqFkhtGJ5b6HoR/hERpZhtHjw4Eiet0sTFYUW bNW1zqSg30fFnqToVVbKc4tWTPHF3UMQySa7L+XEayUOl8ZY3YIl9qyslh8vjVdkcv9duLzW1/t zalxLrbEDmhiAcEicXodz2gwnaYgiO+VBg8IYDNMykXGBvC+92WTBTUmGXWm3CtE+lDl79F1+M1 5rvfXIW5t/9HaATGPrCiQFXiIGcfWMH5/w== X-Received: by 2002:a05:600c:35cb:b0:434:ff30:a159 with SMTP id 5b1f17b1804b1-436550af78dmr13420365e9.0.1734505396887; Tue, 17 Dec 2024 23:03:16 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c8060592sm12971612f8f.98.2024.12.17.23.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:16 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Sughosh Ganu , Sam Protsenko , =?utf-8?q?Marek_Beh=C3=BAn?= , Marek Vasut , Simon Glass , Mattijs Korpershoek , Michael Walle , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Baruch Siach , Mayuresh Chitale , Nam Cao , AKASHI Takahiro , Janne Grunau , Prasad Kummari , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v2 5/8] lmb: Remove lmb_add_region() Date: Wed, 18 Dec 2024 09:02:34 +0200 Message-ID: <20241218070251.686383-6-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241218070251.686383-1-ilias.apalodimas@linaro.org> References: <20241218070251.686383-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 Reviewed-by: Sam Protsenko Tested-by: Sam Protsenko 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 18 07:02:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 851668 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp768705wrq; Tue, 17 Dec 2024 23:03:56 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV3KzdijL/GQ2DaZBtnDYnKHjuenDwQ55TUog1nxyouGe+JTYuqNp6lO16c7twDcil3dWXXKw==@linaro.org X-Google-Smtp-Source: AGHT+IHNSt49tWh4/je6dBKJGj8r4jR2JPpmItEcYpytbGo9BIB75JzoGW5sF/xXZxgncNdMFb/g X-Received: by 2002:a05:6402:5008:b0:5d3:cff5:635e with SMTP id 4fb4d7f45d1cf-5d7ee3ef462mr4570910a12.26.1734505436607; Tue, 17 Dec 2024 23:03:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734505436; cv=none; d=google.com; s=arc-20240605; b=CzOhGVuuPDLv+pb8AOBx7QnXIQ1/HMWVXLPbZROeeuYzZeR++DNZUZF7mEsxslMlEq jQhH8wkJfz3nzXZV+fo78TW8IiWwoOGH490aVbb0Uy2FsFEkYNq4qB6B9dch5F4BMi8I Sww5FrieOEGTAftae3cM13rFZLaoyEfaVdp3zpvtgORes0cHj/lOJVfWVBqXCMH+RkmW BVrqmv2IiflDktEnLNPd2IUUDaZfAXt0vgeT8xr0MI+TLP2YkIgZ38mwiXug612YvZmD lm4AGrm0YIxJAWzn/A3Xi7sLOfXlyfDWgmUIMr2LngjandNxky5DjxK28MMr4+nEyIX5 HOwQ== 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=wAGJkBIwNOsSutnccXwuAcu3Cb4fiUiBWKCSjpp2MNc=; fh=JOeb8cyimKYOPtFsGKnfkyzjqQth1C7aDb3WCA6iP3o=; b=gsbaN85CkJNvxH02aLd9HFmLIzaXTvo7a9y8iPr9qu2RhYBhQAJHuPMng2m4e4rQUa ZVhzyqi6PJu6iP7ScysFVROU2n49IbU/yuPXSTSy2Sl2v+oVpn5W2ntp/hl0Yz2cC+CF kJf0gSjSOrRYkn3aZypgXJhntfkQ64JoRxh9B+XWChzI+LrK5PNnZ1kb/LzICgpayqb9 B7SHfeBqoGcE2cKsnX2M0HdrWllsOuQq1bMXhaGABQhlaRrB/gpxJR/VJHxzOw9Q8VIl EpJvyNN6QMcmnU0qi14rWxWJZqOthlbJwV6BzJCbiqM+JdzTPtERiLe2O5vLpDoeTFkB tyJQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xSUafSFs; 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-aab9639446esi585448566b.882.2024.12.17.23.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:56 -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=xSUafSFs; 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 A0CC780327; Wed, 18 Dec 2024 08:03: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="xSUafSFs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6301A80317; Wed, 18 Dec 2024 08:03: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-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 1E5ED80214 for ; Wed, 18 Dec 2024 08:03: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-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4361f796586so67127485e9.3 for ; Tue, 17 Dec 2024 23:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734505400; x=1735110200; 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=wAGJkBIwNOsSutnccXwuAcu3Cb4fiUiBWKCSjpp2MNc=; b=xSUafSFs6VRRHlaz2mfZBHWb4M/5OKP0z5y0wkFhuB0ZqI5iJ1DlfMzFqH++joS2Ti ybsbz+//pv3FmVoRs6bd22M4q+mVDJq+d/Gc5jfNj7nWGuqiVplpmZZ54bnoTsUu9cqC +0PElo16hzwu2cqD+Irmguj46XI2a9prqS6A3kUuyZW60SAsUcOpG0oFqBrmIUF4GPmS dpMYfdVMhNe/P1YYo++5xSXBhmC8O+dBKZEn/oUynZY/FX8IQSnNfGvWCm7ZbboPhVbm k0LZhqkixSSs2tdgdIQtuSJ7kujtQFOz512g9FvQvdAIiEHvkXOduqEW33/zhVCPy9/x L64g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734505400; x=1735110200; 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=wAGJkBIwNOsSutnccXwuAcu3Cb4fiUiBWKCSjpp2MNc=; b=MBWZVvCzNdmkHRl4feSMNOP6lVz2OhCEyGuJYor9HgYik5621xjbgyc9ultSQXXBwL KaXzZdkqDHc+SolwqgFZH3g7LqcbAyxDB67dukgycGQbW4pKW4PPUbFYSyNC7O+/TsjG bLxwq+HnBOe2oclZviojEcSv2MyeB925XTwSgbf8+FkW2SEWXCAHDAOjDLR9IdeGrtUL T8CvUB0+0xuocEC98bnbK1IOX5FJE3xTd36/Kf1rXocjC+zq4/EdWi0Oy7aQ0j48tbsY VLfL+57lj6c5OpibvZpt0h0gnfUq2g+H6LfYQNXPR5WhqM8qK7KT3YON92HNX820D3YG gByg== X-Forwarded-Encrypted: i=1; AJvYcCWDY9m3l3mPAdUjTKkjoUpq/3uaSBIKLm4DmnuhENsHtk+THSQX1GbKmku0PJg9uylURMgLGGo=@lists.denx.de X-Gm-Message-State: AOJu0YwLAkivPcD8Be0TI8x1e85NUDoOe4kDWMC4XnK+wRUj7fQ0L2Tq tyXNUEKaO7vH43oqvgxYrxAx8/LT9Hqwh4XUsD2lW6GV+jh5vMJrO2c/cUXn0tc= X-Gm-Gg: ASbGncu9NAiJSrzn15KpGlsbzZ8UxCC/vfbHlKGcnfN3nlxY3NAJ1Vk0VmZDWRfVJej 1MD6QZftsRvNyosbKtbSmkx+ZNaVrpZA1Num87X7kmhBg07QkyohKaC+jUltkXsJmClqHWe+V3a xQEZhCCUUxXVo0L+JJ6bqnwrB5iFTB3qbsVjileWeeWAjNOrsnRy5UuqueldQF5pzQizAY2koEj s5QdGJaATVxkFZSKV1TSWLTXqIWGHoDQN9OFSrBREtFoLQBJ8tYMsesFltlCXd7mvW3g6f6CX09 vTOkSETgoUw61mdF2nohps2V9F5tJj2JlQ== X-Received: by 2002:a05:6000:4021:b0:385:f6f4:f8e with SMTP id ffacd0b85a97d-388e4db8a44mr1043836f8f.50.1734505400496; Tue, 17 Dec 2024 23:03:20 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c8060592sm12971612f8f.98.2024.12.17.23.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:20 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Sam Protsenko , =?utf-8?q?Marek_Beh=C3=BAn?= , Marek Vasut , Sughosh Ganu , Simon Glass , Mattijs Korpershoek , Michael Walle , Roman Stratiienko , Peter Korsgaard , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Sean Anderson , Nam Cao , AKASHI Takahiro , Prasad Kummari , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v2 6/8] lmb: Remove lmb_alloc_addr_flags() Date: Wed, 18 Dec 2024 09:02:35 +0200 Message-ID: <20241218070251.686383-7-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241218070251.686383-1-ilias.apalodimas@linaro.org> References: <20241218070251.686383-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. Reviewed-by: Sam Protsenko Tested-by: Sam Protsenko 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 18030c610ab2..e38af036a0d0 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -94,7 +94,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); /** @@ -115,8 +114,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 @@ -127,8 +126,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 @@ -166,7 +164,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 18 07:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 851669 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp768750wrq; Tue, 17 Dec 2024 23:04:05 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUtH5VoxqiakWiMk+OVaupntrCig4p4toQ3Plkos6rIv5Vf1lb0EIFWTdbKdA0W6HKkSsRteg==@linaro.org X-Google-Smtp-Source: AGHT+IE90Bsyk7rJWZ8BEAgVGLkTCtJyopr9/uvxoUagWGiFa/JVP89AFHTfwmUHY1sUrYHfnTux X-Received: by 2002:a17:907:2d1e:b0:aa6:6ea7:e5a7 with SMTP id a640c23a62f3a-aabf477a2b4mr129887466b.28.1734505445279; Tue, 17 Dec 2024 23:04:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734505445; cv=none; d=google.com; s=arc-20240605; b=N9SSIRNd7HDTZw2WSZ9+3S3ptADwXYvedvsWk6QaTrYlBruw3gvvQT5uaGyrGcEoVO qAkzeUNEKfw/4PFicYzC5bWK9sRc13gHuY5nIuJ1wei2SeqLdNqnHAZL5qbNxYiPHVwD I3Sd9d6KX6bNKRQRjw9b9BPO/j9pqp/rrKSQxt58axJLJHQ7R/hD8++biGhjjds80cf5 zDJXSazoP5drgrY2CENfrmfFFRSdEslHm55S+LgCdZmMztBBjXMU2DHOJ9GkZqcuBzzM AK3DnQweantSQVS1ryH6S4CugVUSYnLyunTzseLuv+zeUmhC3LN5d3sE8PJ6/0e3HDVY VPNg== 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=nZoqy5ApK1lE77i+xi36rzIAJ7MNo42oHPI6/sOtP9M=; fh=oQ4LCUe5B+IrBxQCCe0jIeofAAfaOJx/Ig/D+WfqBlM=; b=ExVlRd3QxTSGVWHR1UOdBxr558ZSaMXT62mtRqQr0x8GnP/uvYH9ws9/wjbZ+8B5Qw /xcOLT7PJcFEGZJc7OtmlyYRzOlmwC81i8/rUgTjmDh5gN+0IowSvRbWPPvzLqfGxu9d k7da5/3JkQADswlOE9+7gD/8QLe5olXENYK1TdDoRPC+85v3PwDjbPQkTcATVCC5Iudv NFpEU+ebaVX6YE0PHtZ1vfLD8n1QFaff3cefQSEuq0WnQVcUPnopUmM/t1v2275Zc5eH BIrjrZ9VE8sq5PwHZosXOAxUYSYaA3+5VkUu119pwQujkqTE6f3nGIDukviq719yTSOs 2JQg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hB+Qo4lE; 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-aab96329ad0si565398366b.575.2024.12.17.23.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:04:05 -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=hB+Qo4lE; 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 F09F88022B; Wed, 18 Dec 2024 08:03: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=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="hB+Qo4lE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 83A1080214; Wed, 18 Dec 2024 08:03: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-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (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 99EA28033D for ; Wed, 18 Dec 2024 08:03: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=ilias.apalodimas@linaro.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-43621d27adeso42386195e9.2 for ; Tue, 17 Dec 2024 23:03:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734505404; x=1735110204; 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=nZoqy5ApK1lE77i+xi36rzIAJ7MNo42oHPI6/sOtP9M=; b=hB+Qo4lEZHZDKKGvvezCbjpdrYfcBY/Q+yHjJW9ZZ4x6zRrrZaG9a+4dhf5iFsPCvY UiYQPjwTMXv5h8GxQqQLJ8glAaZ8cT037r1rTwX3kW6USwNkBXbfVF8XEjUGmDAe+TTb v7uvAX1SxnMk/QdWfEXzygbV6VZgBNL1VVjgTE06pVELcBUcGwSFNXzqMRBka5CJ1ELR 5G34GjpaKlEB5u2/HuNLSFmYghYn+gWyompkvAYa2TjmQpb1TKs0GjPUplWrHYXS4Bwu 0a+cYEei/HG9qagt5vV6t9yakxNiuBa9aU4WlXYJMiNhlAZzP+LHA2Um6SdRlO2PpGGg QKlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734505404; x=1735110204; 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=nZoqy5ApK1lE77i+xi36rzIAJ7MNo42oHPI6/sOtP9M=; b=sl2GZr7CKq5bnX+JWbB5ydxrPuGnFEWZR5vldeJ6Y1+VUVgeklfB8I/LBDPjwZX70G 4q1ddmXWOgI8l1mvqr55zRHBuoh2LBDx5hybQcDAGwJfc2pLNNEYEW8LlCNcMDnk1JwJ oDp5cYmmFhlDg0unXVzaGyWrYq3knZSO3KrXMp/R5uzdcJI4PLC+IfkdcAT0lfep5sbS lSWwW1CzmoYckwpoM+BI/iZsPen6mOx9qjAX/ihxKnN2Vft5cozPY3vcOVRPs1n3avQZ ZidOwTtnM7TU0uxNbO/nMVXM2bFDWCcWPC9WwFPKm8THD8kVSjnH7WcSMP6G1tO0g2Uk bEtw== X-Forwarded-Encrypted: i=1; AJvYcCU1KqlYlss2ouSGLu2CjGDiRpYmgvrRMFemaKnrafsko3zN5wp6wBNFC3QQEfFz46ZbkHetLYQ=@lists.denx.de X-Gm-Message-State: AOJu0YzNHnrJ7JlcqHgi4rz1z2DSWn42nqHZWbuRJRNlY2xxBKm7Nlml fwcK+g1C4u4kUoczd3srO0CqvrPoLNr5azUvoTLyyHmIjdtg2DshyRK6ktn65mE= X-Gm-Gg: ASbGncvm8k9WoJrSrJmdSg+ShnTPUIDH9zxk1XUCXeRsIy7w/x8cpYS1L5XW1aJR9/1 bc3QiI1BM/NVJLJDEiVexDl4WEzP2nn+U3BTUWJNoiTPaFOX09jZ6osjkJ7R8WQRcUClpxZ+VJV yUzt8Xw9r8FWiktaM4fWSljx4CNzco1zkCaVJF7prnAJ9KHpVx7XJaYeIGCPAdKLFMWRACODezh VMQSIa9pS4j7ne0GtdXVDqLu5No6M3ULltnZ3FjwmWAhtA3lgtOz4/8MQoZykl5MEfUisBKw06e WjH2V+iH0f1H7JK/askiSWumfUmAzmSqCA== X-Received: by 2002:a05:600c:1d29:b0:434:a902:97cd with SMTP id 5b1f17b1804b1-4365535dd89mr12066595e9.12.1734505404043; Tue, 17 Dec 2024 23:03:24 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c8060592sm12971612f8f.98.2024.12.17.23.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:23 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Sam Protsenko , =?utf-8?q?Marek_Beh=C3=BAn?= , Marek Vasut , Simon Glass , Sughosh Ganu , Mattijs Korpershoek , Michael Walle , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , Nam Cao , Mayuresh Chitale , AKASHI Takahiro , Prasad Kummari , Janne Grunau , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v2 7/8] lmb: Remove lmb_alloc_base_flags() Date: Wed, 18 Dec 2024 09:02:36 +0200 Message-ID: <20241218070251.686383-8-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241218070251.686383-1-ilias.apalodimas@linaro.org> References: <20241218070251.686383-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. Reviewed-by: Sam Protsenko Tested-by: Sam Protsenko 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 e38af036a0d0..a0e666a1f7c3 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -93,11 +93,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 @@ -110,8 +109,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 18 07:02:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 851670 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp768803wrq; Tue, 17 Dec 2024 23:04:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXEm8BH2Cb3+naQ9ecnY0o6OWcOZS2mqy+T0jiCJpYkO872zH5600U/OsqdUZ0vtlEjTqzZ4A==@linaro.org X-Google-Smtp-Source: AGHT+IF7tyRekQFKcsFgq0abBaLkvCK00eGAoZNkzdUADxWVVmJU77CFD8UPIT5HpEJ/Pt0WncvH X-Received: by 2002:a17:907:25c5:b0:aa6:aa8e:c89c with SMTP id a640c23a62f3a-aabf48d51c3mr111406366b.39.1734505454366; Tue, 17 Dec 2024 23:04:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734505454; cv=none; d=google.com; s=arc-20240605; b=TaAi9pqrBEKp55n2UbTOXVkfxeiIPRww1wbdOt3MGa21Z3gCpb39GsmLAWfSN/pMa9 ikTLOBqFZw5NVqZs+l35Qaxb2aLfoCNGfUfyoOI4rgGq40A4vn/jL1Ho+pALwaIMsS5y gSwSqUDmkMCezxPXqF6DO3hYWbllKyJ5XSbEsJsgztirSnPl1NmdRSFpW5eyjVSeuQuS GyKAeAlHbcwxseCBIP47dH9BpVB2109jmWyJnKinWfH0ALNz9wiNFq/HdqdN+TZc5YGo cW66PXGQ5YxJk2BjxOgPMlC2FnO4wbykAkNknqGfgcQ0V+C4ne+vqAYkXGEHmK8htc/r sTTg== 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=VHjfhKSufUxe6H0UxS/zV+U31aw3+THDEM8QQrvPjqk=; fh=4/hSQE5fA7NzGEMLXVaHOE2854SmMLJ1iT1qC5+XCaw=; b=GHhiysIhRHzHDU3j5vgNlWwui+J6p2QaKNhN3bdfoi5G3Q5xnkFvUgg06a5gzZYX2w 0NV+jCaBlNou7146TDJhvraFwf6w11aZduKd0YHFMBejsa/cSMUOode2qkZGZ0QynOoI QTCvdDWv/LwiKnAYL7yFqXl2jkDJH9NQEC9clYJPMJsbj4SDrxGHNcDav93t2qX/SMxY lowgOia4qG4+0rDiGmh5ynLFiXRcBKsjPz1Hfg+t+aJxhJPCouq0mnEfkIF/5Q+avkmp AhrqHtUJrxCXuqbGECfpD//RV/LJ8bPk3K2kKYQGyl0pKc0YEN+40vDewaVItRE6Gk6i hDKw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lvVyOe2w; 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-aabc6a539bdsi334416566b.892.2024.12.17.23.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:04:14 -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=lvVyOe2w; 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 4FF438021A; Wed, 18 Dec 2024 08:03: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="lvVyOe2w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1CE38021A; Wed, 18 Dec 2024 08:03: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-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 F257D80243 for ; Wed, 18 Dec 2024 08:03: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-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-435f8f29f8aso43998275e9.2 for ; Tue, 17 Dec 2024 23:03:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734505408; x=1735110208; 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=VHjfhKSufUxe6H0UxS/zV+U31aw3+THDEM8QQrvPjqk=; b=lvVyOe2w0L/z2lG9FSQ9dcjebFuoPPFaLCfMWcphLAtFMfmYMnZwp5k+eNxlG4T56R eGRiVYntn66xEWmKqKZT+b4/hFakiPuhhX6O0kiX0cTizlkE1+WoIF1V9fi+gmaVOhUz ccB8BCaxUbrHj/Zt6zOV4tVnOiybdMj3KfNOXxQ7cgyH4C+ubY3CjTqyeXWhA+Eutt1X sYUCwJhv9f+29azziW5haMJC4xJWrGGeXus457f41qQpZoIyEzjFOLAi/D5WaARZF70A mhF7/qdfnXEF69c6SKLtXzoA7v7Fu18cbBtYE/2wuWCvCtXgtpH/ZugN8Xw9PYelnV56 jqeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734505408; x=1735110208; 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=VHjfhKSufUxe6H0UxS/zV+U31aw3+THDEM8QQrvPjqk=; b=tQwBEQN6grY58GDjaFyBQ9yIRASfGvCWGn44lL1qfs52BWaMR27OuCL+gB7UTGArhL Kmr3cFYZhO3W9DNUtdbQNIGE+tO7BMYfOZ/OPgjUtSRXwOy1OAMBTHSWpo6udZAbx/iH 5I2m86XnYoTm4QuVz9uxUPBnvLjD44IFOvOYLBT5TTmERIMIC9aaI8EStgWFJpvTMlnl pz3y3jAeDWM9GmPEKKOcEm8ZkX/O3ZZxOSwT0KqsYMRTqmtnJeLC0tBlcuhUt2+Sc/w4 b71tttfxOgPLMX/vkaDTEDcCK7tQJeNCqsQyQT8HHjVLAEge9QdCfRRaYSLbmXVgltQT PXZA== X-Forwarded-Encrypted: i=1; AJvYcCUyo9SgEmRcpr2f6Q52cymsSNI901/bCsjAHQWwEZMpvzxibO2R8qzjLF1qEXBFqtyyHTHnvU4=@lists.denx.de X-Gm-Message-State: AOJu0YyBU8Yxrua0Q0BOYdpC7MutTLIINbFq7FLq+JHDj6GqS46cusFY dZKg7u3cOT/epRIEQPTcQq1Y5tgJOvtulqW/4QRzT73Ct9c7/oYeYNpQRJIZKXY= X-Gm-Gg: ASbGncsd3n0FSjHN4Xy3f5/IoUVDHHkbF6hQreyx2jSY9bX4iL/V5gw1XAUmTZ8YhlN UtRTFT5XG13sParM/ubx5JhRqxIXoxFA3cI546zwyyVNcAvM06N2Ne1kKdPHwQ1B8rmB1tu1bba G6w6FE1ZvKRHe1+dpzolw0H8r6bkq8/CGJHwO3ZKs3/B8WUdjJb4BIZ0BCkPdUFpFgxhVQ354qd 7NAicEWo1VoNjPmcjyKbLos1RwL+X/AL4PCHDLh5iBu+paDw6ZkGf+hNkPJNm+hkv0mO3NYKBW/ JN+ciMhi+uWnBD6WphQNUKxH7ZKPgGgc0w== X-Received: by 2002:a5d:6c63:0:b0:385:d7f9:f166 with SMTP id ffacd0b85a97d-388e4d424a7mr1428060f8f.17.1734505408269; Tue, 17 Dec 2024 23:03:28 -0800 (PST) Received: from localhost.localdomain (ppp176092181030.access.hol.gr. [176.92.181.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c8060592sm12971612f8f.98.2024.12.17.23.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 23:03:27 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Sam Protsenko , =?utf-8?q?Marek_Beh=C3=BAn?= , Marek Vasut , Simon Glass , Sughosh Ganu , Mattijs Korpershoek , Michael Walle , Peter Korsgaard , Roman Stratiienko , Laurent Pinchart , Matthias Schiffer , Dario Binacchi , AKASHI Takahiro , Nam Cao , Janne Grunau , Prasad Kummari , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH v2 8/8] lmb: Rename _lmb_alloc_addr() to lmb_alloc_addr_flags() Date: Wed, 18 Dec 2024 09:02:37 +0200 Message-ID: <20241218070251.686383-9-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241218070251.686383-1-ilias.apalodimas@linaro.org> References: <20241218070251.686383-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. Reviewed-by: Sam Protsenko Tested-by: Sam Protsenko 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 a0e666a1f7c3..d9d7435a431e 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -125,7 +125,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) {