Skip to contentSkip to conversation

drm: Fix console blank on QEMU

PATCH In review Takashi Iwai 2 participants 12 messages Jul 26, 2017 – Jul 27, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover drm: Fix console blank on QEMU

Hi,

this is a revised patchset after thinking of Daniel's suggestion. In this version, drm_fb_helper_blank() is modified to treat the error code from the connector dpms callback, so that the caller side, fbcon, can fall back to the generic blank code gracefully for the drivers that don't support DPMS properly.

Takashi

===

Takashi Iwai (5):
drm: Propagate error from connector dpms function in
drm_fb_helper_blank()
drm/bochs: Return an error from connector dpms callback drm/virtio: Return an error from connector dpms callback drm/qxl: Return an error from connector dpms callback drm/cirrus: Return an error from connector dpms callback

 drivers/gpu/drm/bochs/bochs_kms.c        |  9 ++++++++-
 drivers/gpu/drm/cirrus/cirrus_mode.c     |  9 ++++++++-
 drivers/gpu/drm/drm_fb_helper.c          | 30 ++++++++++++++++++++----------
 drivers/gpu/drm/qxl/qxl_display.c        |  9 ++++++++-
 drivers/gpu/drm/virtio/virtgpu_display.c |  9 ++++++++-
 5 files changed, 52 insertions(+), 14 deletions(-)
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 1/5 drm: Propagate error from connector dpms function in drm_fb_helper_blank()

Currently the DRM fbcon helper for console blank, drm_fb_helper_blank(), simply calls drm_fb_helper_dpms() and always returns zero, supposing the driver dealing with DPMS properly for blanking the screen. However, it turned out that the console blank doesn't work at all on KVM/QEMU when DRM driver is used: most of the relevant drivers (bochs, qxl, and virtio) just ignore DPMS, and even cirrus driver doesn't work because the DPMS register bits the driver fiddles with are also ignored by KVM/QEMU.

A simple fix for this problem would be not to rely on DPMS but let fbcon performs the generic blank code. This can be achieved just by returning an error from drm_fb_helper_blank().

In this patch, we change the drm_fb_helper_dpms() to give back an error code returned from the connector dpms callback, so that the error is propagated to drm_fb_helper_blank(). After this change, each driver needs just to return an error to fall back to the generic fbcon blank mode.

---
 drivers/gpu/drm/drm_fb_helper.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +20 -10
index 574af01d3ce9..db31747ae598 100644
@@ -581,21 +581,22 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = {
 static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };
 #endif
 
-static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
+static int drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
 {
 	struct drm_fb_helper *fb_helper = info->par;
 	struct drm_device *dev = fb_helper->dev;
 	struct drm_crtc *crtc;
 	struct drm_connector *connector;
 	int i, j;
+	int ret = 0;
 
 	/*
 	 * For each CRTC in this fb, turn the connectors on/off.
 	 */
 	drm_modeset_lock_all(dev);
 	if (!drm_fb_helper_is_bound(fb_helper)) {
-		drm_modeset_unlock_all(dev);
-		return;
+		ret = -ENODEV;
+		goto out;
 	}
 
 	for (i = 0; i < fb_helper->crtc_count; i++) {
@@ -607,12 +608,16 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
 		/* Walk the connectors & encoders on this fb turning them on/off */
 		drm_fb_helper_for_each_connector(fb_helper, j) {
 			connector = fb_helper->connector_info[j]->connector;
-			connector->funcs->dpms(connector, dpms_mode);
+			ret = connector->funcs->dpms(connector, dpms_mode);
+			if (ret < 0)
+				goto out;
 			drm_object_property_set_value(&connector->base,
 				dev->mode_config.dpms_property, dpms_mode);
 		}
 	}
+ out:
 	drm_modeset_unlock_all(dev);
+	return ret;
 }
 
 /**
@@ -622,32 +627,37 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
  */
 int drm_fb_helper_blank(int blank, struct fb_info *info)
 {
+	int dpms_mode;
+
 	if (oops_in_progress)
 		return -EBUSY;
 
 	switch (blank) {
 	/* Display: On; HSync: On, VSync: On */
 	case FB_BLANK_UNBLANK:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_ON);
+		dpms_mode = DRM_MODE_DPMS_ON;
 		break;
 	/* Display: Off; HSync: On, VSync: On */
 	case FB_BLANK_NORMAL:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY);
+		dpms_mode = DRM_MODE_DPMS_STANDBY;
 		break;
 	/* Display: Off; HSync: Off, VSync: On */
 	case FB_BLANK_HSYNC_SUSPEND:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY);
+		dpms_mode = DRM_MODE_DPMS_STANDBY;
 		break;
 	/* Display: Off; HSync: On, VSync: Off */
 	case FB_BLANK_VSYNC_SUSPEND:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_SUSPEND);
+		dpms_mode = DRM_MODE_DPMS_SUSPEND;
 		break;
 	/* Display: Off; HSync: Off, VSync: Off */
 	case FB_BLANK_POWERDOWN:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_OFF);
+		dpms_mode = DRM_MODE_DPMS_OFF;
 		break;
+	default:
+		return 0; /* ignored */
 	}
-	return 0;
+
+	return drm_fb_helper_dpms(info, dpms_mode);
 }
 EXPORT_SYMBOL(drm_fb_helper_blank);
 
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH 1/5] drm: Propagate error from connector dpms function in drm_fb_helper_blank()

Quoted 13 lines · Takashi Iwai

Currently the DRM fbcon helper for console blank, drm_fb_helper_blank(), simply calls drm_fb_helper_dpms() and always returns zero, supposing the driver dealing with DPMS properly for blanking the screen. However, it turned out that the console blank doesn't work at all on KVM/QEMU when DRM driver is used: most of the relevant drivers (bochs, qxl, and virtio) just ignore DPMS, and even cirrus driver doesn't work because the DPMS register bits the driver fiddles with are also ignored by KVM/QEMU.

A simple fix for this problem would be not to rely on DPMS but let fbcon performs the generic blank code. This can be achieved just by returning an error from drm_fb_helper_blank().

Quoted 7 lines

In this patch, we change the drm_fb_helper_dpms() to give back an error code returned from the connector dpms callback, so that the error is propagated to drm_fb_helper_blank(). After this change, each driver needs just to return an error to fall back to the generic fbcon blank mode.

This needs to be rebased onto -next, this code changed a lot. -Daniel

Quoted 103 lines
---
 drivers/gpu/drm/drm_fb_helper.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +20 -10
index 574af01d3ce9..db31747ae598 100644
@@ -581,21 +581,22 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = {
 static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };
 #endif
 
-static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
+static int drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
 {
 	struct drm_fb_helper *fb_helper = info->par;
 	struct drm_device *dev = fb_helper->dev;
 	struct drm_crtc *crtc;
 	struct drm_connector *connector;
 	int i, j;
+	int ret = 0;
 
 	/*
 	 * For each CRTC in this fb, turn the connectors on/off.
 	 */
 	drm_modeset_lock_all(dev);
 	if (!drm_fb_helper_is_bound(fb_helper)) {
-		drm_modeset_unlock_all(dev);
-		return;
+		ret = -ENODEV;
+		goto out;
 	}
 
 	for (i = 0; i < fb_helper->crtc_count; i++) {
@@ -607,12 +608,16 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
 		/* Walk the connectors & encoders on this fb turning them on/off */
 		drm_fb_helper_for_each_connector(fb_helper, j) {
 			connector = fb_helper->connector_info[j]->connector;
-			connector->funcs->dpms(connector, dpms_mode);
+			ret = connector->funcs->dpms(connector, dpms_mode);
+			if (ret < 0)
+				goto out;
 			drm_object_property_set_value(&connector->base,
 				dev->mode_config.dpms_property, dpms_mode);
 		}
 	}
+ out:
 	drm_modeset_unlock_all(dev);
+	return ret;
 }
 
 /**
@@ -622,32 +627,37 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
  */
 int drm_fb_helper_blank(int blank, struct fb_info *info)
 {
+	int dpms_mode;
+
 	if (oops_in_progress)
 		return -EBUSY;
 
 	switch (blank) {
 	/* Display: On; HSync: On, VSync: On */
 	case FB_BLANK_UNBLANK:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_ON);
+		dpms_mode = DRM_MODE_DPMS_ON;
 		break;
 	/* Display: Off; HSync: On, VSync: On */
 	case FB_BLANK_NORMAL:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY);
+		dpms_mode = DRM_MODE_DPMS_STANDBY;
 		break;
 	/* Display: Off; HSync: Off, VSync: On */
 	case FB_BLANK_HSYNC_SUSPEND:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY);
+		dpms_mode = DRM_MODE_DPMS_STANDBY;
 		break;
 	/* Display: Off; HSync: On, VSync: Off */
 	case FB_BLANK_VSYNC_SUSPEND:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_SUSPEND);
+		dpms_mode = DRM_MODE_DPMS_SUSPEND;
 		break;
 	/* Display: Off; HSync: Off, VSync: Off */
 	case FB_BLANK_POWERDOWN:
-		drm_fb_helper_dpms(info, DRM_MODE_DPMS_OFF);
+		dpms_mode = DRM_MODE_DPMS_OFF;
 		break;
+	default:
+		return 0; /* ignored */
 	}
-	return 0;
+
+	return drm_fb_helper_dpms(info, dpms_mode);
 }
 EXPORT_SYMBOL(drm_fb_helper_blank);
 
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 2/5 drm/bochs: Return an error from connector dpms callback

In reply to Takashi Iwai

The bochs drm driver doesn't treat with DPMS, so we should return an error from the connector dpms callback so that the fbcon can fall back to the generic blank mode.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_kms.c +8 -1
index 6a91e62da2f4..a60d1a05950f 100644
@@ -217,6 +217,13 @@ bochs_connector_best_encoder(struct drm_connector *connector)
 	return NULL;
 }
 
+static int bochs_connector_dpms(struct drm_connector *connector, int mode)
+{
+	drm_helper_connector_dpms(connector, mode);
+	/* FIXME: return error to make fbcon generic blank working */
+	return -EINVAL;
+}
+
 static const struct drm_connector_helper_funcs bochs_connector_connector_helper_funcs = {
 	.get_modes = bochs_connector_get_modes,
 	.mode_valid = bochs_connector_mode_valid,
@@ -224,7 +231,7 @@ static const struct drm_connector_helper_funcs bochs_connector_connector_helper_
 };
 
 static const struct drm_connector_funcs bochs_connector_connector_funcs = {
-	.dpms = drm_helper_connector_dpms,
+	.dpms = bochs_connector_dpms,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = drm_connector_cleanup,
 };
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Re: [PATCH 2/5] drm/bochs: Return an error from connector dpms callback

Quoted 14 lines · Takashi Iwai

The bochs drm driver doesn't treat with DPMS, so we should return an error from the connector dpms callback so that the fbcon can fall back to the generic blank mode.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -0
index 6a91e62da2f4..a60d1a05950f 100644

drivers/gpu/drm/bochs/bochs_kms.c bochs_connector_best_encoder(struct drm_connector *connector) · line 224

Quoted 8 lines
drivers/gpu/drm/bochs/bochs_kms.c +5 -0
@@ -217,6 +217,13 @@ bochs_connector_best_encoder(struct drm_connector *connector)
 	return NULL;
 }
 
+static int bochs_connector_dpms(struct drm_connector *connector, int mode)
+{
+	drm_helper_connector_dpms(connector, mode);
+	/* FIXME: return error to make fbcon generic blank working */
+	return -EINVAL;

Thought about this some more, disabling the screen and return -EINVAL (to userspace even) feels like rather bad semantics. Could we just do an -EINVAL instead?

I thought the DPMS off change doesn't do anything anyway, so this is pure dead code.
-Daniel

Quoted 21 lines
drivers/gpu/drm/bochs/bochs_kms.c +3 -1
+}
+
 static const struct drm_connector_helper_funcs bochs_connector_connector_helper_funcs = {
 	.get_modes = bochs_connector_get_modes,
 	.mode_valid = bochs_connector_mode_valid,
@@ -224,7 +231,7 @@ static const struct drm_connector_helper_funcs bochs_connector_connector_helper_
 };
 
 static const struct drm_connector_funcs bochs_connector_connector_funcs = {
-	.dpms = drm_helper_connector_dpms,
+	.dpms = bochs_connector_dpms,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = drm_connector_cleanup,
 };
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

PATCH 3/5 drm/virtio: Return an error from connector dpms callback

In reply to Takashi Iwai

The virtio drm driver doesn't treat with DPMS, so we should return an error from the connector dpms callback so that the fbcon can fall back to the generic blank mode.

---
 drivers/gpu/drm/virtio/virtgpu_display.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +8 -1
index d51bd4521f17..77d5bad49c5f 100644
@@ -249,8 +249,15 @@ static void virtio_gpu_conn_destroy(struct drm_connector *connector)
 	kfree(virtio_gpu_output);
 }
 
+static int virtio_gpu_conn_dpms(struct drm_connector *connector, int mode)
+{
+	drm_atomic_helper_connector_dpms(connector, mode);
+	/* FIXME: return error to make fbcon generic blank working */
+	return -EINVAL;
+}
+
 static const struct drm_connector_funcs virtio_gpu_connector_funcs = {
-	.dpms = drm_atomic_helper_connector_dpms,
+	.dpms = virtio_gpu_conn_dpms,
 	.detect = virtio_gpu_conn_detect,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = virtio_gpu_conn_destroy,
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

Re: [PATCH 3/5] drm/virtio: Return an error from connector dpms callback

Quoted 14 lines · Takashi Iwai

The virtio drm driver doesn't treat with DPMS, so we should return an error from the connector dpms callback so that the fbcon can fall back to the generic blank mode.

---
 drivers/gpu/drm/virtio/virtgpu_display.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +0 -0
index d51bd4521f17..77d5bad49c5f 100644

drivers/gpu/drm/virtio/virtgpu_display.c static void virtio_gpu_conn_destroy(struct drm_connector *connector) · line 255

Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_display.c +4 -0
@@ -249,8 +249,15 @@ static void virtio_gpu_conn_destroy(struct drm_connector *connector)
 	kfree(virtio_gpu_output);
 }
 
+static int virtio_gpu_conn_dpms(struct drm_connector *connector, int mode)
+{
+	drm_atomic_helper_connector_dpms(connector, mode);
+	/* FIXME: return error to make fbcon generic blank working */

Why FIXME here? You just fixed that issue, feels like should just be a normal comment. I'd just say

	/* no DPMS for virtual drivers, it would close the window, making
	 * the guest inaccesible */

drivers/gpu/drm/virtio/virtgpu_display.c static void virtio_gpu_conn_destroy(struct drm_connector *connector) · line 256

Quoted 1 line
drivers/gpu/drm/virtio/virtgpu_display.c +1 -0
+	return -EINVAL;

Ok, I've changed my plans for properties and DPMS a bit for atomic drivers, and the ->dpms hook will be gone really soon. There's also the problem that rejecting DPMS through the legacy interface, but allowing it through the atomic interface isn't good api (and yes we have igts to check for that).

I think it'd be better to reject this properly in the atomic_check phase in the crtc_helper_funcs->atomic_check function, with something like this:

	if (crtc->state->enable && !crtc->state->active)
		return -EINVAL;

That should result in an -EINVAL for any caller who tries to update the DPMS property. Which is important, since with the new atomic fbdev helper code, fbdev does directly call into the atomic code and entirely bypasses the ->dpms hook (that part is merged already, and why you need to rebase patch 1).

That would also make sure that we don't return -EINVAL and still shut down the screen (atomic does that for you, there's no difference between DPMS off and fully disabling it).

Sorry that I'm dragging you all over with this for yet another respin :-/

Thanks, Daniel

Quoted 15 lines
drivers/gpu/drm/virtio/virtgpu_display.c +3 -1
+}
+
 static const struct drm_connector_funcs virtio_gpu_connector_funcs = {
-	.dpms = drm_atomic_helper_connector_dpms,
+	.dpms = virtio_gpu_conn_dpms,
 	.detect = virtio_gpu_conn_detect,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = virtio_gpu_conn_destroy,
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

Re: [PATCH 3/5] drm/virtio: Return an error from connector dpms callback

Quoted 50 lines · Daniel Vetter
Quoted 14 lines · Takashi Iwai

The virtio drm driver doesn't treat with DPMS, so we should return an error from the connector dpms callback so that the fbcon can fall back to the generic blank mode.

---
 drivers/gpu/drm/virtio/virtgpu_display.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +0 -0
index d51bd4521f17..77d5bad49c5f 100644

drivers/gpu/drm/virtio/virtgpu_display.c static void virtio_gpu_conn_destroy(struct drm_connector *connector) · line 255

Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_display.c +4 -0
@@ -249,8 +249,15 @@ static void virtio_gpu_conn_destroy(struct drm_connector *connector)
 	kfree(virtio_gpu_output);
 }
 
+static int virtio_gpu_conn_dpms(struct drm_connector *connector, int mode)
+{
+	drm_atomic_helper_connector_dpms(connector, mode);
+	/* FIXME: return error to make fbcon generic blank working */

Why FIXME here? You just fixed that issue, feels like should just be a normal comment. I'd just say

	/* no DPMS for virtual drivers, it would close the window, making
	 * the guest inaccesible */

drivers/gpu/drm/virtio/virtgpu_display.c static void virtio_gpu_conn_destroy(struct drm_connector *connector) · line 256

Quoted 1 line
drivers/gpu/drm/virtio/virtgpu_display.c +1 -0
+	return -EINVAL;

Ok, I've changed my plans for properties and DPMS a bit for atomic drivers, and the ->dpms hook will be gone really soon. There's also the problem that rejecting DPMS through the legacy interface, but allowing it through the atomic interface isn't good api (and yes we have igts to check for that).

I think it'd be better to reject this properly in the atomic_check phase in the crtc_helper_funcs->atomic_check function, with something like this:

	if (crtc->state->enable && !crtc->state->active)
		return -EINVAL;

That should result in an -EINVAL for any caller who tries to update the DPMS property. Which is important, since with the new atomic fbdev helper code, fbdev does directly call into the atomic code and entirely bypasses the ->dpms hook (that part is merged already, and why you need to rebase patch 1).

Quoted 5 lines

That would also make sure that we don't return -EINVAL and still shut down the screen (atomic does that for you, there's no difference between DPMS off and fully disabling it).

Sorry that I'm dragging you all over with this for yet another respin :-/

OK, no problem, my patchset was a quite easy one.

The atomic fb helper change looks going to a right direction. When the above check is implemented in the helper side, is still anything needed in each driver side?

Also, for legacy drivers, we still need tricks as done in this patchset, right?

thanks,

Takashi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Re: [PATCH 3/5] drm/virtio: Return an error from connector dpms callback

Quoted 56 lines · Takashi Iwai
Quoted 54 lines · Daniel Vetter
Quoted 14 lines · Takashi Iwai

The virtio drm driver doesn't treat with DPMS, so we should return an error from the connector dpms callback so that the fbcon can fall back to the generic blank mode.

---
 drivers/gpu/drm/virtio/virtgpu_display.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +0 -0
index d51bd4521f17..77d5bad49c5f 100644

drivers/gpu/drm/virtio/virtgpu_display.c static void virtio_gpu_conn_destroy(struct drm_connector *connector) · line 255

Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_display.c +4 -0
@@ -249,8 +249,15 @@ static void virtio_gpu_conn_destroy(struct drm_connector *connector)
    kfree(virtio_gpu_output);
 }
 
+static int virtio_gpu_conn_dpms(struct drm_connector *connector, int mode)
+{
+   drm_atomic_helper_connector_dpms(connector, mode);
+   /* FIXME: return error to make fbcon generic blank working */

Why FIXME here? You just fixed that issue, feels like should just be a normal comment. I'd just say

/* no DPMS for virtual drivers, it would close the window, making
* the guest inaccesible */

drivers/gpu/drm/virtio/virtgpu_display.c static void virtio_gpu_conn_destroy(struct drm_connector *connector) · line 256

Quoted 1 line
drivers/gpu/drm/virtio/virtgpu_display.c +1 -0
+   return -EINVAL;

Ok, I've changed my plans for properties and DPMS a bit for atomic drivers, and the ->dpms hook will be gone really soon. There's also the problem that rejecting DPMS through the legacy interface, but allowing it through the atomic interface isn't good api (and yes we have igts to check for that).

I think it'd be better to reject this properly in the atomic_check phase in the crtc_helper_funcs->atomic_check function, with something like this:

      if (crtc->state->enable && !crtc->state->active)
              return -EINVAL;

That should result in an -EINVAL for any caller who tries to update the DPMS property. Which is important, since with the new atomic fbdev helper code, fbdev does directly call into the atomic code and entirely bypasses the ->dpms hook (that part is merged already, and why you need to rebase patch 1).

That would also make sure that we don't return -EINVAL and still shut down the screen (atomic does that for you, there's no difference between DPMS off and fully disabling it).

Quoted 7 lines
Quoted 1 line

Sorry that I'm dragging you all over with this for yet another respin :-/

OK, no problem, my patchset was a quite easy one.

The atomic fb helper change looks going to a right direction. When the above check is implemented in the helper side, is still anything needed in each driver side?

The above check would need to be added to the crtc_funcs->atomic_check callback for vritio and qxl, not the shared atomic helpers.

Quoted 2 lines

Also, for legacy drivers, we still need tricks as done in this patchset, right?

Yes, those still need a dpms callback that just returns -EINVAL. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

Re: [PATCH 3/5] drm/virtio: Return an error from connector dpms callback

Quoted 60 lines · Daniel Vetter
Quoted 58 lines · Takashi Iwai
Quoted 55 lines · Daniel Vetter
Quoted 14 lines · Takashi Iwai

The virtio drm driver doesn't treat with DPMS, so we should return an error from the connector dpms callback so that the fbcon can fall back to the generic blank mode.

---
 drivers/gpu/drm/virtio/virtgpu_display.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +0 -0
index d51bd4521f17..77d5bad49c5f 100644

drivers/gpu/drm/virtio/virtgpu_display.c static void virtio_gpu_conn_destroy(struct drm_connector *connector) · line 255

Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_display.c +4 -0
@@ -249,8 +249,15 @@ static void virtio_gpu_conn_destroy(struct drm_connector *connector)
    kfree(virtio_gpu_output);
 }
 
+static int virtio_gpu_conn_dpms(struct drm_connector *connector, int mode)
+{
+   drm_atomic_helper_connector_dpms(connector, mode);
+   /* FIXME: return error to make fbcon generic blank working */

Why FIXME here? You just fixed that issue, feels like should just be a normal comment. I'd just say

/* no DPMS for virtual drivers, it would close the window, making
* the guest inaccesible */

drivers/gpu/drm/virtio/virtgpu_display.c static void virtio_gpu_conn_destroy(struct drm_connector *connector) · line 256

Quoted 1 line
drivers/gpu/drm/virtio/virtgpu_display.c +1 -0
+   return -EINVAL;

Ok, I've changed my plans for properties and DPMS a bit for atomic drivers, and the ->dpms hook will be gone really soon. There's also the problem that rejecting DPMS through the legacy interface, but allowing it through the atomic interface isn't good api (and yes we have igts to check for that).

I think it'd be better to reject this properly in the atomic_check phase in the crtc_helper_funcs->atomic_check function, with something like this:

      if (crtc->state->enable && !crtc->state->active)
              return -EINVAL;

That should result in an -EINVAL for any caller who tries to update the DPMS property. Which is important, since with the new atomic fbdev helper code, fbdev does directly call into the atomic code and entirely bypasses the ->dpms hook (that part is merged already, and why you need to rebase patch 1).

That would also make sure that we don't return -EINVAL and still shut down the screen (atomic does that for you, there's no difference between DPMS off and fully disabling it).

Sorry that I'm dragging you all over with this for yet another respin :-/

Quoted 8 lines
Quoted 5 lines

OK, no problem, my patchset was a quite easy one.

The atomic fb helper change looks going to a right direction. When the above check is implemented in the helper side, is still anything needed in each driver side?

The above check would need to be added to the crtc_funcs->atomic_check callback for vritio and qxl, not the shared atomic helpers.

Ah, now it's clearly understood.

Quoted 4 lines
Quoted 2 lines

Also, for legacy drivers, we still need tricks as done in this patchset, right?

Yes, those still need a dpms callback that just returns -EINVAL.

OK.

thanks,

Takashi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw

PATCH 4/5 drm/qxl: Return an error from connector dpms callback

In reply to Takashi Iwai

The qxl drm driver doesn't treat with DPMS, so we should return an error from the connector dpms callback so that the fbcon can fall back to the generic blank mode.

---
 drivers/gpu/drm/qxl/qxl_display.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_display.c +8 -1
index 03fe182203ce..48db53d0285d 100644
@@ -1019,8 +1019,15 @@ static void qxl_conn_destroy(struct drm_connector *connector)
 	kfree(qxl_output);
 }
 
+static int qxl_conn_dpms(struct drm_connector *connector, int mode)
+{
+	drm_helper_connector_dpms(connector, mode);
+	/* FIXME: return error to make fbcon generic blank working */
+	return -EINVAL;
+}
+
 static const struct drm_connector_funcs qxl_connector_funcs = {
-	.dpms = drm_helper_connector_dpms,
+	.dpms = qxl_conn_dpms,
 	.detect = qxl_conn_detect,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.set_property = qxl_conn_set_property,
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH 5/5 drm/cirrus: Return an error from connector dpms callback

In reply to Takashi Iwai

Although the cirrus drm driver handles DPMS and sets the register bits accordingly, currently KVM/QEMU ignores it, resulting in the non-functional console blank. This patch makes the connector dpms callback always returning an error so that the fbcon can fall back to the generic blank mode.

---
 drivers/gpu/drm/cirrus/cirrus_mode.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/cirrus/cirrus_mode.c +8 -1
index 53f6f0f84206..7412660bb014 100644
@@ -506,13 +506,20 @@ static void cirrus_connector_destroy(struct drm_connector *connector)
 	kfree(connector);
 }
 
+static int cirrus_connector_dpms(struct drm_connector *connector, int mode)
+{
+	drm_helper_connector_dpms(connector, mode);
+	/* FIXME: return error to make fbcon generic blank working */
+	return -EINVAL;
+}
+
 static const struct drm_connector_helper_funcs cirrus_vga_connector_helper_funcs = {
 	.get_modes = cirrus_vga_get_modes,
 	.best_encoder = cirrus_connector_best_encoder,
 };
 
 static const struct drm_connector_funcs cirrus_vga_connector_funcs = {
-	.dpms = drm_helper_connector_dpms,
+	.dpms = cirrus_connector_dpms,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = cirrus_connector_destroy,
 };
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel