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

From: Philipp Stanner

Date: Tue Sep 08 2026 - 08:30:26 EST


On Tue, 2026-09-08 at 13:59 +0800, oushixiong1025@xxxxxxx wrote:
> From: Shixiong Ou <oushixiong@xxxxxxxxxx>
>
> The DRM scheduler KUnit tests pass NULL for the dev field in
> drm_sched_init_args, which NULL-pointer dereferences in the drm_sched_job
> trace event via dev_name() on sched->dev.
>
> Give the mock scheduler a device with kunit_device_register(), which is
> also cleaned up at test exit. A per-function counter keeps the device
> names unique, since some tests create several mock schedulers.
>
> Fixes: 5a99350794fe ("drm/sched: Add scheduler unit testing infrastructure and some basic tests")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Shixiong Ou <oushixiong@xxxxxxxxxx>
> Acked-by: Maxime Ripard <mripard@xxxxxxxxxx>
>
> ---
> v3->v4:
>   - Initialize the instance counter explicitly

You learn something new every day – apparently that must not be done,
according to the DRM rules.

My bad.

I reverted it locally and pushed to drm-misc-fixes

Thx Shixiong.

P.