From: Will Deacon <will@kernel.org>
To: Pierre Gondois <pierre.gondois@arm.com>
Cc: linux-kernel@vger.kernel.org, James Morse <james.morse@arm.com>,
Huacai Chen <chenhuacai@kernel.org>,
John Garry <john.garry@huawei.com>,
Shaokun Zhang <zhangshaokun@hisilicon.com>,
WANG Xuerui <git@xen0n.name>, Qi Liu <liuqi115@huawei.com>,
Bharat Bhushan <bbhushan2@marvell.com>,
Huang Ying <ying.huang@intel.com>, Bibo Mao <maobibo@loongson.cn>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] firmware: arm_sdei: Fix sleep from invalid context BUG
Date: Mon, 7 Nov 2022 16:14:12 +0000 [thread overview]
Message-ID: <20221107161411.GF21157@willie-the-truck> (raw)
In-Reply-To: <20221018130456.1356081-1-pierre.gondois@arm.com>
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): [<ffffda301e85b7bc>] finish_task_switch+0xb4/0x2b0
> [ 15.683236] hardirqs last disabled at (36): [<ffffda301e812fec>] cpuhp_thread_fun+0x21c/0x248
> [ 15.683238] softirqs last enabled at (0): [<ffffda301e80b184>] 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 <james.morse@arm.com>
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
> ---
> 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-11-07 16:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 13:04 [PATCH v2] firmware: arm_sdei: Fix sleep from invalid context BUG Pierre Gondois
2022-10-18 13:07 ` Pierre Gondois
2023-02-01 16:23 ` Pierre Gondois
2022-11-07 16:14 ` Will Deacon [this message]
2023-02-10 17:42 ` James Morse
2023-02-15 15:55 ` Pierre Gondois
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221107161411.GF21157@willie-the-truck \
--to=will@kernel.org \
--cc=Jason@zx2c4.com \
--cc=bbhushan2@marvell.com \
--cc=chenhuacai@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=git@xen0n.name \
--cc=james.morse@arm.com \
--cc=john.garry@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuqi115@huawei.com \
--cc=maobibo@loongson.cn \
--cc=pierre.gondois@arm.com \
--cc=ying.huang@intel.com \
--cc=zhangshaokun@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox