Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4065565ioo; Wed, 25 May 2022 14:08:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzR44NyE0PnB8a4UJvusznEe8JMQdIkS/rp+JFJWaRV+SQ+yILVwtUpdu9FGyBUffNsA+0J X-Received: by 2002:a17:90b:1bc6:b0:1df:cb4b:836e with SMTP id oa6-20020a17090b1bc600b001dfcb4b836emr12391150pjb.117.1653512927341; Wed, 25 May 2022 14:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653512927; cv=none; d=google.com; s=arc-20160816; b=kb/JbSUyjfzLF225y1bceAlYKnQqI3IhSU0+uFmNOchscXTgb1GccbNHq9v/8C8fwc I3ECe4DjvqkZ1srOUvdhZgP4hT5LfzHhZVjlcU7AngWG7Vy7HLqOrxgXSKNlVEeB5tVC n5vaoapEvNIhS/KERat6XnIYRwQtko72gyAJjflspdjvokWNEOLAHXLsVaQbXk2p4XDx grqbaLYVabsg/vnr/N8e48Te7B9WpFE+Z5fr/mcsFHQOQol7tlfSFKjEBAJt/TpZBVZq PAiCFQpp6pnFaf7BZ8oxv2fxfWbGMz/7C8eAvh0OuqHdp4TwEiAX3wfL8OWx5OOwsx88 oVEg== 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:dkim-signature; bh=Czn4vjfoB3UGZdHyB0RBK3ip2+oJqttDVwdJod4OVxo=; b=gRcM2CSCAkPJz5sx7ohKXvr424cU2dAO0MGWFoj2j+XpHIHna7qbUSxBnNsJyKQ7Uf U7KUxfdrr7C/UKMMHkXbXI5s1tgAGB6jyg/Aq6rbFb5YMTgWd9PKX2wAx0yfKLqtCG26 /GMFn0uISMqv5l5CowKF464GkECm+RRypj4ORHsfbPL1fyDPyRulYwEA7h2rMe8Epe04 SoeJwka17QR3E7R4bvNIt3Bpz2P6/OYs0+e7Kk9+YmwtSPSBQ6fuxr6a/uM9HIIEzYB3 ns39mQUMx/A9k1RJdBZxevbEseI0sm2tB9BR4fq67WE/BjdU2UqQEwksly4YD51d9W/X tmvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fWA1Aifi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hi18-20020a17090b30d200b001d26e95f5f5si3817459pjb.182.2022.05.25.14.08.31; Wed, 25 May 2022 14:08:47 -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; dkim=pass header.i=@collabora.com header.s=mail header.b=fWA1Aifi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241488AbiEXUQy (ORCPT + 99 others); Tue, 24 May 2022 16:16:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231410AbiEXUQx (ORCPT ); Tue, 24 May 2022 16:16:53 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEFDB2317B; Tue, 24 May 2022 13:16:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id F2E871F447A6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1653423409; bh=zYjjoQPSRD28QTzcQmCkF+0zDUTSRxsuI5oi8F0+rRQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=fWA1AifiGfpu5zAody+hWBW74K5h5PJY4o9syShHoFUvcDbGztdgO0rxpFXKrmy2Y v+m0QvVaF2TMOM3FrIQn4vCIIUWVeH9erQlS971HHUB5axW0nhIjNhf2t83dRltpj5 F+MJuBOytIM400P1utntTu0dMtY0yhe0QZvOmzJR1Di7UCyoNz6N/1CjkNfHCg26JH 3c5z3Ze+AYN7fowyq3Sq6g1iqMrOvzo1fQihDQtpwVaXvHM7BJiRY1axu6Kqy3ixZu ZneM8hZeXSfA/wa0YX+aUD23BvnxfaiuWymTABWNglyXpsDZsuQOqKpz07ThIMgq+Y y0ERqGVUsfdJQ== Message-ID: <72eceb0c-8654-6c63-f1c4-c9374f99dfb3@collabora.com> Date: Tue, 24 May 2022 23:16:41 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v8 07/27] kernel/reboot: Add kernel_can_power_off() Content-Language: en-US To: Geert Uytterhoeven 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 References: <20220509233235.995021-1-dmitry.osipenko@collabora.com> <20220509233235.995021-8-dmitry.osipenko@collabora.com> From: Dmitry Osipenko In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable 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 On 5/24/22 18:03, Geert Uytterhoeven wrote: > 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 Great! I'll send the proper patch soon. -- Best regards, Dmitry