Skip to contentSkip to conversation

drm/xe/tests: Fix some additional gen_params signatures

PATCH In review David Gow 2 participants 4 messages Aug 21, 2025

Subsystems (5)
lore
Share & tools
lore

David Gow

author
#0 lore raw

PATCH v2 1/2 drm/xe/tests: Fix some additional gen_params signatures

In 444be9072fca ("kunit: Pass parameterized test context to generate_params()") prototype used for gen_params functions was changed to add a struct kunit parameter. However, a few of these used in xe were not updated.

Update these so that the xe_pci tests build and run again.

Fixes 444be9072fca ("kunit: Pass parameterized test context to generate_params()")

---

Sorry, the last fix here caused a warning (thanks to the test robot for finding it).

I'm still happy to sqash and re-send the whole original series if that's preferred.

Changes since v1:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Add the missing <kunit/test.h> include for struct kunit

---
 drivers/gpu/drm/xe/tests/xe_pci.c      | 12 ++++++------
 drivers/gpu/drm/xe/tests/xe_pci_test.h |  9 +++++----
 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/tests/xe_pci.c +6 -6
index a65705814b9a..f707e0a54295 100644
@@ -44,9 +44,9 @@ KUNIT_ARRAY_PARAM(pci_id, pciidlist, xe_pci_id_kunit_desc);
  *
  * Return: pointer to the next parameter or NULL if no more parameters
  */
-const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc)
+const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc)
 {
-	return graphics_ip_gen_params(prev, desc);
+	return graphics_ip_gen_params(test, prev, desc);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param);
 
@@ -61,9 +61,9 @@ EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param);
  *
  * Return: pointer to the next parameter or NULL if no more parameters
  */
-const void *xe_pci_media_ip_gen_param(const void *prev, char *desc)
+const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc)
 {
-	return media_ip_gen_params(prev, desc);
+	return media_ip_gen_params(test, prev, desc);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
 
@@ -78,9 +78,9 @@ EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
  *
  * Return: pointer to the next parameter or NULL if no more parameters
  */
-const void *xe_pci_id_gen_param(const void *prev, char *desc)
+const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc)
 {
-	const struct pci_device_id *pci = pci_id_gen_params(prev, desc);
+	const struct pci_device_id *pci = pci_id_gen_params(test, prev, desc);
 
 	return pci->driver_data ? pci : NULL;
 }
drivers/gpu/drm/xe/tests/xe_pci_test.h +5 -4
index ce4d2b86b778..6d8bc56f7bde 100644
@@ -7,6 +7,7 @@
 #define _XE_PCI_TEST_H_
 
 #include <linux/types.h>
+#include <kunit/test.h>
 
 #include "xe_platform_types.h"
 #include "xe_sriov_types.h"
@@ -25,9 +26,9 @@ struct xe_pci_fake_data {
 
 int xe_pci_fake_device_init(struct xe_device *xe);
 
-const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc);
-const void *xe_pci_media_ip_gen_param(const void *prev, char *desc);
-const void *xe_pci_id_gen_param(const void *prev, char *desc);
-const void *xe_pci_live_device_gen_param(const void *prev, char *desc);
+const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc);
+const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc);
+const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc);
+const void *xe_pci_live_device_gen_param(struct kunit *test, const void *prev, char *desc);
 
 #endif
Signature · 1 line
2.51.0.rc2.233.g662b1ed5c5-goog
author
#1 lore raw

PATCH v2 2/2 kunit: Only output a test plan if we're using kunit_array_gen_params

In 6a2a027e254b ("kunit: Enable direct registration of parameter arrays to a KUnit test"), we now output a test plan for parameterised tests which use parameter arrays. This uses the size of the array (via the ARRAY_SIZE macro) to determine the number of subtests, which otherwise was indeterminate.

However some tests (particularly xe_pci.check_platform_gt_count) use their own gen_params function which further filters the array, resulting in the test plan being inaccurate (and hence kunit.py failing).

For now, only print the test plan line if the gen_params function is the provided kunit_array_gen_params. Unfortunately, this catches a lot of tests which would work, but at least makes sure we don't regress anything until we can rework how some of these macros function.

Fixes 6a2a027e254b ("kunit: Enable direct registration of parameter arrays to a KUnit test")

---

No changes since v1:
https://lore.kernel.org/linux-kselftest/[email protected]/

(The change was in patch 1.)

---
 lib/kunit/test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/kunit/test.c +3 -1
index b661407ad0a3..bb66ea1a3eac 100644
@@ -732,10 +732,12 @@ int kunit_run_tests(struct kunit_suite *suite)
 				  "KTAP version 1\n");
 			kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT
 				  "# Subtest: %s", test_case->name);
-			if (test.params_array.params)
+			if (test.params_array.params &&
+			    test_case->generate_params == kunit_array_gen_params) {
 				kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT
 					  KUNIT_SUBTEST_INDENT "1..%zd\n",
 					  test.params_array.num_params);
+			}
 
 			while (curr_param) {
 				struct kunit param_test = {
Signature · 1 line
2.51.0.rc2.233.g662b1ed5c5-goog
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] kunit: Only output a test plan if we're using kunit_array_gen_params

Quoted 10 lines · David Gow

In 6a2a027e254b ("kunit: Enable direct registration of parameter arrays to a KUnit test"), we now output a test plan for parameterised tests which use parameter arrays. This uses the size of the array (via the ARRAY_SIZE macro) to determine the number of subtests, which otherwise was indeterminate.

However some tests (particularly xe_pci.check_platform_gt_count) use their own gen_params function which further filters the array, resulting in the test plan being inaccurate (and hence kunit.py failing).

Quoted 7 lines

For now, only print the test plan line if the gen_params function is the provided kunit_array_gen_params. Unfortunately, this catches a lot of tests which would work, but at least makes sure we don't regress anything until we can rework how some of these macros function.

Fixes 6a2a027e254b ("kunit: Enable direct registration of parameter arrays to a KUnit test")

Hello!

This makes sense to me. Maybe we can work on this feature in the future. Thanks!

Thanks!
-Rae

Quoted 32 lines

---

No changes since v1:
https://lore.kernel.org/linux-kselftest/[email protected]/

(The change was in patch 1.)

---
 lib/kunit/test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/kunit/test.c +3 -2
index b661407ad0a3..bb66ea1a3eac 100644
@@ -732,10 +732,12 @@ int kunit_run_tests(struct kunit_suite *suite)
                                  "KTAP version 1\n");
                        kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT
                                  "# Subtest: %s", test_case->name);
-                       if (test.params_array.params)
+                       if (test.params_array.params &&
+                           test_case->generate_params == kunit_array_gen_params) {
                                kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT
                                          KUNIT_SUBTEST_INDENT "1..%zd\n",
                                          test.params_array.num_params);
+                       }
 
                        while (curr_param) {
                                struct kunit param_test = {
--

2.51.0.rc2.233.g662b1ed5c5-goog

Reviewed-by on v2 1/2
#3 lore raw
In reply to David Gow
Quoted 14 lines · David Gow

In 444be9072fca ("kunit: Pass parameterized test context to generate_params()") prototype used for gen_params functions was changed to add a struct kunit parameter. However, a few of these used in xe were not updated.

Update these so that the xe_pci tests build and run again.

Fixes 444be9072fca ("kunit: Pass parameterized test context to generate_params()")

---

Sorry, the last fix here caused a warning (thanks to the test robot for finding it).

Quoted 7 lines

I'm still happy to sqash and re-send the whole original series if that's preferred.

Changes since v1:
https://lore.kernel.org/linux-kselftest/[email protected]/
- Add the missing <kunit/test.h> include for struct kunit

Hello!

Thanks for this change! It looks good to me!

Thanks!
-Rae

Quoted 74 lines
---
 drivers/gpu/drm/xe/tests/xe_pci.c      | 12 ++++++------
 drivers/gpu/drm/xe/tests/xe_pci_test.h |  9 +++++----
 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/tests/xe_pci.c +6 -6
index a65705814b9a..f707e0a54295 100644
@@ -44,9 +44,9 @@ KUNIT_ARRAY_PARAM(pci_id, pciidlist, xe_pci_id_kunit_desc);
  *
  * Return: pointer to the next parameter or NULL if no more parameters
  */
-const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc)
+const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc)
 {
-       return graphics_ip_gen_params(prev, desc);
+       return graphics_ip_gen_params(test, prev, desc);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param);
 
@@ -61,9 +61,9 @@ EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param);
  *
  * Return: pointer to the next parameter or NULL if no more parameters
  */
-const void *xe_pci_media_ip_gen_param(const void *prev, char *desc)
+const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc)
 {
-       return media_ip_gen_params(prev, desc);
+       return media_ip_gen_params(test, prev, desc);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
 
@@ -78,9 +78,9 @@ EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
  *
  * Return: pointer to the next parameter or NULL if no more parameters
  */
-const void *xe_pci_id_gen_param(const void *prev, char *desc)
+const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc)
 {
-       const struct pci_device_id *pci = pci_id_gen_params(prev, desc);
+       const struct pci_device_id *pci = pci_id_gen_params(test, prev, desc);
 
        return pci->driver_data ? pci : NULL;
 }
drivers/gpu/drm/xe/tests/xe_pci_test.h +5 -5
index ce4d2b86b778..6d8bc56f7bde 100644
@@ -7,6 +7,7 @@
 #define _XE_PCI_TEST_H_
 
 #include <linux/types.h>
+#include <kunit/test.h>
 
 #include "xe_platform_types.h"
 #include "xe_sriov_types.h"
@@ -25,9 +26,9 @@ struct xe_pci_fake_data {
 
 int xe_pci_fake_device_init(struct xe_device *xe);
 
-const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc);
-const void *xe_pci_media_ip_gen_param(const void *prev, char *desc);
-const void *xe_pci_id_gen_param(const void *prev, char *desc);
-const void *xe_pci_live_device_gen_param(const void *prev, char *desc);
+const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc);
+const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc);
+const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc);
+const void *xe_pci_live_device_gen_param(struct kunit *test, const void *prev, char *desc);
 
 #endif
--

2.51.0.rc2.233.g662b1ed5c5-goog