Wait for in-flight URBs from the previous frame before sending out
the current frame. Throttles frame rate to USB limits.

PC display usually runs with a refresh rate of 60 Hz or more. Sending
out URBs for each frame at this rate easily overloads the USB. This
results in display lag up to several seconds. Udl currently avoids
this by limiting the number of URBs to 20 at a time. This prevents
overloading the USB, but also prevents udl from using all the
bandwidth available.

Solving this requires more flexibility in the number of in-flight
URBs. The exact value depends on the framebuffer configuration and
the available bandwidth on the USB.

Before removing the limit on the URB count, add another means of
synchronizing the frame rate to the USB. Do this in atomic_begin, so
that the USB has the maximum time between sending two frames.

Signed-off-by: Thomas Zimmermann <[email protected]>
---
 drivers/gpu/drm/udl/udl_modeset.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/udl/udl_modeset.c 
b/drivers/gpu/drm/udl/udl_modeset.c
index bbba1dee8e4f..caa0a117e3c2 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -329,6 +329,23 @@ static const struct drm_plane_funcs 
udl_primary_plane_funcs = {
  * CRTC
  */
 
+static void udl_crtc_helper_atomic_begin(struct drm_crtc *crtc, struct 
drm_atomic_commit *state)
+{
+       struct drm_device *dev = crtc->dev;
+       struct udl_device *udl = to_udl(dev);
+       int idx;
+
+       if (!drm_dev_enter(dev, &idx))
+               return;
+
+       /*
+        * It is acceptable to briefly block in this call, but
+        * having it timeout frequently indicates a problem.
+        */
+       udl_sync_pending_urbs(udl);
+       drm_dev_exit(idx);
+}
+
 static void udl_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct 
drm_atomic_commit *state)
 {
        struct drm_device *dev = crtc->dev;
@@ -395,6 +412,7 @@ static void udl_crtc_helper_atomic_disable(struct drm_crtc 
*crtc, struct drm_ato
 
 static const struct drm_crtc_helper_funcs udl_crtc_helper_funcs = {
        .atomic_check = drm_crtc_helper_atomic_check,
+       .atomic_begin = udl_crtc_helper_atomic_begin,
        .atomic_enable = udl_crtc_helper_atomic_enable,
        .atomic_disable = udl_crtc_helper_atomic_disable,
 };
-- 
2.56.0

Reply via email to