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;