Skip to contentSkip to conversation

drm/sched: Fix clang build warning in kunit tests

PATCH In review Tvrtko Ursulin 2 participants 6 messages May 22 – May 29

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/sched: Fix clang build warning in kunit tests

Initializing compile time constant struct or arrays from another such variable is a gcc extension, while clang strictly requires a compile time constant literal.

As reported by LKP:

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/scheduler/tests/tests_scheduler.c:675:10: error: initializer element is not a compile-time constant

                                 drm_sched_scheduler_two_clients_attr),
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:224:13: note: expanded from macro 'KUNIT_CASE_PARAM_ATTR'
                     .attr = attributes, .module_name = KBUILD_MODNAME}
                             ^~~~~~~~~~

1 error generated.

vim +675 drivers/gpu/drm/scheduler/tests/tests_scheduler.c

671
672 static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
673 KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
674 drm_sched_scheduler_two_clients_gen_params,

Quoted 1 line

675 drm_sched_scheduler_two_clients_attr),

676 {}
677 };
678

Fix it by using a compound literal as other tests do.

Fixes 97ef806a5314 ("drm/sched: Add some scheduling quality unit tests")
Cc Philipp Stanner <[email protected]>
---
 drivers/gpu/drm/scheduler/tests/tests_scheduler.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/gpu/drm/scheduler/tests/tests_scheduler.c +2 -10
index 8b2e4ef9915f..90d31888cf92 100644
@@ -666,14 +666,10 @@ static void drm_sched_scheduler_two_clients_test(struct kunit *test)
 	}
 }
 
-static const struct kunit_attributes drm_sched_scheduler_two_clients_attr = {
-	.speed = KUNIT_SPEED_SLOW,
-};
-
 static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
 	KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
 			      drm_sched_scheduler_two_clients_gen_params,
-			      drm_sched_scheduler_two_clients_attr),
+			      { .speed = KUNIT_SPEED_SLOW }),
 	{}
 };
 
@@ -858,14 +854,10 @@ static void drm_sched_scheduler_many_clients_test(struct kunit *test)
 		drm_mock_sched_entity_free(client[i].entity);
 }
 
-static const struct kunit_attributes drm_sched_scheduler_many_clients_attr = {
-	.speed = KUNIT_SPEED_SLOW,
-};
-
 static struct kunit_case drm_sched_scheduler_many_clients_tests[] = {
 	KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_many_clients_test,
 			      drm_sched_scheduler_many_clients_gen_params,
-			      drm_sched_scheduler_many_clients_attr),
+			      { .speed = KUNIT_SPEED_SLOW }),
 	{}
 };
 
Signature · 1 line
2.54.0
#1 lore raw

Yo Tvrtko,

Quoted 6 lines · Tvrtko Ursulin

Initializing compile time constant struct or arrays from another such variable is a gcc extension, while clang strictly requires a compile time constant literal.

As reported by LKP:

Quoted 7 lines
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/scheduler/tests/tests_scheduler.c:675:10: error: initializer element is not a compile-time constant

                                 drm_sched_scheduler_two_clients_attr), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/kunit/test.h:224:13: note: expanded from macro 'KUNIT_CASE_PARAM_ATTR' .attr = attributes, .module_name = KBUILD_MODNAME} ^~~~~~~~~~
   1 error generated.

Hmm, is it now a build error, or a build warning? The commit title says "warning".

Depending on what it really is, where should it go, misc-next or misc- fixes?

P.

Quoted 59 lines

vim +675 drivers/gpu/drm/scheduler/tests/tests_scheduler.c

   671
   672 static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
   673 KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
   674       drm_sched_scheduler_two_clients_gen_params,
 > 675       drm_sched_scheduler_two_clients_attr),
   676 {}
   677 };
   678

Fix it by using a compound literal as other tests do.

Fixes 97ef806a5314 ("drm/sched: Add some scheduling quality unit tests")
Cc Philipp Stanner <[email protected]>

---
 drivers/gpu/drm/scheduler/tests/tests_scheduler.c | 12 ++----------

 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/gpu/drm/scheduler/tests/tests_scheduler.c +0 -0
index 8b2e4ef9915f..90d31888cf92 100644
@@ -666,14 +666,10 @@ static void drm_sched_scheduler_two_clients_test(struct kunit *test)
  	}
  }

drivers/gpu/drm/scheduler/tests/tests_scheduler.c +0 -4
-static const struct kunit_attributes drm_sched_scheduler_two_clients_attr = {
-	.speed = KUNIT_SPEED_SLOW,
-};
-

 static struct kunit_case drm_sched_scheduler_two_clients_tests[] = { KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test, drm_sched_scheduler_two_clients_gen_params,

drivers/gpu/drm/scheduler/tests/tests_scheduler.c +1 -1
-			      drm_sched_scheduler_two_clients_attr),
+			      { .speed = KUNIT_SPEED_SLOW }),

  {}
 };

drivers/gpu/drm/scheduler/tests/tests_scheduler.c +0 -0
@@ -858,14 +854,10 @@ static void drm_sched_scheduler_many_clients_test(struct kunit *test)
  		drm_mock_sched_entity_free(client[i].entity);
  }

drivers/gpu/drm/scheduler/tests/tests_scheduler.c +0 -4
-static const struct kunit_attributes drm_sched_scheduler_many_clients_attr = {
-	.speed = KUNIT_SPEED_SLOW,
-};
-

 static struct kunit_case drm_sched_scheduler_many_clients_tests[] = { KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_many_clients_test, drm_sched_scheduler_many_clients_gen_params,

drivers/gpu/drm/scheduler/tests/tests_scheduler.c +1 -1
-			      drm_sched_scheduler_many_clients_attr),
+			      { .speed = KUNIT_SPEED_SLOW }),

  {}
 };

#2 lore raw
Quoted 17 lines · Philipp Stanner

Yo Tvrtko,

Quoted 6 lines · Tvrtko Ursulin

Initializing compile time constant struct or arrays from another such variable is a gcc extension, while clang strictly requires a compile time constant literal.

As reported by LKP:

Quoted 7 lines
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/scheduler/tests/tests_scheduler.c:675:10: error: initializer element is not a compile-time constant

                                 drm_sched_scheduler_two_clients_attr), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/kunit/test.h:224:13: note: expanded from macro 'KUNIT_CASE_PARAM_ATTR' .attr = attributes, .module_name = KBUILD_MODNAME} ^~~~~~~~~~
   1 error generated.

Quoted 5 lines

Hmm, is it now a build error, or a build warning? The commit title says "warning".

Depending on what it really is, where should it go, misc-next or misc- fixes?

Right, warning or error it depends if someone enabled CONFIG_DRM_WERROR.

According to drm-misc commiter guidelines, since we are in -rc5, it can go to drm-misc-next.

Regards,

Tvrtko

Quoted 59 lines
Quoted 58 lines

vim +675 drivers/gpu/drm/scheduler/tests/tests_scheduler.c

   671
   672 static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
   673 KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
   674       drm_sched_scheduler_two_clients_gen_params,
 > 675       drm_sched_scheduler_two_clients_attr),
   676 {}
   677 };
   678

Fix it by using a compound literal as other tests do.

Fixes 97ef806a5314 ("drm/sched: Add some scheduling quality unit tests")
Cc Philipp Stanner <[email protected]>
---
  drivers/gpu/drm/scheduler/tests/tests_scheduler.c | 12 ++----------
  1 file changed, 2 insertions(+), 10 deletions(-)
drivers/gpu/drm/scheduler/tests/tests_scheduler.c +2 -10
index 8b2e4ef9915f..90d31888cf92 100644
@@ -666,14 +666,10 @@ static void drm_sched_scheduler_two_clients_test(struct kunit *test)
  	}
  }
 
-static const struct kunit_attributes drm_sched_scheduler_two_clients_attr = {
-	.speed = KUNIT_SPEED_SLOW,
-};
-
  static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
  	KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
  			      drm_sched_scheduler_two_clients_gen_params,
-			      drm_sched_scheduler_two_clients_attr),
+			      { .speed = KUNIT_SPEED_SLOW }),
  	{}
  };
 
@@ -858,14 +854,10 @@ static void drm_sched_scheduler_many_clients_test(struct kunit *test)
  		drm_mock_sched_entity_free(client[i].entity);
  }
 
-static const struct kunit_attributes drm_sched_scheduler_many_clients_attr = {
-	.speed = KUNIT_SPEED_SLOW,
-};
-
  static struct kunit_case drm_sched_scheduler_many_clients_tests[] = {
  	KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_many_clients_test,
  			      drm_sched_scheduler_many_clients_gen_params,
-			      drm_sched_scheduler_many_clients_attr),
+			      { .speed = KUNIT_SPEED_SLOW }),
  	{}
  };
 
#3 lore raw
Quoted 22 lines · Tvrtko Ursulin
Quoted 20 lines · Philipp Stanner

Yo Tvrtko,

Quoted 6 lines · Tvrtko Ursulin

Initializing compile time constant struct or arrays from another such variable is a gcc extension, while clang strictly requires a compile time constant literal.

As reported by LKP:

Quoted 7 lines
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/scheduler/tests/tests_scheduler.c:675:10: error: initializer element is not a compile-time constant

                                  drm_sched_scheduler_two_clients_attr), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/kunit/test.h:224:13: note: expanded from macro 'KUNIT_CASE_PARAM_ATTR' .attr = attributes, .module_name = KBUILD_MODNAME} ^~~~~~~~~~
    1 error generated.

Hmm, is it now a build error, or a build warning? The commit title says "warning".

Quoted 6 lines
Quoted 2 lines

Depending on what it really is, where should it go, misc-next or misc- fixes?

Right, warning or error it depends if someone enabled CONFIG_DRM_WERROR.

According to drm-misc commiter guidelines, since we are in -rc5, it can go to drm-misc-next.

Now it's drm-misc-next-fixes I think since Maarten sent the last drm-misc-next pull request yesterday.

Regards,

Tvrtko

Quoted 60 lines
Quoted 59 lines
Quoted 58 lines

vim +675 drivers/gpu/drm/scheduler/tests/tests_scheduler.c

    671
    672    static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
    673 KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
    674                      drm_sched_scheduler_two_clients_gen_params, > 675                      drm_sched_scheduler_two_clients_attr), 676        {}
    677    };
    678

Fix it by using a compound literal as other tests do.

Fixes 97ef806a5314 ("drm/sched: Add some scheduling quality unit tests")
Cc Philipp Stanner <[email protected]>

---
  drivers/gpu/drm/scheduler/tests/tests_scheduler.c | 12 ++----------

  1 file changed, 2 insertions(+), 10 deletions(-)
drivers/gpu/drm/scheduler/tests/tests_scheduler.c +2 -10
index 8b2e4ef9915f..90d31888cf92 100644
@@ -666,14 +666,10 @@ static void 
 drm_sched_scheduler_two_clients_test(struct kunit *test)
       }
   }
-static const struct kunit_attributes 
 drm_sched_scheduler_two_clients_attr = {
-    .speed = KUNIT_SPEED_SLOW,
-};
-
   static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
       KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
                     drm_sched_scheduler_two_clients_gen_params,
-                  drm_sched_scheduler_two_clients_attr),
+                  { .speed = KUNIT_SPEED_SLOW }),
       {}
   };
@@ -858,14 +854,10 @@ static void 
 drm_sched_scheduler_many_clients_test(struct kunit *test)
           drm_mock_sched_entity_free(client[i].entity);
   }
-static const struct kunit_attributes 
 drm_sched_scheduler_many_clients_attr = {
-    .speed = KUNIT_SPEED_SLOW,
-};
-
   static struct kunit_case drm_sched_scheduler_many_clients_tests[] = {
       KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_many_clients_test,
                     drm_sched_scheduler_many_clients_gen_params,
-                  drm_sched_scheduler_many_clients_attr),
+                  { .speed = KUNIT_SPEED_SLOW }),
       {}
   };
#4 lore raw
Quoted 30 lines · Tvrtko Ursulin
Quoted 28 lines · Tvrtko Ursulin
Quoted 25 lines · Philipp Stanner

Yo Tvrtko,

Quoted 9 lines · Tvrtko Ursulin

Initializing compile time constant struct or arrays from another such variable is a gcc extension, while clang strictly requires a compile time
constant literal.

As reported by LKP:

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/scheduler/tests/tests_scheduler.c:675:10: error:
initializer element is not a compile-time constant

Quoted 7 lines

                                  drm_sched_scheduler_two_clients_attr), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/kunit/test.h:224:13: note: expanded from macro 'KUNIT_CASE_PARAM_ATTR'
                      .attr = attributes, .module_name = KBUILD_MODNAME} ^~~~~~~~~~
    1 error generated.

Hmm, is it now a build error, or a build warning? The commit title says "warning".

Depending on what it really is, where should it go, misc-next or misc- fixes?

Quoted 7 lines
Quoted 4 lines

Right, warning or error it depends if someone enabled CONFIG_DRM_WERROR.

According to drm-misc commiter guidelines, since we are in -rc5, it can go to drm-misc-next.

Now it's  drm-misc-next-fixes I think since Maarten sent the last drm-misc-next pull request yesterday.

Feel free to do that as you see fit

Thx
P.

Quoted 71 lines

Regards,

Tvrtko

Quoted 65 lines
Quoted 64 lines
Quoted 63 lines

vim +675 drivers/gpu/drm/scheduler/tests/tests_scheduler.c

    671
    672    static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
    673 KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test, 674                      drm_sched_scheduler_two_clients_gen_params, > 675                      drm_sched_scheduler_two_clients_attr), 676        {}
    677    };
    678

Fix it by using a compound literal as other tests do.

[email protected]/

Fixes 97ef806a5314 ("drm/sched: Add some scheduling quality unit

tests")
Cc: Philipp Stanner <[email protected]>
---
  drivers/gpu/drm/scheduler/tests/tests_scheduler.c | 12 ++----------

  1 file changed, 2 insertions(+), 10 deletions(-)
(quoted diff) renamed from drivers/gpu/drm/scheduler/tests/tests_scheduler.c +0 -0

drivers/gpu/drm/scheduler/tests/tests_scheduler.c
index 8b2e4ef9915f..90d31888cf92 100644

drivers/gpu/drm/scheduler/tests/tests_scheduler.c +2 -10
@@ -666,14 +666,10 @@ static void 
 drm_sched_scheduler_two_clients_test(struct kunit *test)
       }
   }
-static const struct kunit_attributes 
 drm_sched_scheduler_two_clients_attr = {
-    .speed = KUNIT_SPEED_SLOW,
-};
-
   static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
       KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
                     drm_sched_scheduler_two_clients_gen_params,
-                  drm_sched_scheduler_two_clients_attr),
+                  { .speed = KUNIT_SPEED_SLOW }),
       {}
   };
@@ -858,14 +854,10 @@ static void 
 drm_sched_scheduler_many_clients_test(struct kunit *test)
           drm_mock_sched_entity_free(client[i].entity);
   }
-static const struct kunit_attributes 
 drm_sched_scheduler_many_clients_attr = {
-    .speed = KUNIT_SPEED_SLOW,
-};
-
   static struct kunit_case drm_sched_scheduler_many_clients_tests[] = {
       KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_many_clients_test,
                     drm_sched_scheduler_many_clients_gen_params,
-                  drm_sched_scheduler_many_clients_attr),
+                  { .speed = KUNIT_SPEED_SLOW }),
       {}
   };
author Applied
#5 lore raw
Quoted 36 lines · Philipp Stanner
Quoted 35 lines · Tvrtko Ursulin
Quoted 32 lines · Tvrtko Ursulin
Quoted 20 lines · Philipp Stanner

Yo Tvrtko,

Quoted 9 lines · Tvrtko Ursulin

Initializing compile time constant struct or arrays from another such variable is a gcc extension, while clang strictly requires a compile time
constant literal.

As reported by LKP:

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/scheduler/tests/tests_scheduler.c:675:10: error:
initializer element is not a compile-time constant

Quoted 7 lines

                                  drm_sched_scheduler_two_clients_attr), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/kunit/test.h:224:13: note: expanded from macro
'KUNIT_CASE_PARAM_ATTR'
                      .attr = attributes, .module_name = KBUILD_MODNAME} ^~~~~~~~~~
    1 error generated.

Quoted 5 lines

Hmm, is it now a build error, or a build warning? The commit title says "warning".

Depending on what it really is, where should it go, misc-next or misc- fixes?

Right, warning or error it depends if someone enabled CONFIG_DRM_WERROR.

According to drm-misc commiter guidelines, since we are in -rc5, it can go to drm-misc-next.

Quoted 6 lines
Quoted 2 lines

Now it's  drm-misc-next-fixes I think since Maarten sent the last drm-misc-next pull request yesterday.

Feel free to do that as you see fit

Pushed to drm-misc-next-fixes, thank you!

Regards,

Tvrtko

Quoted 67 lines
Quoted 66 lines
Quoted 65 lines
Quoted 64 lines
Quoted 63 lines

vim +675 drivers/gpu/drm/scheduler/tests/tests_scheduler.c

    671
    672    static struct kunit_case
drm_sched_scheduler_two_clients_tests[] = {
    673
KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
    674                      drm_sched_scheduler_two_clients_gen_params, > 675                      drm_sched_scheduler_two_clients_attr), 676        {}
    677    };
    678

Fix it by using a compound literal as other tests do.

[email protected]/

Fixes 97ef806a5314 ("drm/sched: Add some scheduling quality unit

tests")
Cc: Philipp Stanner <[email protected]>

---
   drivers/gpu/drm/scheduler/tests/tests_scheduler.c | 12 ++----------
   1 file changed, 2 insertions(+), 10 deletions(-)
(quoted diff) renamed from drivers/gpu/drm/scheduler/tests/tests_scheduler.c +0 -0

drivers/gpu/drm/scheduler/tests/tests_scheduler.c
index 8b2e4ef9915f..90d31888cf92 100644

drivers/gpu/drm/scheduler/tests/tests_scheduler.c +2 -10
@@ -666,14 +666,10 @@ static void
 drm_sched_scheduler_two_clients_test(struct kunit *test)
       }
   }
-static const struct kunit_attributes
 drm_sched_scheduler_two_clients_attr = {
-    .speed = KUNIT_SPEED_SLOW,
-};
-
   static struct kunit_case drm_sched_scheduler_two_clients_tests[] = {
       KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_two_clients_test,
                     drm_sched_scheduler_two_clients_gen_params,
-                  drm_sched_scheduler_two_clients_attr),
+                  { .speed = KUNIT_SPEED_SLOW }),
       {}
   };
@@ -858,14 +854,10 @@ static void
 drm_sched_scheduler_many_clients_test(struct kunit *test)
           drm_mock_sched_entity_free(client[i].entity);
   }
-static const struct kunit_attributes
 drm_sched_scheduler_many_clients_attr = {
-    .speed = KUNIT_SPEED_SLOW,
-};
-
   static struct kunit_case drm_sched_scheduler_many_clients_tests[] = {
       KUNIT_CASE_PARAM_ATTR(drm_sched_scheduler_many_clients_test,
                     drm_sched_scheduler_many_clients_gen_params,
-                  drm_sched_scheduler_many_clients_attr),
+                  { .speed = KUNIT_SPEED_SLOW }),
       {}
   };