mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] resource, kunit: stop selecting GET_FREE_REGION
@ 2026-09-26  0:26 Karl Mehltretter
  2026-09-26 10:37 ` Bradley Morgan
  0 siblings, 1 reply; 2+ messages in thread
From: Karl Mehltretter @ 2026-09-26  0:26 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Karl Mehltretter, Ying Huang, Geert Uytterhoeven,
	Brendan Higgins, David Gow, Rae Moar, linux-kselftest, kunit-dev,
	linux-kernel

RESOURCE_KUNIT_TEST selects GET_FREE_REGION even when no other option
needs it. Remove the selection to follow the dependency rule in
Documentation/dev-tools/kunit/style.rst.

Skip resource_test_region_intersects() when GET_FREE_REGION is disabled.
GET_FREE_REGION has no prompt, so configurations without a production
consumer cannot enable it. Most configurations will therefore skip this
case; this is intentional. The union and intersection tests remain
available.

Since kunit_skip() does not return, the compiler drops the reference to
the unavailable alloc_free_mem_region(), as in the CONFIG_OF_ADDRESS
check in drivers/of/of_test.c.

Fixes: 99185c10d5d9 ("resource, kunit: add test case for region_intersects()")
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
Validation:
- Clang 22 and GCC 13 ARM builds pass with RESOURCE_KUNIT_TEST=y and =m
  while GET_FREE_REGION=n. The built-in vmlinux images have no
  alloc_free_mem_region symbol, and the modules have no undefined
  reference to it.
- Clang 22 x86_64 builds and QEMU 11.0.2 runs pass. GET_FREE_REGION=n
  reports two passes and resource_test_region_intersects as SKIP;
  DEVICE_PRIVATE=y enables GET_FREE_REGION and reports three passes.

 kernel/resource_kunit.c | 3 +++
 lib/Kconfig.debug       | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/resource_kunit.c b/kernel/resource_kunit.c
index 42785796f1db..9eeb2b1a85c0 100644
--- a/kernel/resource_kunit.c
+++ b/kernel/resource_kunit.c
@@ -225,6 +225,9 @@ static void resource_test_region_intersects(struct kunit *test)
 	struct resource *parent;
 	resource_size_t start;
 
+	if (!IS_ENABLED(CONFIG_GET_FREE_REGION))
+		kunit_skip(test, "CONFIG_GET_FREE_REGION is disabled");
+
 	/* Find an iomem_resource hole to hold test resources */
 	parent = alloc_free_mem_region(&iomem_resource, RES_TEST_TOTAL_SIZE, SZ_1M,
 				       "test resources");
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 134b15a44625..e7c5d5b5870f 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -2776,7 +2776,6 @@ config RESOURCE_KUNIT_TEST
 	tristate "KUnit test for resource API" if !KUNIT_ALL_TESTS
 	depends on KUNIT
 	default KUNIT_ALL_TESTS
-	select GET_FREE_REGION
 	help
 	  This builds the resource API unit test.
 	  Tests the logic of API provided by resource.c and ioport.h.

base-commit: aa98230e410f0ed212b6788c46b1e4d49e0ff7ca
-- 
2.39.5 (Apple Git-154)

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

* Re: [PATCH] resource, kunit: stop selecting GET_FREE_REGION
  2026-09-26  0:26 [PATCH] resource, kunit: stop selecting GET_FREE_REGION Karl Mehltretter
@ 2026-09-26 10:37 ` Bradley Morgan
  0 siblings, 0 replies; 2+ messages in thread
From: Bradley Morgan @ 2026-09-26 10:37 UTC (permalink / raw)
  To: kmehltretter
  Cc: akpm, brendan.higgins, david, geert, huang.ying.caritas,
	kunit-dev, linux-kernel, linux-kselftest, raemoar63

On 26 September 2026 01:26:51 BST, Karl Mehltretter
<kmehltretter@gmail.com> wrote:
>RESOURCE_KUNIT_TEST selects GET_FREE_REGION even when no other option
>needs it. Remove the selection to follow the dependency rule in
>Documentation/dev-tools/kunit/style.rst.
>
>Skip resource_test_region_intersects() when GET_FREE_REGION is disabled.
>GET_FREE_REGION has no prompt, so configurations without a production
>consumer cannot enable it. Most configurations will therefore skip this
>case; this is intentional. The union and intersection tests remain
>available.
>
>Since kunit_skip() does not return, the compiler drops the reference to
>the unavailable alloc_free_mem_region(), as in the CONFIG_OF_ADDRESS
>check in drivers/of/of_test.c.
>
>Fixes: 99185c10d5d9 ("resource, kunit: add test case for region_intersects()")
>Assisted-by: LLM
>Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
>---
>Validation:
>- Clang 22 and GCC 13 ARM builds pass with RESOURCE_KUNIT_TEST=y and =m
>  while GET_FREE_REGION=n. The built-in vmlinux images have no
>  alloc_free_mem_region symbol, and the modules have no undefined
>  reference to it.
>- Clang 22 x86_64 builds and QEMU 11.0.2 runs pass. GET_FREE_REGION=n
>  reports two passes and resource_test_region_intersects as SKIP;
>  DEVICE_PRIVATE=y enables GET_FREE_REGION and reports three passes.
>
> kernel/resource_kunit.c | 3 +++
> lib/Kconfig.debug       | 1 -
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/kernel/resource_kunit.c b/kernel/resource_kunit.c
>index 42785796f1db..9eeb2b1a85c0 100644
>--- a/kernel/resource_kunit.c
>+++ b/kernel/resource_kunit.c
>@@ -225,6 +225,9 @@ static void resource_test_region_intersects(struct kunit *test)
> 	struct resource *parent;
> 	resource_size_t start;
> 
>+	if (!IS_ENABLED(CONFIG_GET_FREE_REGION))
>+		kunit_skip(test, "CONFIG_GET_FREE_REGION is disabled");

Interesting.

Reviewed-by: Bradley Morgan <brads@mainlining.org>

Tested on Power10 (PowerPC), in courtesy of osuosl:

Tested-by: Bradley Morgan <brads@mainlining.org> # Power10


>+
> 	/* Find an iomem_resource hole to hold test resources */
> 	parent = alloc_free_mem_region(&iomem_resource, RES_TEST_TOTAL_SIZE, SZ_1M,
> 				       "test resources");
>diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
>index 134b15a44625..e7c5d5b5870f 100644
>--- a/lib/Kconfig.debug
>+++ b/lib/Kconfig.debug
>@@ -2776,7 +2776,6 @@ config RESOURCE_KUNIT_TEST
> 	tristate "KUnit test for resource API" if !KUNIT_ALL_TESTS
> 	depends on KUNIT
> 	default KUNIT_ALL_TESTS
>-	select GET_FREE_REGION
> 	help
> 	  This builds the resource API unit test.
> 	  Tests the logic of API provided by resource.c and ioport.h.
>
>base-commit: aa98230e410f0ed212b6788c46b1e4d49e0ff7ca
>

--- Thanks!
"I'm not a very positive person" - Linus torvalds

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

end of thread, other threads:[~2026-09-26 10:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-26  0:26 [PATCH] resource, kunit: stop selecting GET_FREE_REGION Karl Mehltretter
2026-09-26 10:37 ` Bradley Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®