From patchwork Mon Aug 26 11:59:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 822450 Delivered-To: patch@linaro.org Received: by 2002:adf:e044:0:b0:367:895a:4699 with SMTP id w4csp1477829wrh; Mon, 26 Aug 2024 05:02:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1TFqJV6zBnma4dSj7Sf6IAL3xTu99K4433DRleMEAYw5QqocaBl0p/dXtICdA5l+mIbtyRA==@linaro.org X-Google-Smtp-Source: AGHT+IFDVGDkEdFOea7Aj9AW1jPMJH+km7OuNSgOtJwhSAcOh+bJ/X5/2MEn26xSD4dZ6qqbpwpJ X-Received: by 2002:a05:600c:4e87:b0:426:623f:34ae with SMTP id 5b1f17b1804b1-42acc8d4ed8mr63218115e9.16.1724673772931; Mon, 26 Aug 2024 05:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724673772; cv=none; d=google.com; s=arc-20240605; b=lnubzh9NplkZrl6YdBYkKUby+e2c0G41u2nJ6TdBWn3t2JDEGViacPSUCiYR4laFHn N10Zs9tEp2HNqAl0iqY5CnRFJAj3vKcy62jvbSVT5KfU1X1u3AhNFymlL1UhDnIX2eis KYy/t7jio5bR86Ta/w4py+sEgANL2Whox+L05mNh/2gmxDjNlCVXL5t93WMdoEDZ4Zc3 UFSg8JiSG9o9tMleMP/nx4boz26nbEHyqNXTmL330PIFJRE/luQ99QGZ05dw1RQHnnad 7htp5cluP+KiBMZRO9k/AT+AvRnhSROmMRFghMVJrBaWCgrOOjVmLNUBV+HnwV1ClN1E 8lWQ== 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=ekZP53RJ4JpE45M8lYAnTN8JwwsEl8OdRfImgeGXByU=; fh=8IbOOFAUJYCfGYrzM0jWqtoOP7AaZuPOmdHZ5mvNk1Q=; b=ZpT4URqZ3Sv9lkxiWFPA2xEiWb0eHwiQt0uqi6UT5ZYx9wxmNl9zRyteVhzr7kETn0 STT8VjTlUd2B4DxOj3haEhiyJGzb16vILXSxejgVPTHILiqFN2tXhKxPRAq4ydMCtJGt oYgQ2+3t3XawjugrgssT81d9EFceaCSvAvQda46c50IMEQrAsAh6jWMWfQRQ+LhYPial SOhb1racwoVNVb7oDQuuAVd1QEUN2hkEOUn8vN9RlVehop3RSnxh+TKXnon0jm5xTsaT aPzEFhyZMZ2xs8YcTorYN4OaLJ79gFRtJ1yCo5aZc5DYIO4cEqJLtkV9r5vcAh/6jksS 6rcg==; 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-42abed89416si57510515e9.32.2024.08.26.05.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 05:02:52 -0700 (PDT) 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 B1EE288B35; Mon, 26 Aug 2024 14:01:17 +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 D352388B16; Mon, 26 Aug 2024 14:01:16 +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,T_SCC_BODY_TEXT_LINE 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 9AE2788B59 for ; Mon, 26 Aug 2024 14:01:14 +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 451CCDA7; Mon, 26 Aug 2024 05:01:40 -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 61E8C3F762; Mon, 26 Aug 2024 05:01:10 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Marek Vasut , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , =?utf-8?q?Marek_Beh=C3=BAn?= , Sughosh Ganu Subject: [PATCH v4 16/27] ppc: lmb: move arch specific lmb reservations to arch_misc_init() Date: Mon, 26 Aug 2024 17:29:29 +0530 Message-Id: <20240826115940.3233167-17-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240826115940.3233167-1-sughosh.ganu@linaro.org> References: <20240826115940.3233167-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 All the current function definitions of arch_lmb_reserve() are doing the same thing -- reserve the U-Boot memory region. The powerpc(ppc) architecture, in addition, is making some LMB reservations for the bootm related image loading. Move these ppc specific reservations to the arch_misc_init() function. This allows to move the U-Boot memory region reservation to a different function, and remove arch_lmb_reserve() in a subsequent commit. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass --- Changes since V3: * Removed the additional blank line in arch/powerpc/lib/misc.c as suggested by checkpatch. * Added spaces in the CFG_SYS_LINUX_LOWMEM_MAX_SIZE value as suggested by checkpatch. * Added a missing blank line in arch/powerpc/lib/misc.c as suggested by checkpatch. arch/powerpc/cpu/mpc85xx/cpu_init.c | 16 -------- arch/powerpc/lib/Makefile | 1 + arch/powerpc/lib/bootm.c | 40 ------------------- arch/powerpc/lib/misc.c | 62 +++++++++++++++++++++++++++++ lib/Kconfig | 1 + 5 files changed, 64 insertions(+), 56 deletions(-) create mode 100644 arch/powerpc/lib/misc.c diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init.c b/arch/powerpc/cpu/mpc85xx/cpu_init.c index a7b805bc67..739d14f800 100644 --- a/arch/powerpc/cpu/mpc85xx/cpu_init.c +++ b/arch/powerpc/cpu/mpc85xx/cpu_init.c @@ -940,22 +940,6 @@ int cpu_init_r(void) return 0; } -#ifdef CONFIG_ARCH_MISC_INIT -int arch_misc_init(void) -{ - if (IS_ENABLED(CONFIG_FSL_CAAM)) { - struct udevice *dev; - int ret; - - ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(caam_jr), &dev); - if (ret) - printf("Failed to initialize caam_jr: %d\n", ret); - } - - return 0; -} -#endif - void arch_preboot_os(void) { u32 msr; diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index bb819dcbb6..ecc2aba8f3 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@ -39,6 +39,7 @@ obj-y += cache.o obj-y += extable.o obj-y += interrupts.o obj-$(CONFIG_CMD_KGDB) += kgdb.o +obj-y += misc.o obj-y += stack.o obj-y += time.o obj-y += traps.o diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c index 752f72f873..8f21cdb0a5 100644 --- a/arch/powerpc/lib/bootm.c +++ b/arch/powerpc/lib/bootm.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -41,10 +40,6 @@ static ulong get_sp (void); extern void ft_fixup_num_cores(void *blob); static void set_clocks_in_mhz (struct bd_info *kbd); -#ifndef CFG_SYS_LINUX_LOWMEM_MAX_SIZE -#define CFG_SYS_LINUX_LOWMEM_MAX_SIZE (768*1024*1024) -#endif - static void boot_jump_linux(struct bootm_headers *images) { void (*kernel)(struct bd_info *, ulong r4, ulong r5, ulong r6, @@ -116,41 +111,6 @@ static void boot_jump_linux(struct bootm_headers *images) return; } -void arch_lmb_reserve(void) -{ - phys_size_t bootm_size; - ulong size, bootmap_base; - - bootmap_base = env_get_bootm_low(); - bootm_size = env_get_bootm_size(); - -#ifdef DEBUG - if (((u64)bootmap_base + bootm_size) > - (CFG_SYS_SDRAM_BASE + (u64)gd->ram_size)) - puts("WARNING: bootm_low + bootm_size exceed total memory\n"); - if ((bootmap_base + bootm_size) > get_effective_memsize()) - puts("WARNING: bootm_low + bootm_size exceed eff. memory\n"); -#endif - - size = min(bootm_size, get_effective_memsize()); - size = min(size, (ulong)CFG_SYS_LINUX_LOWMEM_MAX_SIZE); - - if (size < bootm_size) { - ulong base = bootmap_base + size; - printf("WARNING: adjusting available memory from 0x%lx to 0x%llx\n", - size, (unsigned long long)bootm_size); - lmb_reserve(base, bootm_size - size); - } - - arch_lmb_reserve_generic(get_sp(), gd->ram_top, 4096); - -#ifdef CONFIG_MP - cpu_mp_lmb_reserve(); -#endif - - return; -} - static void boot_prep_linux(struct bootm_headers *images) { #ifdef CONFIG_MP diff --git a/arch/powerpc/lib/misc.c b/arch/powerpc/lib/misc.c new file mode 100644 index 0000000000..4cd23b3406 --- /dev/null +++ b/arch/powerpc/lib/misc.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2024 Linaro Ltd. + */ + +#include +#include +#include + +#include +#include +#include + +#ifndef CFG_SYS_LINUX_LOWMEM_MAX_SIZE +#define CFG_SYS_LINUX_LOWMEM_MAX_SIZE (768 * 1024 * 1024) +#endif + +int arch_misc_init(void) +{ + if (CONFIG_IS_ENABLED(CMD_BOOTM)) { + phys_size_t bootm_size; + ulong size, bootmap_base; + + bootmap_base = env_get_bootm_low(); + bootm_size = env_get_bootm_size(); + +#ifdef DEBUG + if (((u64)bootmap_base + bootm_size) > + (CFG_SYS_SDRAM_BASE + (u64)gd->ram_size)) + puts("WARNING: bootm_low + bootm_size exceed total memory\n"); + if ((bootmap_base + bootm_size) > get_effective_memsize()) + puts("WARNING: bootm_low + bootm_size exceed eff. memory\n"); +#endif + + size = min(bootm_size, get_effective_memsize()); + size = min(size, (ulong)CFG_SYS_LINUX_LOWMEM_MAX_SIZE); + + if (size < bootm_size) { + ulong base = bootmap_base + size; + + printf("WARNING: adjusting available memory from 0x%lx to 0x%llx\n", + size, (unsigned long long)bootm_size); + lmb_reserve(base, bootm_size - size); + } + +#ifdef CONFIG_MP + cpu_mp_lmb_reserve(); +#endif + } + + if (IS_ENABLED(CONFIG_FSL_CAAM)) { + struct udevice *dev; + int ret; + + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_DRIVER_GET(caam_jr), &dev); + if (ret) + printf("Failed to initialize caam_jr: %d\n", ret); + } + + return 0; +} diff --git a/lib/Kconfig b/lib/Kconfig index 6a9338390a..e352b5550a 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1102,6 +1102,7 @@ config LMB bool "Enable the logical memory blocks library (lmb)" default y if ARC || ARM || M68K || MICROBLAZE || MIPS || \ NIOS2 || PPC || RISCV || SANDBOX || SH || X86 || XTENSA + select ARCH_MISC_INIT if PPC help Support the library logical memory blocks. This will require a malloc() implementation for defining the data structures