Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3627997ioo; Wed, 25 May 2022 04:59:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAxFJ8ohg1E6LVdgQVuuaZItPWJD35iXqS2PeTVkeUnw5ruXm65Y3oAzHa6F5DH+/qCABv X-Received: by 2002:a17:902:f707:b0:161:435d:d069 with SMTP id h7-20020a170902f70700b00161435dd069mr31962883plo.105.1653479941264; Wed, 25 May 2022 04:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653479941; cv=none; d=google.com; s=arc-20160816; b=FPb3Vj1DarGq1U0d5pi5zpG8dix8jp4KMht/8NMD7GHjp4ElP31mtkJFv6OUs6XnC4 d0GDlhGl0mXL0T9Xe37IpG2Vn+8BIy+q6mYgJE7Kp7dZTMlZuyAPs0MCRsqoFpfSKPFz KhTfYV1hijfeGJ0Kd/RTjJMruGC1Jqgp58kwewdlLwpsvuvHF071l2uivJzF1s8OBNLX 8hFyJbHRHn+pjgbr8MovJfqYQuBrkuxO+6c17k5Gy8PpQgJrmR4Xge3emU7WSyrTRj1i Ho7emjF4PIOAYzuhlXGCzTxAwI5zOwKuBzmmuUCi3+mAd6a0+o00SMOsLHxH6h7vQlod 8k+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=cWMBERiSEwvonhpQY7HhVf55BWyMdm6aulJGqFnptK0=; b=z74V+G2gKoXSLH5w6WSW4k4JT1fXYf7rtt1VA+zIBuIsI+OtOR5JFpwjmsayFVS0t/ LQ0Ku7bwDBZ74C1ka9avPu17VTTqWNcZr0P7OppLKnv/02dmOjl07m37uS/Im0yQqLD4 kBbGgIadatcH1ww6jY2Ig81QS8FUPgEbCnhrZp0JqIUDk5+0f3g5+vAZABwObULlQIYg 6Xt7zbKZ8FZHHFGkg6HR1pAYJsDwZK6jIhwYGt/lo9wiQEU1hTZWWVdJ4Tdfp/XJpe02 mCRKDThDEImunmBWb4H4giDmBsl2GtePhqlpKyxnw8It/+OvFrpdmVbvM1vaNLiE47JX 8DWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf9-20020a17090b1d8900b001dc28f260d4si3491724pjb.43.2022.05.25.04.58.48; Wed, 25 May 2022 04:59:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238614AbiEXPDy convert rfc822-to-8bit (ORCPT + 99 others); Tue, 24 May 2022 11:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236693AbiEXPDs (ORCPT ); Tue, 24 May 2022 11:03:48 -0400 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 355BD8AE4C; Tue, 24 May 2022 08:03:47 -0700 (PDT) Received: by mail-qt1-f182.google.com with SMTP id hh4so14886798qtb.10; Tue, 24 May 2022 08:03:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=xvY3YRGz6Q5JdIA0GD3/2z1w0vgXjW2K3nWPGIL58cE=; b=xmw6PBJiSKQWxyIlk16DzUlnKILhKmHhqG8uMXbF+yPCpsjbkkIGNrPKL+ptX2oSWM 10hxtw6XYabM9Y6OFj5CbNeOA11OELyYv1s2LMJi0B+U7SaIcApYvttqfLYa3DLLFIe6 S1XMdU4rNuEnzPKmVtdKefOHqVUQBOc1Pg+PLs8+H6hmY3FdIRDD2MEQ+B/QlLapC+Jh V54GLpUZUm8uVkePXQ2BZmAFyFCrb/ErCxRFnlyNGmCTIV6PeP7HbUeKM+eqQkev274K 5QGR/DRp6vwg+1wk+89Ky86U/IXZiASfyi9yRqe2FcFNhh84gv4iAPVQvPxpgKfOfeuV 7zIw== X-Gm-Message-State: AOAM533jFVWX6MTIzltEAkzjXD+sgLwm/jLPRMy1Ure0h6xAde70GoHj b543jcrjuUQklrGLL37dklIHDP06AnN3uGYc X-Received: by 2002:a05:622a:1aa9:b0:2f9:8593:76c0 with SMTP id s41-20020a05622a1aa900b002f9859376c0mr1039264qtc.278.1653404626186; Tue, 24 May 2022 08:03:46 -0700 (PDT) Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com. [209.85.219.177]) by smtp.gmail.com with ESMTPSA id 7-20020a370707000000b0069fc13ce244sm6230671qkh.117.2022.05.24.08.03.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 May 2022 08:03:43 -0700 (PDT) Received: by mail-yb1-f177.google.com with SMTP id g72so3324900ybf.0; Tue, 24 May 2022 08:03:42 -0700 (PDT) X-Received: by 2002:a81:2143:0:b0:2fb:1274:247e with SMTP id h64-20020a812143000000b002fb1274247emr28501106ywh.384.1653404610585; Tue, 24 May 2022 08:03:30 -0700 (PDT) MIME-Version: 1.0 References: <20220509233235.995021-1-dmitry.osipenko@collabora.com> <20220509233235.995021-8-dmitry.osipenko@collabora.com> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 24 May 2022 17:03:19 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 07/27] kernel/reboot: Add kernel_can_power_off() To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Russell King , Catalin Marinas , Will Deacon , Guo Ren , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Sebastian Reichel , Linus Walleij , Philipp Zabel , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "the arch/x86 maintainers" , "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , "Rafael J. Wysocki" , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Pavel Machek , Lee Jones , Andrew Morton , Guenter Roeck , Daniel Lezcano , Andy Shevchenko , Ulf Hansson , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Linux Kernel Mailing List , linux-csky@vger.kernel.org, "linux-ia64@vger.kernel.org" , linux-m68k , "open list:BROADCOM NVRAM DRIVER" , Parisc List , linux-riscv , Linux-sh list , xen-devel@lists.xenproject.org, ACPI Devel Maling List , Linux PM list , linux-tegra , Linux-Renesas Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry, On Tue, May 24, 2022 at 3:41 PM Dmitry Osipenko wrote: > On 5/24/22 16:14, Geert Uytterhoeven wrote: > > On Tue, May 10, 2022 at 1:33 AM Dmitry Osipenko > > wrote: > >> Add kernel_can_power_off() helper that replaces open-coded checks of > >> the global pm_power_off variable. This is a necessary step towards > >> supporting chained power-off handlers. > >> > >> Signed-off-by: Dmitry Osipenko > > > > Thanks for your patch, which is now commit 0e2110d2e910e44c > > ("kernel/reboot: Add kernel_can_power_off()") in pm/linux-next. > > > > This causes the "poweroff" command (Debian nfsroot) to no longer > > cleanly halt the system on arm32 systems, but fail with a panic > > instead: > > > > -reboot: System halted > > +reboot: Power down > > +Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000 > > +CPU: 0 PID: 1 Comm: systemd-shutdow Not tainted > > 5.18.0-rc7-shmobile-00007-g0e2110d2e910 #1274 > > +Hardware name: Generic R-Car Gen2 (Flattened Device Tree) > > + unwind_backtrace from show_stack+0x10/0x14 > > + show_stack from dump_stack_lvl+0x40/0x4c > > + dump_stack_lvl from panic+0xf4/0x330 > > + panic from do_exit+0x1c8/0x8e4 > > + do_exit from __do_sys_reboot+0x174/0x1fc > > + __do_sys_reboot from ret_fast_syscall+0x0/0x54 > > +Exception stack(0xf0815fa8 to 0xf0815ff0) > > +5fa0: 004e6954 00000000 fee1dead 28121969 4321fedc f0d94600 > > +5fc0: 004e6954 00000000 00000000 00000058 befa0c78 00000000 befa0c10 004e56f8 > > +5fe0: 00000058 befa0b6c b6ec8d45 b6e4a746 > > +---[ end Kernel panic - not syncing: Attempted to kill init! > > exitcode=0x00000000 ]--- > > > > On arm64, "poweroff" causes a clean "reboot: Power down" before/after. > > > > On both arm32 and arm64, the same handlers are registered: > > - SYS_OFF_MODE_POWER_OFF_PREPARE: legacy_pm_power_off_prepare > > - SYS_OFF_MODE_POWER_OFF: legacy_pm_power_off > > > > On both arm32 and arm64, legacy_pm_power_off_prepare() is called. > > On both arm32 and arm64, legacy_pm_power_off() does not seem to > > be called. > > > > On arm32, both pm_power_off_prepare and pm_power_off are NULL. > > On arm64, pm_power_off_prepare is NULL, and > > pm_power_off is psci_sys_poweroff. > > > > Do you have a clue? > > Thanks! > > Thank you, Geert! I see the problem, the kernel_can_power_off() checks whether power-off handler is registered, but it's always registered because legacy_pm_power_off is registered unconditionally. So it causes trouble for platforms that don't have power-off handler installed at all. All platforms that I tested have a power-off handler, so now wonder that I didn't notice this before. > > This change should fix the problem, please give it a try: Thank you, that fixes the problem for me! Tested-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds