Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2734614pxb; Mon, 31 Jan 2022 03:11:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfzuW+s1pGsWH/HYq0qratNhL+AfuP3pTog4sPe+XHGMO7cqNnTq4fD9TeLiOdjPDdWzsA X-Received: by 2002:a17:903:234c:: with SMTP id c12mr19497594plh.55.1643627504878; Mon, 31 Jan 2022 03:11:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643627504; cv=none; d=google.com; s=arc-20160816; b=DjFwLVgoMyw4f+bCa1OAg6Y2TcQ+iUnk8b6xRwRjQ/j1hmq7OVFNcOCA/DblmMxOeS u0Yz+755UtBz9k1yvUC/JOp9FwjxNVhjNmz995OosbBLcEdhsjwrYtYX9riXo2rnjEJ8 Uf3MnfPI6phcyy0nT2KZPLNXgWiHftGo2paqeJ0dgAn3aUw++1iP08EjzxX4V1tP2KK+ lh3KZ8YSIr/MAvAXk4GjOHMUJPcvbQxCrFMdOKaYte6Qh9qhqsIqgurX2Dmi1iim73Yv bUp5fxGLOjvNDUKi4qgavA5rAxbuIXZKFZxPXU9/2UkK9Z02yMYD5ehCS0k8AEs1Uzz5 V+og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=rB3vRTa89ZSkSn6pM4nNsmxL1DKv4F6VVf/YhgzziM0=; b=uHfkLcZKR1U4Y/YEs6UMsZ3m7be6JX7CYV7Ixwp6Yvj7RiJYvvH2CzsRtSMoQ9h3a4 H7y/J+5kuqhxiyDIB2h6+eYU9Lodaz1f1SyUWkw/1cdQdZztJ2j4pkfUYu6R5+uWG+3Q iVe7n08JHm6ZE/OobKr2qrlybt/i8EcRn1pXLZvUdw5NuCvFDWutHp6vSx58S4+4lgqe H50p3PaiWuVx6fgGBNkSVluQY7RMe+xtjzQAEgVr+RPofDOVs/q2lTkfe0Fty4Wt/9Qc dEmNFtR173z2lhyclWkNisskiP3Zf+AmwTXoXQAle76H0T41hEoXTXJu2jrv8wRi+Zka qR0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kalYI+1o; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hk13si8708425pjb.110.2022.01.31.03.11.34; Mon, 31 Jan 2022 03:11:44 -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=@gmail.com header.s=20210112 header.b=kalYI+1o; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244544AbiA1POh (ORCPT + 99 others); Fri, 28 Jan 2022 10:14:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244673AbiA1POX (ORCPT ); Fri, 28 Jan 2022 10:14:23 -0500 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3DF2C06173B for ; Fri, 28 Jan 2022 07:14:22 -0800 (PST) Received: by mail-oi1-x236.google.com with SMTP id g205so12836518oif.5 for ; Fri, 28 Jan 2022 07:14:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=rB3vRTa89ZSkSn6pM4nNsmxL1DKv4F6VVf/YhgzziM0=; b=kalYI+1ojLFtijCHW7+3xe1I+L0jOeGrozDpJGKUEjFzMghPHRsHON0O//RgyAKi8C ziT7EDmQMMZrGiWw/TP+W97XF4qIbXcl1etx9oOdQTpzGO6qowGg9gEqYrRttWuZBPFx D4u+9lk9W0IbnlN+l0khOkFxcVWXEWCo826hrVFqB/BLNSiErY4Z7A7zzJPpAkONXOre SHQ406F/59hSbFKLuSHCTDZgXU3aWHA51cceWocool1SXbX5XVG4/554soD/ESOHNJdM Ljwu6TA+Q7HPcBfiXXdAcPHbXFfQdanwhaoSffJ+luUWorgoFwfmCNMTI/NRav4W/Kgo oEnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=rB3vRTa89ZSkSn6pM4nNsmxL1DKv4F6VVf/YhgzziM0=; b=N83ouAvAsOTMqVkISmgAgpvzqwaOEXh9Ira/6yqklCZyUY4u4Utp6bSsFMbE3Yz3Av wOsOfGDEzqNxx5ydRg7WPBsKNYLaltELrKjXTFJylvsLlcAWIXGVVaA9X6AdF0fDZ8Io cQQ9HDEQU7kNIMeXzKkO57u+3jBJyrzSlLS+7JUV+vTZ63eaFq2857Tb/v4CRHgYCygT LC8jY7KUKCNaKc7thp6RqYM4eMRUkdxfB42hOrCp1B1LNdIPZ49oTl9WmQQBObIobchO FB3PkC9UBwXsIcNV+wg5ebiMhGSdchxIYkxYFqSCY0a/fx6Q6ZFEcl27OtbcUpWX1u9/ K2YA== X-Gm-Message-State: AOAM530ClRDkfmEU1UDR5ik2TyKJiGJVJMHhuz+yDXS1vjWMa5116DWt FW8Y11TfgbVpjpBPgvIRzqnXU479M3BsnA== X-Received: by 2002:aca:ab83:: with SMTP id u125mr5803032oie.276.1643382862290; Fri, 28 Jan 2022 07:14:22 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e20sm13090149oiw.38.2022.01.28.07.14.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jan 2022 07:14:21 -0800 (PST) Sender: Guenter Roeck Message-ID: <58da38d1-6a1f-ccdf-fc65-b53bf79851e1@roeck-us.net> Date: Fri, 28 Jan 2022 07:14:19 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2] arm64: move efi_reboot to restart handler Content-Language: en-US To: Krzysztof Adamski , Catalin Marinas , Will Deacon , Mark Rutland , Peter Collingbourne , Wolfram Sang Cc: Alexander Sverdlin , Matija Glavinic-Pecotic , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: From: Guenter Roeck In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/28/22 05:50, Krzysztof Adamski wrote: > 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 Reviewed-by: Guenter Roeck > --- > > 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);