Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1242584lfc; Wed, 1 Jun 2022 12:51:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt/7tkphheByJS3O4zDAAS45OkmMe8EG21leFo5jJto0uPnSwBrl9VIMZXLGfgSxC5Z79i X-Received: by 2002:a17:90b:4d05:b0:1e0:b53:f4a3 with SMTP id mw5-20020a17090b4d0500b001e00b53f4a3mr24411085pjb.3.1654113090086; Wed, 01 Jun 2022 12:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654113090; cv=none; d=google.com; s=arc-20160816; b=DS3z6nT74vL8MIRBONdTfCKsBCiksDuwShuPSeBYciTiwOWjyaqJl/uNFNrczgWNcV NSZMLoC8l/sxbtheR/eegqiFuX2nEk3ftNpcKfE8W8B6LF3/emovwnoRTZIm4PkKLkMx W0mzvYnJ/zT/LCLPKflIhw0PlaIiPgnBK+WozG5AwJYAHm7nuNPLo1kujsd0MMGJA/AV w2XUZ3nfkh+Bv7i+MGnOETFk8ZRv44g1d2H+oxcXNOyrKzTJKkIWL96a3MK1YJ4cTJ1k OpipYX/G706SlLECc1r1vZ0ND7FO7WMfPrVRKNW/aD8CYOETF99EHgN9cBxF8ClryxEO au0w== 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=zet5E3E2oiS1t+Nprpqfo9D7YZBfYdCJp0U5UtGdYNs=; b=OP8bJyUE6eVDVqA8qoZCInPgE50ARjkWp6DZukKn+NHNfexp2bTnrgmftMIsZmjeIk MGQEW176gRh9jg0gsvWLQGV8862NO7rcCjXXePou1yrJS2q7lkHS9CLgG9e9AMWclyXC wsP9qFs6pOebYEC6/jNMNUwYP+m2iYw/imZUjPEt/hjgK+kThwJxa3fi2/j2H0APmnOH cls0QD8Tw8e/d0nDG2JtHT3sXe4eL1qrA3eyD9u8EYiUWk2t8gEpvZRsdpQVNueWZYyH ke2r63h9ZkSUx2JnWhCt1m0XKkUR3X8yn9Iytmco4BsMCdNeUGFHwCCdP4iNWIYpqcEf ViIA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o15-20020a635d4f000000b003ab938b9b53si3235332pgm.242.2022.06.01.12.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:51:30 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 7707C1F89A6; Wed, 1 Jun 2022 12:13:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347223AbiEaTEj convert rfc822-to-8bit (ORCPT + 99 others); Tue, 31 May 2022 15:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231464AbiEaTEh (ORCPT ); Tue, 31 May 2022 15:04:37 -0400 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 882835A16A; Tue, 31 May 2022 12:04:36 -0700 (PDT) Received: by mail-qt1-f173.google.com with SMTP id hf10so1773586qtb.7; Tue, 31 May 2022 12:04:36 -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=1ZeGJTUXZPxAO5jhONwtVhilmc3GtYxBhVB9MqXOe9g=; b=pZTlsKPPrr7OlIeBxRn7GAu78CrTE8lb9O2HLaC6BEJ0mWx86LY4N5feFKOpdYEZyN rt+mdNS/ttWHvJmdhMQwY5HRFv2l5zU7jY4sVZnScZWGxbvAcXCvk14oKPlla86MFr7h /U8E21OiqkMjG3GvTLC5jA+Etj3NO3NpDs+lPqzEhvMFjIpOeA+1vPTAzDzJJPmwz4nq S4Emquz4AmabNLdqxnUgHAD8lKwQvIRS+kZWFHH8DatmZWY5qJ0vNBj4wzlNQz1265Gz EKOHmza2dZLs3RBu3AYZk53mwtRnrZvrjU2uAQJ5iu3pin+uCf1RjRvqZkF2//J5awai nNfQ== X-Gm-Message-State: AOAM5338iMbRdK1EKg1Y2uRR1e1RXJaEVdopVthaq3SUb4rnIU+tWkt6 GpvTWA6YJU5Ut+HxhRoeR7BZ5dCA2hBpLg== X-Received: by 2002:a05:622a:54f:b0:2f3:d566:e22c with SMTP id m15-20020a05622a054f00b002f3d566e22cmr49654230qtx.466.1654023875385; Tue, 31 May 2022 12:04:35 -0700 (PDT) Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com. [209.85.219.176]) by smtp.gmail.com with ESMTPSA id c135-20020ae9ed8d000000b0069fc13ce232sm9757209qkg.99.2022.05.31.12.04.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 May 2022 12:04:34 -0700 (PDT) Received: by mail-yb1-f176.google.com with SMTP id v22so6971497ybd.5; Tue, 31 May 2022 12:04:34 -0700 (PDT) X-Received: by 2002:a05:6902:905:b0:64a:2089:f487 with SMTP id bu5-20020a056902090500b0064a2089f487mr61384058ybb.202.1654023864081; Tue, 31 May 2022 12:04:24 -0700 (PDT) MIME-Version: 1.0 References: <20220509233235.995021-1-dmitry.osipenko@collabora.com> <20220509233235.995021-17-dmitry.osipenko@collabora.com> In-Reply-To: <20220509233235.995021-17-dmitry.osipenko@collabora.com> From: Geert Uytterhoeven Date: Tue, 31 May 2022 21:04:12 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 16/27] m68k: Switch to new sys-off handler API 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 Hi Dmitry, On Tue, May 10, 2022 at 1:34 AM Dmitry Osipenko wrote: > Kernel now supports chained power-off handlers. Use > register_power_off_handler() that registers power-off handlers and > do_kernel_power_off() that invokes chained power-off handlers. Legacy > pm_power_off() will be removed once all drivers will be converted to > the new sys-off API. > > Normally arch code should adopt only the do_kernel_power_off() at first, > but m68k is a special case because it uses pm_power_off() "inside out", > i.e. pm_power_off() invokes machine_power_off() [in fact it does nothing], > while it's machine_power_off() that should invoke the pm_power_off(), and > thus, we can't convert platforms to the new API separately. There are only > two platforms changed here, so it's not a big deal. > > Acked-by: Geert Uytterhoeven > Reviewed-by: Michał Mirosław > Signed-off-by: Dmitry Osipenko Thanks for your patch, which is now commit f0f7e5265b3b37b0 ("m68k: Switch to new sys-off handler API") upstream. > --- a/arch/m68k/emu/natfeat.c > +++ b/arch/m68k/emu/natfeat.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -90,5 +91,5 @@ void __init nf_init(void) > pr_info("NatFeats found (%s, %lu.%lu)\n", buf, version >> 16, > version & 0xffff); > > - mach_power_off = nf_poweroff; > + register_platform_power_off(nf_poweroff); Unfortunately nothing is registered, as this is called very early (from setup_arch(), before the memory allocator is available. Hence register_sys_off_handler() fails with -ENOMEM, and poweroff stops working. Possible solutions: - As at most one handler can be registered, register_platform_power_off() could use a static struct sys_off_handler instance, - Keep mach_power_off, and call register_platform_power_off() later. Anything else? Thanks! > --- a/arch/m68k/mac/config.c > +++ b/arch/m68k/mac/config.c > @@ -12,6 +12,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -140,7 +141,6 @@ void __init config_mac(void) > mach_hwclk = mac_hwclk; > mach_reset = mac_reset; > mach_halt = mac_poweroff; > - mach_power_off = mac_poweroff; > #if IS_ENABLED(CONFIG_INPUT_M68K_BEEP) > mach_beep = mac_mksound; > #endif > @@ -160,6 +160,8 @@ void __init config_mac(void) > > if (macintosh_config->ident == MAC_MODEL_IICI) > mach_l2_flush = via_l2_flush; > + > + register_platform_power_off(mac_poweroff); > } This must have the same problem. 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