From patchwork Mon Jun 27 14:39:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 9200735 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 002A3607D3 for ; Mon, 27 Jun 2016 14:41:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA27D2804C for ; Mon, 27 Jun 2016 14:41:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEFD02859C; Mon, 27 Jun 2016 14:41:28 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 397CC2804C for ; Mon, 27 Jun 2016 14:41:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHXhp-0001bY-5j; Mon, 27 Jun 2016 14:40:09 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHXhl-0000LY-G8; Mon, 27 Jun 2016 14:40:05 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4EB802F; Mon, 27 Jun 2016 07:40:35 -0700 (PDT) Received: from e104818-lin.cambridge.arm.com (e104818-lin.cambridge.arm.com [10.1.203.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 986143F246; Mon, 27 Jun 2016 07:39:42 -0700 (PDT) Date: Mon, 27 Jun 2016 15:39:39 +0100 From: Catalin Marinas To: James Morse Subject: Re: [PATCH v20 04/14] arm64/kexec: Add core kexec support Message-ID: <20160627143939.GC6847@e104818-lin.cambridge.arm.com> References: <018ac873d87fbfc45185cdab91ebc8731f64f94c.1466702804.git.geoff@infradead.org> <57710B92.2080603@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <57710B92.2080603@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160627_074005_563424_C6C12052 X-CRM114-Status: GOOD ( 16.14 ) 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: Mark Rutland , Geoff Levand , kexec@lists.infradead.org, Will Deacon , AKASHI Takahiro , marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org 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 On Mon, Jun 27, 2016 at 12:18:42PM +0100, James Morse wrote: > On 23/06/16 18:54, Geoff Levand wrote: > > "Can't kexec: secondary CPUs are stuck in the kernel.\n" > > > + return -EBUSY; > > + } > > + > > > + if (num_online_cpus() > 1) { > > + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { > > + /* any_cpu as we don't mind being preempted */ > > + int any_cpu = raw_smp_processor_id(); > > + > > + if (cpu_ops[any_cpu]->cpu_die) > > + return 0; > > + } > > + > > + pr_err("Can't kexec: no mechanism to offline secondary CPUs.\n"); > > + return -EBUSY; > > + } > > This if() {} hunk isn't necessary with the version of cpus_are_stuck_in_kernel() > you have in patch 2. This logic is the '|| smp_spin_tables' part of that helper > function. (hibernate needed it too) I can make the changes locally but just to be clear I understand what you meant, here's the diff on top of Geoff's patch: ----8<------------------------- diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index 945ce326654c..bc96c8a7fc79 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -68,24 +68,9 @@ int machine_kexec_prepare(struct kimage *kimage) kexec_image_info(kimage); - if (kimage->type != KEXEC_TYPE_CRASH) { - if (cpus_are_stuck_in_kernel()) { - pr_err("Can't kexec: failed CPUs are stuck in the kernel.\n"); - return -EBUSY; - } - - if (num_online_cpus() > 1) { - if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { - /* any_cpu as we don't mind being preempted */ - int any_cpu = raw_smp_processor_id(); - - if (cpu_ops[any_cpu]->cpu_die) - return 0; - } - - pr_err("Can't kexec: no mechanism to offline secondary CPUs.\n"); - return -EBUSY; - } + if (kimage->type != KEXEC_TYPE_CRASH && cpus_are_stuck_in_kernel()) { + pr_err("Can't kexec: CPUs are stuck in the kernel.\n"); + return -EBUSY; } return 0; @@ -163,7 +148,7 @@ void machine_kexec(struct kimage *kimage) /* * New cpus may have become stuck_in_kernel after we loaded the image. */ - BUG_ON(cpus_are_stuck_in_kernel() && (num_online_cpus() > 1)); + BUG_ON(cpus_are_stuck_in_kernel() || (num_online_cpus() > 1)); reboot_code_buffer_phys = page_to_phys(kimage->control_code_page); reboot_code_buffer = phys_to_virt(reboot_code_buffer_phys);