Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2759790ybc; Mon, 25 Nov 2019 03:48:32 -0800 (PST) X-Google-Smtp-Source: APXvYqxdxfoc0Z1snd62UUwES8Djz+OONBVyxgtlv2PUnom83coXXujJ1FQrSYDn446AhWndztzc X-Received: by 2002:a17:906:ce2f:: with SMTP id sd15mr37910963ejb.270.1574682511962; Mon, 25 Nov 2019 03:48:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574682511; cv=none; d=google.com; s=arc-20160816; b=iIo4UC08TsIV34IxUbudecHHD/TdMHEvLnNOtazWiiE8U+T1j6iQDPU+US2p8qifSE 0NzLRHi7iewQrrBcnlafaA/bQBu03SB0x2IpHxnjfz/zlEhVSUkGIKuWEA3jc9l4CA99 LPYdxOdNB+HE+gFK3MClX0rjbozTIWcLPEPGr0Ryf3SxMt2kdVxVIEmyjoAx5Gxi/HJz c+kZDUDrEpKdDxvq+/yNNGtsh3t4r95dgGNvPTKPiU9UpqTATvOU8EqdDoT1wfiLWGf+ 3Zs/jAEqjLNICeiQCSUFK2WCsZ3tVqbphsfm/Uod9iFVl6Wp4vwXIhZuXjZ+xJGmBBcp pUFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=uLe/hexxT9ao1Ww9Rk6EjZg2t5mzK36dIZQ/h+NPJVM=; b=vSfZ9HPIqWX62Ck16M4CuT8BAMih8IjwrgQS9xlUvBUQfCZSzZkdApurVo0IgemHPP wN9RxJwtgf46FA1QAUHu9tfnFqW2V/PWzSuYUeSxV0WgENJ3HBHhnSuyw9K7iepBxAST IboqndHELYprTMt7UWKwUMrd0L/Y9kWXWYIGXVdqfNFmgzK3umWD6zYl5syTwH35N8sz B6C636BL6VkycnALanTJhyZYpjdGnOJC9sA+eO1Cq3BIZ/tpzyMmJggrgyOZGIwBK7CG PWkXz9R5o/XZq0vhelovpldBG3yUfK+/lgWB13QqntJwwZfTVAB59N5kHL+PwHo+qotW 459A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z24si5048565edd.127.2019.11.25.03.48.07; Mon, 25 Nov 2019 03:48:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727751AbfKYL2N (ORCPT + 99 others); Mon, 25 Nov 2019 06:28:13 -0500 Received: from foss.arm.com ([217.140.110.172]:48954 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727722AbfKYL2M (ORCPT ); Mon, 25 Nov 2019 06:28:12 -0500 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 B3A8E1396; Mon, 25 Nov 2019 03:28:11 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 67C593F52E; Mon, 25 Nov 2019 03:28:09 -0800 (PST) From: Qais Yousef To: Thomas Gleixner , Greg Kroah-Hartman Cc: Qais Yousef , Catalin Marinas , Will Deacon , Steve Capper , Richard Fontana , James Morse , Mark Rutland , Josh Poimboeuf , Ingo Molnar , "Peter Zijlstra (Intel)" , Nicholas Piggin , Daniel Lezcano , Jiri Kosina , Pavankumar Kondeti , Zhenzhong Duan , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 04/14] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu) Date: Mon, 25 Nov 2019 11:27:44 +0000 Message-Id: <20191125112754.25223-5-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191125112754.25223-1-qais.yousef@arm.com> References: <20191125112754.25223-1-qais.yousef@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to make cpu_up/down private - move the user in arm64 hibernate.c to use a new generic function that provides what arm64 needs. Signed-off-by: Qais Yousef CC: Catalin Marinas CC: Will Deacon CC: Steve Capper CC: Richard Fontana CC: James Morse CC: Mark Rutland CC: Thomas Gleixner CC: Josh Poimboeuf CC: Ingo Molnar CC: "Peter Zijlstra (Intel)" CC: Nicholas Piggin CC: Daniel Lezcano CC: Jiri Kosina CC: Pavankumar Kondeti CC: Zhenzhong Duan CC: linux-arm-kernel@lists.infradead.org CC: linux-kernel@vger.kernel.org --- arch/arm64/kernel/hibernate.c | 13 +++++-------- include/linux/cpu.h | 1 + kernel/cpu.c | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index a96b2921d22c..8ae348107f97 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -166,14 +166,11 @@ int arch_hibernation_header_restore(void *addr) sleep_cpu = -EINVAL; return -EINVAL; } - if (!cpu_online(sleep_cpu)) { - pr_info("Hibernated on a CPU that is offline! Bringing CPU up.\n"); - ret = cpu_up(sleep_cpu); - if (ret) { - pr_err("Failed to bring hibernate-CPU up!\n"); - sleep_cpu = -EINVAL; - return ret; - } + + ret = bringup_hibernate_cpu(sleep_cpu); + if (ret) { + sleep_cpu = -EINVAL; + return ret; } resume_hdr = *hdr; diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 8229932fb053..f05168b49fab 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -92,6 +92,7 @@ int cpu_up(unsigned int cpu); void notify_cpu_starting(unsigned int cpu); extern void cpu_maps_update_begin(void); extern void cpu_maps_update_done(void); +extern int bringup_hibernate_cpu(unsigned int sleep_cpu); #else /* CONFIG_SMP */ #define cpuhp_tasks_frozen 0 diff --git a/kernel/cpu.c b/kernel/cpu.c index 94055a0d989e..9610442c8dbc 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1221,6 +1221,30 @@ int cpu_up(unsigned int cpu) } EXPORT_SYMBOL_GPL(cpu_up); +/** + * bringup_hibernate_cpu - Bring up the CPU that we hibernated on + * @sleep_cpu: The cpu we hibernated on and should be brought up. + * + * On some archs like arm64, we can hibernate on any CPU, but on wake up the + * CPU we hibernated on might be offline as a side effect of using maxcpus= for + * example. + */ +int bringup_hibernate_cpu(unsigned int sleep_cpu) +{ + int ret; + + if (!cpu_online(sleep_cpu)) { + pr_info("Hibernated on a CPU that is offline! Bringing CPU up.\n"); + ret = cpu_up(sleep_cpu); + if (ret) { + pr_err("Failed to bring hibernate-CPU up!\n"); + return ret; + } + } + + return 0; +} + #ifdef CONFIG_PM_SLEEP_SMP static cpumask_var_t frozen_cpus; -- 2.17.1