From patchwork Wed Jul 24 06:01:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 814129 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2617761wro; Tue, 23 Jul 2024 23:04:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUhJYtzVsIfL1xvv+4+1TJDfVnbZ64IjJwDIRuIkv00I9iVCvI0jXF3mi2D1eMuq1ohx1TMNg/2fd38AIW+wLpJ X-Google-Smtp-Source: AGHT+IEdjXvTOkqaGo/9/hN6MwO3faWCiVJuXzDfD7E/4UoiLpKkNtSRSbc7/9vpuoyT/DGnnBux X-Received: by 2002:a05:6000:2c3:b0:367:434f:caa2 with SMTP id ffacd0b85a97d-369bad3a81amr9454683f8f.0.1721801061608; Tue, 23 Jul 2024 23:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721801061; cv=none; d=google.com; s=arc-20160816; b=BNWUgJivCGPeVWjD4cIzX+mdAS7NOl2/qIplMbTkWUN2SB1qJ9MmzxdyE8h9BmMfcl ymmo0KdjfTH3a2ggk2/o+9simGrQxm/Qx1ZRGKRJyYJ6dAwMA7IP0UKpFJYmwZBY+2g/ sZW/etDX7zADUHvjVTaEZpXFduRtykpqsEy+9IJJgGkSUnB122MdWYiPIeUCMx798fut G/rHWeKcyAqVH51s+371b96tTgP+lv+K17jXZubP5D7qgGjl3v5xklVRRW/JKfq8VHdw YBhxMmPlq1hLi2H08HdtrmFXoG1q39Pa6Lp7lvWdWYycW+fyIjcsWo/n/UDwiDs1Ksxa kK5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=y6aEQKjfd91HvCQgi1DPRGNDShuy+qXJbqS+TobRD7M=; fh=eimiGswTlodK8yi2DcDfSicmKwvq5bxKQKpD+SkkTNY=; b=bgOb3RyJu+/Miu5LW9pntLVR0JvEg2aLndfHHHqlZD1ot9tLRRQqUXVaJrsWHa+yh7 PbqiD+hsZhuGQngO+9sIs8vkyO1yudFko7WJXpQ9WZmTs9LYtkSaKLZRm8+9uj/iEDGq iovCosnVFpiEzNzj8F/Z3ZRbWy/zX+oHFwTgbElmOGf9j0rZshNYM+oo4nLi4vus2rpy c70xkLL/lYSpV6Kjo9ZtczCWFWb4gz0nY+874B8WU0Vys00ldyWqXDnvOIQRYhnSLnu3 xKjV/rXAyy3ojGzVQGVb1SuRM8AMQL6wBsUJBb0wCxVHGlWEflyVQMR4tGNcR1g3fmax b4rQ==; 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 ffacd0b85a97d-369e365ce3fsi1378397f8f.100.2024.07.23.23.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 23:04:21 -0700 (PDT) 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 980F18881C; Wed, 24 Jul 2024 08:03:14 +0200 (CEST) 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 26BC688845; Wed, 24 Jul 2024 08:03:13 +0200 (CEST) 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_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 3790488005 for ; Wed, 24 Jul 2024 08:03:09 +0200 (CEST) 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 2D62E1476; Tue, 23 Jul 2024 23:03:34 -0700 (PDT) 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 1A3FF3F766; Tue, 23 Jul 2024 23:03:03 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , Huan Wang , Angelo Dureghello , Daniel Schwierzeck , Thomas Chou , Rick Chen , Max Filippov , Sughosh Ganu Subject: [PATCH 05/40] spl: alloc: call full alloc functions if malloc pool is available Date: Wed, 24 Jul 2024 11:31:49 +0530 Message-Id: <20240724060224.3071065-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240724060224.3071065-1-sughosh.ganu@linaro.org> References: <20240724060224.3071065-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 If the malloc simple functionality is enabled in SPL, it is not possible to call the full-implementation alloc functions even after the heap is set-up in ram memory. Check for this condition and call the functions when enabled. Signed-off-by: Sughosh Ganu --- Changes since rfc: New patch common/malloc_simple.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/malloc_simple.c b/common/malloc_simple.c index 4e6d7952b3..982287defe 100644 --- a/common/malloc_simple.c +++ b/common/malloc_simple.c @@ -40,6 +40,10 @@ void *malloc_simple(size_t bytes) { void *ptr; +#if IS_ENABLED(CONFIG_SPL_SYS_MALLOC) && IS_ENABLED(CONFIG_SPL_LMB) + if (gd->flags & GD_FLG_FULL_MALLOC_INIT) + return mALLOc(bytes); +#endif ptr = alloc_simple(bytes, 1); if (!ptr) return ptr; @@ -50,6 +54,15 @@ void *malloc_simple(size_t bytes) return ptr; } +void *realloc_simple(void *oldmem, size_t bytes) +{ +#if IS_ENABLED(CONFIG_SPL_SYS_MALLOC) && IS_ENABLED(CONFIG_SPL_LMB) + if (gd->flags & GD_FLG_FULL_MALLOC_INIT) + return rEALLOc(oldmem, bytes); +#endif + return NULL; +} + void *memalign_simple(size_t align, size_t bytes) { void *ptr;