From patchwork Wed Jan 18 20:29:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 9524709 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 1F3316020B for ; Wed, 18 Jan 2017 20:32:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D308285D4 for ; Wed, 18 Jan 2017 20:32:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00DE32861F; Wed, 18 Jan 2017 20:32:32 +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_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E7CE285D4 for ; Wed, 18 Jan 2017 20:32:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cTwuA-0008A6-FC; Wed, 18 Jan 2017 20:32:26 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTwsx-0005vr-5E for linux-arm-kernel@lists.infradead.org; Wed, 18 Jan 2017 20:31:14 +0000 Received: by mail-pg0-x243.google.com with SMTP id t6so2179744pgt.1 for ; Wed, 18 Jan 2017 12:30:51 -0800 (PST) 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=PqBN60LO+w7G0yVXVqMEav/ikbIMfviDpVjyOuLkZZE=; b=mi3Q9i62mN6LNMdHMnQdejgC+v7BXuQi1uYxOdzjztE7AD5/xBEQDRT0g0iCkpylQL Q+20J0J8RMf9gh81kmysBzy74CAkCdv29B3CwdIg8KS/+N3e9IH9dYL3CshJ8WklXTdD 2CmT206i8E0DWAeFRvkq4aK/5n3wfCGrXQENh4qHrAvThDqR1HXmMOyCFSi2SM940pnt uMNc/kkO2MHhCE9aXa+at5nyfTNjS8juPfFzMAtBd9tbNfN5EuMHyKjvQCZbTbKYrQ9R hEo2PtIdCHMIk64Bb3l6/3wudBxsoaZQNJVdk1005Q4e5oZ+RoXvjVeoLuj/6ZOHibks ikvw== 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=PqBN60LO+w7G0yVXVqMEav/ikbIMfviDpVjyOuLkZZE=; b=sQStBu3dm96UAbwLBG3Et+cn6Dr11o1u/O+RQnNnGH+g8FjBvMqUUPHcXuo6kGh3lw sGV5da01u0c8wppcJQYjjfkV4b6KZuw3X5q5Qic5jgwg1gpyBJm/ShcKMVVLbK/BPxFm KOhzDxNraKT64USocJMvifDA9TYUcWCDpN3ymhcrLWSNYifZuDvOJnmPVy9+EDyoGhgO cdf6ci3HxwHz1wOsgR1UUO7jzMwJx4cVfL7OwgLpcXwYUKGY9+lSLk3IZSi/F14c2fHQ gPbQBiXXlDCml4OBpwEWduwoxriDbAlHB56qg/ILjTxU7sgARysKfMuoEfS63o5w5n7y dKgA== X-Gm-Message-State: AIkVDXICVsMoRCQcLMZZotFX98j3MhgSQkH9Dph/9DoiXOz/kUi3AuVdZw8LiYFFrtIvdw== X-Received: by 10.84.141.164 with SMTP id 33mr7794018plv.86.1484771450939; Wed, 18 Jan 2017 12:30:50 -0800 (PST) Received: from fainelli-desktop.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id f65sm2860415pfk.5.2017.01.18.12.30.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jan 2017 12:30:49 -0800 (PST) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 6/7] ARM: B15: Register reboot notifier for KEXEC Date: Wed, 18 Jan 2017 12:29:25 -0800 Message-Id: <20170118202927.28740-7-f.fainelli@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170118202927.28740-1-f.fainelli@gmail.com> References: <20170118202927.28740-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170118_123111_407171_81F29BA1 X-CRM114-Status: GOOD ( 18.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Vladimir Murzin , Jonathan Austin , Nicolas Pitre , Sebastian Andrzej Siewior , will.deacon@arm.com, Russell King , open list , Florian Fainelli , "maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE" , Zhaoxiu Zeng , Thomas Gleixner , Anna-Maria Gleixner MIME-Version: 1.0 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 During kexec, we will go through kernel_kexec() -> syscore_suspend() if CONFIG_KEXEC_JUMP is set, if not, down the road we end-up calling kernel_restart_prepare() which invokes reboot notifiers with SYS_RESTART. We register a reboot notifier to make sure that the B15 read-ahead cache is disabled, since it is another level of instruction and data cache, and we want to avoid any potential side effects with booting a new kernel with such a cache still turned on. Signed-off-by: Florian Fainelli --- arch/arm/mm/cache-b15-rac.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/arm/mm/cache-b15-rac.c b/arch/arm/mm/cache-b15-rac.c index ef5e93e4b5c2..148d51fdfc3d 100644 --- a/arch/arm/mm/cache-b15-rac.c +++ b/arch/arm/mm/cache-b15-rac.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -151,6 +152,29 @@ static void b15_rac_enable(void) __b15_rac_enable(enable); } +static int b15_rac_reboot_notifier(struct notifier_block *nb, + unsigned long action, + void *data) +{ + /* During kexec, we are not yet migrated on the boot CPU, so we need to + * make sure we are SMP safe here. Once the RAC is disabled, flag it as + * suspended such that the hotplug notifier returns early. + */ + if (action == SYS_RESTART) { + spin_lock(&rac_lock); + b15_rac_disable_and_flush(); + clear_bit(RAC_ENABLED, &b15_rac_flags); + set_bit(RAC_SUSPENDED, &b15_rac_flags); + spin_unlock(&rac_lock); + } + + return NOTIFY_DONE; +} + +static struct notifier_block b15_rac_reboot_nb = { + .notifier_call = b15_rac_reboot_notifier, +}; + #ifdef CONFIG_HOTPLUG_CPU /* The CPU hotplug case is the most interesting one, we basically need to make * sure that the RAC is disabled for the entire system prior to having a CPU @@ -191,6 +215,12 @@ static void b15_rac_enable(void) /* Running on the dying CPU */ static int b15_rac_dying_cpu(unsigned int cpu) { + /* During kexec/reboot, the RAC is disabled via the reboot notifier + * return early here. + */ + if (test_bit(RAC_SUSPENDED, &b15_rac_flags)) + return 0; + spin_lock(&rac_lock); /* Indicate that we are starting a hotplug procedure */ @@ -207,6 +237,12 @@ static int b15_rac_dying_cpu(unsigned int cpu) /* Running on a non-dying CPU */ static int b15_rac_dead_cpu(unsigned int cpu) { + /* During kexec/reboot, the RAC is disabled via the reboot notifier + * return early here. + */ + if (test_bit(RAC_SUSPENDED, &b15_rac_flags)) + return 0; + spin_lock(&rac_lock); /* And enable it */ @@ -272,6 +308,13 @@ static int __init b15_rac_init(void) goto out; } + ret = register_reboot_notifier(&b15_rac_reboot_nb); + if (ret) { + pr_err("failed to register reboot notifier\n"); + iounmap(b15_rac_base); + goto out; + } + #ifdef CONFIG_HOTPLUG_CPU ret = cpuhp_setup_state_nocalls(CPUHP_AP_ARM_CACHE_B15_RAC_DEAD, "arm/cache-b15-rac:dead", @@ -308,6 +351,7 @@ static int __init b15_rac_init(void) out_cpu_dead: cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CACHE_B15_RAC_DYING); out_unmap: + unregister_reboot_notifier(&b15_rac_reboot_nb); iounmap(b15_rac_base); out: of_node_put(dn);