linux_dsm_epyc7002/drivers/gpu/drm/rockchip
Sean Paul d4da4e3334 drm: Measure Self Refresh Entry/Exit times to avoid thrashing
Currently the self refresh idle timer is a const set by the crtc. This
is fine if the self refresh entry/exit times are well-known for all
panels used on that crtc. However panels and workloads can vary quite a
bit, and a timeout which works well for one doesn't work well for
another.

In the extreme, if the timeout is too short we could get in a situation
where the self refresh exits are taking so long we queue up a self refresh
entry before the exit commit is even finished.

This patch changes the idle timeout to a moving average of the entry
times + a moving average of exit times + the crtc constant.

This patch was tested on rockchip, with a kevin CrOS panel the idle
delay averages out to about ~235ms (35 entry + 100 exit + 100 const). On
the same board, the bob panel idle delay lands around ~340ms (90 entry
+ 150 exit + 100 const).

WRT the dedicated mutex in self_refresh_data, it would be nice if we
could rely on drm_crtc.mutex to protect the average times, but there are
a few reasons why a separate lock is a better choice:
- We can't rely on drm_crtc.mutex being held if we're doing a nonblocking
  commit
- We can't grab drm_crtc.mutex since drm_modeset_lock() doesn't tell us
  whether the lock was already held in the acquire context (it eats
  -EALREADY), so we can't tell if we should drop it or not
- We don't need such a heavy-handed lock for what we're trying to do,
  commit ordering doesn't matter, so a point-of-use lock will be less
  contentious

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link to v1: https://patchwork.freedesktop.org/patch/msgid/20190917200443.64481-2-sean@poorly.run
Link: https://patchwork.freedesktop.org/patch/msgid/20190918200734.149876-2-sean@poorly.run

Changes in v2:
- Migrate locking explanation from comment to commit msg (Daniel)
- Turf constant entry delay and multiply the avg times by 2 (Daniel)
2019-09-19 10:03:32 -04:00
..
analogix_dp-rockchip.c drm/rockchip: Use the helpers for PSR 2019-07-26 14:48:03 -04:00
cdn-dp-core.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
cdn-dp-core.h Linus 5.3-rc1 2019-07-22 21:24:10 +02:00
cdn-dp-reg.c Merge remote-tracking branch 'drm/drm-next' into drm-misc-next 2019-06-19 12:32:13 +02:00
cdn-dp-reg.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
dw_hdmi-rockchip.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
dw-mipi-dsi-rockchip.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
inno_hdmi.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
inno_hdmi.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile drm/rockchip: Use the helpers for PSR 2019-07-26 14:48:03 -04:00
rk3066_hdmi.c drm: rockchip: introduce rk3066 hdmi 2019-03-31 14:24:30 +02:00
rk3066_hdmi.h drm: rockchip: introduce rk3066 hdmi 2019-03-31 14:24:30 +02:00
rockchip_drm_drv.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
rockchip_drm_drv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
rockchip_drm_fb.c drm/rockchip: Use drm_atomic_helper_commit_tail_rpm 2019-07-26 14:48:03 -04:00
rockchip_drm_fb.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
rockchip_drm_fbdev.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
rockchip_drm_fbdev.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
rockchip_drm_gem.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
rockchip_drm_gem.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
rockchip_drm_vop.c drm: Measure Self Refresh Entry/Exit times to avoid thrashing 2019-09-19 10:03:32 -04:00
rockchip_drm_vop.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
rockchip_lvds.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
rockchip_lvds.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
rockchip_rgb.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
rockchip_rgb.h drm/rockchip: rgb: update SPDX license identifier 2019-01-25 14:50:07 +01:00
rockchip_vop_reg.c drm/rockchip: drop use of drmP.h 2019-07-17 12:52:55 +02:00
rockchip_vop_reg.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00