From patchwork Thu Feb 20 09:56:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 866740 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1f85:b0:38f:210b:807b with SMTP id hj5csp115564wrb; Thu, 20 Feb 2025 01:58:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUTmxExf56syw4Z21bPcFL4flC363cwJ2T08LvxeCh54POeOJ4JH/cvnLp/SbO6QbqlmQuang==@linaro.org X-Google-Smtp-Source: AGHT+IEUFkJIhChh+QxFzuxwRgJaWHX/ZFMTUnkHQ59AuBdRGuL7f9cU3BlMHRKsRoMo9sc5g5xa X-Received: by 2002:a05:600c:458a:b0:439:3d5c:8bfb with SMTP id 5b1f17b1804b1-43999dd11d6mr63382925e9.22.1740045500515; Thu, 20 Feb 2025 01:58:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740045500; cv=none; d=google.com; s=arc-20240605; b=fbbD6RfKgrXGWe9I/qbZA+cSv6e/s+EuJv3UwGoxISn/D+vNAsH+3oZtqrztrtnERI bpy2zfpv6KxWygrMyAPikjj7WWr89rk8oG7d3nqwORxL44Kl+c1sjssLFNp5wKJM0u17 TjOFbdsGcdtU/jKW8h44Yj9t3/nQ9YwJYXyoZRW/e8ihax8n5lQXXp8qMZANugBeQFrH OLx2Sx5ZxoKKhTv63cMoJNKB+JlhRSa8N8xuW9aY4pB9E2HWk4+11IXdCd+9PfNJAb3w vmb5+Z5NtNzcxJePiCORiaMlBMjNCNW56PUKBOKTaUXRztTq6e7Ezi2hBmfpXW63bOXu 2PAw== 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=ADVVLtgbFTNyNko3gblTHKRV9WFn6p7G8j1FKFVK7P0=; fh=2HGKihHUAicyV3F+aHiaoPpwvqWA0zlC04Ew6QaQoEg=; b=Ly749s5a9quiAzpIZ9GMLm3vP/feli7p8V0yAm3n4EeyhOE4+zgBmKBN9O4ClGBWsO VrE3mkHgwFIu7ghsFprd/uh8vmr+W2rcU+OVfu56/T+pftLDoNz32G9PqgzWjdedcVaf +C5Ey1SZ+GH/p0Ir2675/7oFgklWL+DFSByiF5L+JXsS3lhtCcsHF87AKK3Mj5TMdwgf g5uISXRoGfGd9TCJfs0j0lXrdvACEXpWTLTaMPInABHte86iD6J+WKNwumx60OpGDRJC d3Pai89qmxnGu6P8jYgh70/Zh1g/ESmOTqNq4Vd/RiOTIuC89wLhEQi6dXN1bC4z7xoK ud+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 5b1f17b1804b1-439618b0226si143728495e9.127.2025.02.20.01.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2025 01:58:20 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 BE67E80F77; Thu, 20 Feb 2025 10:57:45 +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 AD14680F7B; Thu, 20 Feb 2025 10:57:44 +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 B7BA480FA4 for ; Thu, 20 Feb 2025 10:57:41 +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 4F4CF1BB0; Thu, 20 Feb 2025 01:57:59 -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 913493F59E; Thu, 20 Feb 2025 01:57: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 v2 6/6] lmb: optimise the lmb allocation functions Date: Thu, 20 Feb 2025 15:26:54 +0530 Message-Id: <20250220095654.121634-7-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 actual logic to allocate a region of memory is in the _lmb_alloc_base() function. The lmb_alloc() API function calls lmb_alloc_base(), which then calls _lmb_alloc_base() to do the allocation. Instead, call the _lmb_alloc_base() directly from both the allocation API's, and move the error message to the _lmb_alloc_base(). Signed-off-by: Sughosh Ganu --- Changes since V1: New patch lib/lmb.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index 874063fc1f5..6bfc0dbc9ce 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -758,26 +758,22 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, base = ALIGN_DOWN(res_base - size, align); } } + + log_err("Failed to allocate 0x%lx bytes below 0x%lx\n", (ulong)size, + (ulong)max_addr); + return 0; } phys_addr_t lmb_alloc(phys_size_t size, ulong align) { - return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE, LMB_NONE); + return _lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE, LMB_NONE); } phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, uint flags) { - phys_addr_t alloc; - - alloc = _lmb_alloc_base(size, align, max_addr, flags); - - if (alloc == 0) - printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", - (ulong)size, (ulong)max_addr); - - return alloc; + return _lmb_alloc_base(size, align, max_addr, flags); } phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags)