Skip to contentSkip to conversation

VT switchless v3

PATCH In review Jesse Barnes 4 participants 13 messages Feb 15, 2013 – Feb 19, 2013

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/6 drm/i915: don't restore LVDS enable state blindly v2

We still rely on a few LVDS bits, but restoring the enable bit can cause trouble at this point, so don't.

v2: use the right mask to prevent restore (Daniel)
conditionalize on KMS support (Denial)

---
 drivers/gpu/drm/i915/i915_suspend.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_suspend.c +6 -2
index 2135f21..c1e02b0 100644
@@ -255,6 +255,7 @@ static void i915_save_display(struct drm_device *dev)
 static void i915_restore_display(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 mask = 0xffffffff;
 
 	/* Display arbitration */
 	if (INTEL_INFO(dev)->gen <= 4)
@@ -267,10 +268,13 @@ static void i915_restore_display(struct drm_device *dev)
 	if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev))
 		I915_WRITE(BLC_PWM_CTL2, dev_priv->regfile.saveBLC_PWM_CTL2);
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		mask = ~LVDS_PORT_EN;
+
 	if (HAS_PCH_SPLIT(dev)) {
-		I915_WRITE(PCH_LVDS, dev_priv->regfile.saveLVDS);
+		I915_WRITE(PCH_LVDS, dev_priv->regfile.saveLVDS & mask);
 	} else if (IS_MOBILE(dev) && !IS_I830(dev))
-		I915_WRITE(LVDS, dev_priv->regfile.saveLVDS);
+		I915_WRITE(LVDS, dev_priv->regfile.saveLVDS & mask);
 
 	if (!IS_I830(dev) && !IS_845G(dev) && !HAS_PCH_SPLIT(dev))
 		I915_WRITE(PFIT_CONTROL, dev_priv->regfile.savePFIT_CONTROL);
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/6 drm/i915: add sprite restore function v2

In reply to Jesse Barnes

To be used to restore sprite state on resume.

v2: move sprite tracking bits up so we don't track modified sprite state

---
 drivers/gpu/drm/i915/intel_drv.h    |    5 +++++
 drivers/gpu/drm/i915/intel_sprite.c |   23 +++++++++++++++++++++++
 2 files changed, 28 insertions(+)
drivers/gpu/drm/i915/intel_drv.h +5 -0
index 005a91f..1b548e0 100644
@@ -247,6 +247,10 @@ struct intel_plane {
 	bool can_scale;
 	int max_downscale;
 	u32 lut_r[1024], lut_g[1024], lut_b[1024];
+	int crtc_x, crtc_y;
+	unsigned int crtc_w, crtc_h;
+	uint32_t x, y;
+	uint32_t src_w, src_h;
 	void (*update_plane)(struct drm_plane *plane,
 			     struct drm_framebuffer *fb,
 			     struct drm_i915_gem_object *obj,
@@ -532,6 +536,7 @@ extern bool intel_encoder_check_is_cloned(struct intel_encoder *encoder);
 extern void intel_connector_dpms(struct drm_connector *, int mode);
 extern bool intel_connector_get_hw_state(struct intel_connector *connector);
 extern void intel_modeset_check_state(struct drm_device *dev);
+extern void intel_plane_restore(struct drm_plane *plane);
 
 
 static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector)
drivers/gpu/drm/i915/intel_sprite.c +23 -0
index 03cfd62..ca171af 100644
@@ -438,6 +438,15 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	old_obj = intel_plane->obj;
 
+	intel_plane->crtc_x = crtc_x;
+	intel_plane->crtc_y = crtc_y;
+	intel_plane->crtc_w = crtc_w;
+	intel_plane->crtc_h = crtc_h;
+	intel_plane->x = x;
+	intel_plane->y = y;
+	intel_plane->src_w = src_w;
+	intel_plane->src_h = src_h;
+
 	src_w = src_w >> 16;
 	src_h = src_h >> 16;
 
@@ -644,6 +653,20 @@ out_unlock:
 	return ret;
 }
 
+void intel_plane_restore(struct drm_plane *plane)
+{
+	struct intel_plane *intel_plane = to_intel_plane(plane);
+
+	if (!plane->crtc || !plane->fb)
+		return;
+
+	intel_update_plane(plane, plane->crtc, plane->fb,
+			   intel_plane->crtc_x, intel_plane->crtc_y,
+			   intel_plane->crtc_w, intel_plane->crtc_h,
+			   intel_plane->x, intel_plane->y,
+			   intel_plane->src_w, intel_plane->src_h);
+}
+
 static const struct drm_plane_funcs intel_plane_funcs = {
 	.update_plane = intel_update_plane,
 	.disable_plane = intel_disable_plane,
Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH 2/6] drm/i915: add sprite restore function v2

Quoted 15 lines · Jesse Barnes

To be used to restore sprite state on resume.

v2: move sprite tracking bits up so we don't track modified sprite state

---
 drivers/gpu/drm/i915/intel_drv.h    |    5 +++++
 drivers/gpu/drm/i915/intel_sprite.c |   23 +++++++++++++++++++++++
 2 files changed, 28 insertions(+)
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 005a91f..1b548e0 100644

drivers/gpu/drm/i915/intel_drv.h struct intel_plane { · line 252

Quoted 6 lines
drivers/gpu/drm/i915/intel_drv.h +3 -0
@@ -247,6 +247,10 @@ struct intel_plane {
 	bool can_scale;
 	int max_downscale;
 	u32 lut_r[1024], lut_g[1024], lut_b[1024];
+	int crtc_x, crtc_y;
+	unsigned int crtc_w, crtc_h;
+	uint32_t x, y;

Can we call just them src_x/src_y instead?

Quoted 17 lines
drivers/gpu/drm/i915/intel_drv.h +2 -0
+	uint32_t src_w, src_h;
 	void (*update_plane)(struct drm_plane *plane,
 			     struct drm_framebuffer *fb,
 			     struct drm_i915_gem_object *obj,
@@ -532,6 +536,7 @@ extern bool intel_encoder_check_is_cloned(struct intel_encoder *encoder);
 extern void intel_connector_dpms(struct drm_connector *, int mode);
 extern bool intel_connector_get_hw_state(struct intel_connector *connector);
 extern void intel_modeset_check_state(struct drm_device *dev);
+extern void intel_plane_restore(struct drm_plane *plane);
 
 
 static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector)
drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 03cfd62..ca171af 100644

drivers/gpu/drm/i915/intel_sprite.c intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, · line 446

Quoted 9 lines
drivers/gpu/drm/i915/intel_sprite.c +6 -0
@@ -438,6 +438,15 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	old_obj = intel_plane->obj;
 
+	intel_plane->crtc_x = crtc_x;
+	intel_plane->crtc_y = crtc_y;
+	intel_plane->crtc_w = crtc_w;
+	intel_plane->crtc_h = crtc_h;
+	intel_plane->x = x;
+	intel_plane->y = y;

x and y are not fixed point numbers. They just contain the integer parts of src_x and src_y. So you need to use src_x and src_y here instead.

Quoted 34 lines
drivers/gpu/drm/i915/intel_sprite.c +17 -0
+	intel_plane->src_w = src_w;
+	intel_plane->src_h = src_h;
+
 	src_w = src_w >> 16;
 	src_h = src_h >> 16;
 
@@ -644,6 +653,20 @@ out_unlock:
 	return ret;
 }
 
+void intel_plane_restore(struct drm_plane *plane)
+{
+	struct intel_plane *intel_plane = to_intel_plane(plane);
+
+	if (!plane->crtc || !plane->fb)
+		return;
+
+	intel_update_plane(plane, plane->crtc, plane->fb,
+			   intel_plane->crtc_x, intel_plane->crtc_y,
+			   intel_plane->crtc_w, intel_plane->crtc_h,
+			   intel_plane->x, intel_plane->y,
+			   intel_plane->src_w, intel_plane->src_h);
+}
+
 static const struct drm_plane_funcs intel_plane_funcs = {
 	.update_plane = intel_update_plane,
 	.disable_plane = intel_disable_plane,
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
#4 lore raw

Re: [PATCH 2/6] drm/i915: add sprite restore function v2

Quoted 45 lines · On Mon, 18 Feb 2013 19:19:55 +0200 Ville Syrjälä…
Quoted 15 lines · Jesse Barnes

To be used to restore sprite state on resume.

v2: move sprite tracking bits up so we don't track modified sprite state

---
 drivers/gpu/drm/i915/intel_drv.h    |    5 +++++
 drivers/gpu/drm/i915/intel_sprite.c |   23 +++++++++++++++++++++++
 2 files changed, 28 insertions(+)
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 005a91f..1b548e0 100644

drivers/gpu/drm/i915/intel_drv.h struct intel_plane { · line 252

Quoted 6 lines
drivers/gpu/drm/i915/intel_drv.h +3 -0
@@ -247,6 +247,10 @@ struct intel_plane {
 	bool can_scale;
 	int max_downscale;
 	u32 lut_r[1024], lut_g[1024], lut_b[1024];
+	int crtc_x, crtc_y;
+	unsigned int crtc_w, crtc_h;
+	uint32_t x, y;

Can we call just them src_x/src_y instead?

Quoted 20 lines
drivers/gpu/drm/i915/intel_drv.h +2 -0
+	uint32_t src_w, src_h;
 	void (*update_plane)(struct drm_plane *plane,
 			     struct drm_framebuffer *fb,
 			     struct drm_i915_gem_object *obj,
@@ -532,6 +536,7 @@ extern bool intel_encoder_check_is_cloned(struct intel_encoder *encoder);
 extern void intel_connector_dpms(struct drm_connector *, int mode);
 extern bool intel_connector_get_hw_state(struct intel_connector *connector);
 extern void intel_modeset_check_state(struct drm_device *dev);
+extern void intel_plane_restore(struct drm_plane *plane);
 
 
 static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector)
drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 03cfd62..ca171af 100644
@@ -438,6 +438,15 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	old_obj = intel_plane->obj;
 
Quoted 10 lines

drivers/gpu/drm/i915/intel_sprite.c intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, · line 446

Quoted 6 lines
drivers/gpu/drm/i915/intel_sprite.c +6 -0
+	intel_plane->crtc_x = crtc_x;
+	intel_plane->crtc_y = crtc_y;
+	intel_plane->crtc_w = crtc_w;
+	intel_plane->crtc_h = crtc_h;
+	intel_plane->x = x;
+	intel_plane->y = y;

x and y are not fixed point numbers. They just contain the integer parts of src_x and src_y. So you need to use src_x and src_y here instead.

Oops, thanks. Will fix and use the suggested terminology to avoid future confusion.

Signature · 5 lines
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH 3/6 drm/i915: restore cursor and sprite state when forcing a config restore

In reply to Jesse Barnes

Needed for VT switchless resume.

---
 drivers/gpu/drm/i915/intel_display.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +14 -1
index 3e6dadf..2bf076e 100644
@@ -8985,6 +8985,7 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	enum pipe pipe;
 	u32 tmp;
+	struct drm_plane *plane;
 	struct intel_crtc *crtc;
 	struct intel_encoder *encoder;
 	struct intel_connector *connector;
@@ -9081,8 +9082,20 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
 
 	if (force_restore) {
 		for_each_pipe(pipe) {
-			intel_crtc_restore_mode(dev_priv->pipe_to_crtc_mapping[pipe]);
+			struct drm_crtc *crtc =
+				dev_priv->pipe_to_crtc_mapping[pipe];
+			struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+
+			intel_crtc_restore_mode(crtc);
+			if (intel_crtc->cursor_visible) {
+				/* Force update for previously enabled cursor */
+				intel_crtc->cursor_visible = false;
+				intel_crtc_update_cursor(&intel_crtc->base,
+							 true);
+			}
 		}
+		list_for_each_entry(plane, &dev->mode_config.plane_list, head)
+			intel_plane_restore(plane);
 
 		i915_redisable_vga(dev);
 	} else {
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 4/6 drm/i915: enable VT switchless resume v2

In reply to Jesse Barnes

With the other bits in place, we can do this safely.

v2: disable backlight on suspend to prevent premature enablement on resume

---
 drivers/gpu/drm/i915/i915_drv.c |   12 +++++++++---
 drivers/gpu/drm/i915/intel_fb.c |    3 +++
 2 files changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +9 -3
index c5b8c81..e76b038 100644
@@ -492,9 +492,10 @@ static int i915_drm_freeze(struct drm_device *dev)
 
 		cancel_delayed_work_sync(&dev_priv->rps.delayed_resume_work);
 
-		intel_modeset_disable(dev);
-
 		drm_irq_uninstall(dev);
+
+		if (dev_priv->backlight)
+			intel_panel_disable_backlight(dev);
 	}
 
 	i915_save_state(dev);
@@ -569,9 +570,14 @@ static int __i915_drm_thaw(struct drm_device *dev)
 		mutex_unlock(&dev->struct_mutex);
 
 		intel_modeset_init_hw(dev);
-		intel_modeset_setup_hw_state(dev, false);
+
 		drm_irq_install(dev);
 		intel_hpd_init(dev);
+
+		/* Resume the modeset for every activated CRTC */
+		drm_modeset_lock_all(dev);
+		intel_modeset_setup_hw_state(dev, true);
+		drm_modeset_unlock_all(dev);
 	}
 
 	intel_opregion_init(dev);
drivers/gpu/drm/i915/intel_fb.c +3 -0
index 1c510da..987bc33 100644
@@ -149,6 +149,9 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
 	}
 	info->screen_size = size;
 
+	/* This driver doesn't need a VT switch to restore the mode on resume */
+	info->skip_vt_switch = true;
+
 //	memset(info->screen_base, 0, size);
 
 	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 5/6 drm/i915: emit a hotplug event on resume

In reply to Jesse Barnes

This will poke userspace into probing for configuration changes that may have occurred across suspend/resume.

---
 drivers/gpu/drm/i915/i915_drv.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +20 -0
index e76b038..1b37eec 100644
@@ -551,6 +551,24 @@ void intel_console_resume(struct work_struct *work)
 	console_unlock();
 }
 
+static void intel_resume_hotplug(struct drm_device *dev)
+{
+	struct drm_mode_config *mode_config = &dev->mode_config;
+	struct intel_encoder *encoder;
+
+	mutex_lock(&mode_config->mutex);
+	DRM_DEBUG_KMS("running encoder hotplug functions\n");
+
+	list_for_each_entry(encoder, &mode_config->encoder_list, base.head)
+		if (encoder->hot_plug)
+			encoder->hot_plug(encoder);
+
+	mutex_unlock(&mode_config->mutex);
+
+	/* Just fire off a uevent and let userspace tell us what to do */
+	drm_helper_hpd_irq_event(dev);
+}
+
 static int __i915_drm_thaw(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -578,6 +596,8 @@ static int __i915_drm_thaw(struct drm_device *dev)
 		drm_modeset_lock_all(dev);
 		intel_modeset_setup_hw_state(dev, true);
 		drm_modeset_unlock_all(dev);
+
+		intel_resume_hotplug(dev);
 	}
 
 	intel_opregion_init(dev);
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH 6/6 drm/i915: remove disabled memset of framebuffer from intel_fb

In reply to Jesse Barnes

Commented out and unneeded.

---
 drivers/gpu/drm/i915/intel_fb.c |    2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/intel_fb.c +0 -2
index 987bc33..f4e0b88 100644
@@ -152,8 +152,6 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
 	/* This driver doesn't need a VT switch to restore the mode on resume */
 	info->skip_vt_switch = true;
 
-//	memset(info->screen_base, 0, size);
-
 	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
 	drm_fb_helper_fill_var(info, &ifbdev->helper, sizes->fb_width, sizes->fb_height);
 
Signature · 1 line
1.7.9.5
#9 lore raw
In reply to Jesse Barnes
Quoted 1 line · Jesse Barnes

A few more fixes from Daniel.

So one thing that crossed my mind which we should at least quickly
discuss: How is userspace supposed to notice the resume? On a lot of desktops (and even Androids) the normal thing seems to be to draw the screensave/lock after resume, which means that we'll show the desktop for a frame or so. Which is not too nice. Is userspace simply supposed to draw the screen lock before sleep, or does it need a helping hand from the kernel to fix this issue?
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#10 lore raw
Quoted 10 lines · Daniel Vetter
Quoted 1 line · Jesse Barnes

A few more fixes from Daniel.

So one thing that crossed my mind which we should at least quickly
discuss: How is userspace supposed to notice the resume? On a lot of desktops (and even Androids) the normal thing seems to be to draw the screensave/lock after resume, which means that we'll show the desktop for a frame or so. Which is not too nice. Is userspace simply supposed to draw the screen lock before sleep, or does it need a helping hand from the kernel to fix this issue?

Yup, I second that and I've mentioned it to Jesse before. VTs in KD_GRAPHICS mode are already responsible for re-setting their mode when you switch back to them after having switched away. Surely they should have the option to handle setting mode and potentially present a lockscreen when coming back from resume. In case of weston, we have the option to handle this very well, since the compositor can launch prepare a lock screen (potentailly launching a helper client to do that) and just not set a mode or dpms on until the UI is ready.

Kristian

Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#11 lore raw
Quoted 12 lines · On Mon, 18 Feb 2013 19:58:26 -0500 Kristian Høgsberg <[email protected]> wrote:
Quoted 10 lines · Daniel Vetter
Quoted 1 line · Jesse Barnes

A few more fixes from Daniel.

So one thing that crossed my mind which we should at least quickly
discuss: How is userspace supposed to notice the resume? On a lot of desktops (and even Androids) the normal thing seems to be to draw the screensave/lock after resume, which means that we'll show the desktop for a frame or so. Which is not too nice. Is userspace simply supposed to draw the screen lock before sleep, or does it need a helping hand from the kernel to fix this issue?

Quoted 8 lines

Yup, I second that and I've mentioned it to Jesse before. VTs in KD_GRAPHICS mode are already responsible for re-setting their mode when you switch back to them after having switched away. Surely they should have the option to handle setting mode and potentially present a lockscreen when coming back from resume. In case of weston, we have the option to handle this very well, since the compositor can launch prepare a lock screen (potentailly launching a helper client to do that) and just not set a mode or dpms on until the UI is ready.

Rob Bradford mentioned that GNOME had a bug here where on suspend the lock screen daemon would be notified, but the suspend would happen too quickly for it to actually receive the notification and take action. So when you resumed, you'd see your desktop until the daemon was re-run and then the lock screen would appear. That's been fixed apparently, but it illustrates that you don't want to do things on resume, you want to do them on suspend like Kristian points out.

Signature · 5 lines
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw
In reply to Daniel Vetter
Quoted 10 lines · On Mon, 18 Feb 2013 16:03:20 +0100 Daniel Vetter <[email protected]> wrote:
Quoted 1 line · Jesse Barnes

A few more fixes from Daniel.

So one thing that crossed my mind which we should at least quickly
discuss: How is userspace supposed to notice the resume? On a lot of desktops (and even Androids) the normal thing seems to be to draw the screensave/lock after resume, which means that we'll show the desktop for a frame or so. Which is not too nice. Is userspace simply supposed to draw the screen lock before sleep, or does it need a helping hand from the kernel to fix this issue?

Userspace initiates the suspend, so GNOME or whatever is supposed to lock things at that point. I've heard talk of a uevent or dbus thing to broadcast it as well, but I'm not sure of the status of that.

IIRC Android already has a hack like this; they don't want the fbcon to ever be visible during usage...

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center