Skip to content

Commit 8b7078d

Browse files
6by9pelwell
authored andcommitted
drm/vc4: Free all stale dlists if channel is disabled
The code handling freeing stale dlists had 2 issues: - it disabled the interrupt as soon as the first EOF interrupt occurred, even if it didn't clear all stale allocations, thus leading to stale entries - It didn't free stale entries from disabled channels, so eg "kmstest -c 0" could leave a stale alloc on channel 1 floating around. Keep the interrupt enabled whilst there are any outstanding allocs, and discard those on disabled channels. This second channel does require us to call vc4_hvs_stop_channel from vc4_crtc_atomic_disable so that the channel actually gets stopped. Signed-off-by: Dave Stevenson <[email protected]>
1 parent 31c4c35 commit 8b7078d

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,8 @@ static void vc4_crtc_atomic_disable(struct drm_crtc *crtc,
660660

661661
vc4_crtc_disable(crtc, encoder, state, old_vc4_state->assigned_channel);
662662

663+
vc4_hvs_atomic_disable(crtc, state);
664+
663665
/*
664666
* Make sure we issue a vblank event after disabling the CRTC if
665667
* someone was waiting it.

drivers/gpu/drm/vc4/vc4_hvs.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,8 @@ static void vc4_hvs_schedule_dlist_sweep(struct vc4_hvs *hvs,
697697
if (!list_empty(&hvs->stale_dlist_entries))
698698
queue_work(system_unbound_wq, &hvs->free_dlist_work);
699699

700-
vc4_hvs_irq_clear_eof(hvs, channel);
700+
if (list_empty(&hvs->stale_dlist_entries))
701+
vc4_hvs_irq_clear_eof(hvs, channel);
701702

702703
spin_unlock_irqrestore(&hvs->mm_lock, flags);
703704
}
@@ -712,6 +713,27 @@ static bool vc4_hvs_frcnt_lte(u8 cnt1, u8 cnt2)
712713
return (s8)((cnt1 << 2) - (cnt2 << 2)) <= 0;
713714
}
714715

716+
bool vc4_hvs_check_channel_active(struct vc4_hvs *hvs, unsigned int fifo)
717+
{
718+
struct vc4_dev *vc4 = hvs->vc4;
719+
struct drm_device *drm = &vc4->base;
720+
bool enabled = false;
721+
int idx;
722+
723+
WARN_ON_ONCE(vc4->gen > VC4_GEN_6);
724+
725+
if (!drm_dev_enter(drm, &idx))
726+
return 0;
727+
728+
if (vc4->gen >= VC4_GEN_6)
729+
enabled = HVS_READ(SCALER6_DISPX_CTRL0(fifo)) & SCALER6_DISPX_CTRL0_ENB;
730+
else
731+
enabled = HVS_READ(SCALER_DISPCTRLX(fifo)) & SCALER_DISPCTRLX_ENABLE;
732+
733+
drm_dev_exit(idx);
734+
return enabled;
735+
}
736+
715737
/*
716738
* Some atomic commits (legacy cursor updates, mostly) will not wait for
717739
* the next vblank and will just return once the commit has been pushed
@@ -746,7 +768,8 @@ static void vc4_hvs_dlist_free_work(struct work_struct *work)
746768
u8 frcnt;
747769

748770
frcnt = vc4_hvs_get_fifo_frame_count(hvs, cur->channel);
749-
if (!vc4_hvs_frcnt_lte(cur->target_frame_count, frcnt))
771+
if (vc4_hvs_check_channel_active(hvs, cur->channel) &&
772+
!vc4_hvs_frcnt_lte(cur->target_frame_count, frcnt))
750773
continue;
751774

752775
vc4_hvs_free_dlist_entry_locked(hvs, cur);

0 commit comments

Comments
 (0)