drm: vc4: Free the dlist alloc immediately if it never hit the hw
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Wed, 22 Nov 2023 18:36:54 +0000 (18:36 +0000)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:35:15 +0000 (11:35 +0000)
atomic_check creates a state, and allocates the dlist memory for
it such that atomic_flush can not fail.

On destroy that dlist allocation was being put in the stale list,
even though it had never been programmed into the hardware,
therefore doing lots of atomic_checks could consume all the dlist
memory and fail.

If the dlist has never been programmed into the hardware, then
free it immediately.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_hvs.c

index deeeeac..8d95d5c 100644 (file)
@@ -667,6 +667,7 @@ struct vc4_hvs_dlist_allocation {
        struct drm_mm_node mm_node;
        unsigned int channel;
        u8 target_frame_count;
+       bool dlist_programmed;
 };
 
 struct vc4_crtc_state {
index 028ba50..d486091 100644 (file)
@@ -697,8 +697,11 @@ void vc4_hvs_mark_dlist_entry_stale(struct vc4_hvs *hvs,
         * Kunit tests run with a mock device and we consider any hardware
         * access a test failure. Let's free the dlist allocation right away if
         * we're running under kunit, we won't risk a dlist corruption anyway.
+        *
+        * Likewise if the allocation was only checked and never programmed, we
+        * can destroy the allocation immediately.
         */
-       if (kunit_get_current_test()) {
+       if (kunit_get_current_test() || !alloc->dlist_programmed) {
                spin_lock_irqsave(&hvs->mm_lock, flags);
                vc4_hvs_free_dlist_entry_locked(hvs, alloc);
                spin_unlock_irqrestore(&hvs->mm_lock, flags);
@@ -1201,6 +1204,7 @@ static void vc4_hvs_install_dlist(struct drm_crtc *crtc)
                return;
 
        WARN_ON(!vc4_state->mm);
+       vc4_state->mm->dlist_programmed = true;
 
        if (vc4->gen >= VC4_GEN_6)
                HVS_WRITE(SCALER6_DISPX_LPTRS(vc4_state->assigned_channel),