From patchwork Thu Feb 13 13:11:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 864826 Delivered-To: patch@linaro.org Received: by 2002:a5d:47a6:0:b0:38f:210b:807b with SMTP id 6csp416093wrb; Thu, 13 Feb 2025 05:12:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV7OzeZVRVNAQp+6AqvYEPF0ekzDNineOlK611HqD4NVjozKhQuHblUKsZeJWWfkoaOVstszw==@linaro.org X-Google-Smtp-Source: AGHT+IGWvNnx+bhKfDWiZCJUmJ5lbsQtfm9B2pk5bh1htRsPE/UXdwnvkBVtNv5jbU6XTOkJGa2A X-Received: by 2002:adf:ec04:0:b0:38a:888c:679c with SMTP id ffacd0b85a97d-38f24519dbamr2901330f8f.42.1739452320126; Thu, 13 Feb 2025 05:12:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739452320; cv=none; d=google.com; s=arc-20240605; b=WR9lQhvKdYxyPq9VRyZNpVZ224NCJ2pAXWCRH7Ia9aVZqb8Xi6HC7z/UH7me48m/Ku fSbWhqzigOPMdpqR9ioDYC0oAUu4NyGMSgLiz7E/l6WCh73xc5eElEDLzTaLjIGugnqk 4Hb77mQkf8+oSvhUsWjmAQjLCz749JtWeyrrq3ovM3evr+seWI+FojEH+F58QcllxmbG JkUCEfz7M/qcNZB8smD+gXxjqAOkW/wpkY+cdpRhiIf5S7R5p6QF6/BuIArfDgQQcV3d zM7SKF0ccWBNoa8TgVqqST9hsycgBooqhevAC5HZYTBE3sbtVcoep7UHtcCCJfCehQ20 jg6Q== 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; bh=uyVok02cWCEfhbicJgoFYE7LFKT3zJSkHD5oYW/Oj+0=; fh=2HGKihHUAicyV3F+aHiaoPpwvqWA0zlC04Ew6QaQoEg=; b=Rq1jYs3axjsYYZrmrFYkGp5id7GGf1+n1/NRWdkP/voK3Vfq2uYFvd8aKOQD5qyfet YggVXXafuGqgAE5cf5zbgUBW2WDdm4lG8umhsmPeqR1K0MJRlP5zbcYap36bHLwTwHFM bvThFH/M/lW/HX715GSwBHP7upP7AZiHOjBbOHrnfEpLdzS9YS1xZfYrQ81But4/Tami ESaY92lJezMKBzI/kP/9HMWaUv9bojx0CyR19WE/WNZ8uPedBvOni+jxln44SD8MU9Si A2QTsTdVwJbz2mHx3+BjvvX+8p0AYUF85U4h7e+6N6+wmhgyPjAOqFonVLd+PBiwVGGS oidA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=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 ffacd0b85a97d-38f25a32b1esi1351182f8f.781.2025.02.13.05.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 05:12:00 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3B38680F03; Thu, 13 Feb 2025 14:11:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 8333980EB7; Thu, 13 Feb 2025 14:11:45 +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=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 48FD680ECB for ; Thu, 13 Feb 2025 14:11:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6CB5216F3; Thu, 13 Feb 2025 05:12:02 -0800 (PST) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1BB173F58B; Thu, 13 Feb 2025 05:11:38 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Quentin Schulz , Udit Kumar , Heinrich Schuchardt , Sughosh Ganu Subject: [PATCH 3/4] lmb: check for a region's coalescing with all existing regions Date: Thu, 13 Feb 2025 18:41:03 +0530 Message-Id: <20250213131104.186663-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250213131104.186663-1-sughosh.ganu@linaro.org> References: <20250213131104.186663-1-sughosh.ganu@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 The lmb_add_region_flags() first checks if the new region to be added can be coalesced with existing regions. The check stops if the two regions are adjecent but their flags do not match. However, it is possible that the newly added region might be adjacent with the next existing region and with matching flags. Check for this possibility by not breaking out of the loop. Signed-off-by: Sughosh Ganu --- lib/lmb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index a5216bdccc7..a55bfe289db 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -204,14 +204,14 @@ static long lmb_add_region_flags(struct alist *lmb_rgn_lst, phys_addr_t base, ret = lmb_addrs_adjacent(base, size, rgnbase, rgnsize); if (ret > 0) { if (flags != rgnflags) - break; + continue; rgn[i].base -= size; rgn[i].size += size; coalesced++; break; } else if (ret < 0) { if (flags != rgnflags) - break; + continue; rgn[i].size += size; coalesced++; break;