diff mbox series

[2/2] drm/gud: Add async_flush module parameter

Message ID 20210703141321.35494-2-noralf@tronnes.org (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/gud: Add Raspberry Pi Pico ID | expand

Commit Message

Noralf Trønnes July 3, 2021, 2:13 p.m. UTC
Provide a way for userspace to choose synchronous flushing/pageflips.
This helps save CPU and power.

It is also useful for test scripts since userspace can know when a flush
has happended and wait before doing the next visual test.

Cc: Peter Stuge <peter@stuge.se>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
---
 drivers/gpu/drm/gud/gud_pipe.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Peter Stuge July 3, 2021, 7:29 p.m. UTC | #1
Noralf Trønnes wrote:
> Provide a way for userspace to choose synchronous flushing/pageflips.
> This helps save CPU and power.
> 
> It is also useful for test scripts since userspace can know when a flush
> has happended and wait before doing the next visual test.
> 
> Cc: Peter Stuge <peter@stuge.se>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

Reviewed-by: Peter Stuge <peter@stuge.se>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
index e0fb6cc969a3..8f56bf618ac2 100644
--- a/drivers/gpu/drm/gud/gud_pipe.c
+++ b/drivers/gpu/drm/gud/gud_pipe.c
@@ -23,6 +23,19 @@ 
 
 #include "gud_internal.h"
 
+/*
+ * Some userspace rendering loops runs all displays in the same loop.
+ * This means that a fast display will have to wait for a slow one.
+ * For this reason gud does flushing asynchronous by default.
+ * The down side is that in e.g. a single display setup userspace thinks
+ * the display is insanely fast since the driver reports back immediately
+ * that the flush/pageflip is done. This wastes CPU and power.
+ * Such users might want to set this module parameter to false.
+ */
+static bool gud_async_flush = true;
+module_param_named(async_flush, gud_async_flush, bool, 0644);
+MODULE_PARM_DESC(async_flush, "Enable asynchronous flushing [default=true]");
+
 /*
  * FIXME: The driver is probably broken on Big Endian machines.
  * See discussion:
@@ -578,6 +591,8 @@  void gud_pipe_update(struct drm_simple_display_pipe *pipe,
 		if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE)
 			drm_rect_init(&damage, 0, 0, fb->width, fb->height);
 		gud_fb_queue_damage(gdrm, fb, &damage);
+		if (!gud_async_flush)
+			flush_work(&gdrm->work);
 	}
 
 	if (!crtc->state->enable)