Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp759pxb; Mon, 31 Jan 2022 03:46:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJy04uxxTigzQJ2Y+PBrgDGrGRdajl9pinbEbzoB9e7mqY8qnB4LC+YnPUKeEMYLMN/rmUey X-Received: by 2002:a17:902:b583:: with SMTP id a3mr15970333pls.77.1643629562969; Mon, 31 Jan 2022 03:46:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643629562; cv=pass; d=google.com; s=arc-20160816; b=hN+A4b+QuGqjHtgizr7hU7/B7F3Iu4DHeScMuPqR8IT6oj9s8M8wfyotn0TbgvkcEW 8aXc+Too/8N10XXs+Oec1Ae9l+k20UNNT9M55FRUDlUQdTNDxkHxTcTtMJjHA5o0vOlr I9uzpcRX9Mni5QA5c0DPW/3EdD538i08ZcP+7RWOnT/t5KtJyGoBfLNNY0D0oBIykBVX pRoSwHyOEVXXen1/ljPZUzFt23Rcr3fdjEe2BL/VL5DdsrohiTG11SBZE89nfdhZfwAo 1vQSBYByZLKhRBg4ugjs0TME6rxp6dj2h0d2ZX4TljCbGscTR2qR9yJnuIifTsg/lHzh jL3Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to :content-transfer-encoding:content-disposition:references:message-id :subject:cc:to:from:date:dkim-signature; bh=pYvctaIL45KuTsMGH1h/Y8HfebQIANgjFe2qsqK3kRg=; b=c5OU5r/E0rAaZgj3T81LnBe78I1AXGCZboWnSMEdjq5KcvvVM35Dj/npeRjvH9XETy KiJnHWIje0I61ZA+ujgfHsR0hS0jD0eivC2CSeZyFO2dnan1j7+X+O3NjaOFLwt7q44R l6gdIlPbBm/fWBPIlAonspmrRRicj7Kv7wpnKFVbNiYb/Aso8dX3ofudOzfY+apSphz1 gCTyFwpmpUh55flwFk+23dyqBG0mNtjYwWcuN7cE3XNYvF5vX2a+VEgd3IOJVsXh6ucC TmEJkks4xPi+/zmx9k3XLTbhPlFT6IE7Mc3YuOCgZncCzQUoObYirQME79w8sfQj4wJS omEA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=iDvTOomt; 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 r142si12798181pgr.622.2022.01.31.03.45.45; Mon, 31 Jan 2022 03:46:02 -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=iDvTOomt; 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 S1343705AbiA1WFs (ORCPT + 99 others); Fri, 28 Jan 2022 17:05:48 -0500 Received: from mail-eopbgr70117.outbound.protection.outlook.com ([40.107.7.117]:8289 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229608AbiA1WFr (ORCPT ); Fri, 28 Jan 2022 17:05:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nWbuG6bh5zzJwi5ITx7Q27iXrwEV6gF5z7dsZ6jU8APYd0xmyelTOb7RdBLrWegHure0MEwjsBW7e3PoU0z+JZOPZiamSE3tbqRLKj5MmLeGysB1ZddL8pvf6TvTeRsDBADfkH7P1/6PbGXUjJxAuQxAFHT4XSwSEWtVk3TMMrULL5iyoSHw05Zlt5Vq0y3dqaQeZj02K4gG/tJvDLbMG6OJlzpVtm7TH8Y0ZBnfDvShYHsEEYNjdPbbnlrCbwnOZAOQtbF08D+c+0hf8DYlGTV8m7/UUqTF7KJNasYIUhsfXiu/zMXKMd/pJNyS7AkEaklLybL5Fh0YfPfRY3kVpg== 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=pYvctaIL45KuTsMGH1h/Y8HfebQIANgjFe2qsqK3kRg=; b=bW9/w9hHiGoxPPX9ik6hWNb3aHeZiA2FDPjrR04gAXqQ95frcLRgB7EZ2zzXkM3MNWnp6wah4oluiFB6X3D9f5xV1M5ZtxFACVN9iLVWaN5wSE63a2RLzcDScAGwQKenoynZ2pPS087ccWNa9TxcQ2PSqN1cVkFQY3irRNNg/APCj6q0+ysURLYNX7SFx82buIDlcO2e5TX1h2RVIPdOoKckHs77faS61ZOLyLUEkrH0xf3j+dc8zjm0M6xr2gzGOO2M/gqA6bXt185m4KHNBi64UDUX3HmUtb72glOdS1VH3jfSUjYS0NcNnadEAg930YfGne+L54+/kMFOxhsuDg== 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=pYvctaIL45KuTsMGH1h/Y8HfebQIANgjFe2qsqK3kRg=; b=iDvTOomtupyknpBFynK285hwNFg8NmF9CRofEC88NtX44RQg8iCL0/gDMsXZFFYVEHoe7+gGjSymaKFMfXgk+HqmKm9mN2xZ+JF0LuyZYUF4seMreZNqc5QJ5C2LoRfYvSeqGnJ0MCe62n5UtIBwstEotUUgWaqSoDPegcnDis4= 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 AM6PR07MB6005.eurprd07.prod.outlook.com (2603:10a6:20b:2c::27) 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 22:05:44 +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 22:05:44 +0000 Date: Fri, 28 Jan 2022 23:05:32 +0100 From: Krzysztof Adamski To: Mark Rutland 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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: CH0PR03CA0437.namprd03.prod.outlook.com (2603:10b6:610:10e::17) 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: ee1535c2-42f9-4e21-f4e1-08d9e2aa5444 X-MS-TrafficTypeDiagnostic: AM6PR07MB6005:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c+8kwkfF1oM9L2Q/YFB07zlXa4/LQ3JGw0xXYGUdH87eJ2NiS9ho2Tlgl3mLS0EH6JaUVYB2n4QdTnd1eOM02SGa2o+7InCpv5Nm7zmN9SPF2YaSlArklz40lbdfY49/6ggGVrRDr5Nhgx7cv5AJAE35MwBkZWVRZIfb2hU54tivTAbQBBAs1ZXoMAJ77Fdm3nvHMZej5veaDxV7GAMnyQtPZ2B/5Wo3EOYXRrTa2ZWaMedjFVvtqmVA7Pu5caL9sSFO34yeAQmLVOl7EFF7395mV6GRzK39a/etfOMzBZFxZoNOrh+hw6jzThOQ0yL9JANdKxSZDEqCn0AMMSjudZa4+40NZtM4S0m3ubVl6icpyMUTNBCZVRkbmhfkVBKNU9gvCFdslc3s5eUGZqHJCZbPQnhfPfJkJaLhF8shkn9UrRzOKtaAze5Okrn1glecR9jNcc87i3fUPJANb6C0jXSgmaPvXxRflYKPovC5kGxa2gVAmFfuUCQp4SLQbpR2Lzf1DmH2dezx+NtQhFZG+w/re3PTd2HL27eIHx1URXJno00iFFsS+Iwp+cT9QpwtHzr+WM8fu5AV79pGzcQXhQ2aJdA+cf3WRcl58QNsxG/BEN7JRKNJ+POMc1q+5br+zZNnN68Z8rY9vHbBO5qn6dQDiHXhnXQyRK/e9i5LFhA6skI7Ly77OyY0/9iDIGpuTYhxCnVSkaj9VJpw4yI7/S55cf4hwrjbICmTRYsiLdw= 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)(54906003)(316002)(6916009)(66556008)(86362001)(66476007)(66946007)(44832011)(26005)(52116002)(186003)(5660300002)(38100700002)(83380400001)(38350700002)(82960400001)(8676002)(6666004)(8936002)(508600001)(4326008)(9686003)(6506007)(2906002)(6512007)(6486002)(67856001)(20210929001);DIR:OU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bVNlcGZLVjhuRys5?= =?utf-8?B?WkNOZmdkMnNnckcwVE85a0hzQVFTem5MdERmYjNYN3RVK1RiYUszblNYSnlj?= =?utf-8?B?eUF2aWYvT2FuakxkaVBaZWx5OFhxaGM0dHA1MnRiYXdkd0Vyd05EOStUM3d0?= =?utf-8?B?MHRsaXJJRDI1STZYZXZkY3dNUlhGdkVncndSNFF6SEtia2N2VjBmeXJ4dlRP?= =?utf-8?B?dVB6NFl2TTczVUtabld3bU5uWUNObTRrZjRIWTJoOUhtZXgvWWNGZW9KVWQz?= =?utf-8?B?b2NCWFBjc2sxSXovZUo0VWhiTUJNL3R5WFQwNjM3VDM2N0VwN1JLTjVoMUNG?= =?utf-8?B?bktsSU90TGw4WWN4cEdvZ3RoRjM0cStOb29LREk4bWJRNTFXVDVzbTlJa0R1?= =?utf-8?B?cHVVZnluSVUzc0VZaEZiRDRLOWs0aEgyVFBvcmpLRWRoZkJOcmxwLzhHdVZY?= =?utf-8?B?d0tHWVYyd0FrYzdMSkxEaW5iclFqWS84YkpoVlE2eWoxVlBDZ245R041MlA2?= =?utf-8?B?L1BMdXBoMW5zRTV0ZU55VkJ2M3pBPT0=?= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee1535c2-42f9-4e21-f4e1-08d9e2aa5444 X-MS-Exchange-CrossTenant-AuthSource: DU2PR07MB8110.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 22:05:44.6994 (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: LDg+Di2mjWzXeF2keVMphAw54jpdZSWcNbSLDYEw/aEIFceC+4PTAOIX+bsKRpRBM4SP8C+IwTH7LQV8PceW9eYn5/VkctH86HNvdCkaOJQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR07MB6005 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, Thank you for your feedback. I don't know UEFI specification that much, it is quite complicated so maybe I am misunderstnading something. Let's clarify. Dnia Fri, Jan 28, 2022 at 04:01:41PM +0000, Mark Rutland napisaƂ(a): >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. But efi_reboot calls ResetSystem(), which according to the spec: "Resets all processors and devices and reboots the system." So nothing should be able to run *after* this call. Thus, none of the reset handlers will ever run on a system where efi_reboot() is used (with current, unmodified kernel code) so this case is invalid. > >* 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. If we use the restart handlers only to reset the system, this is indeed true. But technically, restart handlers support the scenario where the handler does some action that does not do reset of the whole system and passes the control further down the chain, eventually reaching a handler that will reset the whole system. This can be done on non-uefi systems without problems but it doesn't work on UEFI bases arm64 systems and this is a problem for us. In other words, I would like to be able to run a restart handler on EFI based ARM64 systems, just like I can on other systems, just for its "side effects", not to do the actual reboot. Current code disables this possibility on an ARM64 EFI system. > >> 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). Again, I'm not saying EFI restart is not required. I would just like to have the flexibility I have on other architectures, and run some code just before restart. My understanding is that pwrseq_emmc.c driver does exactly that, for example, but there are also other possibilities: - using gpio-restart to notify external components about reset of the CPU - starting an external watchdog that makes sure we are not stuck in the reset procedure, etc. >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. The benefit for me is this added flexibility and unification between architectures. On other systems, like ARM32 or non-EFI ARM64 I can insert a custom reset handler to do some actions just before restart and on EFI based ARM64, I can't. You could argue that restart handlers were not created for that but they suit this purpose ideally and it wouldn't make much sense (in my opinion) to add yet another notifier chain that would run before reset notifiers, for code that is not supposed to reset the whole system and this is exacly what I would have to do if efi_reboot() is forced to be called before all handlers. Best regards, Krzysztof Adamski