From patchwork Thu Feb 20 09:56:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 866734 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1f85:b0:38f:210b:807b with SMTP id hj5csp115286wrb; Thu, 20 Feb 2025 01:57:28 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUprUn4xt1OyUT/tsjL9eNM8Zao5McUcDBA2Egb8C+4GZwEMD02/os1re+3cbd+4moyt75JyA==@linaro.org X-Google-Smtp-Source: AGHT+IFU1WvDHJtjIrlFGxR363ybyN8OPCoMtR/3KKb9EGbf7OGaVPGAzgqA2tmlQzJwD+LkrxFX X-Received: by 2002:a05:600c:1c86:b0:439:88bb:d000 with SMTP id 5b1f17b1804b1-43999dd981bmr58917055e9.25.1740045447920; Thu, 20 Feb 2025 01:57:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740045447; cv=none; d=google.com; s=arc-20240605; b=HEejK4TWusOfjfOQVyoTHaWf24TxuN1ZZzyM2nfx6QZiYRXuc3Yqaz3BQCrfbYBdVl LlANj9ig6KXB+8lKX16SGf3oMhjqe8e3hXV7iiyW5u/Ep0mS+jNt8CrW+lGEwVD1AGdH RAIEo0UDS4hJTZhnO/fAwecg/fT05K3cSR/lgAWTtkoln7Q1jmQsNYwLhy936xL2+2W0 ffbPlA7Xie1GTWuT4YrLj97X9SLkTHOnKZzE8xO81gkNSuj6mdvxf6zZx12rHobo4+KB kom/m/g737UVX3vbpVHec9OGzikIqQ30JwEFh/kTvP5blR7uq7wevvB+fzmWE9q4qnJN 4U3w== 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=cGg4HCHtFEDqtSgc/bFnCKeMUPXcshuZRTDL/RyXVMQ=; fh=d4XVj+8HdmsbsoM1smqjwzmIkzY0nU/RUGJJUff3t00=; b=g7zlcmgGba/bNKl71L+C70L8Re687y+tFmIxU+Q96CcqM+NBtxVGEti67KiMDerhEd yqHgcD8jJiOrFsCEv9bYsn5huyoOryojdf8VoEggWcKY4+f1/Lr9pK1fzE4C7G/fZpLT 0D/7kWLWfUmeWpp52ocpKUapwmlzYKoJx5xQUTLSKRpyX8XoDU+0xyJTPYRR/A0tIcgi 0GlcGgrTTsFu+LYfO58MQssZf7CBOLT7dMovMrCsdAGddn7xnIK1wD8ck9+Tm/IhqV3h I3A4QGwhkexe/0U8TNhRfgEHD+SZwAGVeyhS4tR04c503b/WMi+i0prr28aDIGLCCknU RTkw==; 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-43959d495e6si165836665e9.46.2025.02.20.01.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 01:57:27 -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 9DCC080F32; Thu, 20 Feb 2025 10:57:26 +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 97AB580C98; Thu, 20 Feb 2025 10:57:25 +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 6CAE780077 for ; Thu, 20 Feb 2025 10:57:23 +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 981201BB0; Thu, 20 Feb 2025 01:57:40 -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 22DB13F59E; Thu, 20 Feb 2025 01:57:19 -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 v2 0/6] lmb: miscellaneous fixes and improvements Date: Thu, 20 Feb 2025 15:26:48 +0530 Message-Id: <20250220095654.121634-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 V1: * Add documentation for the lmb_can_reserve_region() function. * Add an additional test case where a new region is being added, and the new region overlaps two different existing regions, with mismatching flags. * Some cleanup of comments in the lib_test_lmb_overlapping_reserve() function. * Use lmb_resize_regions() to fix the overlap instead of lmb_fix_over_lap_regions(). * Remove the now superfluous lmb_fix_over_lap_regions(). * Continue the loop only in the case where the newly added region is after the existing region. 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(-)