Re: [PATCH v2] drm/sched: Create a fake device for KUnit tests

From: Shixiong Ou

Date: Tue Sep 08 2026 - 02:01:58 EST


Hi,

First of all, thanks for the review and the suggestions.
I had already sent v3 by the time your full comments came in -- here is
the v3 patch for reference:  https://lkml.org/lkml/2026/9/4/547

Both points will be addressed in v4 later.


On 2026/9/4 15:02, Philipp Stanner wrote:
On Thu, 2026-09-03 at 20:15 +0800, oushixiong1025@xxxxxxx wrote:
[…]

+
 #include "sched_tests.h"
 /*
@@ -288,6 +290,7 @@ static const struct drm_sched_backend_ops drm_mock_scheduler_ops = {
  */
 struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test, long timeout)
 {
+ static unsigned int instance;
I know statics are initialized to 0 automatically, but writing it out
explicitly is probably advantageous for readability, especially since
we're incrementing.

One note: this trips checkpatch's "do not initialise statics to 0"
error, so I followed your suggestion over the checkpatch rule.


  struct drm_sched_init_args args = {
  .ops = &drm_mock_scheduler_ops,
  .num_rqs = DRM_SCHED_PRIORITY_COUNT,
@@ -297,11 +300,19 @@ struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test, long timeout)
  .name = "drm-mock-scheduler",
  };
  struct drm_mock_scheduler *sched;
+ struct device *dev;
+ char name[64];
  int ret;
  sched = kunit_kzalloc(test, sizeof(*sched), GFP_KERNEL);
  KUNIT_ASSERT_NOT_NULL(test, sched);
+ snprintf(name, sizeof(name), "%s-%u", args.name, ++instance);
Any particular reason why you begin with index 1?

No particular reason -- switched to instance++ so the numbering
starts at 0.

The updated v4 patch will be send later.
Thanks again for your time and for catching these points.

Best regards,
Shixiong Ou