Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2043008rwb; Mon, 7 Nov 2022 08:30:45 -0800 (PST) X-Google-Smtp-Source: AMsMyM67tU2wEE15s0/kY+Bmgc3E/6GnXPC2JAfADtTjzPR4vTK0zvcUIOq8Gckd5ga1GeaWeQlV X-Received: by 2002:a63:1455:0:b0:438:e26b:ab1f with SMTP id 21-20020a631455000000b00438e26bab1fmr42673822pgu.183.1667838645175; Mon, 07 Nov 2022 08:30:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667838645; cv=none; d=google.com; s=arc-20160816; b=GwsE1R70+uMKKjxiskMY6LSIeQsxzwKRzTuTaq7xOTp34J2voHouuKvLHHEYpdf+zE AuefgHjNYXKz9FQDNchp+Pq2pBkNIhG/HnykhwhlGpw1f3Ju8IDImNefE3hWyFjU80Cy TDv4Tb0+sK0WyjIN6Rl7k99nLgLwXqCYhC+mlQGnfLDvvtqoqpznD7JAnc2y+4yLKnsO kiHFghEmuzuG72ozGn9nJVH7ug63Ms1Pvd6HlYe7Zx2BeqDOqrSfGrW5UHbvwals2PIV CiHLdUz4Q6sJUMkkX6lmvkkwCiqi75hN85OYRXPEVekF7YjA9VygBtOFhf7DvN1cIvz5 JxJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=evXajjZrMENBv1JToU8Jtsbtbu/69OKMUbRFHUpgDLs=; b=CmF0RcNRwtH5NF5Fgf7loBTwKgxSuPyGmdKrZ+ofxO4UXzcKT0Mww+RCpApnS78ggl RiWGAWEkAtlvuMqmgsb6ayvuaqXLPMPMXNGzuDF4YLRgDiSx4V3bPgEyA3xoqO/lfFsF OZ3FDnA+GWTWZaARZOWJcZjR5MCStic/r9d8mWCEPSg/8Uuz1hV/xFDF91aDu5sQd4YF +ft5FBDw2PTORt1xVD7wgcBm8VApptbnJd1jy7/nU5DcxAZvxFgqSIcgBjJ4BpVleWTN jb9bp+Xxaeh/OrIGphKNikHhq+LRW8k9UdCzz/1Kq+Z30zhhRfLGWepCge4eIfcOjS/W c2hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BA1A5ifI; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a631d09000000b0044fb27b64c7si10336436pgd.326.2022.11.07.08.30.32; Mon, 07 Nov 2022 08:30:45 -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=@kernel.org header.s=k20201202 header.b=BA1A5ifI; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232743AbiKGQOZ (ORCPT + 92 others); Mon, 7 Nov 2022 11:14:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232511AbiKGQOW (ORCPT ); Mon, 7 Nov 2022 11:14:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C187D6B for ; Mon, 7 Nov 2022 08:14:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 43781B81151 for ; Mon, 7 Nov 2022 16:14:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 597BEC433C1; Mon, 7 Nov 2022 16:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667837658; bh=8drlGFPWT+4zRBSJGyTdu5Q3x+jj0nADH5k69cVKWOs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BA1A5ifIWCD5A52rdUTVJbghYPT4GLWS3cEeOuePzU+zC8zHluxCV1Bfvlkpm8viH 3sZsz07PQISTVga3BHnvC4fRJVKnlRhIvZvQuSuBY8r8bYQdiWZSV2hZ4zrJxZvyoG 8DQQ0jpscMw3e5R+k6zAvLJu9VA9oSVlKsCGecvZ8qT3KeYA2Od57twEPQ3o4NtnqS 9Udy3W4CQkdGgSnr93fyiZnEufgIWwmvRKyqeYTzLsZs/NmmNad0rHhxHdcCbzJfVN /lsjf4suUXEtvrRoHk0zo5tMx8cQdURfJsNvJA5pYb9RVsmIvkp/8p9Xdeda19jbgc ZeSwMmMh4m1Ww== Date: Mon, 7 Nov 2022 16:14:12 +0000 From: Will Deacon To: Pierre Gondois Cc: linux-kernel@vger.kernel.org, James Morse , Huacai Chen , John Garry , Shaokun Zhang , WANG Xuerui , Qi Liu , Bharat Bhushan , Huang Ying , Bibo Mao , "Jason A. Donenfeld" , Daniel Lezcano , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2] firmware: arm_sdei: Fix sleep from invalid context BUG Message-ID: <20221107161411.GF21157@willie-the-truck> References: <20221018130456.1356081-1-pierre.gondois@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221018130456.1356081-1-pierre.gondois@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 18, 2022 at 03:04:53PM +0200, Pierre Gondois wrote: > On an Ampere Altra, > Running a preemp_rt kernel based on v5.19-rc3-rt5 on an > Ampere Altra triggers: > [ 15.683141] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46 > [ 15.683154] in_atomic(): 0, irqs_disabled(): 128, non_block: 0, pid: 24, name: cpuhp/0 > [ 15.683157] preempt_count: 0, expected: 0 > [ 15.683159] RCU nest depth: 0, expected: 0 > [ 15.683163] 3 locks held by cpuhp/0/24: > [ 15.683167] #0: ffffda30217c70d0 (cpu_hotplug_lock){++++}-{0:0}, at: cpuhp_thread_fun+0x5c/0x248 > [ 15.683201] #1: ffffda30217c7120 (cpuhp_state-up){+.+.}-{0:0}, at: cpuhp_thread_fun+0x5c/0x248 > [ 15.683205] #2: ffffda3021c711f0 (sdei_list_lock){....}-{3:3}, at: sdei_cpuhp_up+0x3c/0x130 > [ 15.683224] irq event stamp: 36 > [ 15.683226] hardirqs last enabled at (35): [] finish_task_switch+0xb4/0x2b0 > [ 15.683236] hardirqs last disabled at (36): [] cpuhp_thread_fun+0x21c/0x248 > [ 15.683238] softirqs last enabled at (0): [] copy_process+0x63c/0x1ac0 > [ 15.683245] softirqs last disabled at (0): [<0000000000000000>] 0x0 > [ 15.683258] CPU: 0 PID: 24 Comm: cpuhp/0 Not tainted 5.19.0-rc3-rt5-[...] > [ 15.683265] Hardware name: WIWYNN Mt.Jade Server System B81.03001.0005/Mt.Jade Motherboard, BIOS 1.08.20220218 (SCP: 1.08.20220218) 2022/02/18 > [ 15.683268] Call trace: > [ 15.683271] dump_backtrace+0x114/0x120 > [ 15.683277] show_stack+0x20/0x70 > [ 15.683279] dump_stack_lvl+0x9c/0xd8 > [ 15.683288] dump_stack+0x18/0x34 > [ 15.683289] __might_resched+0x188/0x228 > [ 15.683292] rt_spin_lock+0x70/0x120 > [ 15.683301] sdei_cpuhp_up+0x3c/0x130 > [ 15.683303] cpuhp_invoke_callback+0x250/0xf08 > [ 15.683305] cpuhp_thread_fun+0x120/0x248 > [ 15.683308] smpboot_thread_fn+0x280/0x320 > [ 15.683315] kthread+0x130/0x140 > [ 15.683321] ret_from_fork+0x10/0x20 > > sdei_cpuhp_up() is called in the STARTING hotplug section, > which runs whith interrupts disabled. Move CPUHP_AP_ARM_SDEI_ > state to the _ONLINE section to execute the cpuhp cb with > preemption enabled. > > 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. This means that no check will be done for some > cases, e.g. sdei_mask_local_cpu() invocations. > > Also add a check for the SDEI_1_0_FN_SDEI_PRIVATE_RESET SDEI call > which acts on the calling CPU. > > Suggested-by: James Morse > Signed-off-by: Pierre Gondois > --- > drivers/firmware/arm_sdei.c | 28 ++++++++++++++-------------- > include/linux/cpuhotplug.h | 2 +- > 2 files changed, 15 insertions(+), 15 deletions(-) James -- are you taking care of this one, or should I queue it via arm64? Will