From patchwork Wed Aug 21 10:58:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 820966 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp640327wrm; Wed, 21 Aug 2024 04:01:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUnnJ28gBIO+1tCInulJKEAfonRAm0HnPFUK/CNMZ95mn4Xq4nt6iscU/YBjmbvoNlTwji9mw==@linaro.org X-Google-Smtp-Source: AGHT+IEuct4MK68TyjulQQHc9xcgkYzKgMYnUwA1ns51Xfc21Ia/1yLD8OPxzziEaYIPvsW17aYS X-Received: by 2002:a17:906:d7c1:b0:a6f:8265:8f2 with SMTP id a640c23a62f3a-a866f371b48mr152107866b.37.1724238106798; Wed, 21 Aug 2024 04:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724238106; cv=none; d=google.com; s=arc-20160816; b=l0bFgw3/H1Hxg3LL4nh3C3ObzNEAJ81RwgoGs2ewvRIJ5tUz1OhUStFXRJjsa7JvSH k8V0C4tg3NbVh5vmlxmgt5/pY8CpZw7UewDf4OomlLe/4SrcNuKVmmRs0xFLFJSFTniw Ieoj+fLjmzZS4oF88gZfePbUlqIsydU0fVM4TZOrzR4ZN9qrM4ABE4ZVe4uDcUhmXUw1 xmOYaPpC+mTfbZAuUlHhosswyvvlhm9jNoQdih5udISxOM+OD0Trz9ra2XjSiPWuOWU3 DetJ2M3ULVF3rVU8LGKiqQqKgiJEiWKDSlxYGc3qJ3K/x2S5Ycd0ppkhV/VjHHQcUT+o dK8A== 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=I3ggXAhcjvmR1mdLHCIIpB90e7QU8GXB9F09EUdBepA=; fh=pnMZGD6unUPoMrkOwzXlkuYg+kVwGnSNRCTlQoWqjVc=; b=IztLSwLcYBrJwJXqrQegbUZow26BfyVdg0ZoX800OccnTYKI+wjXRtxFed98n367E6 PJUClkdDResIeRsiuyeJPzIiMGmXKo2i5gr/K3g+Itlv/eeXuDXFiFbEOR1aKjffZtHn gH/4QFD5PabfZ+rcUBbqvvhWBGTS/2OTb6b1GEH3MzTr9NL3CvPx7aQuTYN7f2RBQxDT RfzwbEFIWUxRm8qmP0gUWPL0h3cmahgeTctTHgew4bHCbJ9KI6J0ROQu46ANsZbNWpjO 7NFL1vsiXw2kqhs2DEYj+DCU7svm+LqyiKgPjXQWot/FLPXXEBfEUqDcJgIyby4Aywlx wNGA==; 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 a640c23a62f3a-a867cac9842si50811366b.289.2024.08.21.04.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 04:01:46 -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 8037D88DD4; Wed, 21 Aug 2024 13:00:04 +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 28CCB88DC7; Wed, 21 Aug 2024 13:00:03 +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 71F0088DBA for ; Wed, 21 Aug 2024 13:00:00 +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 F100EDA7; Wed, 21 Aug 2024 04:00:25 -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 8AB8B3F73B; Wed, 21 Aug 2024 03:59:56 -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 , Sughosh Ganu Subject: [PATCH v3 16/27] ppc: lmb: move arch specific lmb reservations to arch_misc_init() Date: Wed, 21 Aug 2024 16:28:28 +0530 Message-Id: <20240821105839.2870293-17-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821105839.2870293-1-sughosh.ganu@linaro.org> References: <20240821105839.2870293-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 V2: New patch 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 6c35664ff3..5402e0bb35 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..0ea9ab1358 --- /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