Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp431835iof; Mon, 6 Jun 2022 06:19:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxpGlGDKTbjikKUZfwLKr/naOHU7Iw12KRLovPAwbT9x1NQ+GxBcEav02Kh3NJzt0YVc4+ X-Received: by 2002:a17:90a:5d03:b0:1e0:cc5b:4808 with SMTP id s3-20020a17090a5d0300b001e0cc5b4808mr26591711pji.180.1654521541158; Mon, 06 Jun 2022 06:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654521541; cv=none; d=google.com; s=arc-20160816; b=MqISmVYwAWb/PJikeumxNIAmg8BACJBZvvEvp8LLP4xRU2UrCInirzulmIgayctwEU UFHC//wYNFDzIN6hEOpE7WghhNzWiGyfhE4CoSvVuz1i1i1spVlBcIJ7tOpqcEj8h1Dz Mb0t7NEFAC8eSO5S25zxm8j+ksm9AfmvS0MZPp427jCfEgktasrdQjMvQAUoR2xlw5PL 5vcwPUNY0KkimDWvBSdKhSBIvieird7bYn4IzCr1QoiB7RL7LBp72aKFbiZGksLQEAqS KjnlsblHz0mJDLqcb++LTX0KGrXAu5IyqtU2/kOg4FY7Du885LHHZjMZhidZN9qfoSZx 6WlA== 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=Xz+qtIQEzZbGbUVPWr7bmy4eiBJDOE6ShVuWuew/0ac=; b=zkOguY3y81/aGwB/qW34lIKj7IDTXh1XK94GtTL0ltb/TPOtP4HM1r/aI1WslJrRXs QRGlvn1f44AIwGGdWo4ETK3xi55EN+p1s1VmIDHJ52CNG+MOepyzRVfcXqxYkN2MjmF+ kkL8Bx0x+QkbsQvuG7o6prZmA8jG2qVZEddaeW6qE8tde6s83R1jRmNBzbaA5QiE2CPg hKhsAKgP4b9fFkGT3MyoqIZcMKE5NaTSbam8CMlbuaxdFJZCYuUpFnvZWAREYYtswf1C uP8mAoihWH9k8AwxZdyZTHJ99Kr5BvEfdXRXvG0ST/Z64TUH9ohb3xBq5i+nzviGzqu2 JFcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=J7lZtYY4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pj7-20020a17090b4f4700b001e33cfa3116si25483336pjb.109.2022.06.06.06.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 06:19:01 -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=@collabora.com header.s=mail header.b=J7lZtYY4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 54C8491579; Mon, 6 Jun 2022 06:08:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238285AbiFFNHv (ORCPT + 99 others); Mon, 6 Jun 2022 09:07:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238128AbiFFNHo (ORCPT ); Mon, 6 Jun 2022 09:07:44 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB1449A for ; Mon, 6 Jun 2022 06:07:36 -0700 (PDT) Received: from [192.168.2.145] (109-252-138-163.dynamic.spd-mgts.ru [109.252.138.163]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id E0FE76601E95; Mon, 6 Jun 2022 14:07:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654520855; bh=LSsMVAQZyPb3UHQGiFXE07RX1x68iQrPgzsQm/Y6N8k=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=J7lZtYY4Cuoa9mBoGgmh7HzBulDfQSltbib9XF0llbPdiEZUwfyVZy75VhebvcF6x LfmN/6WvLMFFEd57Xiq7Uzj+VOp0wfPESDbkDSRDN6xRfXFaLAm4pYCXfTKCIrWFm6 I+X9pOVA9y74JXswamQvAzNzliEeOrb5vaFb2pmkT5f1/ClW23KrVJzH+FPh9bWfFi rm98yIYgZ2/sQ022F4i2iXIM+DIY0sElaY+mEkqwrv2OmPUZuJ+eQtTxFBedW+5+NQ 2F6zphwJ+8t02wTzUfaL3YwkCUl/mWTeXfB6lLJvQR/OJVYwnCxTbFcT9A2j0v4cD/ ZVYJRqnvVnp8g== Message-ID: <5dbf4f96-7218-f238-5426-1ad0b4045aeb@collabora.com> Date: Mon, 6 Jun 2022 16:07:32 +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 v1] kernel/reboot: Change registration order of legacy power-off handler Content-Language: en-US To: Michael Ellerman , "Rafael J . Wysocki" , Geert Uytterhoeven Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <20220524212118.425702-1-dmitry.osipenko@collabora.com> <8735gjq365.fsf@mpe.ellerman.id.au> <87r142ndps.fsf@mpe.ellerman.id.au> From: Dmitry Osipenko In-Reply-To: <87r142ndps.fsf@mpe.ellerman.id.au> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE 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 6/6/22 16:06, Michael Ellerman wrote: > 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 Awesome, thank you! -- Best regards, Dmitry