Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1642917ybv; Sun, 23 Feb 2020 11:30:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxAlgHaC+ZQLcxRyupLFVif+vS1ehPEF8AMoVz+1GOEcxjnHxhMjz6WvwV4i07JZT6gWj1+ X-Received: by 2002:a05:6830:114c:: with SMTP id x12mr37652117otq.324.1582486226331; Sun, 23 Feb 2020 11:30:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582486226; cv=none; d=google.com; s=arc-20160816; b=0HEjHTHyaeRudpX5tTiU7akLIiIUb1eCwi+AhLSWWPgPv3OaXcGBGjhYC8GFnWNIYD unWohXhACYb7COyxCLkQg+NqyPpefUfNJPxb0d2ORbPLtc1PyEUN0Wasfvy1O+msMffu VmaDOxcBc4+xwgqB+wNr6IcxZl7l706+4TtAj9kIv3jju/l4TSzEA2OcaqMRcnW7liIg B3ReLQpwwx/CEYTq27I79JfXO+uyJ7zAltJgaXpzyRpyUOPqjEBfsqN+E9DYz/a+EmrM 5OL1To66EzBUCh5EvSYjrVIPYT2uhFwL8/BDEeyfJ2Wp30oW/DoUN+3fKx5+ySvFww6e +3kg== 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=9uXS+49tR8HsVkFepZHsRyCAKrj3ebDbpjQY9AIflS0=; b=nk00d3URcLa3L0B2AWnSkuf2Br8fT3L04RPZLIgpHVh6lEc+LyHIILbfhMSBxO5vvN EUezCyrOP/51rlJlhk1daHKBBs/VC1+Lnary5HjsXD6S6J3v3lG5a0g72lMr+MBZ6Tcd wRVy171aPNzt2kgs2/v6W2vK+6XJTkRGPOGssDVqUX5693F8aRphrRnoiOp1zSviv4KY g9JU12x45f8Cl+PaPLsBzfutFa+UH0czWKW0K1yc/9DHSLVKwxLGDjKQKCC8s4PyfUWX wSgiXeo/StaOeiAuZ7P94xcoGL43oqF4wZ/UEdzMdJF+L6kVQ8Q5ahH4o4AxPhsOHjnW gAdw== 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 n11si5194802otk.290.2020.02.23.11.30.14; Sun, 23 Feb 2020 11:30:26 -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 S1727235AbgBWTaE (ORCPT + 99 others); Sun, 23 Feb 2020 14:30:04 -0500 Received: from foss.arm.com ([217.140.110.172]:51348 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727201AbgBWTaD (ORCPT ); Sun, 23 Feb 2020 14:30:03 -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 0D69A30E; Sun, 23 Feb 2020 11:30:03 -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 B1E333F6CF; Sun, 23 Feb 2020 11:30:00 -0800 (PST) From: Qais Yousef To: Thomas Gleixner Cc: "Paul E . McKenney" , 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 v3 06/15] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu) Date: Sun, 23 Feb 2020 19:29:33 +0000 Message-Id: <20200223192942.18420-7-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223192942.18420-1-qais.yousef@arm.com> References: <20200223192942.18420-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 590963c9c609..5b73e92c99e3 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 64a246e9c8db..aebe8186cb07 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -93,6 +93,7 @@ int add_cpu(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 03c727195b65..bf39c5bfb6d9 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1275,6 +1275,30 @@ int add_cpu(unsigned int cpu) } EXPORT_SYMBOL_GPL(add_cpu); +/** + * 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