Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2737871pxb; Mon, 31 Jan 2022 03:16:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzyPwOR7XzwA1wCaKREIVMa4/Grtqw6z9CT/aJNDFRmClB6fExu/mAyp2C1h0k1b170SzK X-Received: by 2002:a05:6402:787:: with SMTP id d7mr20523800edy.390.1643627786159; Mon, 31 Jan 2022 03:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643627786; cv=none; d=google.com; s=arc-20160816; b=PHgiaQ/SgTjUxZNP5B/qxXbGvzIOe7Su8yFYxxxRk9ZSqSHkHK0tMrzS4a1A9fi6fK mx8dhWsKiJxHqKktp/dyenABM5I2pNS/uscqwzNKpjYY9+VTStKrGHgAgxHe9kDNT7bE O23Fq8dlkd8Afv3nVOeAVfnC50VasCDR0WKhZphpxfyPZkcN7kJcDEmET/g+yMbxH4Rp caC/zJqRfziAHpduXk23u5hhhJEBRJocl+tuVyjwjSnblKlsjcEvGv1Ssu1bN7zE4KOn ht9kvOPv3aydDWkv2UgQ9FHWDyzKlpcgKTZOX9hfVM8NA90JzwmaeRFtfa/otHQFDy7A ABrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=V71Jwik4fDI+GRtelq3xz2lu2S4TEgrgHZ/rnpjflho=; b=IpBYLezGKis4vMHZiRZf9S4i8iNZ++vrZlhxWJudIJ7clWdNWyKRXfnhttuxp+yDUd F+E3VavMB3nkRCKs0whEqkqUps5/ujIBwhXGh11Vbqsvr2IlYFFJPn9uk9arDXkUnoNl YyzZwSS28nUJtMTHgJu1DGE3UwrjR3i0ncoRl8w9uNOOkOhj4n53pG/bSyAtrCPqL33J viJ+XaMX4tbo8289xbk090pS7a6uvFTfgaoaabmItUjfhyMq9dyomEuGnCM0sm9jQygN OqYI/PMLASFqdizqh3uvuFV/aXaLCNYXDAk+gVYc5vN3LB67upIeOapv15z0E+qy31pM /Miw== ARC-Authentication-Results: i=1; mx.google.com; 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=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si5234556edp.76.2022.01.31.03.16.01; Mon, 31 Jan 2022 03:16:26 -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; 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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244114AbiA1QBy (ORCPT + 99 others); Fri, 28 Jan 2022 11:01:54 -0500 Received: from foss.arm.com ([217.140.110.172]:51310 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242668AbiA1QBw (ORCPT ); Fri, 28 Jan 2022 11:01:52 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EB214113E; Fri, 28 Jan 2022 08:01:51 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.13.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 36E003F793; Fri, 28 Jan 2022 08:01:50 -0800 (PST) Date: Fri, 28 Jan 2022 16:01:41 +0000 From: Mark Rutland To: Krzysztof Adamski Cc: Catalin Marinas , Will Deacon , Peter Collingbourne , Guenter Roeck , Wolfram Sang , Alexander Sverdlin , Matija Glavinic-Pecotic , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] arm64: move efi_reboot to restart handler Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 28, 2022 at 02:50:26PM +0100, Krzysztof Adamski wrote: > On EFI enabled arm64 systems, efi_reboot was called before > do_kernel_restart, completely omitting the reset_handlers functionality. As I pointed out before, per the EFI spec we *need* to do this before any other restart mechanism so that anything which EFI ties to the restart actually occurs as expected -- e.g. UpdateCapsule(), as the comment says. AFAICT, either: * The other restart handlers have lower priority, in which case they'll be called after this anyway, and in such cases this patch is not necessary. * At least one other restart handler has higher priority, and the EFI restart isn't actually used, and so any functionaltiy tied to the EFI restart will not work on that machine. > 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. On which platforms is it necessary that these are used in preference to the EFI restart? Can you please give a specific example? If there's a specific platform that needs this, then we should call that out and explain why the EFI restart isn't actually required on that (or if it is, and functionality is broken, why that's acceptable). Otherwise this patch is making this logic more complicated *and* making it possible to have problems which we avoid by construction today, without any actual benefit. Thanks, Mark. > 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 >