LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: fix drm lastclose ignoring closed active fbs
@ 2024-04-19 17:45 Bob Beckett
  0 siblings, 0 replies; only message in thread
From: Bob Beckett @ 2024-04-19 17:45 UTC (permalink / raw
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter
  Cc: kernel, Robert Beckett, dri-devel, linux-kernel

From: Robert Beckett <bob.beckett@collabora.com>

when fb's have been marked as closed, if there is still something active
then don't restore fbdev during lastclose

Signed-off-by: Robert Beckett <bob.beckett@collabora.com>
---
 drivers/gpu/drm/drm_fb_helper.c |  3 +++
 drivers/gpu/drm/drm_plane.c     | 21 +++++++++++++++++++++
 include/drm/drm_plane.h         |  2 ++
 3 files changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index d612133e2cf7e..b7509b0cd926a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2002,6 +2002,9 @@ EXPORT_SYMBOL(drm_fb_helper_hotplug_event);
  */
 void drm_fb_helper_lastclose(struct drm_device *dev)
 {
+	if (drm_has_active_plane(dev))
+		return;
+
 	drm_fb_helper_restore_fbdev_mode_unlocked(dev->fb_helper);
 }
 EXPORT_SYMBOL(drm_fb_helper_lastclose);
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 672c655c7a8e7..7eb3d06696ca7 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -930,6 +930,27 @@ static int __setplane_check(struct drm_plane *plane,
 	return 0;
 }
 
+/**
+ * drm_has_active_plane - check whether any planes are currently active
+ * @dev: the DRM device
+ *
+ * Return true if any planes are currently active
+ */
+bool drm_has_active_plane(struct drm_device *dev)
+{
+	struct drm_plane *plane;
+
+	drm_for_each_plane(plane, dev) {
+		if (plane->state && plane->state->crtc && plane->state->fb)
+			return true;
+		if (plane->crtc && plane->fb)
+			return true;
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_has_active_plane);
+
 /**
  * drm_any_plane_has_format - Check whether any plane supports this format and modifier combination
  * @dev: DRM device
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 641fe298052dc..74fec8cbee8c6 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -965,6 +965,8 @@ static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
 #define drm_for_each_plane(plane, dev) \
 	list_for_each_entry(plane, &(dev)->mode_config.plane_list, head)
 
+bool drm_has_active_plane(struct drm_device *dev);
+
 bool drm_any_plane_has_format(struct drm_device *dev,
 			      u32 format, u64 modifier);
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-19 17:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-19 17:45 [PATCH] drm: fix drm lastclose ignoring closed active fbs Bob Beckett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).