Skip to content

Commit b16c745

Browse files
mripardpopcornmix
authored andcommitted
drm/vc4: hvs: Destroy dlist allocations immediately when running a test
When running a kunit test, the driver runs with a mock device. As such, any attempt to read or write to a hardware register will fail the current test immediately. The dlist allocation management recently introduced will read the current frame count from the HVS to defer its destruction until a subsequent frame has been output. This obviously involves a register read that fails the Kunit tests. Change the destruction deferral function to destroy the allocation immediately if we run under kunit. This is essentially harmless since the main reason for that deferall is to prevent any access to the hardware dlist while a frame described by that list is rendered. On our mock driver, we have neither a hardware dlist nor a rendering, so it doesn't matter. Signed-off-by: Maxime Ripard <maxime@cerno.tech>
1 parent 31ee7bb commit b16c745

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/gpu/drm/vc4/vc4_hvs.c

+12
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,18 @@ void vc4_hvs_mark_dlist_entry_stale(struct vc4_hvs *hvs,
490490
if (!drm_mm_node_allocated(&alloc->mm_node))
491491
return;
492492

493+
/*
494+
* Kunit tests run with a mock device and we consider any hardware
495+
* access a test failure. Let's free the dlist allocation right away if
496+
* we're running under kunit, we won't risk a dlist corruption anyway.
497+
*/
498+
if (kunit_get_current_test()) {
499+
spin_lock_irqsave(&hvs->mm_lock, flags);
500+
vc4_hvs_free_dlist_entry_locked(hvs, alloc);
501+
spin_unlock_irqrestore(&hvs->mm_lock, flags);
502+
return;
503+
}
504+
493505
frcnt = vc4_hvs_get_fifo_frame_count(hvs, alloc->channel);
494506
alloc->target_frame_count = (frcnt + 1) & ((1 << 6) - 1);
495507

0 commit comments

Comments
 (0)