From patchwork Thu Feb 20 09:56:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 866737 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1f85:b0:38f:210b:807b with SMTP id hj5csp115437wrb; Thu, 20 Feb 2025 01:57:55 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUk0reogasy4meRGygNQPAptOylZqTI6hi88d6yjKoP2ydQnSroez6Aza/31diIDbXvYW0yGQ==@linaro.org X-Google-Smtp-Source: AGHT+IE6QAv2fwLjnFtbVP97y8DPfS+lefcDxvyhweX2U5dpmPTZaR2qTrlyXjFUkUJqj32n6SUv X-Received: by 2002:a05:600c:5101:b0:439:9496:181c with SMTP id 5b1f17b1804b1-43994961a51mr96605045e9.29.1740045475101; Thu, 20 Feb 2025 01:57:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740045475; cv=none; d=google.com; s=arc-20240605; b=OSZJ4PNoI8Ybn0dUpdjgWb0b4SdWp3ZLqR2q5waXrOhka75bpjyAF6xLzunbBIaUNS IZF4mGB99IFs8NDrC6TyTWAXPBZoLCHEQhHC3KRfBBdT7Vp5mSlRJiJiqI8q4K2xE11w AaoOvZOhM4sIXSLzjrDZgy6rWzjqVXL4COMfFi/GscO8fEohf0iXHV2eDhA1aROTQaQ6 36TGoHt/j7tPSrGGl/Q5Tt8VsCx6YMpCqejVhovptNt3Lt84PqlJdwACQN815hga86QK 20OeUYns6o0eyZ5fY7uP+WLEKL1lKxai+LjQWDZN46xMwQn6DFHIfhlwGiWIJV55+rvl QqxQ== 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=iyL5pNhWk6tw2RwW3HpN/Y7Q2HB3QR4S+KFr8y8XHLU=; fh=2HGKihHUAicyV3F+aHiaoPpwvqWA0zlC04Ew6QaQoEg=; b=DMN42n+HgLfVUFmrcDbMrRmJnc1Zoqlc4zrc3smVxfsXOks4Oj2z1iqnWleQMRoVoQ V7nZvw2TYR5Oa9yHtw6Wd/AkWpwl8lbyEK8IwsPqJIsD0CWUwERiATM+sgLQ8BTn+r34 37YUBUHpMnoTrh4MXmv+TvRO2X7EK/4HCH9YTi4TvMJYK+nIN1OU7PoJaeHl4niAICX+ 6+1k4CKOHYVT0hmFSr9PFBOUmgC8JXclek7y8wGQGirMqnUu4lHB53kQua1QebhfUPJx 4IZlfF14f26L+l9b2SbFcCAm0J1lfGV/JKKRsv5g6LLcdgQDY7g55qygoVN3xVr8tdJ0 tWDQ==; 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 5b1f17b1804b1-439958e8215si37151425e9.138.2025.02.20.01.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 01:57:55 -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 C4FBB80F67; Thu, 20 Feb 2025 10:57:35 +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 886C480A46; Thu, 20 Feb 2025 10:57:34 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_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 5EDB880F96 for ; Thu, 20 Feb 2025 10:57:32 +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 F02E01BB0; Thu, 20 Feb 2025 01:57:49 -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 3C1923F59E; Thu, 20 Feb 2025 01:57:28 -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 v2 3/6] lmb: check for a region's coalescing with all existing regions Date: Thu, 20 Feb 2025 15:26:51 +0530 Message-Id: <20250220095654.121634-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220095654.121634-1-sughosh.ganu@linaro.org> References: <20250220095654.121634-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 Reviewed-by: Heinrich Schuchardt --- Changes since V1: * Continue the loop only in the case where the newly added region is after the existing region. lib/lmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lmb.c b/lib/lmb.c index 207f059ceb9..45888989457 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -194,7 +194,7 @@ static long lmb_add_region_flags(struct alist *lmb_rgn_lst, phys_addr_t base, break; } else if (ret < 0) { if (flags != rgnflags) - break; + continue; rgn[i].size += size; coalesced++; break;