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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BD92C636CC for ; Wed, 15 Feb 2023 18:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbjBOSNa (ORCPT ); Wed, 15 Feb 2023 13:13:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbjBOSN2 (ORCPT ); Wed, 15 Feb 2023 13:13:28 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E4CD33B66B for ; Wed, 15 Feb 2023 10:13:26 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F26C1042; Wed, 15 Feb 2023 10:14:09 -0800 (PST) Received: from [10.1.196.177] (eglon.cambridge.arm.com [10.1.196.177]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 89FFF3F663; Wed, 15 Feb 2023 10:13:24 -0800 (PST) Message-ID: <2b06fd6c-83d5-3dbe-0227-02091f5d3dac@arm.com> Date: Wed, 15 Feb 2023 18:13:19 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH v3] firmware: arm_sdei: Fix sleep from invalid context BUG Content-Language: en-GB To: Pierre Gondois , Will Deacon Cc: Huacai Chen , Atish Patra , Shaokun Zhang , WANG Xuerui , Guangbin Huang , Bharat Bhushan , Bibo Mao , "Jason A. Donenfeld" , Juergen Gross , Nick Child , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20230215160949.94602-1-pierre.gondois@arm.com> From: James Morse In-Reply-To: <20230215160949.94602-1-pierre.gondois@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pierre, Will, On 15/02/2023 16:09, Pierre Gondois wrote: > Running a preemp_rt kernel based on vv6.2-rc3-rt1 based kernel on an > Ampere Altra triggers: > BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46 > in_atomic(): 0, irqs_disabled(): 128, non_block: 0, pid: 24, name: cpuhp/0 > preempt_count: 0, expected: 0 > RCU nest depth: 0, expected: 0 > 3 locks held by cpuhp/0/24: > #0: ffffda30217c70d0 (cpu_hotplug_lock){++++}-{0:0}, at: cpuhp_thread_fun+0x5c/0x248 > #1: ffffda30217c7120 (cpuhp_state-up){+.+.}-{0:0}, at: cpuhp_thread_fun+0x5c/0x248 > #2: ffffda3021c711f0 (sdei_list_lock){....}-{3:3}, at: sdei_cpuhp_up+0x3c/0x130 > irq event stamp: 36 > hardirqs last enabled at (35): [] finish_task_switch+0xb4/0x2b0 > hardirqs last disabled at (36): [] cpuhp_thread_fun+0x21c/0x248 > softirqs last enabled at (0): [] copy_process+0x63c/0x1ac0 > softirqs last disabled at (0): [<0000000000000000>] 0x0 > CPU: 0 PID: 24 Comm: cpuhp/0 Not tainted 5.19.0-rc3-rt5-[...] > Hardware name: WIWYNN Mt.Jade Server [...] > Call trace: > dump_backtrace+0x114/0x120 > show_stack+0x20/0x70 > dump_stack_lvl+0x9c/0xd8 > dump_stack+0x18/0x34 > __might_resched+0x188/0x228 > rt_spin_lock+0x70/0x120 > sdei_cpuhp_up+0x3c/0x130 > cpuhp_invoke_callback+0x250/0xf08 > cpuhp_thread_fun+0x120/0x248 > smpboot_thread_fn+0x280/0x320 > kthread+0x130/0x140 > ret_from_fork+0x10/0x20 > > sdei_cpuhp_up() is called in the STARTING hotplug section, > which runs whith interrupts disabled. Use a CPUHP_AP_ONLINE_DYN entry Typo: with > instead to execute the cpuhp cb later, with preemption enabled. > > SDEI originaly got its own cpuhp slot because to allow interracting Typo: originally Typo: interacting > with perf. It got superseded by pNMI and this early slot is not > relevant anymore. [1] (Please add a spell checker to your workflow. 'codespell' knows which bits of a diff it should check) "because to allow interacting" isn't easy to parse, "to allow an interaction with"? > Some SDEI calls (e.g. SDEI_1_0_FN_SDEI_PE_MASK) take actions on the > calling CPU. It is checked that preemption is disabled for them. > _ONLINE cpuhp cb are executed in the 'per CPU hotplug thread'. > Preemption is enabled in those threads, but their cpumask is limited > to 1 CPU. > Move 'WARN_ON_ONCE(preemptible())' statements so that SDEI cpuhp cb > don't trigger them. > > Also add a check for the SDEI_1_0_FN_SDEI_PRIVATE_RESET SDEI call > which acts on the calling CPU. Thanks for sticking with this, Reviewed-by: James Morse Will, are you happy to pick this up and fix the typos, or would you prefer a clean version to be posted? Thanks, James