Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2729283pxb; Mon, 31 Jan 2022 03:04:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyKQOy71stPwuJoeMMe5lO3sUpUAmzt58JbMx3aRGN3Sir29wpY2Q2W2vswQMvAIo996Mv X-Received: by 2002:a62:1643:: with SMTP id 64mr19541477pfw.55.1643627096726; Mon, 31 Jan 2022 03:04:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643627096; cv=pass; d=google.com; s=arc-20160816; b=Jzht4X63F561TQ8dlFHWq8mup6Cps7GV5TmK5rnkj92LBRW8NHJ0cWEWjcu/XdtK7d emwUS2vm6Sd0BBSXFsZpt3b1fYtFb/4TIDuv+JpZc1UPxQNB/hYxu1AcmP9nAqTI7gm/ Fk2FylmES/k0XkYlaeaD+FGjKJdE/gWOw9F1PLLajWAbo//GiFCnaxtsIpGCQ1jX44v4 idxYX23y+YqgsGbfTVw0X/2/o5YYm4wOF9hec6+zbF+3mkJ90bG8WcNd/Rt2vjR1aepu Xem5YunUpD7vtcOMAmTEzm8lOKII+zPu2KpONU5qx73r9hF3UgcGbO0F8qQgm9BNHdvk Y6VQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-disposition:message-id :subject:cc:to:from:date:dkim-signature; bh=Xn1jHAIEAchzovuvuO0ffAC0y73Af6z9jQa8ClpwsUQ=; b=Y/solFqZ82Sz17MbEXONMCX225lTexfLHFgNHl/G0483O0pPXp9CrpV9EzF5d8oEhw CBkX6mckFN/Yae8+5l3/Y+a+CK8i9KynElfLDrrnuTolJEgAeZkCHoMQ7HLS7BFGjqLu b8q6Icd6+UL3DYvjONiaSt4kV85+t5mFxavCLSE2CILp8mjEUL7GFHk8TkdN8btRH2nq 0EOJWM6LMvxvNUz7sZoFMmhmmoGAYsZMuAylrsYvQE3uXZV6qyWBLiNNmwmOS7eYsFg2 gvTLJlE7+QFb6/9pmh9BoF5yGxlHickCuiqzPWndp/EOwDb6xLpKEeYk6bkPsXzHpMLg h85w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=i3gDEag2; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si5458755pjs.72.2022.01.31.03.04.46; Mon, 31 Jan 2022 03:04:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=i3gDEag2; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241905AbiA1Nul (ORCPT + 99 others); Fri, 28 Jan 2022 08:50:41 -0500 Received: from mail-db8eur05on2127.outbound.protection.outlook.com ([40.107.20.127]:18368 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236497AbiA1Nuk (ORCPT ); Fri, 28 Jan 2022 08:50:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aK2QyIJZ7WSp83/ezAgNU3oe0ju2ojdj1zFV7ya5OPuGlgV6nCnP9UP+HhdcPkJ0TbP7nXII4LsFAhtiB3/X8VrxPaKtaDF3xwjnvthhwEJiugDNOzd2oNl2BBKXE3sNl4mMZC5WH+p2+qiiwG9j3Gpx1ZdrMvDT/xEeNAdfetN/trgcqO8PZDxQfU/sfNVEmI/kjGmcIAakUFu5B3kKP7+QA33Fd93NOulWu65ycZi5sJj3UA7Si2YIlWw3q37FFQGR5p07FxdW8DYZDG1wrQ4hYZnXT3Ykloqs8w8rcxU/yY/fyOFTNbF9qRdNobjqeQHClcLZfpZq8Cldokz87w== 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=Xn1jHAIEAchzovuvuO0ffAC0y73Af6z9jQa8ClpwsUQ=; b=S7G2chKoTA3Tj5SnQoHZvPneKqU3vklPz5LJIkBxMVMkNzRV75cOrwpIjIhcwWI+qvrz/uU97ZM+KIv8lTSA5HdxSK3fUvskFuUu/KYFtyW28dw4vi6eeijq0KqHUq1vCbB2+6BhHo+QXAKKXgDSU+om7yTQgvhkd1FlYZhqpthg+M8Bnwmx4e7+Lhp54XM0RtHwZuxCaIX6cX17ij3w1iBeBtlOjv889jVCf8sbazzry6b+l7uZvlJklTx6f4zExk784vw6QLM/K5MjB4jqw3qjLe7yNkRYuQisudn0JtdqQSdtXdb/nfBOHtlGBlt6jIvYDEzNYk7ZAdub6jxfHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=Xn1jHAIEAchzovuvuO0ffAC0y73Af6z9jQa8ClpwsUQ=; b=i3gDEag2Hvp+XjTDKLvM+HMiHyn1UxpkwZzVIc4fcZK72vBTFGkSzUe2Wo4xD48/D2aDVpPpFKN5d+Y4MXI0ni+N7Q7e6a0IOKs0fKfP2Xsvk11GjM3Y8REmRRxN0sRt5N0N8alVYOv4AU0A8oQ8htB+bqWSU4+50IYhTp9SGS8= 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 DB7PR07MB4571.eurprd07.prod.outlook.com (2603:10a6:5:32::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.6; Fri, 28 Jan 2022 13:50:39 +0000 Received: from DU2PR07MB8110.eurprd07.prod.outlook.com ([fe80::adfc:7f91:31e5:f103]) by DU2PR07MB8110.eurprd07.prod.outlook.com ([fe80::adfc:7f91:31e5:f103%6]) with mapi id 15.20.4951.006; Fri, 28 Jan 2022 13:50:38 +0000 Date: Fri, 28 Jan 2022 14:50:26 +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 v2] arm64: move efi_reboot to restart handler Message-ID: Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-ClientProxiedBy: CH0PR03CA0446.namprd03.prod.outlook.com (2603:10b6:610:10e::35) 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: fb0a705f-9ddd-485a-dafa-08d9e2652a5f X-MS-TrafficTypeDiagnostic: DB7PR07MB4571:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /C3QncFK70j8i8HVY1IsHfKi3kZDbtFIlNacOPb5olX1TjmKsgNL+kfLZrxq+NPk4GnuPZQy4KVpIANEZK7irvte8jNddm2/PNjApeDqkP86jYiSdCF+17a7urh1Zps6pXcaeDgMguXI8DbcaHh0I8E0vmm9FOgjnYooH3rqjIrX6Ei3cnKPNBKZNbk2Z9zMFQcEneypvvmID6lpbpuGAvkjGk4vgCyi/OSb53pOKTpfHf7xYJ1Xj8XrilEKVvpXAAKW7K1ZcKgedR51yhy2EzMV7pjQdtvy3hxbfvuoqCr79a/JM/AxKAdlrNUtWkbKNLj9zpYtwauk7V0T7jmjNtTZQfaU9oOprqIopPpez8l7oAo4TZi1DdAfL/r85E8rcqQXDxUAgp75edE/3QkhC+cw4ghx96CMd1Vp0cFByZ9oFqMgWrWiqb2G020D0XZ2/S6JBlU6qpmas3+z3fu7a2qPgqt8w4Yo/69uLSeX29hBRSvEz9eDkN7Mj3ngGAf7wPUmTol4WjHfoPSJH63hQxSioJL14EIxsqCmyAXpnVB4QHiiFBQuS8uPUS7tysvHu/Z4Ym1BVW0AexlmFWpedPjMidR10ihFXKThpSJFn37jY1y2AEavH/cjBGhvsTE2iiUwD7qraldoCcE1PVCHCJm8WEdIEafXXpfEZYkDASbWCM/i4L09Z9WxQaW84tT5 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)(83380400001)(186003)(5660300002)(2906002)(82960400001)(44832011)(86362001)(26005)(38100700002)(508600001)(38350700002)(9686003)(6512007)(4326008)(6506007)(8936002)(8676002)(66946007)(66556008)(316002)(66476007)(6486002)(54906003)(110136005)(52116002)(6666004)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+Vylt7QnJ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Qnb?= =?us-ascii?Q?b8tw5C+5F/HevCxITFNyKFiKYhKleFqTt1Lj/5uZ/IdFoxtAZGAt+/0cKWFN?= =?us-ascii?Q?oOrP32bqcAxsJ2GjJReHtOvy4yLlGus99hkXZD3Nrv/8Pm48X2BKYx2szBDn?= =?us-ascii?Q?F5oM3GDXaj4cwX6M+na/dVxGMZH2BkyYikuH1rbfOVTmKuEIxVVMmssnGE++?= =?us-ascii?Q?7/OyunQAYQFs0+GxsjwgbsR+F0ityW/6A/euC5JpYR0LrA7Lh0bskS83eSG+?= =?us-ascii?Q?dX8iT1EtP2TykGlEQgvERpJ/OfqNzTeOqiEeVH/B0JeBGgbOe7GGdR2r/rbf?= =?us-ascii?Q?qsU/nzyoub8d1vaSxdmSSUB4RMkK+kLYldm1G/Ay4jWt6A88AVsyChLzdmJl?= =?us-ascii?Q?4LsvmB6hGrjlWdavnL8zvVRCN1Tzt92DKndmO2BYrNcoL7TlFjokZ3L2lips?= =?us-ascii?Q?I2KvMQHUSMUMDog3CZqorDeKjtJ6yMu462oea6hWpbnm/p5CjRUGNfRi2iQK?= =?us-ascii?Q?3mCRaKOCp+zvyyESdbxFDG/VuK0hr/h5MTa8ye7gQ0D7mFoTwtxqDAljzh5f?= =?us-ascii?Q?TvYMCL7wwcB0XFKsMCAxtrO3pv9XBvE5U2jpsfAgn2SuoGdswFk7vf2gkNmG?= =?us-ascii?Q?+KzDH5pf/qoVCQnoY3hq33LLytOVsd8W9ANMg/xyJbAa8WAGrxIopFLP950y?= =?us-ascii?Q?+SuaiSVHWWHYICUa5XjK5xNXjVPtrP220w4BoikZuADc1d/WB/H1UQI1FLhl?= =?us-ascii?Q?a1M7xB/g0QC0FXG3Q0zQcjJuCZGA8M/FatUHI/iNxYRRyXqUKIUSOuDZqXl1?= =?us-ascii?Q?bJKT/g=3D=3D?= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb0a705f-9ddd-485a-dafa-08d9e2652a5f X-MS-Exchange-CrossTenant-AuthSource: DU2PR07MB8110.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 13:50:38.7209 (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: iiDE6EKRuaWvdVZ1jAI0XULEfDhFvSXu8tQi9Qh8OAeo4ISBGE8k25tBlRJFfdDAD6HPJhptGxSRJOteOR5QjDSSOOq+2ZFjC92ZsYezZQM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR07MB4571 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 130 is one higher than PSCI, to overrule that but still allow to easily register higher prio handlers, if needed. Signed-off-by: Krzysztof Adamski --- Changes in v2: - Register the handler in EFI code, instead of arm64 setup.c - Remove the contdition from the handler - it should be run in all cases when it is registered - Bump the priority to 130 to make it completly obious this should be run before PSCI (which has priority of 129) arch/arm64/kernel/process.c | 7 ------- drivers/firmware/efi/arm-runtime.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/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 3359ae2adf24..b9a2cdbe80b4 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -80,6 +80,24 @@ static bool __init efi_virtmap_init(void) return true; } +static int efi_restart(struct notifier_block *nb, unsigned long action, + void *data) +{ + /* + * UpdateCapsule() depends on the system being reset via + * ResetSystem(). + */ + efi_reboot(reboot_mode, NULL); + + return NOTIFY_DONE; +} + +static struct notifier_block efi_restart_nb = { + .notifier_call = efi_restart, + /* We want this to take priority over PSCI which has priority of 129. */ + .priority = 130, +}; + /* * Enable the UEFI Runtime Services if all prerequisites are in place, i.e., * non-early mapping of the UEFI system table and virtual mappings for all @@ -148,6 +166,9 @@ static int __init arm_enable_runtime_services(void) efi_native_runtime_setup(); set_bit(EFI_RUNTIME_SERVICES, &efi.flags); + if (IS_ENABLED(CONFIG_ARM64)) + register_restart_handler(&efi_restart_nb); + return 0; } early_initcall(arm_enable_runtime_services); -- 2.34.1