From patchwork Mon Mar 3 13:32:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 869831 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1561:b0:38f:210b:807b with SMTP id 1csp2122153wrz; Mon, 3 Mar 2025 05:33:02 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWl4EBUbKbIiz/q7GX3hWjsywfY/XvKnKQ0/NhLmDig0ueIZxm2ig2JLYJZI4DRpJm11Rg2Gg==@linaro.org X-Google-Smtp-Source: AGHT+IH+WV8bzgRRx95psp7wPgR/wMyzY5lW9fdLhBveFS2P2p7BWZY0upJdx/xqzLgdIGRG+2lf X-Received: by 2002:a17:90b:3511:b0:2ee:dd9b:e402 with SMTP id 98e67ed59e1d1-2febab5e1a0mr24692841a91.12.1741008781958; Mon, 03 Mar 2025 05:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741008781; cv=none; d=google.com; s=arc-20240605; b=Rl8K4XktFE4tL4W7y0vANZsLit1rfAl03fyOoUvk7kcCGwjSSiNSJbiLUCbYuRrVYv TNW15cD9+/m82HW16VhbLB2SXa0o9xrQI+QSlR+8pJe+omRHGooE2ih9SNTQeA1P0Q0I h1Y3Ns1ikEV5MogQAaDsYVVGwzstQrkxCQJBPrKhrDYu5NZnyIOiJH1zjpNNIg3FlpL3 DGD/z7YObHzXe7sfp5ASuuN8ckS8iNtK70X6hCU+7629JsM/Xn0a805BoEwdStRxljdO lj3YELwoqZ7iDrFokVWWOEdvswQsVksiOcbuW2O2yRIGtC4BDw72vaQ6BK8rYQn+aL7d 0gcA== 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:message-id:date:subject:cc:to:from; bh=cZe1K+X3CTe+ImEicy77+xx4Mt1ysA67rhwGhWPcIq0=; fh=d4XVj+8HdmsbsoM1smqjwzmIkzY0nU/RUGJJUff3t00=; b=ARo85SrWyUfr3BOPleFVjb/UERTDPez5nR2hhBY9bzsytQdnUDcsaF0u+VzPMVht0s 69ltzmUK17HmxO8e9eekqCe5So4OkMe9z8RJIfipFVnYhzQjBDuGH2fO3mtUn6zbdGnk E9FzRDpFPsyrRbJB8xG4252nkPVKf8F2BSXZL+FXOvmHI9xwKyQi4c59IcsdlIeixtj3 O+r3CO4rUPklwMrRzEFAecM0xee8k4idMdvWypXY6CrjDAQTDA2mVCD1PDfGx2v1T9cf bL4Avp+JfpKgW9L4MYjZu4rjrN3Luvn6g+vRKLWnZsphlsCG6J2h0sUrmAIqT+i3Vc/5 XmPw==; 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 98e67ed59e1d1-2fe825e3503si18313850a91.58.2025.03.03.05.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Mar 2025 05:33:01 -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 2929D811DF; Mon, 3 Mar 2025 14:32:57 +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 02A0D811DF; Mon, 3 Mar 2025 14:32:56 +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 DAA60811B2 for ; Mon, 3 Mar 2025 14:32:53 +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 5762F106F; Mon, 3 Mar 2025 05:33:07 -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 F048E3F673; Mon, 3 Mar 2025 05:32:50 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Tom Rini , Quentin Schulz , Udit Kumar , Heinrich Schuchardt Subject: [PATCH v3 0/6] lmb: miscellaneous fixes and improvements Date: Mon, 3 Mar 2025 19:02:25 +0530 Message-Id: <20250303133231.405279-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 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 patch series contains some fixes and improvements in the lmb code, along with addition of corresponding test cases for the changes made. The lmb_reserve() function currently does not check if the requested reservation would overlap with existing reserved regions. While some scenarios are being handled, some corner cases still exist. These are being handled by patch 1, along with adding test cases for these scenarios. Patch 2 is handling the case of reserving a new region of memory, but that region overlaps with an existing region. The current code only handles one particular scenario, but prints a message for the other scenario of an encompassing overlap and returns back. The patch handles the encompassing overlap. Patch 3 is an improvement whereby we allow coalescing a newly reserved region with an existing region. The current code exits this check prematurely. Patch 4 is removing a now superfluous check for overlapping regions with flag other than LMB_NONE. This now gets handled at an earlier point in lmb_reserve(). Patch 5 is clubbing the functionality to check if two regions are adjacent, or overlap, allowing some code re-use. Patch 6 is optimising the lmb_alloc() function by having it call _lmb_alloc_base() directly. Changes since V2: * Add more description to the commit message on the logic behind this change (patch 4) * Change the print for allocation failure into a debug message as per suggestion from Heinrich Sughosh Ganu (6): lmb: check if a region can be reserved by lmb_reserve() lmb: handle scenario of encompassing overlap lmb: check for a region's coalescing with all existing regions lmb: remove superfluous address overlap check from lmb_add_region_flags() lmb: use a common function to check if regions overlap or are adjacent lmb: optimise the lmb allocation functions lib/lmb.c | 140 +++++++++++++++++++++++++++++-------------------- test/lib/lmb.c | 114 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 194 insertions(+), 60 deletions(-)