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

0 views
Skip to first unread message

David Gow

unread,
Aug 19, 2025, 3:34:38 AMAug 19
to Rae Moar, Marie Zhussupova, marievic...@gmail.com, Rodrigo Vivi, Shuah Khan, David Gow, Stephen Rothwell, Linux Next Mailing List, inte...@lists.freedesktop.org, kuni...@googlegroups.com, linux-k...@vger.kernel.org, linux-...@vger.kernel.org
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()")
Signed-off-by: David Gow <davi...@google.com>
---

This should fix the issues found with the linux-next merge:
https://lore.kernel.org/linux-next/20250818120...@canb.auug.org.au/

The following should reproduce them:
./tools/testing/kunit/kunit.py run --arch x86_64 --kunitconfig drivers/gpu/drm/xe

Ideally, these should be squashed into the corresponding commits: let me
know if you'd like me to re-send out the whole series with these fixes
applied.

Cheers,
-- David

---
drivers/gpu/drm/xe/tests/xe_pci.c | 12 ++++++------
drivers/gpu/drm/xe/tests/xe_pci_test.h | 8 ++++----
2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/xe/tests/xe_pci.c b/drivers/gpu/drm/xe/tests/xe_pci.c
index a65705814b9a..f707e0a54295 100644
--- a/drivers/gpu/drm/xe/tests/xe_pci.c
+++ b/drivers/gpu/drm/xe/tests/xe_pci.c
@@ -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;
}
diff --git a/drivers/gpu/drm/xe/tests/xe_pci_test.h b/drivers/gpu/drm/xe/tests/xe_pci_test.h
index ce4d2b86b778..690b36e6500c 100644
--- a/drivers/gpu/drm/xe/tests/xe_pci_test.h
+++ b/drivers/gpu/drm/xe/tests/xe_pci_test.h
@@ -25,9 +25,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.rc1.167.g924127e9c0-goog

David Gow

unread,
Aug 19, 2025, 3:36:38 AMAug 19
to Rae Moar, Marie Zhussupova, marievic...@gmail.com, Rodrigo Vivi, Shuah Khan, David Gow, Stephen Rothwell, Linux Next Mailing List, inte...@lists.freedesktop.org, kuni...@googlegroups.com, linux-k...@vger.kernel.org, linux-...@vger.kernel.org
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")
Signed-off-by: David Gow <davi...@google.com>
---
lib/kunit/test.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index b661407ad0a3..bb66ea1a3eac 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -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.rc1.167.g924127e9c0-goog

kernel test robot

unread,
Aug 20, 2025, 2:31:36 PMAug 20
to David Gow, Rae Moar, Marie Zhussupova, marievic...@gmail.com, Rodrigo Vivi, Shuah Khan, ll...@lists.linux.dev, oe-kbu...@lists.linux.dev, David Gow, Linux Next Mailing List, inte...@lists.freedesktop.org, kuni...@googlegroups.com, linux-k...@vger.kernel.org, linux-...@vger.kernel.org
Hi David,

kernel test robot noticed the following build errors:

[auto build test ERROR on shuah-kselftest/kunit]
[also build test ERROR on linus/master v6.17-rc2 next-20250820]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/David-Gow/kunit-Only-output-a-test-plan-if-we-re-using-kunit_array_gen_params/20250819-154731
base: https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git kunit
patch link: https://lore.kernel.org/r/20250819073434.1411114-1-davidgow%40google.com
patch subject: [PATCH 1/2] drm/xe/tests: Fix some additional gen_params signatures
config: x86_64-randconfig-071-20250820 (https://download.01.org/0day-ci/archive/20250821/202508210248...@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250821/202508210248...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <l...@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202508210248...@intel.com/

All errors (new ones prefixed by >>):

In file included from <built-in>:4:
>> drivers/gpu/drm/xe/tests/xe_pci_test.h:28:49: error: declaration of 'struct kunit' will not be visible outside of this function [-Werror,-Wvisibility]
28 | const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc);
| ^
drivers/gpu/drm/xe/tests/xe_pci_test.h:29:46: error: declaration of 'struct kunit' will not be visible outside of this function [-Werror,-Wvisibility]
29 | const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc);
| ^
drivers/gpu/drm/xe/tests/xe_pci_test.h:30:40: error: declaration of 'struct kunit' will not be visible outside of this function [-Werror,-Wvisibility]
30 | const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc);
| ^
drivers/gpu/drm/xe/tests/xe_pci_test.h:31:49: error: declaration of 'struct kunit' will not be visible outside of this function [-Werror,-Wvisibility]
31 | const void *xe_pci_live_device_gen_param(struct kunit *test, const void *prev, char *desc);
| ^
4 errors generated.


vim +28 drivers/gpu/drm/xe/tests/xe_pci_test.h

27
> 28 const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc);
29 const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc);
30 const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc);
31 const void *xe_pci_live_device_gen_param(struct kunit *test, const void *prev, char *desc);
32

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

David Gow

unread,
Aug 21, 2025, 9:54:55 AMAug 21
to Rae Moar, Marie Zhussupova, marievic...@gmail.com, Rodrigo Vivi, Shuah Khan, David Gow, Stephen Rothwell, Linux Next Mailing List, inte...@lists.freedesktop.org, kuni...@googlegroups.com, linux-k...@vger.kernel.org, linux-...@vger.kernel.org
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()")
Signed-off-by: David Gow <davi...@google.com>
---

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/20250819073434.1...@google.com/
- 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(-)
index ce4d2b86b778..6d8bc56f7bde 100644
--- a/drivers/gpu/drm/xe/tests/xe_pci_test.h
+++ b/drivers/gpu/drm/xe/tests/xe_pci_test.h
@@ -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

David Gow

unread,
Aug 21, 2025, 9:54:56 AMAug 21
to Rae Moar, Marie Zhussupova, marievic...@gmail.com, Rodrigo Vivi, Shuah Khan, David Gow, Stephen Rothwell, Linux Next Mailing List, inte...@lists.freedesktop.org, kuni...@googlegroups.com, linux-k...@vger.kernel.org, linux-...@vger.kernel.org
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")
Signed-off-by: David Gow <davi...@google.com>
---

No changes since v1:
https://lore.kernel.org/linux-kselftest/20250819073434.1...@google.com/

(The change was in patch 1.)

---
lib/kunit/test.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index b661407ad0a3..bb66ea1a3eac 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -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

Rae Moar

unread,
Aug 21, 2025, 4:16:32 PMAug 21
to David Gow, Marie Zhussupova, marievic...@gmail.com, Rodrigo Vivi, Shuah Khan, Stephen Rothwell, Linux Next Mailing List, inte...@lists.freedesktop.org, kuni...@googlegroups.com, linux-k...@vger.kernel.org, linux-...@vger.kernel.org
On Thu, Aug 21, 2025 at 8:54 AM David Gow <davi...@google.com> wrote:
>
> 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()")
> Signed-off-by: David Gow <davi...@google.com>
> ---
>
> 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/20250819073434.1...@google.com/
> - Add the missing <kunit/test.h> include for struct kunit
>

Hello!

Thanks for this change! It looks good to me!

Reviewed-by: Rae Moar <rm...@google.com>

Thanks!
-Rae

Rae Moar

unread,
Aug 21, 2025, 4:17:27 PMAug 21
to David Gow, Marie Zhussupova, marievic...@gmail.com, Rodrigo Vivi, Shuah Khan, Stephen Rothwell, Linux Next Mailing List, inte...@lists.freedesktop.org, kuni...@googlegroups.com, linux-k...@vger.kernel.org, linux-...@vger.kernel.org
On Thu, Aug 21, 2025 at 8:54 AM David Gow <davi...@google.com> wrote:
>
> 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")
> Signed-off-by: David Gow <davi...@google.com>


Hello!

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

Reviewed-by: Rae Moar <rm...@google.com>

Thanks!
-Rae

Reply all
Reply to author
Forward
0 new messages