WSL2-Linux-Kernel/include/drm
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
..
bridge drm/bridge: dw-hdmi: move audio channel setup out of ahb 2019-08-14 15:03:11 +02:00
i2c
ttm drm-misc-next for 5.4: 2019-08-21 16:44:41 +10:00
amd_asic_type.h drm/amdgpu: add renoir asic_type enum 2019-08-12 12:47:49 -05:00
ati_pcigart.h
drmP.h dma-buf: rename reservation_object to dma_resv 2019-08-13 09:09:30 +02:00
drm_agpsupport.h drm/agp: Remove unused function drm_agp_bind_pages 2019-07-15 18:11:30 +02:00
drm_atomic.h
drm_atomic_helper.h
drm_atomic_state_helper.h
drm_atomic_uapi.h
drm_audio_component.h
drm_auth.h
drm_blend.h
drm_bridge.h
drm_cache.h
drm_client.h drm/client: Support unmapping of DRM client buffers 2019-08-01 15:01:22 +02:00
drm_color_mgmt.h
drm_connector.h drm: Fix kerneldoc warns in connector-related docs 2019-08-12 10:16:39 -04:00
drm_crtc.h drm: Fix kerneldoc and remove unused struct member in self_refresh helper 2019-09-19 10:03:19 -04:00
drm_crtc_helper.h
drm_damage_helper.h
drm_debugfs.h
drm_debugfs_crc.h
drm_device.h
drm_displayid.h drm/edid: parse CEA blocks embedded in DisplayID 2019-06-25 14:32:26 +10:00
drm_dp_dual_mode_helper.h
drm_dp_helper.h drm/dp_mst: Enable registration of AUX devices for MST ports 2019-07-25 16:39:35 -04:00
drm_dp_mst_helper.h drm/dp_mst: Enable registration of AUX devices for MST ports 2019-07-25 16:39:35 -04:00
drm_drv.h drm/prime: Ditch gem_prime_res_obj hook 2019-07-31 10:19:23 +02:00
drm_dsc.h
drm_edid.h
drm_encoder.h
drm_encoder_slave.h
drm_fb_cma_helper.h
drm_fb_helper.h
drm_file.h
drm_fixed.h
drm_flip_work.h
drm_format_helper.h
drm_fourcc.h
drm_framebuffer.h
drm_gem.h dma-buf: rename reservation_object to dma_resv 2019-08-13 09:09:30 +02:00
drm_gem_cma_helper.h
drm_gem_framebuffer_helper.h drm/fb: remove unused function: drm_gem_fbdev_fb_create() 2019-07-21 19:32:38 +02:00
drm_gem_shmem_helper.h drm/shmem: Use mutex_trylock in drm_gem_shmem_purge 2019-08-28 10:02:39 -05:00
drm_gem_vram_helper.h drm/vram: use embedded gem object 2019-08-06 08:21:53 +02:00
drm_hashtab.h
drm_hdcp.h drm/hdcp: update content protection property with uevent 2019-08-06 13:17:23 +05:30
drm_ioctl.h drm/ioctl: Ditch DRM_UNLOCKED except for the legacy vblank ioctl 2019-06-21 19:13:10 +02:00
drm_irq.h
drm_lease.h
drm_legacy.h
drm_mipi_dbi.h drm/tinydrm: Move mipi-dbi 2019-07-25 10:45:07 +02:00
drm_mipi_dsi.h
drm_mm.h
drm_mode_config.h drm: Add Content protection type property 2019-08-06 13:14:07 +05:30
drm_mode_object.h
drm_modes.h drm/selftests: reduce stack usage 2019-07-01 09:50:58 +02:00
drm_modeset_helper.h
drm_modeset_helper_vtables.h
drm_modeset_lock.h
drm_of.h
drm_os_linux.h
drm_panel.h drm/panel: drop return code from drm_panel_detach() 2019-08-10 15:41:48 +02:00
drm_pci.h
drm_pciids.h
drm_plane.h
drm_plane_helper.h
drm_prime.h drm/prime: Align gem_prime_export with obj_funcs.export 2019-06-21 17:30:49 +02:00
drm_print.h
drm_probe_helper.h
drm_property.h
drm_rect.h
drm_scdc_helper.h
drm_self_refresh_helper.h drm: Measure Self Refresh Entry/Exit times to avoid thrashing 2019-09-19 10:03:32 -04:00
drm_simple_kms_helper.h
drm_syncobj.h
drm_sysfs.h drm: uevent for connector status change 2019-08-06 13:16:54 +05:30
drm_util.h
drm_utils.h
drm_vblank.h drm: drop uapi dependency from drm_vblank.h 2019-07-19 23:24:16 +02:00
drm_vma_manager.h
drm_vram_mm_helper.h drm: add missing include to drm_vram_mm_helper.h 2019-07-15 18:11:31 +02:00
drm_writeback.h
gma_drm.h
gpu_scheduler.h
i915_component.h drm/i915/tgl: Add additional ports for Tiger Lake 2019-07-11 16:31:14 -07:00
i915_drm.h drm/i915: Drop extern qualifiers from header function prototypes 2019-07-12 13:04:54 +01:00
i915_mei_hdcp_interface.h
i915_pciids.h drm/i915/cml: Add Missing PCI IDs 2019-08-15 12:55:54 -07:00
intel-gtt.h
intel_lpe_audio.h
spsc_queue.h