Skip to content

Commit 5b65258

Browse files
computersforpeaceKAGA-KOKO
authored andcommitted
genirq/test: Resolve irq lock inversion warnings
irq_shutdown_and_deactivate() is normally called with the descriptor lock held, and interrupts disabled. Nested a few levels down, it grabs the global irq_resend_lock. Lockdep rightfully complains when interrupts are not disabled: CPU0 CPU1 ---- ---- lock(irq_resend_lock); local_irq_disable(); lock(&irq_desc_lock_class); lock(irq_resend_lock); <Interrupt> lock(&irq_desc_lock_class); ... _raw_spin_lock+0x2b/0x40 clear_irq_resend+0x14/0x70 irq_shutdown_and_deactivate+0x29/0x80 irq_shutdown_depth_test+0x1ce/0x600 kunit_try_run_case+0x90/0x120 Grab the descriptor lock and disable interrupts, to resolve the problem. Fixes: 66067c3 ("genirq: Add kunit tests for depth counts") Reported-by: Guenter Roeck <[email protected]> Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/all/[email protected] Closes: https://lore.kernel.org/lkml/[email protected]/
1 parent 9ba0a63 commit 5b65258

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/irq/irq_test.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: LGPL-2.1+
22

3+
#include <linux/cleanup.h>
34
#include <linux/cpu.h>
45
#include <linux/cpumask.h>
56
#include <linux/interrupt.h>
@@ -134,7 +135,8 @@ static void irq_shutdown_depth_test(struct kunit *test)
134135
disable_irq(virq);
135136
KUNIT_EXPECT_EQ(test, desc->depth, 1);
136137

137-
irq_shutdown_and_deactivate(desc);
138+
scoped_guard(raw_spinlock_irqsave, &desc->lock)
139+
irq_shutdown_and_deactivate(desc);
138140

139141
KUNIT_EXPECT_FALSE(test, irqd_is_activated(data));
140142
KUNIT_EXPECT_FALSE(test, irqd_is_started(data));

0 commit comments

Comments
 (0)