drm/atomic: fix self-refresh helpers crtc state dereference
authorRob Clark <robdclark@chromium.org>
Mon, 4 Nov 2019 17:37:36 +0000 (09:37 -0800)
committerSean Paul <seanpaul@chromium.org>
Wed, 6 Nov 2019 18:00:21 +0000 (13:00 -0500)
commit86de88cfeb7cf33c7bbd18360e041c7d4e651bba
treee68b05d9f67df3c30ca92c041ba7cdea649bbab6
parentb330f3972f4f2a829d41fb9e9b552bec7d73a840
drm/atomic: fix self-refresh helpers crtc state dereference

drm_self_refresh_helper_update_avg_times() was incorrectly accessing the
new incoming state after drm_atomic_helper_commit_hw_done().  But this
state might have already been superceeded by an !nonblock atomic update
resulting in dereferencing an already free'd crtc_state.

TODO I *think* this will more or less do the right thing.. althought I'm
not 100% sure if, for example, we enter psr in a nonblock commit, and
then leave psr in a !nonblock commit that overtakes the completion of
the nonblock commit.  Not sure if this sort of scenario can happen in
practice.  But not crashing is better than crashing, so I guess we
should either take this patch or rever the self-refresh helpers until
Sean can figure out a better solution.

Fixes: d4da4e33341c ("drm: Measure Self Refresh Entry/Exit times to avoid thrashing")
Cc: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>
[seanpaul fixed up some checkpatch warns]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191104173737.142558-1-robdclark@gmail.com
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_self_refresh_helper.c
include/drm/drm_self_refresh_helper.h