From patchwork Fri Jun 23 17:52:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 9807219 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 C67DF6086C for ; Fri, 23 Jun 2017 17:54:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B83D82865B for ; Fri, 23 Jun 2017 17:54:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACAF428760; Fri, 23 Jun 2017 17:54:43 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3350E2865B for ; Fri, 23 Jun 2017 17:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8qfMVN9wXFblwCJ7l6nUftzWeeDzz4JW9ybhxKexGxc=; b=oH/ITO/08A5TJK38UMze87kqjT /9uAqMAELJkQAvQKjHKT5Oz69YDVajWJZDgJ6m8gQXk/Q81PN/OeF7Mm/eaFxtkaYzqfJdw5sU0L1 GrhYJrWY0vXOT/657Lm3bgYHFPdxKEV6QIgyrHzdr5nWA6zZP74x474Fsrp12ifRSwNN3wauXhOob 7jhyyPDcPx+xpBvnVjpnDSqv/aCgcWSwO0FjPZKG5EesgIgQza8oVTWGSL40asc57SFoZK83rg5rs EGXdaed5iicXIZC8YS39pqjmEgMjAi4hMOvKB5Yl2lF7NiXGcJMCN62mx3m7Y+0uDT2gGMRxjs8HF QThMwMnQ==; 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 1dOSn2-0002bF-Gj; Fri, 23 Jun 2017 17:54:40 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dOSmI-00018M-IF for linux-arm-kernel@lists.infradead.org; Fri, 23 Jun 2017 17:53:56 +0000 Received: by mail-wr0-x241.google.com with SMTP id k67so14167917wrc.1 for ; Fri, 23 Jun 2017 10:53:34 -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=CRvZSVFg412jSQpr7dM4ByU8d9AtMLcD88xS/CGi+5E=; b=q8IdwVctgHZcizIuUMn4mlW9OudPZGTsrlBM1K111leq58tDn7PqJ+hGhFi33hEgLM WXAvGhHyJ6k+SZT2S/yM2XP+Kil6dvfHW7rQjq6WDCoDa/eIIkRuoBBLq9eeWR0M7dqL tfkdvmi2oUoRs7kPf2qjfhxBHvn07+xUTgkMSEf3QpDN8YR2r7N2w5zEdyp1jfXYgycE h8CAJtq2XNDq30bIuekDLga4K6f5psmj7Gy9AhefPodJy9ZezYLFutahtJgFs7oy5sDX BBQCkRfdj6O+RQe4FFKn5tJMxxeF32PWVrBI5hMF+qdGiicASF7ttSF5qBrSD9eJl/Zt aFAw== 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=CRvZSVFg412jSQpr7dM4ByU8d9AtMLcD88xS/CGi+5E=; b=OoQ1Xb1YrGStd41Y8YV1JUCyMx1nt3I+kTbXAnhqLq9JD2a+rHxajjTdgPl2gwLAxo aFaSV+RcspWNn+2tg0RXZrLTwLHZrDHaC4BS5zEtzkOcOb8V4f+2D6f8G4w/DEgpilQD uxmQ8LP35azZA19Es3cevbiqOs+kQZ3cSHheuAZz3we0iacRj+8JIFuWxSltHsXQCaB2 p0fLcFSIo20BRndE06UbrvEDY81FZ2P4LMm4kvCugdFDoKNDUETm/vyYG1ICtZIQV0NO k9GRCmD8UqInI4lj+wz4C3TDQ66R67wRxaiSh+G3NnsChLRLAc7X5HnQde69/qt4GHdq YkGQ== X-Gm-Message-State: AKS2vOwhkVrxM4DNhVpv87U1in0Dowoa3s9jRpJo+VM0Wah2PN2RLYn9 0HNwK4nb/3T+5XZBl1AALg== X-Received: by 10.223.147.132 with SMTP id 4mr7019120wrp.107.1498240412804; Fri, 23 Jun 2017 10:53:32 -0700 (PDT) Received: from fainelli-desktop.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id v2sm6201909wrb.68.2017.06.23.10.53.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2017 10:53:32 -0700 (PDT) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 6/7] ARM: B15: Register reboot notifier for KEXEC Date: Fri, 23 Jun 2017 10:52:26 -0700 Message-Id: <20170623175227.19743-7-f.fainelli@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170623175227.19743-1-f.fainelli@gmail.com> References: <20170623175227.19743-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170623_105354_847435_8A2F4930 X-CRM114-Status: GOOD ( 19.59 ) 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 , Catalin Marinas , Sebastian Andrzej Siewior , open list , Masahiro Yamada , Ingo Molnar , Christoffer Dall , Florian Fainelli , Russell King , "maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE" , Laura Abbott , Vladimir Murzin , Kees Cook , Pawel Moll , Marc Zyngier , opendmb@gmail.com, Gregory Fong , Doug Anderson , Thomas Gleixner , Mauro Carvalho Chehab , Anna-Maria Gleixner , Richard Cochran , Jonathan Austin , "Martin K. Petersen" , Greg Kroah-Hartman , Douglas Anderson , Andrew Morton , Brian Norris , "David S. Miller" 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 9ee1d89cced0..f76988790011 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);