From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 374D4C433FE for ; Sun, 6 Nov 2022 22:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cVyfHUTdI8YQ19cHV6HW8zgCd55rfqZYE1FYGUAIQgs=; b=LLE5dFOXe0ye+g fUMbnHrL4s9/gBwsCrRpphLOVhWy14ph4UIZsM/2QFnHundiIw2naSCHGrUyv2R+/t7aiqFSZCst8 CuI5uFoNjNHFoeWnoYnZMUrJRPd16nNEdHcwRZ3PXctjXGT9URcKY+mciW7cVJz1v/jD8kqik2LiD NadhZTw0HhcInLyeHXgqMhKlL1+fszc616OXJTQ+euHM/00ZFYVkE13axYITEK7vpVvB1vjIlc4aM fehifeEeKMASs+/jADEwVt3oUpJCDOw9sBf/apuBcHZK9od0VF9BQqu2a3mgQH/eZBIV6T8xmJfpc V2OHZdQAv3wJ4RxVwycA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oro8Y-00AGd5-9Y; Sun, 06 Nov 2022 22:29:06 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oro8U-00AGai-Gu for linux-arm-kernel@lists.infradead.org; Sun, 06 Nov 2022 22:29:04 +0000 Received: from [192.168.2.238] (109-252-117-140.nat.spd-mgts.ru [109.252.117.140]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id 2481E660226C; Sun, 6 Nov 2022 22:28:53 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1667773733; bh=aLC82hYUdpoSkhtiTndL8qGiojFW9ZfDhBbsDDusSNg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Py9eb5IKIzJFg3JgXl5J76l4OcKs0nnM4Bn3M5aiuU1i6PLyutFzFakokzChDdsnA ofIXxZBOho1h98aaTTw5yzMvmk0413A5qcCuhI4gVyOYffHgM/qrB3pjBPsZkn6RQh UODpDqtFyPXI0PxaCS0nTlJDK1T7/r3tr0PpD9nT2f/CZ3PbY2HitBndAscuVBVMch S82KoD0A6MQlZ7tQKoEJc8L0vObrqV14Vjlv7WERo0vPJrHkitxEn/5YPH1yQK3lSF ibhuNlg2eaNnb/ljS+XP4IotSHCMeaw6Ag2+sTfVTqAcWBMzl6vK5SxTTg+AWMbEG3 SGWn8KTc/YHWw== Message-ID: <02d127e1-adbb-3cc0-5da2-de3f961918a3@collabora.com> Date: Mon, 7 Nov 2022 01:28:50 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH 1/2] kernel/reboot: Use the static sys-off handler for any priority Content-Language: en-US To: Samuel Holland , "Rafael J . Wysocki" , Mark Rutland , Lorenzo Pieralisi Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20221105214841.7828-1-samuel@sholland.org> <20221105214841.7828-2-samuel@sholland.org> From: Dmitry Osipenko In-Reply-To: <20221105214841.7828-2-samuel@sholland.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221106_142902_745411_80B5FA59 X-CRM114-Status: GOOD ( 23.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 11/6/22 00:48, Samuel Holland 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, which > needs to 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) do not > need any per-instance data, so .cb_data could be NULL. > > Signed-off-by: Samuel Holland > --- > > 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); Reviewed-by: Dmitry Osipenko -- Best regards, Dmitry _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel