From patchwork Mon Jun 6 17:00:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 9158883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BC5F660572 for ; Mon, 6 Jun 2016 17:11:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A24FB28348 for ; Mon, 6 Jun 2016 17:11:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 971272834E; Mon, 6 Jun 2016 17:11:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FBD227B13 for ; Mon, 6 Jun 2016 17:11:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b9y2L-0005qj-RC; Mon, 06 Jun 2016 17:10:01 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b9y23-0005XB-Me for linux-arm-kernel@lists.infradead.org; Mon, 06 Jun 2016 17:09:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References:In-Reply-To; bh=bphCaiUQmq71BSZNiHq7ZxOu+dfAOosOJbfHQ5/vlQc=; b=OX0J/vU2QGp+24OIt1/ViOunTK+cXa+H4COEEmSqMo/PCjIPw4sjCMylkgXiXiFk8cp+/OC2HUcFSJivX4moBwzupEDEbGr0j/RxRgV+5LAHbBXF1RzskqEg0c0X5/+WR6c4aIhgtZPRZnCRxsC+WcQ308br3uyfgpq4eqaeMiY=; Received: from [2002:4e20:1eda:1:b4eb:e902:622d:f2f0] (port=45158 helo=e0050434b2927.dyn.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1b9xtU-0000J7-ES; Mon, 06 Jun 2016 18:00:54 +0100 Received: from rmk by e0050434b2927.dyn.armlinux.org.uk with local (Exim 4.82) (envelope-from ) id 1b9xtK-0003te-8s; Mon, 06 Jun 2016 18:00:42 +0100 In-Reply-To: <20160606164129.GM1041@n2100.armlinux.org.uk> References: <20160606164129.GM1041@n2100.armlinux.org.uk> From: Russell King To: kexec@lists.infradead.org,linux-arm-kernel@lists.infradead.org Subject: [PATCH kexec-tools v2 23/32] arm: move crash system RAM parsing earlier MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 06 Jun 2016 18:00:42 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160606_100944_486120_198E96AB X-CRM114-Status: GOOD ( 17.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pratyush Anand , Baoquan He Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Pratyush Anand Signed-off-by: Russell King --- kexec/arch/arm/Makefile | 2 ++ kexec/arch/arm/crashdump-arm.c | 51 ++++++++---------------------------------- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/kexec/arch/arm/Makefile b/kexec/arch/arm/Makefile index 60e433a..71db8c3 100644 --- a/kexec/arch/arm/Makefile +++ b/kexec/arch/arm/Makefile @@ -7,6 +7,8 @@ arm_FS2DT = kexec/fs2dt.c arm_FS2DT_INCLUDE = -include $(srcdir)/kexec/arch/arm/crashdump-arm.h \ -include $(srcdir)/kexec/arch/arm/kexec-arm.h +arm_MEM_REGIONS = kexec/mem_regions.c + arm_KEXEC_SRCS= kexec/arch/arm/kexec-elf-rel-arm.c arm_KEXEC_SRCS+= kexec/arch/arm/kexec-zImage-arm.c arm_KEXEC_SRCS+= kexec/arch/arm/kexec-uImage-arm.c diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c index d6db566..f2e6a0d 100644 --- a/kexec/arch/arm/crashdump-arm.c +++ b/kexec/arch/arm/crashdump-arm.c @@ -30,6 +30,7 @@ #include "../../kexec.h" #include "../../kexec-elf.h" #include "../../crashdump.h" +#include "../../mem_regions.h" #include "crashdump-arm.h" #include "iomem.h" @@ -132,39 +133,6 @@ static int get_kernel_page_offset(struct kexec_info *info, } /** - * crash_range_callback() - callback called for each iomem region - * @data: not used - * @nr: not used - * @str: name of the memory region - * @base: start address of the memory region - * @length: size of the memory region - * - * This function is called once for each memory region found in /proc/iomem. It - * locates system RAM and places these into @crash_memory_ranges. Number of - * memory regions is placed in @crash_memory_nr_ranges. - */ -static int crash_range_callback(void *UNUSED(data), int UNUSED(nr), - char *str, unsigned long long base, - unsigned long long length) -{ - struct memory_range *range; - - if (usablemem_rgns.size >= CRASH_MAX_MEMORY_RANGES) - return 1; - - range = usablemem_rgns.ranges + usablemem_rgns.size; - - if (strncmp(str, "System RAM\n", 11) == 0) { - range->start = base; - range->end = base + length - 1; - range->type = RANGE_RAM; - usablemem_rgns.size++; - } - - return 0; -} - -/** * crash_exclude_range() - excludes memory region reserved for crashkernel * * Function locates where crashkernel reserved memory is and removes that region @@ -213,12 +181,6 @@ static void crash_exclude_range(void) */ static int crash_get_memory_ranges(void) { - /* - * First read all memory regions that can be considered as - * system memory including the crash area. - */ - kexec_iomem_for_each_line(NULL, crash_range_callback, NULL); - if (usablemem_rgns.size < 1) { errno = EINVAL; return -1; @@ -414,8 +376,9 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline) * @base: start address of the memory region * @length: size of the memory region * - * This function is called for each memory range in /proc/iomem, and stores - * the location of the crash kernel range into @crash_reserved_mem. + * This function is called for each memory range in /proc/iomem, stores + * the location of the crash kernel range into @crash_reserved_mem, and + * stores the system RAM into @usablemem_rgns. */ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr), char *str, unsigned long long base, @@ -426,6 +389,10 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr), crash_reserved_mem.end = base + length - 1; crash_reserved_mem.type = RANGE_RAM; } + else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) { + return mem_regions_add(&usablemem_rgns, + base, length, RANGE_RAM); + } return 0; } @@ -434,7 +401,7 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr), * * Check for the crashkernel reserved region in /proc/iomem, and return * true if it is present, or false otherwise. We use this to store the - * location of this region. + * location of this region, and system RAM regions. */ int is_crashkernel_mem_reserved(void) {