From patchwork Fri Aug 31 07:30:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 964303 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 421rjS5lSCz9ryn for ; Fri, 31 Aug 2018 17:34:52 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rK6IkZ2p"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 421rjS463PzF38x for ; Fri, 31 Aug 2018 17:34:52 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rK6IkZ2p"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rK6IkZ2p"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 421rcy2CbxzF38W for ; Fri, 31 Aug 2018 17:30:57 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id p12-v6so5128845pfh.2 for ; Fri, 31 Aug 2018 00:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WyZt6pR7Usw98fARtpjcE0IK54BQMvDCQM9wkn2SRu0=; b=rK6IkZ2pAuQZLJApXEe0swnA8MgLJTg0sJSdgYGBdinFnYG0CRYhu3ZHlx9h4ud/BG 6kg/Ys1Kqdl4U2hLkeUDr8PfFwzmOlFfKU5tc17b2MH+jhhU/5zj3P0EgUfBReRZ09Uu K+8822U6DMjrJIlfMOCOA2eUjBmKyA48aFg5OeCWfV9EpQcyyEllqU3L7zSR8OAIJyvU efcKNAWNAweWobA31WK7+y/sf3TIPIyffUDwB4BTt9NEjITiXjkmi6CweWGXsJPORfit cv3EDDAVk7M8fLD/Sf21VjUekZkzWf1Oow2v/kciureP27riBRKrZfvzEpnm480p9i0i HUvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WyZt6pR7Usw98fARtpjcE0IK54BQMvDCQM9wkn2SRu0=; b=RHsDt/rzERF9yKqyv63zStXmasOhIce44vsh4crNObGwirAGYwl1E6C9bFSjaGYlEz Rwyq5TJEQbiCT17uKfRxbH+VpLhpntlNkG1p9w+oxMge2aeaLd1PITgtECkw9ItAZtrQ wG/3QtyhZ149M/yaOAi1FtFVKC/eD7RgotOGaLiwWLQ1OWOQQK6kV0z+SZpoqLmD/Lqi PdyFLYNgfDDihNCXXb/RVwo0pFBHtRFwVDe0j74Pt/ZYNPrQLp8Q8huH41RCYekXdp/3 QBBA8L1zj/7H0oizQOx49A9Ljiu2Elx9TzMyqghTqn6dbwX6tZIYAEU7zQ28qaCT7HPk yAyQ== X-Gm-Message-State: APzg51De7quyHaK1SiyCZSj88xcfbFNB14Ycu1z0EzwvfIObxGhvDJ6B nxkpOkKXTdLsoXrhuzRwj95X6bI= X-Google-Smtp-Source: ANB0VdbTMpVIyD2EKwMdw/nIDYTqeCrl4SolGuI++VqjfYTikYOIDPFG+/Z9lPUZ0NdnUzPNVjrY2g== X-Received: by 2002:a63:60c1:: with SMTP id u184-v6mr13141334pgb.266.1535700653428; Fri, 31 Aug 2018 00:30:53 -0700 (PDT) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id h190-v6sm23358156pge.18.2018.08.31.00.30.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 00:30:52 -0700 (PDT) From: Pingfan Liu To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/2] powerpc/prom: move mmu_early_init_devtree() before early_init_dt_scan_cpus() Date: Fri, 31 Aug 2018 15:30:22 +0800 Message-Id: <1535700623-23750-2-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535700623-23750-1-git-send-email-kernelfans@gmail.com> References: <1535700623-23750-1-git-send-email-kernelfans@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Pingfan Liu , Anton Blanchard , Hari Bathini Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" In early_init_dt_scan_cpus() -> allocate_paca(), using ppc64_bolted_size() to get the limitation. Although MMU_SEGSIZE_256M is enough for boot cpu's paca, but in fact the bolted segment size may be MMU_SEGSIZE_1T. Hence moving mmu_early_init_devtree() a little earlier, and let any callers of ppc64_bolted_size() get the right value. Signed-off-by: Pingfan Liu Cc: Benjamin Herrenschmidt Cc: Michael Ellerman Cc: Hari Bathini Cc: Mahesh Salgaonkar Cc: Anton Blanchard --- arch/powerpc/kernel/prom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index c4d7078..cae4a78 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -760,6 +760,7 @@ void __init early_init_devtree(void *params) DBG("Scanning CPUs ...\n"); dt_cpu_ftrs_scan(); + mmu_early_init_devtree(); /* Retrieve CPU related informations from the flat tree * (altivec support, boot CPU ID, ...) @@ -777,8 +778,6 @@ void __init early_init_devtree(void *params) spinning_secondaries = boot_cpu_count - 1; #endif - mmu_early_init_devtree(); - #ifdef CONFIG_PPC_POWERNV /* Scan and build the list of machine check recoverable ranges */ of_scan_flat_dt(early_init_dt_scan_recoverable_ranges, NULL); From patchwork Fri Aug 31 07:30:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 964304 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 421rm64jyHz9ryn for ; Fri, 31 Aug 2018 17:37:10 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="azPG6/nD"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 421rm63BDxzF35K for ; Fri, 31 Aug 2018 17:37:10 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="azPG6/nD"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="azPG6/nD"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 421rd01sqnzF38S for ; Fri, 31 Aug 2018 17:31:00 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id j26-v6so5108104pfi.10 for ; Fri, 31 Aug 2018 00:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nMayo02jTxXpAFY03AkG1kql8qrHdm9/TQH+370x740=; b=azPG6/nDq0OLAGW3kcMeYkZ5Y5kicbS1aPHyLAWTAoTVAoC2VN4h980t1bY2g1mrpf 2jklxolUL8FX6vUyy6AaEK9KZwMheWjh5/9saipC9vPIAk8reulGXaSeIyZszYDfsDM5 zVOP5ElOk5VBjmUBOGGsXaSuM9HMg4uBYDLUjmFZfgBxrrU0PQsStwFrWEqTjQoXLS8m o1i1R+6EzIsAjphIJUqC7BGwqjkbjlRRxlb57cW/PeGAgvaJCZqBsxUVs1iLQVMk8b21 xUY5+wfJpyX3ARvfxB/PfDsT6xQvT/wcsJoVQgwu9RAhkxmaZ9QRu37JfneSJtTS+T3K MVow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nMayo02jTxXpAFY03AkG1kql8qrHdm9/TQH+370x740=; b=enxEAnmOU1mGCv3Y1vhT7aG0zFcBqn7uTT5RwW2jOwTSLG+FSr69VJwx92+bUJUOGr V3cINhCRBQTe3VWWL+dxwx1OCz1/VcPh//G1fe30wM8LMCA+q/XTUKdtLgEUA586cTy6 DuG8oo6H+fw+G6GIM6H28sN42ZULfLU177fDrnhUR3iejPhq8Vaf+82O13yrBuWYwbbE wuK51wcr+d/EdFNGyNtaA5p9CsZhGkyc4So4Vk+yJ26EKOkHgklvm+ibaQ1BKNaMWYhk vlMMzPyqbISB0nXjoZQVm871oLxj9RcSjorGzBduJV67gjunx57D2sUN0rRLVTk4qxhi MM5w== X-Gm-Message-State: APzg51BNT+3wnnKu+tMFSUyLbcjZFEpqMI5hKQPDbjiFv1kXX7PkV/TF v8lYzG0vptvD8aFdTxUFs/WwWfI= X-Google-Smtp-Source: ANB0VdZTFbg6/MO/EttfRoV8Lwqy0ydcvH3WgyiJE0YKVhZ6ImLvQWdjsHbCGtT8FtNVjS3HxzSR/g== X-Received: by 2002:a63:a011:: with SMTP id r17-v6mr13245206pge.166.1535700658330; Fri, 31 Aug 2018 00:30:58 -0700 (PDT) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id h190-v6sm23358156pge.18.2018.08.31.00.30.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 00:30:57 -0700 (PDT) From: Pingfan Liu To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/2] powerpc/kexec: avoid hard coding when automatically allocating mem for crashkernel Date: Fri, 31 Aug 2018 15:30:23 +0800 Message-Id: <1535700623-23750-3-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535700623-23750-1-git-send-email-kernelfans@gmail.com> References: <1535700623-23750-1-git-send-email-kernelfans@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Pingfan Liu , Anton Blanchard , Hari Bathini Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" If no start address is specified for crashkernel, the current program hard code as: crashk_res.start = min(0x8000000ULL, (ppc64_rma_size / 2)); This limits the candidate memory region, and may cause failure while there is enough mem for crashkernel. This patch suggests to find a suitable mem chunk by memblock_find_in_range() Signed-off-by: Pingfan Liu Cc: Benjamin Herrenschmidt Cc: Michael Ellerman Cc: Hari Bathini Cc: Mahesh Salgaonkar Cc: Anton Blanchard --- arch/powerpc/kernel/machine_kexec.c | 24 +++++++++++++++--------- arch/powerpc/kernel/prom.c | 7 +++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c index 63f5a93..78005bf 100644 --- a/arch/powerpc/kernel/machine_kexec.c +++ b/arch/powerpc/kernel/machine_kexec.c @@ -22,6 +22,9 @@ #include #include #include +#include + +#include "setup.h" void machine_kexec_mask_interrupts(void) { unsigned int i; @@ -117,6 +120,7 @@ void machine_kexec(struct kimage *image) void __init reserve_crashkernel(void) { unsigned long long crash_size, crash_base; + phys_addr_t start, up_boundary; int ret; /* use common parsing */ @@ -146,22 +150,24 @@ void __init reserve_crashkernel(void) #else if (!crashk_res.start) { #ifdef CONFIG_PPC64 - /* - * On 64bit we split the RMO in half but cap it at half of - * a small SLB (128MB) since the crash kernel needs to place - * itself and some stacks to be in the first segment. - */ - crashk_res.start = min(0x8000000ULL, (ppc64_rma_size / 2)); + up_boundary = min(ppc64_bolted_size(), ppc64_rma_size); + start = memblock_find_in_range(KDUMP_KERNELBASE, up_boundary, + crash_size, PAGE_SIZE); + if (start == 0) { + pr_err("Failed to reserve memory for crashkernel!\n"); + crashk_res.start = crashk_res.end = 0; + return; + } else + crashk_res.start = start; #else crashk_res.start = KDUMP_KERNELBASE; #endif } - crash_base = PAGE_ALIGN(crashk_res.start); - if (crash_base != crashk_res.start) { + if (crashk_res.start != PAGE_ALIGN(crashk_res.start)) { printk("Crash kernel base must be aligned to 0x%lx\n", PAGE_SIZE); - crashk_res.start = crash_base; + crashk_res.start = PAGE_ALIGN(crashk_res.start); } #endif diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index cae4a78..8b2ab99 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -688,6 +688,7 @@ static void tm_init(void) { } void __init early_init_devtree(void *params) { phys_addr_t limit; + bool fadump_enabled = false; DBG(" -> early_init_devtree(%p)\n", params); @@ -737,9 +738,9 @@ void __init early_init_devtree(void *params) * If we fail to reserve memory for firmware-assisted dump then * fallback to kexec based kdump. */ - if (fadump_reserve_mem() == 0) + if (fadump_reserve_mem() == 1) + fadump_enabled = true; #endif - reserve_crashkernel(); early_reserve_mem(); /* Ensure that total memory size is page-aligned. */ @@ -761,6 +762,8 @@ void __init early_init_devtree(void *params) dt_cpu_ftrs_scan(); mmu_early_init_devtree(); + if (!fadump_enabled) + reserve_crashkernel(); /* Retrieve CPU related informations from the flat tree * (altivec support, boot CPU ID, ...)