linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] genirq/test: Platform/architecture fixes
@ 2025-08-22 18:59 Brian Norris
  2025-08-22 18:59 ` [PATCH v2 1/6] genirq/test: Select IRQ_DOMAIN Brian Norris
                   ` (7 more replies)
  0 siblings, 8 replies; 23+ messages in thread
From: Brian Norris @ 2025-08-22 18:59 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: David Gow, linux-kernel, Guenter Roeck, Geert Uytterhoeven,
	kunit-dev, Brian Norris

The new kunit tests at kernel/irq/irq_test.c were primarily tested on
x86_64, with QEMU and with ARCH=um builds. Naturally, there are other
architectures that throw complications in the mix, with various CPU
hotplug and IRQ implementation choices.

Guenter has been dutifully noticing and reporting these errors, in
places like:
https://lore.kernel.org/all/b4cf04ea-d398-473f-bf11-d36643aa50dd@roeck-us.net/

I hope I've addressed all the failures, but it's hard to tell when I
don't have cross-compilers and QEMU setups for all of these
architectures.

I've tested what I could on arm, arm64, m68k, powerpc64, x86_64, and um
ARCH. (Notably, patch 4 ("genirq/test: Depend on SPARSE_IRQ") drops
support for ARCH=um and ARCH=m68k.)

This series is based on David's patch for these tests:

[PATCH] genirq/test: Fix depth tests on architectures with NOREQUEST by default.
https://lore.kernel.org/all/20250816094528.3560222-2-davidgow@google.com/

Changes in v2:
 * Make all tests depend on SPARSE_IRQ, not just a few (resolves
   ARCH=m68k issues)
 * Add David's Reviewed-by on unchanged patches

Brian Norris (6):
  genirq/test: Select IRQ_DOMAIN
  genirq/test: Factor out fake-virq setup
  genirq/test: Fail early if we can't request an IRQ
  genirq/test: Depend on SPARSE_IRQ
  genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions
  genirq/test: Ensure CPU 1 is online for hotplug test

 kernel/irq/Kconfig    |  2 ++
 kernel/irq/irq_test.c | 61 +++++++++++++++++++------------------------
 2 files changed, 29 insertions(+), 34 deletions(-)

-- 
2.51.0.rc2.233.g662b1ed5c5-goog


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 1/6] genirq/test: Select IRQ_DOMAIN
  2025-08-22 18:59 [PATCH v2 0/6] genirq/test: Platform/architecture fixes Brian Norris
@ 2025-08-22 18:59 ` Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  2025-08-22 18:59 ` [PATCH v2 2/6] genirq/test: Factor out fake-virq setup Brian Norris
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Brian Norris @ 2025-08-22 18:59 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: David Gow, linux-kernel, Guenter Roeck, Geert Uytterhoeven,
	kunit-dev, Brian Norris

These tests use irq_domain_alloc_descs() and so require
CONFIG_IRQ_DOMAIN.

Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Closes: https://lore.kernel.org/lkml/ded44edf-eeb7-420c-b8a8-d6543b955e6e@roeck-us.net/
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: David Gow <davidgow@google.com>
---

(no changes since v1)

 kernel/irq/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 1da5e9d9da71..08088b8e95ae 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -148,6 +148,7 @@ config IRQ_KUNIT_TEST
 	bool "KUnit tests for IRQ management APIs" if !KUNIT_ALL_TESTS
 	depends on KUNIT=y
 	default KUNIT_ALL_TESTS
+	select IRQ_DOMAIN
 	imply SMP
 	help
 	  This option enables KUnit tests for the IRQ subsystem API. These are
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 2/6] genirq/test: Factor out fake-virq setup
  2025-08-22 18:59 [PATCH v2 0/6] genirq/test: Platform/architecture fixes Brian Norris
  2025-08-22 18:59 ` [PATCH v2 1/6] genirq/test: Select IRQ_DOMAIN Brian Norris
@ 2025-08-22 18:59 ` Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  2025-08-22 18:59 ` [PATCH v2 3/6] genirq/test: Fail early if we can't request an IRQ Brian Norris
                   ` (5 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Brian Norris @ 2025-08-22 18:59 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: David Gow, linux-kernel, Guenter Roeck, Geert Uytterhoeven,
	kunit-dev, Brian Norris

We have to repeat a few things in tests. Factor out the creation of fake
IRQs.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: David Gow <davidgow@google.com>
---

(no changes since v1)

 kernel/irq/irq_test.c | 45 +++++++++++++++++++------------------------
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
index e220e7b2fc18..f8f4532c2805 100644
--- a/kernel/irq/irq_test.c
+++ b/kernel/irq/irq_test.c
@@ -41,15 +41,15 @@ static struct irq_chip fake_irq_chip = {
 	.flags          = IRQCHIP_SKIP_SET_WAKE,
 };
 
-static void irq_disable_depth_test(struct kunit *test)
+static int irq_test_setup_fake_irq(struct kunit *test, struct irq_affinity_desc *affd)
 {
 	struct irq_desc *desc;
-	int virq, ret;
+	int virq;
 
-	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, NULL);
+	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, affd);
 	KUNIT_ASSERT_GE(test, virq, 0);
 
-	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
+	irq_set_chip_and_handler(virq, &fake_irq_chip, handle_simple_irq);
 
 	desc = irq_to_desc(virq);
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
@@ -57,6 +57,19 @@ static void irq_disable_depth_test(struct kunit *test)
 	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
 	irq_settings_clr_norequest(desc);
 
+	return virq;
+}
+
+static void irq_disable_depth_test(struct kunit *test)
+{
+	struct irq_desc *desc;
+	int virq, ret;
+
+	virq = irq_test_setup_fake_irq(test, NULL);
+
+	desc = irq_to_desc(virq);
+	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
+
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
 	KUNIT_EXPECT_EQ(test, ret, 0);
 
@@ -76,17 +89,11 @@ static void irq_free_disabled_test(struct kunit *test)
 	struct irq_desc *desc;
 	int virq, ret;
 
-	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, NULL);
-	KUNIT_ASSERT_GE(test, virq, 0);
-
-	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
+	virq = irq_test_setup_fake_irq(test, NULL);
 
 	desc = irq_to_desc(virq);
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
-	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
-	irq_settings_clr_norequest(desc);
-
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
 	KUNIT_EXPECT_EQ(test, ret, 0);
 
@@ -118,17 +125,11 @@ static void irq_shutdown_depth_test(struct kunit *test)
 	if (!IS_ENABLED(CONFIG_SMP))
 		kunit_skip(test, "requires CONFIG_SMP for managed shutdown");
 
-	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, &affinity);
-	KUNIT_ASSERT_GE(test, virq, 0);
-
-	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
+	virq = irq_test_setup_fake_irq(test, &affinity);
 
 	desc = irq_to_desc(virq);
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
-	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
-	irq_settings_clr_norequest(desc);
-
 	data = irq_desc_get_irq_data(desc);
 	KUNIT_ASSERT_PTR_NE(test, data, NULL);
 
@@ -181,17 +182,11 @@ static void irq_cpuhotplug_test(struct kunit *test)
 
 	cpumask_copy(&affinity.mask, cpumask_of(1));
 
-	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, &affinity);
-	KUNIT_ASSERT_GE(test, virq, 0);
-
-	irq_set_chip_and_handler(virq, &fake_irq_chip, handle_simple_irq);
+	virq = irq_test_setup_fake_irq(test, &affinity);
 
 	desc = irq_to_desc(virq);
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
-	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
-	irq_settings_clr_norequest(desc);
-
 	data = irq_desc_get_irq_data(desc);
 	KUNIT_ASSERT_PTR_NE(test, data, NULL);
 
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 3/6] genirq/test: Fail early if we can't request an IRQ
  2025-08-22 18:59 [PATCH v2 0/6] genirq/test: Platform/architecture fixes Brian Norris
  2025-08-22 18:59 ` [PATCH v2 1/6] genirq/test: Select IRQ_DOMAIN Brian Norris
  2025-08-22 18:59 ` [PATCH v2 2/6] genirq/test: Factor out fake-virq setup Brian Norris
@ 2025-08-22 18:59 ` Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] genirq/test: Fail early if interrupt request fails tip-bot2 for Brian Norris
  2025-08-22 18:59 ` [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ Brian Norris
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Brian Norris @ 2025-08-22 18:59 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: David Gow, linux-kernel, Guenter Roeck, Geert Uytterhoeven,
	kunit-dev, Brian Norris

Requesting the IRQ is part of basic setup of the test. If it fails, most
of the subsequent tests are likely to fail, and the output gets noisy.
Use "assert" to fail early.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: David Gow <davidgow@google.com>
---

(no changes since v1)

 kernel/irq/irq_test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
index f8f4532c2805..56baeb5041d6 100644
--- a/kernel/irq/irq_test.c
+++ b/kernel/irq/irq_test.c
@@ -71,7 +71,7 @@ static void irq_disable_depth_test(struct kunit *test)
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 
 	KUNIT_EXPECT_EQ(test, desc->depth, 0);
 
@@ -95,7 +95,7 @@ static void irq_free_disabled_test(struct kunit *test)
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 
 	KUNIT_EXPECT_EQ(test, desc->depth, 0);
 
@@ -106,7 +106,7 @@ static void irq_free_disabled_test(struct kunit *test)
 	KUNIT_EXPECT_GE(test, desc->depth, 1);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 	KUNIT_EXPECT_EQ(test, desc->depth, 0);
 
 	free_irq(virq, NULL);
@@ -134,7 +134,7 @@ static void irq_shutdown_depth_test(struct kunit *test)
 	KUNIT_ASSERT_PTR_NE(test, data, NULL);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 
 	KUNIT_EXPECT_TRUE(test, irqd_is_activated(data));
 	KUNIT_EXPECT_TRUE(test, irqd_is_started(data));
@@ -191,7 +191,7 @@ static void irq_cpuhotplug_test(struct kunit *test)
 	KUNIT_ASSERT_PTR_NE(test, data, NULL);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 
 	KUNIT_EXPECT_TRUE(test, irqd_is_activated(data));
 	KUNIT_EXPECT_TRUE(test, irqd_is_started(data));
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ
  2025-08-22 18:59 [PATCH v2 0/6] genirq/test: Platform/architecture fixes Brian Norris
                   ` (2 preceding siblings ...)
  2025-08-22 18:59 ` [PATCH v2 3/6] genirq/test: Fail early if we can't request an IRQ Brian Norris
@ 2025-08-22 18:59 ` Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
                     ` (2 more replies)
  2025-08-22 18:59 ` [PATCH v2 5/6] genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions Brian Norris
                   ` (3 subsequent siblings)
  7 siblings, 3 replies; 23+ messages in thread
From: Brian Norris @ 2025-08-22 18:59 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: David Gow, linux-kernel, Guenter Roeck, Geert Uytterhoeven,
	kunit-dev, Brian Norris

Some architectures have a rather static IRQ layout, with a limited
NR_IRQS. Without SPARSE_IRQ, we may not be able to allocate any new fake
IRQs, and the test will fail. (This occurs on ARCH=m68k, for example.)

Additionally, managed-affinity is only supported with
CONFIG_SPARSE_IRQ=y, so irq_shutdown_depth_test() and
irq_cpuhotplug_test() would fail without it.

Add a 'SPARSE_IRQ' dependency to avoid these problems.

Many architectures 'select SPARSE_IRQ', so this is easy to miss.

Notably, this also excludes ARCH=um from running any of these tests,
even though some of them might work.

Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---

Changes in v2:
 * Make all tests depend on SPARSE_IRQ, not just a few (resolves
   ARCH=m68k issues)

 kernel/irq/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 08088b8e95ae..a75df2bb9db6 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -147,6 +147,7 @@ config GENERIC_IRQ_KEXEC_CLEAR_VM_FORWARD
 config IRQ_KUNIT_TEST
 	bool "KUnit tests for IRQ management APIs" if !KUNIT_ALL_TESTS
 	depends on KUNIT=y
+	depends on SPARSE_IRQ
 	default KUNIT_ALL_TESTS
 	select IRQ_DOMAIN
 	imply SMP
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 5/6] genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions
  2025-08-22 18:59 [PATCH v2 0/6] genirq/test: Platform/architecture fixes Brian Norris
                   ` (3 preceding siblings ...)
  2025-08-22 18:59 ` [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ Brian Norris
@ 2025-08-22 18:59 ` Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  2025-08-22 18:59 ` [PATCH v2 6/6] genirq/test: Ensure CPU 1 is online for hotplug test Brian Norris
                   ` (2 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Brian Norris @ 2025-08-22 18:59 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: David Gow, linux-kernel, Guenter Roeck, Geert Uytterhoeven,
	kunit-dev, Brian Norris

Not all platforms use the generic IRQ migration code, even if they
select GENERIC_IRQ_MIGRATION. (See, for example, powerpc /
pseries_cpu_disable().)

If such platforms don't perform managed shutdown the same way, the IRQ
may not actually shut down, and we'll fail these tests:

[    4.357022][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:211
[    4.357022][  T101]     Expected irqd_is_activated(data) to be false, but is true
[    4.358128][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:212
[    4.358128][  T101]     Expected irqd_is_started(data) to be false, but is true
[    4.375558][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:216
[    4.375558][  T101]     Expected irqd_is_activated(data) to be false, but is true
[    4.376088][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:217
[    4.376088][  T101]     Expected irqd_is_started(data) to be false, but is true
[    4.377851][    T1]     # irq_cpuhotplug_test: pass:0 fail:1 skip:0 total:1
[    4.377901][    T1]     not ok 4 irq_cpuhotplug_test
[    4.378073][    T1] # irq_test_cases: pass:3 fail:1 skip:0 total:4

Rather than test that PowerPC performs migration the same way as the IRQ
core, let's just drop the state checks. The point of the test was to
ensure we kept |depth| balanced, and we can still test for that.

Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: David Gow <davidgow@google.com>
---

(no changes since v1)

 kernel/irq/irq_test.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
index 56baeb5041d6..bbb89a3e1153 100644
--- a/kernel/irq/irq_test.c
+++ b/kernel/irq/irq_test.c
@@ -203,13 +203,9 @@ static void irq_cpuhotplug_test(struct kunit *test)
 	KUNIT_EXPECT_EQ(test, desc->depth, 1);
 
 	KUNIT_EXPECT_EQ(test, remove_cpu(1), 0);
-	KUNIT_EXPECT_FALSE(test, irqd_is_activated(data));
-	KUNIT_EXPECT_FALSE(test, irqd_is_started(data));
 	KUNIT_EXPECT_GE(test, desc->depth, 1);
 	KUNIT_EXPECT_EQ(test, add_cpu(1), 0);
 
-	KUNIT_EXPECT_FALSE(test, irqd_is_activated(data));
-	KUNIT_EXPECT_FALSE(test, irqd_is_started(data));
 	KUNIT_EXPECT_EQ(test, desc->depth, 1);
 
 	enable_irq(virq);
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 6/6] genirq/test: Ensure CPU 1 is online for hotplug test
  2025-08-22 18:59 [PATCH v2 0/6] genirq/test: Platform/architecture fixes Brian Norris
                   ` (4 preceding siblings ...)
  2025-08-22 18:59 ` [PATCH v2 5/6] genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions Brian Norris
@ 2025-08-22 18:59 ` Brian Norris
  2025-08-23  1:14   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  2025-08-22 23:26 ` [PATCH v2 0/6] genirq/test: Platform/architecture fixes Guenter Roeck
  2025-08-23  1:15 ` Guenter Roeck
  7 siblings, 2 replies; 23+ messages in thread
From: Brian Norris @ 2025-08-22 18:59 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: David Gow, linux-kernel, Guenter Roeck, Geert Uytterhoeven,
	kunit-dev, Brian Norris

It's possible to run these tests on platforms that think they have a
hotpluggable CPU1, but for whatever reason, CPU1 is not online and can't
be brought online:

    # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:210
    Expected remove_cpu(1) == 0, but
        remove_cpu(1) == 1 (0x1)
CPU1: failed to boot: -38
    # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:214
    Expected add_cpu(1) == 0, but
        add_cpu(1) == -38 (0xffffffffffffffda)

Check that CPU1 is actually online before trying to run the test.

Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: David Gow <davidgow@google.com>
---

(no changes since v1)

 kernel/irq/irq_test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
index bbb89a3e1153..e2d31914b3c4 100644
--- a/kernel/irq/irq_test.c
+++ b/kernel/irq/irq_test.c
@@ -179,6 +179,8 @@ static void irq_cpuhotplug_test(struct kunit *test)
 		kunit_skip(test, "requires more than 1 CPU for CPU hotplug");
 	if (!cpu_is_hotpluggable(1))
 		kunit_skip(test, "CPU 1 must be hotpluggable");
+	if (!cpu_online(1))
+		kunit_skip(test, "CPU 1 must be online");
 
 	cpumask_copy(&affinity.mask, cpumask_of(1));
 
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/6] genirq/test: Platform/architecture fixes
  2025-08-22 18:59 [PATCH v2 0/6] genirq/test: Platform/architecture fixes Brian Norris
                   ` (5 preceding siblings ...)
  2025-08-22 18:59 ` [PATCH v2 6/6] genirq/test: Ensure CPU 1 is online for hotplug test Brian Norris
@ 2025-08-22 23:26 ` Guenter Roeck
  2025-08-23  1:15 ` Guenter Roeck
  7 siblings, 0 replies; 23+ messages in thread
From: Guenter Roeck @ 2025-08-22 23:26 UTC (permalink / raw)
  To: Brian Norris, Thomas Gleixner
  Cc: David Gow, linux-kernel, Geert Uytterhoeven, kunit-dev

On 8/22/25 11:59, Brian Norris wrote:
> The new kunit tests at kernel/irq/irq_test.c were primarily tested on
> x86_64, with QEMU and with ARCH=um builds. Naturally, there are other
> architectures that throw complications in the mix, with various CPU
> hotplug and IRQ implementation choices.
> 
> Guenter has been dutifully noticing and reporting these errors, in
> places like:
> https://lore.kernel.org/all/b4cf04ea-d398-473f-bf11-d36643aa50dd@roeck-us.net/
> 
> I hope I've addressed all the failures, but it's hard to tell when I
> don't have cross-compilers and QEMU setups for all of these
> architectures.
> 
> I've tested what I could on arm, arm64, m68k, powerpc64, x86_64, and um
> ARCH. (Notably, patch 4 ("genirq/test: Depend on SPARSE_IRQ") drops
> support for ARCH=um and ARCH=m68k.)
> 
> This series is based on David's patch for these tests:
> 
> [PATCH] genirq/test: Fix depth tests on architectures with NOREQUEST by default.
> https://lore.kernel.org/all/20250816094528.3560222-2-davidgow@google.com/
> 

I started a round of qemu tests. I'll send out results later tonight or
tomorrow morning (unless PG&E decides that we don't need power for the rest
of the day/night ;-).

Guenter


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 1/6] genirq/test: Select IRQ_DOMAIN
  2025-08-22 18:59 ` [PATCH v2 1/6] genirq/test: Select IRQ_DOMAIN Brian Norris
@ 2025-08-23  1:13   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: Guenter Roeck @ 2025-08-23  1:13 UTC (permalink / raw)
  To: Brian Norris
  Cc: Thomas Gleixner, David Gow, linux-kernel, Geert Uytterhoeven,
	kunit-dev

On Fri, Aug 22, 2025 at 11:59:02AM -0700, Brian Norris wrote:
> These tests use irq_domain_alloc_descs() and so require
> CONFIG_IRQ_DOMAIN.
> 
> Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Closes: https://lore.kernel.org/lkml/ded44edf-eeb7-420c-b8a8-d6543b955e6e@roeck-us.net/
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Reviewed-by: David Gow <davidgow@google.com>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
> 
> (no changes since v1)
> 
>  kernel/irq/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
> index 1da5e9d9da71..08088b8e95ae 100644
> --- a/kernel/irq/Kconfig
> +++ b/kernel/irq/Kconfig
> @@ -148,6 +148,7 @@ config IRQ_KUNIT_TEST
>  	bool "KUnit tests for IRQ management APIs" if !KUNIT_ALL_TESTS
>  	depends on KUNIT=y
>  	default KUNIT_ALL_TESTS
> +	select IRQ_DOMAIN
>  	imply SMP
>  	help
>  	  This option enables KUnit tests for the IRQ subsystem API. These are
> -- 
> 2.51.0.rc2.233.g662b1ed5c5-goog
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 2/6] genirq/test: Factor out fake-virq setup
  2025-08-22 18:59 ` [PATCH v2 2/6] genirq/test: Factor out fake-virq setup Brian Norris
@ 2025-08-23  1:13   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: Guenter Roeck @ 2025-08-23  1:13 UTC (permalink / raw)
  To: Brian Norris
  Cc: Thomas Gleixner, David Gow, linux-kernel, Geert Uytterhoeven,
	kunit-dev

On Fri, Aug 22, 2025 at 11:59:03AM -0700, Brian Norris wrote:
> We have to repeat a few things in tests. Factor out the creation of fake
> IRQs.
> 
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Reviewed-by: David Gow <davidgow@google.com>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
> 
> (no changes since v1)
> 
>  kernel/irq/irq_test.c | 45 +++++++++++++++++++------------------------
>  1 file changed, 20 insertions(+), 25 deletions(-)
> 
> diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
> index e220e7b2fc18..f8f4532c2805 100644
> --- a/kernel/irq/irq_test.c
> +++ b/kernel/irq/irq_test.c
> @@ -41,15 +41,15 @@ static struct irq_chip fake_irq_chip = {
>  	.flags          = IRQCHIP_SKIP_SET_WAKE,
>  };
>  
> -static void irq_disable_depth_test(struct kunit *test)
> +static int irq_test_setup_fake_irq(struct kunit *test, struct irq_affinity_desc *affd)
>  {
>  	struct irq_desc *desc;
> -	int virq, ret;
> +	int virq;
>  
> -	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, NULL);
> +	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, affd);
>  	KUNIT_ASSERT_GE(test, virq, 0);
>  
> -	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
> +	irq_set_chip_and_handler(virq, &fake_irq_chip, handle_simple_irq);
>  
>  	desc = irq_to_desc(virq);
>  	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
> @@ -57,6 +57,19 @@ static void irq_disable_depth_test(struct kunit *test)
>  	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
>  	irq_settings_clr_norequest(desc);
>  
> +	return virq;
> +}
> +
> +static void irq_disable_depth_test(struct kunit *test)
> +{
> +	struct irq_desc *desc;
> +	int virq, ret;
> +
> +	virq = irq_test_setup_fake_irq(test, NULL);
> +
> +	desc = irq_to_desc(virq);
> +	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
> +
>  	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
>  	KUNIT_EXPECT_EQ(test, ret, 0);
>  
> @@ -76,17 +89,11 @@ static void irq_free_disabled_test(struct kunit *test)
>  	struct irq_desc *desc;
>  	int virq, ret;
>  
> -	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, NULL);
> -	KUNIT_ASSERT_GE(test, virq, 0);
> -
> -	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
> +	virq = irq_test_setup_fake_irq(test, NULL);
>  
>  	desc = irq_to_desc(virq);
>  	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
>  
> -	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
> -	irq_settings_clr_norequest(desc);
> -
>  	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
>  	KUNIT_EXPECT_EQ(test, ret, 0);
>  
> @@ -118,17 +125,11 @@ static void irq_shutdown_depth_test(struct kunit *test)
>  	if (!IS_ENABLED(CONFIG_SMP))
>  		kunit_skip(test, "requires CONFIG_SMP for managed shutdown");
>  
> -	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, &affinity);
> -	KUNIT_ASSERT_GE(test, virq, 0);
> -
> -	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
> +	virq = irq_test_setup_fake_irq(test, &affinity);
>  
>  	desc = irq_to_desc(virq);
>  	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
>  
> -	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
> -	irq_settings_clr_norequest(desc);
> -
>  	data = irq_desc_get_irq_data(desc);
>  	KUNIT_ASSERT_PTR_NE(test, data, NULL);
>  
> @@ -181,17 +182,11 @@ static void irq_cpuhotplug_test(struct kunit *test)
>  
>  	cpumask_copy(&affinity.mask, cpumask_of(1));
>  
> -	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, &affinity);
> -	KUNIT_ASSERT_GE(test, virq, 0);
> -
> -	irq_set_chip_and_handler(virq, &fake_irq_chip, handle_simple_irq);
> +	virq = irq_test_setup_fake_irq(test, &affinity);
>  
>  	desc = irq_to_desc(virq);
>  	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
>  
> -	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
> -	irq_settings_clr_norequest(desc);
> -
>  	data = irq_desc_get_irq_data(desc);
>  	KUNIT_ASSERT_PTR_NE(test, data, NULL);
>  
> -- 
> 2.51.0.rc2.233.g662b1ed5c5-goog
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/6] genirq/test: Fail early if we can't request an IRQ
  2025-08-22 18:59 ` [PATCH v2 3/6] genirq/test: Fail early if we can't request an IRQ Brian Norris
@ 2025-08-23  1:13   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] genirq/test: Fail early if interrupt request fails tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: Guenter Roeck @ 2025-08-23  1:13 UTC (permalink / raw)
  To: Brian Norris
  Cc: Thomas Gleixner, David Gow, linux-kernel, Geert Uytterhoeven,
	kunit-dev

On Fri, Aug 22, 2025 at 11:59:04AM -0700, Brian Norris wrote:
> Requesting the IRQ is part of basic setup of the test. If it fails, most
> of the subsequent tests are likely to fail, and the output gets noisy.
> Use "assert" to fail early.
> 
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Reviewed-by: David Gow <davidgow@google.com>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
> 
> (no changes since v1)
> 
>  kernel/irq/irq_test.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
> index f8f4532c2805..56baeb5041d6 100644
> --- a/kernel/irq/irq_test.c
> +++ b/kernel/irq/irq_test.c
> @@ -71,7 +71,7 @@ static void irq_disable_depth_test(struct kunit *test)
>  	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
>  
>  	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
> -	KUNIT_EXPECT_EQ(test, ret, 0);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
>  
>  	KUNIT_EXPECT_EQ(test, desc->depth, 0);
>  
> @@ -95,7 +95,7 @@ static void irq_free_disabled_test(struct kunit *test)
>  	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
>  
>  	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
> -	KUNIT_EXPECT_EQ(test, ret, 0);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
>  
>  	KUNIT_EXPECT_EQ(test, desc->depth, 0);
>  
> @@ -106,7 +106,7 @@ static void irq_free_disabled_test(struct kunit *test)
>  	KUNIT_EXPECT_GE(test, desc->depth, 1);
>  
>  	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
> -	KUNIT_EXPECT_EQ(test, ret, 0);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
>  	KUNIT_EXPECT_EQ(test, desc->depth, 0);
>  
>  	free_irq(virq, NULL);
> @@ -134,7 +134,7 @@ static void irq_shutdown_depth_test(struct kunit *test)
>  	KUNIT_ASSERT_PTR_NE(test, data, NULL);
>  
>  	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
> -	KUNIT_EXPECT_EQ(test, ret, 0);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
>  
>  	KUNIT_EXPECT_TRUE(test, irqd_is_activated(data));
>  	KUNIT_EXPECT_TRUE(test, irqd_is_started(data));
> @@ -191,7 +191,7 @@ static void irq_cpuhotplug_test(struct kunit *test)
>  	KUNIT_ASSERT_PTR_NE(test, data, NULL);
>  
>  	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
> -	KUNIT_EXPECT_EQ(test, ret, 0);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
>  
>  	KUNIT_EXPECT_TRUE(test, irqd_is_activated(data));
>  	KUNIT_EXPECT_TRUE(test, irqd_is_started(data));
> -- 
> 2.51.0.rc2.233.g662b1ed5c5-goog
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ
  2025-08-22 18:59 ` [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ Brian Norris
@ 2025-08-23  1:13   ` Guenter Roeck
  2025-08-23  6:59   ` David Gow
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  2 siblings, 0 replies; 23+ messages in thread
From: Guenter Roeck @ 2025-08-23  1:13 UTC (permalink / raw)
  To: Brian Norris
  Cc: Thomas Gleixner, David Gow, linux-kernel, Geert Uytterhoeven,
	kunit-dev

On Fri, Aug 22, 2025 at 11:59:05AM -0700, Brian Norris wrote:
> Some architectures have a rather static IRQ layout, with a limited
> NR_IRQS. Without SPARSE_IRQ, we may not be able to allocate any new fake
> IRQs, and the test will fail. (This occurs on ARCH=m68k, for example.)
> 
> Additionally, managed-affinity is only supported with
> CONFIG_SPARSE_IRQ=y, so irq_shutdown_depth_test() and
> irq_cpuhotplug_test() would fail without it.
> 
> Add a 'SPARSE_IRQ' dependency to avoid these problems.
> 
> Many architectures 'select SPARSE_IRQ', so this is easy to miss.
> 
> Notably, this also excludes ARCH=um from running any of these tests,
> even though some of them might work.
> 
> Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Brian Norris <briannorris@chromium.org>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
> 
> Changes in v2:
>  * Make all tests depend on SPARSE_IRQ, not just a few (resolves
>    ARCH=m68k issues)
> 
>  kernel/irq/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
> index 08088b8e95ae..a75df2bb9db6 100644
> --- a/kernel/irq/Kconfig
> +++ b/kernel/irq/Kconfig
> @@ -147,6 +147,7 @@ config GENERIC_IRQ_KEXEC_CLEAR_VM_FORWARD
>  config IRQ_KUNIT_TEST
>  	bool "KUnit tests for IRQ management APIs" if !KUNIT_ALL_TESTS
>  	depends on KUNIT=y
> +	depends on SPARSE_IRQ
>  	default KUNIT_ALL_TESTS
>  	select IRQ_DOMAIN
>  	imply SMP
> -- 
> 2.51.0.rc2.233.g662b1ed5c5-goog
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/6] genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions
  2025-08-22 18:59 ` [PATCH v2 5/6] genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions Brian Norris
@ 2025-08-23  1:13   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: Guenter Roeck @ 2025-08-23  1:13 UTC (permalink / raw)
  To: Brian Norris
  Cc: Thomas Gleixner, David Gow, linux-kernel, Geert Uytterhoeven,
	kunit-dev

On Fri, Aug 22, 2025 at 11:59:06AM -0700, Brian Norris wrote:
> Not all platforms use the generic IRQ migration code, even if they
> select GENERIC_IRQ_MIGRATION. (See, for example, powerpc /
> pseries_cpu_disable().)
> 
> If such platforms don't perform managed shutdown the same way, the IRQ
> may not actually shut down, and we'll fail these tests:
> 
> [    4.357022][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:211
> [    4.357022][  T101]     Expected irqd_is_activated(data) to be false, but is true
> [    4.358128][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:212
> [    4.358128][  T101]     Expected irqd_is_started(data) to be false, but is true
> [    4.375558][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:216
> [    4.375558][  T101]     Expected irqd_is_activated(data) to be false, but is true
> [    4.376088][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:217
> [    4.376088][  T101]     Expected irqd_is_started(data) to be false, but is true
> [    4.377851][    T1]     # irq_cpuhotplug_test: pass:0 fail:1 skip:0 total:1
> [    4.377901][    T1]     not ok 4 irq_cpuhotplug_test
> [    4.378073][    T1] # irq_test_cases: pass:3 fail:1 skip:0 total:4
> 
> Rather than test that PowerPC performs migration the same way as the IRQ
> core, let's just drop the state checks. The point of the test was to
> ensure we kept |depth| balanced, and we can still test for that.
> 
> Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Reviewed-by: David Gow <davidgow@google.com>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
> 
> (no changes since v1)
> 
>  kernel/irq/irq_test.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
> index 56baeb5041d6..bbb89a3e1153 100644
> --- a/kernel/irq/irq_test.c
> +++ b/kernel/irq/irq_test.c
> @@ -203,13 +203,9 @@ static void irq_cpuhotplug_test(struct kunit *test)
>  	KUNIT_EXPECT_EQ(test, desc->depth, 1);
>  
>  	KUNIT_EXPECT_EQ(test, remove_cpu(1), 0);
> -	KUNIT_EXPECT_FALSE(test, irqd_is_activated(data));
> -	KUNIT_EXPECT_FALSE(test, irqd_is_started(data));
>  	KUNIT_EXPECT_GE(test, desc->depth, 1);
>  	KUNIT_EXPECT_EQ(test, add_cpu(1), 0);
>  
> -	KUNIT_EXPECT_FALSE(test, irqd_is_activated(data));
> -	KUNIT_EXPECT_FALSE(test, irqd_is_started(data));
>  	KUNIT_EXPECT_EQ(test, desc->depth, 1);
>  
>  	enable_irq(virq);
> -- 
> 2.51.0.rc2.233.g662b1ed5c5-goog
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 6/6] genirq/test: Ensure CPU 1 is online for hotplug test
  2025-08-22 18:59 ` [PATCH v2 6/6] genirq/test: Ensure CPU 1 is online for hotplug test Brian Norris
@ 2025-08-23  1:14   ` Guenter Roeck
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: Guenter Roeck @ 2025-08-23  1:14 UTC (permalink / raw)
  To: Brian Norris
  Cc: Thomas Gleixner, David Gow, linux-kernel, Geert Uytterhoeven,
	kunit-dev

On Fri, Aug 22, 2025 at 11:59:07AM -0700, Brian Norris wrote:
> It's possible to run these tests on platforms that think they have a
> hotpluggable CPU1, but for whatever reason, CPU1 is not online and can't
> be brought online:
> 
>     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:210
>     Expected remove_cpu(1) == 0, but
>         remove_cpu(1) == 1 (0x1)
> CPU1: failed to boot: -38
>     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:214
>     Expected add_cpu(1) == 0, but
>         add_cpu(1) == -38 (0xffffffffffffffda)
> 
> Check that CPU1 is actually online before trying to run the test.
> 
> Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Reviewed-by: David Gow <davidgow@google.com>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
> 
> (no changes since v1)
> 
>  kernel/irq/irq_test.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
> index bbb89a3e1153..e2d31914b3c4 100644
> --- a/kernel/irq/irq_test.c
> +++ b/kernel/irq/irq_test.c
> @@ -179,6 +179,8 @@ static void irq_cpuhotplug_test(struct kunit *test)
>  		kunit_skip(test, "requires more than 1 CPU for CPU hotplug");
>  	if (!cpu_is_hotpluggable(1))
>  		kunit_skip(test, "CPU 1 must be hotpluggable");
> +	if (!cpu_online(1))
> +		kunit_skip(test, "CPU 1 must be online");
>  
>  	cpumask_copy(&affinity.mask, cpumask_of(1));
>  
> -- 
> 2.51.0.rc2.233.g662b1ed5c5-goog
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/6] genirq/test: Platform/architecture fixes
  2025-08-22 18:59 [PATCH v2 0/6] genirq/test: Platform/architecture fixes Brian Norris
                   ` (6 preceding siblings ...)
  2025-08-22 23:26 ` [PATCH v2 0/6] genirq/test: Platform/architecture fixes Guenter Roeck
@ 2025-08-23  1:15 ` Guenter Roeck
  7 siblings, 0 replies; 23+ messages in thread
From: Guenter Roeck @ 2025-08-23  1:15 UTC (permalink / raw)
  To: Brian Norris, Thomas Gleixner
  Cc: David Gow, linux-kernel, Geert Uytterhoeven, kunit-dev

On 8/22/25 11:59, Brian Norris wrote:
> The new kunit tests at kernel/irq/irq_test.c were primarily tested on
> x86_64, with QEMU and with ARCH=um builds. Naturally, there are other
> architectures that throw complications in the mix, with various CPU
> hotplug and IRQ implementation choices.
> 
> Guenter has been dutifully noticing and reporting these errors, in
> places like:
> https://lore.kernel.org/all/b4cf04ea-d398-473f-bf11-d36643aa50dd@roeck-us.net/
> 
> I hope I've addressed all the failures, but it's hard to tell when I
> don't have cross-compilers and QEMU setups for all of these
> architectures.
> 
> I've tested what I could on arm, arm64, m68k, powerpc64, x86_64, and um
> ARCH. (Notably, patch 4 ("genirq/test: Depend on SPARSE_IRQ") drops
> support for ARCH=um and ARCH=m68k.)
> 
> This series is based on David's patch for these tests:
> 
> [PATCH] genirq/test: Fix depth tests on architectures with NOREQUEST by default.
> https://lore.kernel.org/all/20250816094528.3560222-2-davidgow@google.com/
> 
> Changes in v2:
>   * Make all tests depend on SPARSE_IRQ, not just a few (resolves
>     ARCH=m68k issues)
>   * Add David's Reviewed-by on unchanged patches
> 

My test system says:

Qemu test results
	total: 637 pass: 637 fail: 0
Unit tests:
	pass: 640359 fail: 0

I sent Tested-by: tags for all patches of the series.

Guenter


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ
  2025-08-22 18:59 ` [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
@ 2025-08-23  6:59   ` David Gow
  2025-08-25 21:23     ` Brian Norris
  2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
  2 siblings, 1 reply; 23+ messages in thread
From: David Gow @ 2025-08-23  6:59 UTC (permalink / raw)
  To: Brian Norris
  Cc: Thomas Gleixner, linux-kernel, Guenter Roeck, Geert Uytterhoeven,
	kunit-dev

[-- Attachment #1: Type: text/plain, Size: 1226 bytes --]

On Sat, 23 Aug 2025 at 03:01, Brian Norris <briannorris@chromium.org> wrote:
>
> Some architectures have a rather static IRQ layout, with a limited
> NR_IRQS. Without SPARSE_IRQ, we may not be able to allocate any new fake
> IRQs, and the test will fail. (This occurs on ARCH=m68k, for example.)
>
> Additionally, managed-affinity is only supported with
> CONFIG_SPARSE_IRQ=y, so irq_shutdown_depth_test() and
> irq_cpuhotplug_test() would fail without it.
>
> Add a 'SPARSE_IRQ' dependency to avoid these problems.
>
> Many architectures 'select SPARSE_IRQ', so this is easy to miss.
>
> Notably, this also excludes ARCH=um from running any of these tests,
> even though some of them might work.
>
> Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---

I confess to being disappointed that we lose ARCH=um support with this
-- it's nice to have it run on the "default" configuration -- but the
correct way of solving this is probably to support SPARSE_IRQ on UML,
which is probably more work than it's worth.

So this is, nevertheless,
Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5281 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ
  2025-08-23  6:59   ` David Gow
@ 2025-08-25 21:23     ` Brian Norris
  0 siblings, 0 replies; 23+ messages in thread
From: Brian Norris @ 2025-08-25 21:23 UTC (permalink / raw)
  To: David Gow
  Cc: Thomas Gleixner, linux-kernel, Guenter Roeck, Geert Uytterhoeven,
	kunit-dev

On Sat, Aug 23, 2025 at 02:59:26PM +0800, David Gow wrote:
> On Sat, 23 Aug 2025 at 03:01, Brian Norris <briannorris@chromium.org> wrote:
> > Notably, this also excludes ARCH=um from running any of these tests,
> > even though some of them might work.
> 
> I confess to being disappointed that we lose ARCH=um support with this
> -- it's nice to have it run on the "default" configuration -- but the
> correct way of solving this is probably to support SPARSE_IRQ on UML,
> which is probably more work than it's worth.

I made an educated guess on how to support SPARSE_IRQ for ARCH=um, and I
got something working here:

[PATCH] um: Support SPARSE_IRQ
http://lore.kernel.org/all/20250825212031.111027-1-briannorris@chromium.org

Brian

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [tip: irq/core] genirq/test: Ensure CPU 1 is online for hotplug test
  2025-08-22 18:59 ` [PATCH v2 6/6] genirq/test: Ensure CPU 1 is online for hotplug test Brian Norris
  2025-08-23  1:14   ` Guenter Roeck
@ 2025-09-03 15:12   ` tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: tip-bot2 for Brian Norris @ 2025-09-03 15:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Guenter Roeck, Brian Norris, Thomas Gleixner, David Gow, x86,
	linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     8ad25ebfa70e86860559b306bbc923c7db4fcac6
Gitweb:        https://git.kernel.org/tip/8ad25ebfa70e86860559b306bbc923c7db4fcac6
Author:        Brian Norris <briannorris@chromium.org>
AuthorDate:    Fri, 22 Aug 2025 11:59:07 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Sep 2025 17:04:52 +02:00

genirq/test: Ensure CPU 1 is online for hotplug test

It's possible to run these tests on platforms that think they have a
hotpluggable CPU1, but for whatever reason, CPU1 is not online and can't be
brought online:

    # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:210
    Expected remove_cpu(1) == 0, but
        remove_cpu(1) == 1 (0x1)
CPU1: failed to boot: -38
    # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:214
    Expected add_cpu(1) == 0, but
        add_cpu(1) == -38 (0xffffffffffffffda)

Check that CPU1 is actually online before trying to run the test.

Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: David Gow <davidgow@google.com>
Link: https://lore.kernel.org/all/20250822190140.2154646-7-briannorris@chromium.org

---
 kernel/irq/irq_test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
index bbb89a3..e2d3191 100644
--- a/kernel/irq/irq_test.c
+++ b/kernel/irq/irq_test.c
@@ -179,6 +179,8 @@ static void irq_cpuhotplug_test(struct kunit *test)
 		kunit_skip(test, "requires more than 1 CPU for CPU hotplug");
 	if (!cpu_is_hotpluggable(1))
 		kunit_skip(test, "CPU 1 must be hotpluggable");
+	if (!cpu_online(1))
+		kunit_skip(test, "CPU 1 must be online");
 
 	cpumask_copy(&affinity.mask, cpumask_of(1));
 

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip: irq/core] genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions
  2025-08-22 18:59 ` [PATCH v2 5/6] genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
@ 2025-09-03 15:12   ` tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: tip-bot2 for Brian Norris @ 2025-09-03 15:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Guenter Roeck, Brian Norris, Thomas Gleixner, David Gow, x86,
	linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     add03fdb9d52411cabb3872fb7692df6f4c67586
Gitweb:        https://git.kernel.org/tip/add03fdb9d52411cabb3872fb7692df6f4c67586
Author:        Brian Norris <briannorris@chromium.org>
AuthorDate:    Fri, 22 Aug 2025 11:59:06 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Sep 2025 17:04:52 +02:00

genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions

Not all platforms use the generic IRQ migration code, even if they select
GENERIC_IRQ_MIGRATION. (See, for example, powerpc / pseries_cpu_disable().)

If such platforms don't perform managed shutdown the same way, the interrupt
may not actually shut down, and these tests fail:

[    4.357022][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:211
[    4.357022][  T101]     Expected irqd_is_activated(data) to be false, but is true
[    4.358128][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:212
[    4.358128][  T101]     Expected irqd_is_started(data) to be false, but is true
[    4.375558][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:216
[    4.375558][  T101]     Expected irqd_is_activated(data) to be false, but is true
[    4.376088][  T101]     # irq_cpuhotplug_test: EXPECTATION FAILED at kernel/irq/irq_test.c:217
[    4.376088][  T101]     Expected irqd_is_started(data) to be false, but is true
[    4.377851][    T1]     # irq_cpuhotplug_test: pass:0 fail:1 skip:0 total:1
[    4.377901][    T1]     not ok 4 irq_cpuhotplug_test
[    4.378073][    T1] # irq_test_cases: pass:3 fail:1 skip:0 total:4

Rather than test that PowerPC performs migration the same way as the
unterrupt core, just drop the state checks. The point of the test was to
ensure that the code kept |depth| balanced, which still can be tested for.

Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: David Gow <davidgow@google.com>
Link: https://lore.kernel.org/all/20250822190140.2154646-6-briannorris@chromium.org

---
 kernel/irq/irq_test.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
index 56baeb5..bbb89a3 100644
--- a/kernel/irq/irq_test.c
+++ b/kernel/irq/irq_test.c
@@ -203,13 +203,9 @@ static void irq_cpuhotplug_test(struct kunit *test)
 	KUNIT_EXPECT_EQ(test, desc->depth, 1);
 
 	KUNIT_EXPECT_EQ(test, remove_cpu(1), 0);
-	KUNIT_EXPECT_FALSE(test, irqd_is_activated(data));
-	KUNIT_EXPECT_FALSE(test, irqd_is_started(data));
 	KUNIT_EXPECT_GE(test, desc->depth, 1);
 	KUNIT_EXPECT_EQ(test, add_cpu(1), 0);
 
-	KUNIT_EXPECT_FALSE(test, irqd_is_activated(data));
-	KUNIT_EXPECT_FALSE(test, irqd_is_started(data));
 	KUNIT_EXPECT_EQ(test, desc->depth, 1);
 
 	enable_irq(virq);

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip: irq/core] genirq/test: Depend on SPARSE_IRQ
  2025-08-22 18:59 ` [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
  2025-08-23  6:59   ` David Gow
@ 2025-09-03 15:12   ` tip-bot2 for Brian Norris
  2 siblings, 0 replies; 23+ messages in thread
From: tip-bot2 for Brian Norris @ 2025-09-03 15:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Guenter Roeck, Brian Norris, Thomas Gleixner, David Gow, x86,
	linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     0c888bc86d672e551ce5c58b891c8b44f8967643
Gitweb:        https://git.kernel.org/tip/0c888bc86d672e551ce5c58b891c8b44f8967643
Author:        Brian Norris <briannorris@chromium.org>
AuthorDate:    Fri, 22 Aug 2025 11:59:05 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Sep 2025 17:04:52 +02:00

genirq/test: Depend on SPARSE_IRQ

Some architectures have a static interrupt layout, with a limited number of
interrupts. Without SPARSE_IRQ, the test may not be able to allocate any
fake interrupts, and the test will fail. (This occurs on ARCH=m68k, for
example.)

Additionally, managed-affinity is only supported with CONFIG_SPARSE_IRQ=y,
so irq_shutdown_depth_test() and irq_cpuhotplug_test() would fail without
it.

Add a 'SPARSE_IRQ' dependency to avoid these problems.

Many architectures 'select SPARSE_IRQ', so this is easy to miss.

Notably, this also excludes ARCH=um from running any of these tests, even
though some of them might work.

Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: David Gow <davidgow@google.com>
Link: https://lore.kernel.org/all/20250822190140.2154646-5-briannorris@chromium.org

---
 kernel/irq/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 8bc4de3..1b4254d 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -143,6 +143,7 @@ config GENERIC_IRQ_KEXEC_CLEAR_VM_FORWARD
 config IRQ_KUNIT_TEST
 	bool "KUnit tests for IRQ management APIs" if !KUNIT_ALL_TESTS
 	depends on KUNIT=y
+	depends on SPARSE_IRQ
 	default KUNIT_ALL_TESTS
 	select IRQ_DOMAIN
 	imply SMP

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip: irq/core] genirq/test: Fail early if interrupt request fails
  2025-08-22 18:59 ` [PATCH v2 3/6] genirq/test: Fail early if we can't request an IRQ Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
@ 2025-09-03 15:12   ` tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: tip-bot2 for Brian Norris @ 2025-09-03 15:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Brian Norris, Thomas Gleixner, Guenter Roeck, David Gow, x86,
	linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     988f45467f13c038f73a91f5154b66f278f495d4
Gitweb:        https://git.kernel.org/tip/988f45467f13c038f73a91f5154b66f278f495d4
Author:        Brian Norris <briannorris@chromium.org>
AuthorDate:    Fri, 22 Aug 2025 11:59:04 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Sep 2025 17:04:52 +02:00

genirq/test: Fail early if interrupt request fails

Requesting an interrupt is part of the basic test setup. If it fails, most
of the subsequent tests are likely to fail, and the output gets noisy.

Use "assert" to fail early.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: David Gow <davidgow@google.com>
Link: https://lore.kernel.org/all/20250822190140.2154646-4-briannorris@chromium.org

---
 kernel/irq/irq_test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
index f8f4532..56baeb5 100644
--- a/kernel/irq/irq_test.c
+++ b/kernel/irq/irq_test.c
@@ -71,7 +71,7 @@ static void irq_disable_depth_test(struct kunit *test)
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 
 	KUNIT_EXPECT_EQ(test, desc->depth, 0);
 
@@ -95,7 +95,7 @@ static void irq_free_disabled_test(struct kunit *test)
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 
 	KUNIT_EXPECT_EQ(test, desc->depth, 0);
 
@@ -106,7 +106,7 @@ static void irq_free_disabled_test(struct kunit *test)
 	KUNIT_EXPECT_GE(test, desc->depth, 1);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 	KUNIT_EXPECT_EQ(test, desc->depth, 0);
 
 	free_irq(virq, NULL);
@@ -134,7 +134,7 @@ static void irq_shutdown_depth_test(struct kunit *test)
 	KUNIT_ASSERT_PTR_NE(test, data, NULL);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 
 	KUNIT_EXPECT_TRUE(test, irqd_is_activated(data));
 	KUNIT_EXPECT_TRUE(test, irqd_is_started(data));
@@ -191,7 +191,7 @@ static void irq_cpuhotplug_test(struct kunit *test)
 	KUNIT_ASSERT_PTR_NE(test, data, NULL);
 
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
-	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_ASSERT_EQ(test, ret, 0);
 
 	KUNIT_EXPECT_TRUE(test, irqd_is_activated(data));
 	KUNIT_EXPECT_TRUE(test, irqd_is_started(data));

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip: irq/core] genirq/test: Factor out fake-virq setup
  2025-08-22 18:59 ` [PATCH v2 2/6] genirq/test: Factor out fake-virq setup Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
@ 2025-09-03 15:12   ` tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: tip-bot2 for Brian Norris @ 2025-09-03 15:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Brian Norris, Thomas Gleixner, Guenter Roeck, David Gow, x86,
	linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     59405c248acea65d534497bbe29f34858b0fdd3c
Gitweb:        https://git.kernel.org/tip/59405c248acea65d534497bbe29f34858b0fdd3c
Author:        Brian Norris <briannorris@chromium.org>
AuthorDate:    Fri, 22 Aug 2025 11:59:03 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Sep 2025 17:04:52 +02:00

genirq/test: Factor out fake-virq setup

A few things need to be repeated in tests. Factor out the creation of fake
interrupts.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: David Gow <davidgow@google.com>
Link: https://lore.kernel.org/all/20250822190140.2154646-3-briannorris@chromium.org

---
 kernel/irq/irq_test.c | 45 ++++++++++++++++++------------------------
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c
index e220e7b..f8f4532 100644
--- a/kernel/irq/irq_test.c
+++ b/kernel/irq/irq_test.c
@@ -41,15 +41,15 @@ static struct irq_chip fake_irq_chip = {
 	.flags          = IRQCHIP_SKIP_SET_WAKE,
 };
 
-static void irq_disable_depth_test(struct kunit *test)
+static int irq_test_setup_fake_irq(struct kunit *test, struct irq_affinity_desc *affd)
 {
 	struct irq_desc *desc;
-	int virq, ret;
+	int virq;
 
-	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, NULL);
+	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, affd);
 	KUNIT_ASSERT_GE(test, virq, 0);
 
-	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
+	irq_set_chip_and_handler(virq, &fake_irq_chip, handle_simple_irq);
 
 	desc = irq_to_desc(virq);
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
@@ -57,6 +57,19 @@ static void irq_disable_depth_test(struct kunit *test)
 	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
 	irq_settings_clr_norequest(desc);
 
+	return virq;
+}
+
+static void irq_disable_depth_test(struct kunit *test)
+{
+	struct irq_desc *desc;
+	int virq, ret;
+
+	virq = irq_test_setup_fake_irq(test, NULL);
+
+	desc = irq_to_desc(virq);
+	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
+
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
 	KUNIT_EXPECT_EQ(test, ret, 0);
 
@@ -76,17 +89,11 @@ static void irq_free_disabled_test(struct kunit *test)
 	struct irq_desc *desc;
 	int virq, ret;
 
-	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, NULL);
-	KUNIT_ASSERT_GE(test, virq, 0);
-
-	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
+	virq = irq_test_setup_fake_irq(test, NULL);
 
 	desc = irq_to_desc(virq);
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
-	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
-	irq_settings_clr_norequest(desc);
-
 	ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
 	KUNIT_EXPECT_EQ(test, ret, 0);
 
@@ -118,17 +125,11 @@ static void irq_shutdown_depth_test(struct kunit *test)
 	if (!IS_ENABLED(CONFIG_SMP))
 		kunit_skip(test, "requires CONFIG_SMP for managed shutdown");
 
-	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, &affinity);
-	KUNIT_ASSERT_GE(test, virq, 0);
-
-	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
+	virq = irq_test_setup_fake_irq(test, &affinity);
 
 	desc = irq_to_desc(virq);
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
-	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
-	irq_settings_clr_norequest(desc);
-
 	data = irq_desc_get_irq_data(desc);
 	KUNIT_ASSERT_PTR_NE(test, data, NULL);
 
@@ -181,17 +182,11 @@ static void irq_cpuhotplug_test(struct kunit *test)
 
 	cpumask_copy(&affinity.mask, cpumask_of(1));
 
-	virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, &affinity);
-	KUNIT_ASSERT_GE(test, virq, 0);
-
-	irq_set_chip_and_handler(virq, &fake_irq_chip, handle_simple_irq);
+	virq = irq_test_setup_fake_irq(test, &affinity);
 
 	desc = irq_to_desc(virq);
 	KUNIT_ASSERT_PTR_NE(test, desc, NULL);
 
-	/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
-	irq_settings_clr_norequest(desc);
-
 	data = irq_desc_get_irq_data(desc);
 	KUNIT_ASSERT_PTR_NE(test, data, NULL);
 

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip: irq/core] genirq/test: Select IRQ_DOMAIN
  2025-08-22 18:59 ` [PATCH v2 1/6] genirq/test: Select IRQ_DOMAIN Brian Norris
  2025-08-23  1:13   ` Guenter Roeck
@ 2025-09-03 15:12   ` tip-bot2 for Brian Norris
  1 sibling, 0 replies; 23+ messages in thread
From: tip-bot2 for Brian Norris @ 2025-09-03 15:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Guenter Roeck, Brian Norris, Thomas Gleixner, David Gow, x86,
	linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     f8a44f9babd054ff19e20a30cab661d716ad5459
Gitweb:        https://git.kernel.org/tip/f8a44f9babd054ff19e20a30cab661d716ad5459
Author:        Brian Norris <briannorris@chromium.org>
AuthorDate:    Fri, 22 Aug 2025 11:59:02 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Sep 2025 17:04:52 +02:00

genirq/test: Select IRQ_DOMAIN

These tests use irq_domain_alloc_descs() and so require CONFIG_IRQ_DOMAIN.

Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: David Gow <davidgow@google.com>
Link: https://lore.kernel.org/all/20250822190140.2154646-2-briannorris@chromium.org
Closes: https://lore.kernel.org/lkml/ded44edf-eeb7-420c-b8a8-d6543b955e6e@roeck-us.net/
---
 kernel/irq/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 3667364..8bc4de3 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -144,6 +144,7 @@ config IRQ_KUNIT_TEST
 	bool "KUnit tests for IRQ management APIs" if !KUNIT_ALL_TESTS
 	depends on KUNIT=y
 	default KUNIT_ALL_TESTS
+	select IRQ_DOMAIN
 	imply SMP
 	help
 	  This option enables KUnit tests for the IRQ subsystem API. These are

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2025-09-03 15:12 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22 18:59 [PATCH v2 0/6] genirq/test: Platform/architecture fixes Brian Norris
2025-08-22 18:59 ` [PATCH v2 1/6] genirq/test: Select IRQ_DOMAIN Brian Norris
2025-08-23  1:13   ` Guenter Roeck
2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
2025-08-22 18:59 ` [PATCH v2 2/6] genirq/test: Factor out fake-virq setup Brian Norris
2025-08-23  1:13   ` Guenter Roeck
2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
2025-08-22 18:59 ` [PATCH v2 3/6] genirq/test: Fail early if we can't request an IRQ Brian Norris
2025-08-23  1:13   ` Guenter Roeck
2025-09-03 15:12   ` [tip: irq/core] genirq/test: Fail early if interrupt request fails tip-bot2 for Brian Norris
2025-08-22 18:59 ` [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ Brian Norris
2025-08-23  1:13   ` Guenter Roeck
2025-08-23  6:59   ` David Gow
2025-08-25 21:23     ` Brian Norris
2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
2025-08-22 18:59 ` [PATCH v2 5/6] genirq/test: Drop CONFIG_GENERIC_IRQ_MIGRATION assumptions Brian Norris
2025-08-23  1:13   ` Guenter Roeck
2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
2025-08-22 18:59 ` [PATCH v2 6/6] genirq/test: Ensure CPU 1 is online for hotplug test Brian Norris
2025-08-23  1:14   ` Guenter Roeck
2025-09-03 15:12   ` [tip: irq/core] " tip-bot2 for Brian Norris
2025-08-22 23:26 ` [PATCH v2 0/6] genirq/test: Platform/architecture fixes Guenter Roeck
2025-08-23  1:15 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).