diff mbox series

[v2,4/5] drm/log: Do not draw if drm_master is taken

Message ID 20240816125612.1003295-5-jfalempe@redhat.com (mailing list archive)
State New, archived
Headers show
Series drm/log: Introduce a new boot logger to draw the kmsg on the screen | expand

Commit Message

Jocelyn Falempe Aug. 16, 2024, 12:52 p.m. UTC
When userspace takes drm_master, the drm_client buffer is no more
visible, so drm_log shouldn't waste CPU cycle to draw on it.

Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
---
 drivers/gpu/drm/drm_log.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_log.c b/drivers/gpu/drm/drm_log.c
index 0739a4c72bb7..b94ce3ea48a0 100644
--- a/drivers/gpu/drm/drm_log.c
+++ b/drivers/gpu/drm/drm_log.c
@@ -22,6 +22,7 @@ 
 
 #include "drm_draw.h"
 #include "drm_log.h"
+#include "drm_internal.h"
 
 MODULE_AUTHOR("Jocelyn Falempe");
 MODULE_DESCRIPTION("DRM boot logger");
@@ -361,10 +362,15 @@  static bool drm_log_active_output(void)
 	bool active = false;
 
 	mutex_lock(&drm_log_lock);
-	list_for_each_entry(dclient, &drm_log_clients, head)
-		if (dclient->n_scanout || !dclient->probed)
-			active = true;
-
+	list_for_each_entry(dclient, &drm_log_clients, head) {
+		if (dclient->n_scanout || !dclient->probed) {
+			/* Also check that we are still the master */
+			if (drm_master_internal_acquire(dclient->client.dev)) {
+				drm_master_internal_release(dclient->client.dev);
+				active = true;
+			}
+		}
+	}
 	mutex_unlock(&drm_log_lock);
 	return active;
 }