linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Mike Rapoport <rppt@kernel.org>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Russell King <linux@armlinux.org.uk>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Vasily Gorbik <gor@linux.ibm.com>, Will Deacon <will@kernel.org>,
	linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
	linux-mm@kvack.org, linux-s390@vger.kernel.org
Subject: [RFC/RFT PATCH 4/5] MIPS: switch to generic memblock_setup_resources
Date: Mon, 31 May 2021 15:29:58 +0300	[thread overview]
Message-ID: <20210531122959.23499-5-rppt@kernel.org> (raw)
In-Reply-To: <20210531122959.23499-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

MIPS version of resource setup is very similar to the generic one. The only
difference is the reservation of the crash kernel area that is spread among
several functions.

Switch MIPS to use the generic version.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/mips/kernel/setup.c | 78 +++-------------------------------------
 1 file changed, 5 insertions(+), 73 deletions(-)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 23a140327a0b..be49217f0f22 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -79,10 +79,6 @@ static const char builtin_cmdline[] __initconst = "";
 unsigned long mips_io_port_base = -1;
 EXPORT_SYMBOL(mips_io_port_base);
 
-static struct resource code_resource = { .name = "Kernel code", };
-static struct resource data_resource = { .name = "Kernel data", };
-static struct resource bss_resource = { .name = "Kernel bss", };
-
 unsigned long __kaslr_offset __ro_after_init;
 EXPORT_SYMBOL(__kaslr_offset);
 
@@ -469,31 +465,18 @@ static void __init mips_parse_crashkernel(void)
 		}
 	}
 
+	memblock_reserve(crashk_res.start, resource_size(&crashk_res));
+
 	crashk_res.start = crash_base;
 	crashk_res.end	 = crash_base + crash_size - 1;
-}
-
-static void __init request_crashkernel(struct resource *res)
-{
-	int ret;
-
-	if (crashk_res.start == crashk_res.end)
-		return;
 
-	ret = request_resource(res, &crashk_res);
-	if (!ret)
-		pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
-			(unsigned long)(resource_size(&crashk_res) >> 20),
-			(unsigned long)(crashk_res.start  >> 20));
+	pr_info("Reserving %lldMB of memory at %lldMB for crashkernel\n",
+		crash_base >> 20, crash_size);
 }
 #else /* !defined(CONFIG_KEXEC)		*/
 static void __init mips_parse_crashkernel(void)
 {
 }
-
-static void __init request_crashkernel(struct resource *res)
-{
-}
 #endif /* !defined(CONFIG_KEXEC)  */
 
 static void __init check_kernel_sections_mem(void)
@@ -656,10 +639,6 @@ static void __init arch_mem_init(char **cmdline_p)
 	mips_reserve_vmcore();
 
 	mips_parse_crashkernel();
-#ifdef CONFIG_KEXEC
-	if (crashk_res.start != crashk_res.end)
-		memblock_reserve(crashk_res.start, resource_size(&crashk_res));
-#endif
 	device_tree_init();
 
 	/*
@@ -683,53 +662,6 @@ static void __init arch_mem_init(char **cmdline_p)
 	early_memtest(PFN_PHYS(ARCH_PFN_OFFSET), PFN_PHYS(max_low_pfn));
 }
 
-static void __init resource_init(void)
-{
-	phys_addr_t start, end;
-	u64 i;
-
-	if (UNCAC_BASE != IO_BASE)
-		return;
-
-	code_resource.start = __pa_symbol(&_text);
-	code_resource.end = __pa_symbol(&_etext) - 1;
-	data_resource.start = __pa_symbol(&_etext);
-	data_resource.end = __pa_symbol(&_edata) - 1;
-	bss_resource.start = __pa_symbol(&__bss_start);
-	bss_resource.end = __pa_symbol(&__bss_stop) - 1;
-
-	for_each_mem_range(i, &start, &end) {
-		struct resource *res;
-
-		res = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
-		if (!res)
-			panic("%s: Failed to allocate %zu bytes\n", __func__,
-			      sizeof(struct resource));
-
-		res->start = start;
-		/*
-		 * In memblock, end points to the first byte after the
-		 * range while in resourses, end points to the last byte in
-		 * the range.
-		 */
-		res->end = end - 1;
-		res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
-		res->name = "System RAM";
-
-		request_resource(&iomem_resource, res);
-
-		/*
-		 *  We don't know which RAM region contains kernel data,
-		 *  so we try it repeatedly and let the resource manager
-		 *  test it.
-		 */
-		request_resource(res, &code_resource);
-		request_resource(res, &data_resource);
-		request_resource(res, &bss_resource);
-		request_crashkernel(res);
-	}
-}
-
 #ifdef CONFIG_SMP
 static void __init prefill_possible_map(void)
 {
@@ -771,7 +703,7 @@ void __init setup_arch(char **cmdline_p)
 	arch_mem_init(cmdline_p);
 	dmi_setup();
 
-	resource_init();
+	memblock_setup_resources();
 	plat_smp_setup();
 	prefill_possible_map();
 
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2021-05-31 12:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-31 12:29 [RFC/RFT PATCH 0/5] consolidate "System RAM" resources setup Mike Rapoport
2021-05-31 12:29 ` [RFC/RFT PATCH 1/5] s390: make crashk_res resource a child of "System RAM" Mike Rapoport
2021-06-01  8:45   ` David Hildenbrand
2021-06-01  9:02     ` David Hildenbrand
2021-06-02  6:25       ` Mike Rapoport
2021-06-01 13:18   ` Gerald Schaefer
2021-06-02  6:54     ` Mike Rapoport
2021-05-31 12:29 ` [RFC/RFT PATCH 2/5] memblock: introduce generic memblock_setup_resources() Mike Rapoport
2021-06-01 13:54   ` Russell King (Oracle)
2021-06-02  8:33     ` Mike Rapoport
2021-06-02 10:15       ` Russell King (Oracle)
2021-06-02 13:54         ` Mike Rapoport
2021-06-02 15:51           ` Russell King (Oracle)
2021-06-02 18:43             ` Mike Rapoport
2021-06-02 20:15               ` Russell King (Oracle)
2021-06-03 10:32                 ` Mike Rapoport
2021-05-31 12:29 ` [RFC/RFT PATCH 3/5] arm: switch to " Mike Rapoport
2021-05-31 12:29 ` Mike Rapoport [this message]
2021-05-31 12:29 ` [RFC/RFT PATCH 5/5] arm64: " Mike Rapoport
2021-06-01 13:44 ` [RFC/RFT PATCH 0/5] consolidate "System RAM" resources setup Russell King (Oracle)
2021-06-02  7:05   ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210531122959.23499-5-rppt@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=borntraeger@de.ibm.com \
    --cc=catalin.marinas@arm.com \
    --cc=david@redhat.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=rppt@linux.ibm.com \
    --cc=tsbogend@alpha.franken.de \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).