From patchwork Mon Jan 17 12:31:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Adamski X-Patchwork-Id: 12715392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD24CC433F5 for ; Mon, 17 Jan 2022 12:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=1mKhUZuilVuitz2PP0LsdXg/C3R1i7I/hnuTRnEhmP8=; b=n5f0Hr+eqCURpc L5XLVIReF520ycTZ38Cf1SOf8bkm5pg+84W/GZF6F1aJOw0Irc9G1Ag0kay+5ca+l654wbHf+5RSN ugm82mUu/o4Sw5Upd2Z73KcmuZOxVocDycLuhLixWjhG05gV0ezZmg9qHN0NSD7AV7rBrxQwAHJ50 IUVz8DJDkiHazbjDizuQ0pBCH1xjtWVk3NKc9Javi0iBAXTtmDHtgb94bL4cwP4EHV6RFX1v9W+Fk 3GeOwjtXbDfgi0/3EYo5x3tfmd5WdtcoLbx461KfQe3reWmn/mx+hMFZbODrbXCZBFQE47nFzsa92 gkfcBEG5YoC2gY0ALHeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9RB6-00Eua5-Iw; Mon, 17 Jan 2022 12:32:04 +0000 Received: from mail-eopbgr150111.outbound.protection.outlook.com ([40.107.15.111] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9RB3-00EuYv-Nn for linux-arm-kernel@lists.infradead.org; Mon, 17 Jan 2022 12:32:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lthlrqE5Y7CcpeXlFcDE0PCkJW0plXujOt4hMgk8ZlzXdBlczIl2o4j0HfQj1NSRl81HT9KsSI+wWM/KDwkKy9MjHhqkDMWqyPEhSAT7WqF/abDUqqvEKJPtiJSIG7RGqIBF1TzzCd6KxqTYm3LYvFlY7hYlmiGVdU/yV6XvKPVXJBFoE0FmSH65T/+SsWmMIPiaej92iddRewyeLjbkE95mXphzf/GU3R0rUMl2C+/DSrxcCCzgHQk2UbZfwziKlaqIASbpmftD7K8EVrUNCCvAJ0Tl8kfXGiWg9o2F/bXoaMk2DCa6TXpqxt4NfTT5vdWgldzmHw37ZoUoxvBwXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I+kEUzMyFSNYAqmM/r4OPnrALCI2DqAOoZADFyWoQCw=; b=iuCpADTGnP+fIiwGSSPm2HEaw9FDTv1kqORbngtJ0qYCkrVXDCIojxW0gSaX57jqGvQMEw0nWuxIQ8QwdDBTXOVQUKf5EgyAymqshf0JujvrgfLrLQdrvCcgBFVFT5J2DT/w3YKXscLj5cxgXvQY3/i5Lq8xa+S6RPNuGEjBX6/iPwKQPBajljenc/fUJu75wcxgXW0coHx/PobpYNEVwqgEtmI7e/9BSr8OO1snWcG7k6fU5g2elkQDciRGBsElrhf0Lm2b5eESnw9jAGAthubPuA9FGV5o0JwKLPsIHcXwmwoVqgI23vJa2qV463j1JmR5MzqgbMIjTsiIdG6HsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I+kEUzMyFSNYAqmM/r4OPnrALCI2DqAOoZADFyWoQCw=; b=wDGM26sowF5HC1ce6wJ+H/yuBlCH0fBMEsJ+B9ni7IALEkmyqbdkwDl/3I5wzG0OlS678slRpZz+BfSGKWkhLkBpsA6Noj6zQykLwlfbr2q6GFdDzy2kk8S6dNg5ZsGve+txY/iEm6Ao2tn2zNDwq3pixPPfG/KPJskBuLv9Sp8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from DU2PR07MB8110.eurprd07.prod.outlook.com (2603:10a6:10:239::15) by AM6PR0702MB3733.eurprd07.prod.outlook.com (2603:10a6:209:6::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.5; Mon, 17 Jan 2022 12:31:56 +0000 Received: from DU2PR07MB8110.eurprd07.prod.outlook.com ([fe80::9d2:7ba2:9045:2acf]) by DU2PR07MB8110.eurprd07.prod.outlook.com ([fe80::9d2:7ba2:9045:2acf%5]) with mapi id 15.20.4909.007; Mon, 17 Jan 2022 12:31:56 +0000 Date: Mon, 17 Jan 2022 13:31:48 +0100 From: Krzysztof Adamski To: Catalin Marinas , Will Deacon , Mark Rutland , Peter Collingbourne , Guenter Roeck , Wolfram Sang Cc: Alexander Sverdlin , Matija Glavinic-Pecotic , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arm64: move efi_reboot to restart handler Message-ID: Content-Disposition: inline X-ClientProxiedBy: HE1PR05CA0249.eurprd05.prod.outlook.com (2603:10a6:3:fb::25) To DU2PR07MB8110.eurprd07.prod.outlook.com (2603:10a6:10:239::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 439ddfb7-a3bc-48e4-9181-08d9d9b55954 X-MS-TrafficTypeDiagnostic: AM6PR0702MB3733:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AslyZjrF0dpWvrKltpzKPWM1UKJZqXfnOtJRrUv85qZe0jrR4r4FpPMF3Xq0a/NBI9phja7Sho+xCJ64krcXwJYyNoieo7UuAj+EM2u4ea//HD42/Hd25ukGX6jOpHmKhzeu3BGI0cci7PNQEPvAlMclfIx2egmsApRTg5GjqQHpjtDa1IL3d5b8dcjlz1ABMmSo69SPhkueRVA7UU5yOA/WXMBDOKxTeX5i7jBIh1YmObDfFi4LZ8I/ER4NIy0TRzWPu11T+IZsXg/b66KHQpplu3cJm9RONN/THXXzxtGcRJVPoqV+5Sdm63PHba6F2r6SBUxYMtRlyZ/XOP4UQ2UnBhjkrThUJjUht0Y86qIL+sCj0E/cKB3PyFaetC27eDkasGw9tmhhjMRJteR1jYMFKtqlQiVcvMHH/2tJGeN/QPuLDxCUcMV4GNmvMcAYTvXXsp3vxnGs5MIpoJUVcyIha/idbzOeUw9Xp4PEJ20QIK8gUmnG7D2f1B6OVPzRUN1cXmYALS0ngq21KXJO0bkLiw3fWZe8giSbFhxzVsUGJ8yYX0wHeXUcvbO8rGamCzMVEAOXK6mtrUfZcbpg6/+lX5H33neO12BY4G2Xub+J8IrkZShDaFbRjgThlSqMiUQ7vxgEy9cc/118isQ+NfZ23X+IYKBITsyvPZmZmM6XM3vWB9aXpBXDp/Tv/QBUhtd6nxpjLq4FS7mlMYep8TW6vKXkE0BBRnYVUPrcO+eBkyQpRULIsR/YN6+aQrz8 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR07MB8110.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(86362001)(8936002)(110136005)(54906003)(4326008)(44832011)(8676002)(82960400001)(38100700002)(38350700002)(66946007)(6486002)(316002)(66476007)(66556008)(5660300002)(6666004)(6512007)(52116002)(26005)(186003)(6506007)(508600001)(2906002)(9686003)(83380400001)(20210929001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zh/7goIifNe4V+qcypBkJ+eRwJyzWMKRho0TPrMtTLvdPkA9qR07mnf7O7KqpY4d4iBGgSSR6MfiWFanhRynmIwticGiHmkcIadQLQtBek+8FEqqwutHN4XrhyMgWyp/hge3F7sfBbqMhObcByBZCYGtJo5tYcZgdsXz7V0sqwUCFTttjk+Ah8ql9xAfGWQJOQtSYiber5dhAsGrzJQ9XLOcVQEZalxhDkY7Nz17kIWk6L526V9k62gVC9AalBRcs78m+fhpoM32UB0D2CEfVx03HyjNVo8Fcg2NOhWHkYBDcr9/7zopa6/7fDSV/bXdtb2B2Hl37zKXqev9IuKkcteeKK4dekmnYjurcnp2GdQH9jcw5zi2iP2oOiuDB2QyCdgCx+iZ89ME1I1OxA6Xm7GTCZMnG4zq3hjk2YHkDaU95Gk1UmOYbloK2Fx+4Cq/P8ZRDPljU9+8ds9cHcZiElBpUpcS9MDgR5IQexvKO3KuIqX9bRjMpiHQko1/NMBgXH6+EtgC4hib3p4Ei+yQiBJsSPzXFejvxJMhlpeloz4QbI/0ziiM0EG4CikaVlg+y21RPLV6/6JChajXYzyS9We9gypfMldysKaYE/shgmyxuPbNE5fNJTPnho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change-CrossTenant-Network-Message-Id: 439ddfb7-a3bc-48e4-9181-08d9d9b55954 X-MS-Exchange-CrossTenant-AuthSource: DU2PR07MB8110.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2022 12:31:56.3314 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: frZxoZlsMeD5Ku2X59xTlLegN2A75ggAF7Jv/Z2E4u3yv1LSvpWGhO1x6dkUAqIcw20CunUKLYbp9RoktJK/4mxbXQk16+UsHSZua7m4/tY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0702MB3733 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220117_043201_846668_BD0BAF64 X-CRM114-Status: GOOD ( 15.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On EFI enabled arm64 systems, efi_reboot was called before do_kernel_restart, completely omitting the reset_handlers functionality. By registering efi_reboot as part of the chain with slightly elevated priority, we make it run before the default handler but still allow plugging in other handlers. Thanks to that, things like gpio_restart, restart handlers in watchdog_core, mmc or mtds are working on those platforms. The priority 129 should be high enough as we will likely be the first one to register on this prio so we will be called before others, like PSCI handler. Signed-off-by: Krzysztof Adamski Reviewed-by: Alexander Sverdlin --- arch/arm64/kernel/process.c | 7 ------- arch/arm64/kernel/setup.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 5369e649fa79..b86ef77bb0c8 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -130,13 +130,6 @@ void machine_restart(char *cmd) local_irq_disable(); smp_send_stop(); - /* - * UpdateCapsule() depends on the system being reset via - * ResetSystem(). - */ - if (efi_enabled(EFI_RUNTIME_SERVICES)) - efi_reboot(reboot_mode, NULL); - /* Now call the architecture specific reboot code. */ do_kernel_restart(cmd); diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index f70573928f1b..5fa95980ba73 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -298,6 +299,24 @@ u64 cpu_logical_map(unsigned int cpu) return __cpu_logical_map[cpu]; } +static int efi_restart(struct notifier_block *nb, unsigned long action, + void *data) +{ + /* + * UpdateCapsule() depends on the system being reset via + * ResetSystem(). + */ + if (efi_enabled(EFI_RUNTIME_SERVICES)) + efi_reboot(reboot_mode, NULL); + + return NOTIFY_DONE; +} + +static struct notifier_block efi_restart_nb = { + .notifier_call = efi_restart, + .priority = 129, +}; + void __init __no_sanitize_address setup_arch(char **cmdline_p) { setup_initial_init_mm(_stext, _etext, _edata, _end); @@ -346,6 +365,8 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p) paging_init(); + register_restart_handler(&efi_restart_nb); + acpi_table_upgrade(); /* Parse the ACPI tables for possible boot-time configuration */