Message ID | 20221228161915.13194-2-samuel@sholland.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1972051wrt; Wed, 28 Dec 2022 08:23:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXvDa0kYm/K2AMBWoaUL/WiBRrbt0ha9mMCq9r459YrTKP2xuDuB7BFzn4bgWHI0QvZwM6xZ X-Received: by 2002:a05:6a00:1387:b0:581:26c2:700f with SMTP id t7-20020a056a00138700b0058126c2700fmr13812198pfg.24.1672244624568; Wed, 28 Dec 2022 08:23:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672244624; cv=none; d=google.com; s=arc-20160816; b=06ENRhfbx8RscYlAYFuOr4v0Fn7twOTMmNqR5gtEiMA0XrkMoEqyfOynpb1uIIHjwD K2muJZxfuRTDTRnm6jXMYIkeg6UYizEZJWgFuDd9jwP95cn3gTcL3cSlFqleLaA4yVX7 5GSYdoWeohSTzpgAGFfFIfPESPCMpXreHBOOyJFpDImGUNUBdrMdFpnT8uaGhJTidISn 6iQaeasDXjrEmutmjlsnHEnwQlfWREgyl71f9UWNX/ZExoXQBeoc93uVVGIqZlzLvbT6 0Ny04BsNydoiaq6RhCDXE2Vm+IXxEJoxVqDE02g0xfqtGfrW1GTcllVQ2j+c2YXBYd+Q LDVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=+U8N0UmTlYd9YC+LHaZbBbMVD4CfYomec3Duaw8K1K0=; b=Uus5LFLE/YSLZZOMrnij/WEfN3Q+XhxHB1N9/us33FWZeS/EhU/ameXrZS71GYmXC1 WmWKMhcYhnjQsDlAW0Iku7XKJRYs2t2C2ZBX6pdonRUacZLRtS/C/Df1mpP0UYdifsAn LYklkYXvp/rNtZOEZ9fhUT2gfrH1cLJlQlF3lk7zosTLkjv5FUcj7Ntnuc1tEmp2JAI3 C9xawboenvk78/o3gjVE15zk2SaCh3OaYGeVFX57+95dR7j9lYCaqZ5hQN164SYdF/cT nv3F0sJr9opvLaaO8N0+oB6Wu2u4UXrs96NPnYoVawQega0AUTC836zuPUSMjb8y5QV6 8tSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=zr7fbQXW; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LHKENN4H; 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=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cq26-20020a056a00331a00b00563764cecb3si3894677pfb.279.2022.12.28.08.23.32; Wed, 28 Dec 2022 08:23:44 -0800 (PST) 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=@sholland.org header.s=fm3 header.b=zr7fbQXW; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LHKENN4H; 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=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234592AbiL1QXG (ORCPT <rfc822;eddaouddi.ayoub@gmail.com> + 99 others); Wed, 28 Dec 2022 11:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234479AbiL1QVZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 28 Dec 2022 11:21:25 -0500 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 510701B794 for <linux-kernel@vger.kernel.org>; Wed, 28 Dec 2022 08:19:22 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 85F6D5C018E; Wed, 28 Dec 2022 11:19:20 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 28 Dec 2022 11:19:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672244360; x=1672330760; bh=+U 8N0UmTlYd9YC+LHaZbBbMVD4CfYomec3Duaw8K1K0=; b=zr7fbQXW2nEGBaEc4T INBtGnH6KEP1UgaieU+aZQgiU7aex0jvJZ0hgkFNPQgPnGSGz+BS0aRbXoHxRiT4 6H4yZd4xNTWGevCjZAZI6VU1kZpJdCpqYl2w4409kmFiqPGz8BM/SxKDmUQTqcaJ yVoXJyocG2vIcB8uwuobV8E/tHIkFFDkFQSW+IPlb90zDVUquNiGSUUFeDesMf9B 2YzihJ/Q6yBVKk6oJD+U/89eg4X/mQLNYxsUPf5sZAhBIYcCcojHxGxJuQD6JJPU qLuT6uOM6fSzkL+B021ISwz3y/ey4FRgx/EKS2uiaC009Pqo6zgH0JgQUpyogB4U 3Q8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672244360; x=1672330760; bh=+U8N0UmTlYd9Y C+LHaZbBbMVD4CfYomec3Duaw8K1K0=; b=LHKENN4HaAl9eTzGJzlvlQQpxNiLw iL6iM4q8xbb93azfif+ouJbTwpUljNqJKRjm4A/vC8brr0ZuAxt8ShwIWx82v+zq IyZ7s9L+YoBix7xe3GSigT0lOs/kN+nSuN4Xl9ElTA4MQco4MtwjwbrzRHlfxaIk PH5BgqZP8fWpQ0AhynLvv6xEV5bm7A7ON7moOTSnAMFF9bSX721CQdBwMS55TmU4 Ya04Rq8J3mCLr3I4znNAahnK+TXBMqKIQprlphidStUGpfop7F8fkulJUY9fKEoQ NBNlM1qDxAr4Q6tv1/mU3No71LrlJHkF3AKsZceWe9ptexc5zc5n98NDw== X-ME-Sender: <xms:iGysY0guii7cQfF3e2W_lRxmUExyUnzANv7WpecgE_V6PXRhEBE3-w> <xme:iGysY9CAwFhrx-LblKgItSvPDJurlJRPedCt32q6Na7mhNkVC2QbK3taWaYTrc_N1 XmbSE1yi3VFO5naFw> X-ME-Received: <xmr:iGysY8EQ0tSzJ9YzTNkvQsT_jg3CD6GkFW6sYtmGocEeiuxv3VqITuOBOvHH1Jqmbr2A7Dx2WM6dWpW0VQzzFV0eJckM6IZZmgXr2B9CI-io4-g9oYxMiw81poqa9eKjmmRzig> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedriedvgdeklecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: <xmx:iGysY1T0TW22FduipxSaawhlvwDpX67u9VymKmdZR035lCkXHzO86w> <xmx:iGysYxxEaOW5xKb8sJ6kkMOvKqkT_aNQffn5_4kt561AGRg0ykB2DA> <xmx:iGysYz7ETO1Ke2PXq2Uy55OipoQXUr4zYO-uD5-5G_Qr5ACmte34-g> <xmx:iGysY-id7cP476eOi3xrJGeEeUTYklhs93sfPvleQUlhLpvHpp5SuQ> Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Dec 2022 11:19:19 -0500 (EST) From: Samuel Holland <samuel@sholland.org> To: Palmer Dabbelt <palmer@dabbelt.com>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, "Rafael J . Wysocki" <rafael.j.wysocki@intel.com> Cc: Samuel Holland <samuel@sholland.org>, Albert Ou <aou@eecs.berkeley.edu>, Anup Patel <apatel@ventanamicro.com>, Atish Patra <atishp@rivosinc.com>, Geert Uytterhoeven <geert@linux-m68k.org>, Heiko Stuebner <heiko@sntech.de>, Kai-Heng Feng <kai.heng.feng@canonical.com>, Luis Chamberlain <mcgrof@kernel.org>, "Paul E. McKenney" <paulmck@kernel.org>, Paul Walmsley <paul.walmsley@sifive.com>, Petr Mladek <pmladek@suse.com>, YueHaibing <yuehaibing@huawei.com>, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, tangmeng <tangmeng@uniontech.com> Subject: [PATCH 1/3] kernel/reboot: Use the static sys-off handler for any priority Date: Wed, 28 Dec 2022 10:19:13 -0600 Message-Id: <20221228161915.13194-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221228161915.13194-1-samuel@sholland.org> References: <20221228161915.13194-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753475579612779865?= X-GMAIL-MSGID: =?utf-8?q?1753475579612779865?= |
Series |
riscv: sbi: Switch to the sys-off handler API
|
|
Commit Message
Samuel Holland
Dec. 28, 2022, 4:19 p.m. UTC
commit 587b9bfe0668 ("kernel/reboot: Use static handler for register_platform_power_off()") addded a statically-allocated handler so register_sys_off_handler() could be called before the slab allocator is available. That behavior was limited to the SYS_OFF_PRIO_PLATFORM priority. However, it is also required for handlers such as PSCI on ARM and SBI on RISC-V, which should be registered at SYS_OFF_PRIO_FIRMWARE. Currently, this call stack crashes: start_kernel() setup_arch() psci_dt_init() psci_0_2_init() register_sys_off_handler() kmem_cache_alloc() Generalize the code to use the statically-allocated handler for the first registration, regardless of priority. Check .sys_off_cb for conflicts instead of .cb_data; some callbacks (e.g. firmware drivers) do not need any per-instance data, so .cb_data could be NULL. Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Samuel Holland <samuel@sholland.org> --- kernel/reboot.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
Comments
On Wed, 28 Dec 2022 08:19:13 PST (-0800), samuel@sholland.org wrote: > commit 587b9bfe0668 ("kernel/reboot: Use static handler for > register_platform_power_off()") addded a statically-allocated handler > so register_sys_off_handler() could be called before the slab allocator > is available. > > That behavior was limited to the SYS_OFF_PRIO_PLATFORM priority. > However, it is also required for handlers such as PSCI on ARM and SBI on > RISC-V, which should be registered at SYS_OFF_PRIO_FIRMWARE. Currently, > this call stack crashes: > > start_kernel() > setup_arch() > psci_dt_init() > psci_0_2_init() > register_sys_off_handler() > kmem_cache_alloc() > > Generalize the code to use the statically-allocated handler for the > first registration, regardless of priority. Check .sys_off_cb for > conflicts instead of .cb_data; some callbacks (e.g. firmware drivers) > do not need any per-instance data, so .cb_data could be NULL. > > Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> > Signed-off-by: Samuel Holland <samuel@sholland.org> > --- > > kernel/reboot.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/kernel/reboot.c b/kernel/reboot.c > index 3bba88c7ffc6..38c18d4f0a36 100644 > --- a/kernel/reboot.c > +++ b/kernel/reboot.c > @@ -327,7 +327,7 @@ static int sys_off_notify(struct notifier_block *nb, > return handler->sys_off_cb(&data); > } > > -static struct sys_off_handler platform_sys_off_handler; > +static struct sys_off_handler early_sys_off_handler; > > static struct sys_off_handler *alloc_sys_off_handler(int priority) > { > @@ -338,10 +338,8 @@ static struct sys_off_handler *alloc_sys_off_handler(int priority) > * Platforms like m68k can't allocate sys_off handler dynamically > * at the early boot time because memory allocator isn't available yet. > */ > - if (priority == SYS_OFF_PRIO_PLATFORM) { > - handler = &platform_sys_off_handler; > - if (handler->cb_data) > - return ERR_PTR(-EBUSY); > + if (!early_sys_off_handler.sys_off_cb) { > + handler = &early_sys_off_handler; > } else { > if (system_state > SYSTEM_RUNNING) > flags = GFP_ATOMIC; > @@ -358,7 +356,7 @@ static struct sys_off_handler *alloc_sys_off_handler(int priority) > > static void free_sys_off_handler(struct sys_off_handler *handler) > { > - if (handler == &platform_sys_off_handler) > + if (handler == &early_sys_off_handler) > memset(handler, 0, sizeof(*handler)); > else > kfree(handler); Sorry for being slow here, I'd been assuming someone would Ack this but it looks like maybe there's nobody in the maintainers file for kernel/reboot.c? I'm fine taking this via the RISC-V tree if that's OK with people, but the cover letter suggests the patch is necessary for multiple patch sets.
On 2/14/23 18:17, Palmer Dabbelt wrote: > On Wed, 28 Dec 2022 08:19:13 PST (-0800), samuel@sholland.org wrote: >> commit 587b9bfe0668 ("kernel/reboot: Use static handler for >> register_platform_power_off()") addded a statically-allocated handler >> so register_sys_off_handler() could be called before the slab allocator >> is available. >> >> That behavior was limited to the SYS_OFF_PRIO_PLATFORM priority. >> However, it is also required for handlers such as PSCI on ARM and SBI on >> RISC-V, which should be registered at SYS_OFF_PRIO_FIRMWARE. Currently, >> this call stack crashes: >> >> start_kernel() >> setup_arch() >> psci_dt_init() >> psci_0_2_init() >> register_sys_off_handler() >> kmem_cache_alloc() >> >> Generalize the code to use the statically-allocated handler for the >> first registration, regardless of priority. Check .sys_off_cb for >> conflicts instead of .cb_data; some callbacks (e.g. firmware drivers) >> do not need any per-instance data, so .cb_data could be NULL. >> >> Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> >> Signed-off-by: Samuel Holland <samuel@sholland.org> >> --- >> >> kernel/reboot.c | 10 ++++------ >> 1 file changed, 4 insertions(+), 6 deletions(-) >> >> diff --git a/kernel/reboot.c b/kernel/reboot.c >> index 3bba88c7ffc6..38c18d4f0a36 100644 >> --- a/kernel/reboot.c >> +++ b/kernel/reboot.c >> @@ -327,7 +327,7 @@ static int sys_off_notify(struct notifier_block *nb, >> return handler->sys_off_cb(&data); >> } >> >> -static struct sys_off_handler platform_sys_off_handler; >> +static struct sys_off_handler early_sys_off_handler; >> >> static struct sys_off_handler *alloc_sys_off_handler(int priority) >> { >> @@ -338,10 +338,8 @@ static struct sys_off_handler >> *alloc_sys_off_handler(int priority) >> * Platforms like m68k can't allocate sys_off handler dynamically >> * at the early boot time because memory allocator isn't >> available yet. >> */ >> - if (priority == SYS_OFF_PRIO_PLATFORM) { >> - handler = &platform_sys_off_handler; >> - if (handler->cb_data) >> - return ERR_PTR(-EBUSY); >> + if (!early_sys_off_handler.sys_off_cb) { >> + handler = &early_sys_off_handler; >> } else { >> if (system_state > SYSTEM_RUNNING) >> flags = GFP_ATOMIC; >> @@ -358,7 +356,7 @@ static struct sys_off_handler >> *alloc_sys_off_handler(int priority) >> >> static void free_sys_off_handler(struct sys_off_handler *handler) >> { >> - if (handler == &platform_sys_off_handler) >> + if (handler == &early_sys_off_handler) >> memset(handler, 0, sizeof(*handler)); >> else >> kfree(handler); > > Sorry for being slow here, I'd been assuming someone would Ack this but > it looks like maybe there's nobody in the maintainers file for > kernel/reboot.c? I'm fine taking this via the RISC-V tree if that's OK > with people, but the cover letter suggests the patch is necessary for > multiple patch sets. See also Dmitry's reply[0] to the PSCI thread. (Maybe I should have sent both conversions as one series?) I am happy with the patches going through any tree. The kernel/reboot.c patch is exactly the same between the two series, so it should not hurt if it gets merged twice. Though if you take this series through the RISC-V tree, maybe you want to create a tag for it? I am not sure exactly what needs to be done here; I am happy to do anything that would assist getting both series merged for v6.3, to avoid a regression with axp20x[1]. Regards, Samuel [0]: https://lore.kernel.org/lkml/0a180849-ba1b-2a82-ab06-ed1b8155d5ca@collabora.com/ [1]: https://lore.kernel.org/lkml/e38d29f5-cd3c-4a2b-b355-2bcfad00a24b@sholland.org/
On 2/19/23 02:20, Samuel Holland wrote: > On 2/14/23 18:17, Palmer Dabbelt wrote: ... >> Sorry for being slow here, I'd been assuming someone would Ack this but >> it looks like maybe there's nobody in the maintainers file for >> kernel/reboot.c? I'm fine taking this via the RISC-V tree if that's OK >> with people, but the cover letter suggests the patch is necessary for >> multiple patch sets. > > See also Dmitry's reply[0] to the PSCI thread. (Maybe I should have sent > both conversions as one series?) > > I am happy with the patches going through any tree. The kernel/reboot.c > patch is exactly the same between the two series, so it should not hurt > if it gets merged twice. Though if you take this series through the > RISC-V tree, maybe you want to create a tag for it? > > I am not sure exactly what needs to be done here; I am happy to do > anything that would assist getting both series merged for v6.3, to avoid > a regression with axp20x[1]. > > Regards, > Samuel > > [0]: > https://lore.kernel.org/lkml/0a180849-ba1b-2a82-ab06-ed1b8155d5ca@collabora.com/ > [1]: > https://lore.kernel.org/lkml/e38d29f5-cd3c-4a2b-b355-2bcfad00a24b@sholland.org/ The reboot.c changes should be acked/applied by Rafael. I noticed that you haven't CC'd the linux-pm ML, maybe that's why it hasn't got the attention.
On Sat, 18 Feb 2023 15:32:06 PST (-0800), dmitry.osipenko@collabora.com wrote: > On 2/19/23 02:20, Samuel Holland wrote: >> On 2/14/23 18:17, Palmer Dabbelt wrote: > ... >>> Sorry for being slow here, I'd been assuming someone would Ack this but >>> it looks like maybe there's nobody in the maintainers file for >>> kernel/reboot.c? I'm fine taking this via the RISC-V tree if that's OK >>> with people, but the cover letter suggests the patch is necessary for >>> multiple patch sets. >> >> See also Dmitry's reply[0] to the PSCI thread. (Maybe I should have sent >> both conversions as one series?) >> >> I am happy with the patches going through any tree. The kernel/reboot.c >> patch is exactly the same between the two series, so it should not hurt >> if it gets merged twice. Though if you take this series through the >> RISC-V tree, maybe you want to create a tag for it? >> >> I am not sure exactly what needs to be done here; I am happy to do >> anything that would assist getting both series merged for v6.3, to avoid >> a regression with axp20x[1]. >> >> Regards, >> Samuel >> >> [0]: >> https://lore.kernel.org/lkml/0a180849-ba1b-2a82-ab06-ed1b8155d5ca@collabora.com/ >> [1]: >> https://lore.kernel.org/lkml/e38d29f5-cd3c-4a2b-b355-2bcfad00a24b@sholland.org/ > > The reboot.c changes should be acked/applied by Rafael. > I noticed that you haven't CC'd the linux-pm ML, maybe that's why it > hasn't got the attention. OK, I'm adding them here. Not sure if we're ment to re-send it to the list, no rush on my end I'm just scrubbing through some old stuff on patchwork again.
diff --git a/kernel/reboot.c b/kernel/reboot.c index 3bba88c7ffc6..38c18d4f0a36 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -327,7 +327,7 @@ static int sys_off_notify(struct notifier_block *nb, return handler->sys_off_cb(&data); } -static struct sys_off_handler platform_sys_off_handler; +static struct sys_off_handler early_sys_off_handler; static struct sys_off_handler *alloc_sys_off_handler(int priority) { @@ -338,10 +338,8 @@ static struct sys_off_handler *alloc_sys_off_handler(int priority) * Platforms like m68k can't allocate sys_off handler dynamically * at the early boot time because memory allocator isn't available yet. */ - if (priority == SYS_OFF_PRIO_PLATFORM) { - handler = &platform_sys_off_handler; - if (handler->cb_data) - return ERR_PTR(-EBUSY); + if (!early_sys_off_handler.sys_off_cb) { + handler = &early_sys_off_handler; } else { if (system_state > SYSTEM_RUNNING) flags = GFP_ATOMIC; @@ -358,7 +356,7 @@ static struct sys_off_handler *alloc_sys_off_handler(int priority) static void free_sys_off_handler(struct sys_off_handler *handler) { - if (handler == &platform_sys_off_handler) + if (handler == &early_sys_off_handler) memset(handler, 0, sizeof(*handler)); else kfree(handler);