Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp427108iof; Mon, 6 Jun 2022 06:14:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmT1ZWdMsPZnF5oyKJTO3J4Je4ViRIdcXaL9HcBwYQX7anjKz39uFaWGt6aIN0S+zBrtDS X-Received: by 2002:a65:6c07:0:b0:3f2:5efb:6c7 with SMTP id y7-20020a656c07000000b003f25efb06c7mr21323896pgu.496.1654521260977; Mon, 06 Jun 2022 06:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654521260; cv=none; d=google.com; s=arc-20160816; b=ktlWbd3vDWMyubjEtFkpyP0e52Z4g0dkybISYfySYD1HVpyJ62c7+z8oI7be+z6F66 QqtHVySoWxWvjqMFDfBsP+G8otzybC7ePIrJAqbjhpDqgTiCD2/ouabEiNVQYBevrECW x2idwo1RLilNvx9AAFZ0MT/oVNqkDv6ejZVwO7O8WCTtUGA3mnHCbXzzTJ6GakxRxikI fglnOaKxsouBDd8CGbApU8aTKp08fhQFT4wBRErJ4NhsAre1xeRuRvSkJpJz3o03OWPy sirzAaoKgtBCuwZTXkMhZe+uQWsw4SbcxJo6npziFf73gJqEdxRUezC6BggkyQfCbhLQ zOXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=i9e500zxu1g22ahZBxmWTFnpIkC2mYPGVdl0FhelEpQ=; b=Y62AtnXWUXxTIC1/WM/gcVb41yWCov8EhOw1c4Jpan3bGDpBPYlXwC5Ky3XKgf5iqY SnfXnhDRy0NLhMcfj1tsmwmkJYjFMEEJYnx0PV01q/99JDoMG27kQnrp9RtWmvT5Q13V KfdOOoSBWNoXU29eX7icP/PjcBJQchbq/fFNU17c+Pi5riKiqBR/fY+JcXhg/s9CcI/3 EIeBtwlZEZFu/ce8xXhTe5q4N2a8ZVZFf9k/MOWRsCWTbi76EEF51JKcn+qv3aoabCio Ls9WyU5IFIhhuAi5E9NZd0RBm9rXA7Fu0BkhaEUqxyo3tEvEsXVtxHc0Lj53okPlkJ5e 4ZbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=dWQMsN0g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f2-20020a170902f38200b001562b0bf47bsi17591244ple.58.2022.06.06.06.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 06:14:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=dWQMsN0g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A1665044D; Mon, 6 Jun 2022 06:06:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238092AbiFFNGg (ORCPT + 99 others); Mon, 6 Jun 2022 09:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238363AbiFFNGd (ORCPT ); Mon, 6 Jun 2022 09:06:33 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79EFA47566 for ; Mon, 6 Jun 2022 06:06:30 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4LGtzS1HY4z4xXJ; Mon, 6 Jun 2022 23:06:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1654520788; bh=i9e500zxu1g22ahZBxmWTFnpIkC2mYPGVdl0FhelEpQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=dWQMsN0g3Pei2Ht3cSkeFHMQ7DeuSfJQ8YJ7hCWpHh/MkiHZFHawvu1KDSUtn4LoT RYFaVmj4Y6yttBQOmopkcolRZIS99m4KkC2aPTSPJqvxfAzH/DZwkluVBOma6DpNWa 6f54LQStn+KpWh0dy/ft1VsVJP9XR46hXsm2lUVxhfP8aQQV//F6ED2vSoSnoq/NK4 YxYbJlfhCEPkqVK8QvAtvvvD9leoxHKTT+zSV1EEcIIVkf4Nx7fk4i90u76BKXXGO2 Z3xpMzuix8i4tb9pluZoqysV45gH3ZtNLBwe+GwYF244mtu0npsq5ZLntI93eEwhVh AYOfn25To4wig== From: Michael Ellerman To: Dmitry Osipenko , "Rafael J . Wysocki" , Geert Uytterhoeven Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v1] kernel/reboot: Change registration order of legacy power-off handler In-Reply-To: References: <20220524212118.425702-1-dmitry.osipenko@collabora.com> <8735gjq365.fsf@mpe.ellerman.id.au> Date: Mon, 06 Jun 2022 23:06:23 +1000 Message-ID: <87r142ndps.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 Dmitry Osipenko writes: > Hi Michael, > > On 6/5/22 05:01, Michael Ellerman wrote: >> Dmitry Osipenko writes: >>> We're unconditionally registering sys-off handler for the legacy >>> pm_power_off() callback, this causes problem for platforms that don't >>> use power-off handlers at all and should be halted. Now reboot syscall >>> assumes that there is a power-off handler installed and tries to power >>> off system instead of halting it. >>> >>> To fix the trouble, move the handler's registration to the reboot syscall >>> and check the pm_power_off() presence. >> >> I'm seeing a qemu virtual machine (ppce500) fail to power off using the >> gpio-poweroff driver. I bisected it to this commit. >> >> I think the problem is that the machine is going via kernel_power_off(), >> not sys_reboot(), and so legacy_pm_power_off() has not been registered. >> >> If I just put the core_initcall back then it works as before. Not sure >> if that's a safe change in general though. > > Thank you very much for the testing and reporting the problem! I see now the two more cases that were missed previously: > > 1. There is the orderly_poweroff() used by some drivers. > 2. PowerPC may invoke do_kernel_power_off() directly from xmon code. > > Could you please test this change: That works, thanks. I tested both sysrq-o and the xmon power off path. I couldn't come up with an easy way to test the orderly_poweroff() path, but it boils down to basically the same code in the end. Tested-by: Michael Ellerman cheers