Skip to contentSkip to conversation

drm/virtio: fix unblank

PATCH In review Gerd Hoffmann 2 participants 4 messages Aug 7, 2020 – Aug 17, 2020

Subsystems (4)
lore
Share & tools
lore

Gerd Hoffmann

author maintainer
#0 lore raw

PATCH 1/1 drm/virtio: fix unblank

When going through a disable/enable cycle without changing the framebuffer the optimization added by commit 3954ff10e06e ("drm/virtio:
skip set_scanout if framebuffer didn't change") causes the screen stay blank. Add a bool to force an update to fix that.

Fixes 3954ff10e06e ("drm/virtio: skip set_scanout if framebuffer didn't change")
---
 drivers/gpu/drm/virtio/virtgpu_drv.h     | 1 +
 drivers/gpu/drm/virtio/virtgpu_display.c | 1 +
 drivers/gpu/drm/virtio/virtgpu_plane.c   | 4 +++-
 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
index 9ff9f4ac0522..7b0c319f23c9 100644
@@ -138,6 +138,7 @@ struct virtio_gpu_output {
 	int cur_x;
 	int cur_y;
 	bool enabled;
+	bool need_update;
 };
 #define drm_crtc_to_virtio_gpu_output(x) \
 	container_of(x, struct virtio_gpu_output, crtc)
drivers/gpu/drm/virtio/virtgpu_display.c +1 -0
index cc7fd957a307..378be5956b30 100644
@@ -100,6 +100,7 @@ static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
 	struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
 
 	output->enabled = true;
+	output->need_update = true;
 }
 
 static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
drivers/gpu/drm/virtio/virtgpu_plane.c +3 -1
index 52d24179bcec..5948031a9ce8 100644
@@ -163,7 +163,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 	    plane->state->src_w != old_state->src_w ||
 	    plane->state->src_h != old_state->src_h ||
 	    plane->state->src_x != old_state->src_x ||
-	    plane->state->src_y != old_state->src_y) {
+	    plane->state->src_y != old_state->src_y ||
+	    output->need_update) {
 		DRM_DEBUG("handle 0x%x, crtc %dx%d+%d+%d, src %dx%d+%d+%d\n",
 			  bo->hw_res_handle,
 			  plane->state->crtc_w, plane->state->crtc_h,
@@ -178,6 +179,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 					   plane->state->src_h >> 16,
 					   plane->state->src_x >> 16,
 					   plane->state->src_y >> 16);
+		output->need_update = false;
 	}
 
 	virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle,
Signature · 6 lines
2.18.4

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#1 lore raw
Quoted 43 lines · Gerd Hoffmann

When going through a disable/enable cycle without changing the framebuffer the optimization added by commit 3954ff10e06e ("drm/virtio:
skip set_scanout if framebuffer didn't change") causes the screen stay blank. Add a bool to force an update to fix that.

Fixes 3954ff10e06e ("drm/virtio: skip set_scanout if framebuffer didn't change")
---
 drivers/gpu/drm/virtio/virtgpu_drv.h     | 1 +
 drivers/gpu/drm/virtio/virtgpu_display.c | 1 +
 drivers/gpu/drm/virtio/virtgpu_plane.c   | 4 +++-
 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
index 9ff9f4ac0522..7b0c319f23c9 100644
@@ -138,6 +138,7 @@ struct virtio_gpu_output {
 	int cur_x;
 	int cur_y;
 	bool enabled;
+	bool need_update;
 };
 #define drm_crtc_to_virtio_gpu_output(x) \
 	container_of(x, struct virtio_gpu_output, crtc)
drivers/gpu/drm/virtio/virtgpu_display.c +1 -0
index cc7fd957a307..378be5956b30 100644
@@ -100,6 +100,7 @@ static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
 	struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
 
 	output->enabled = true;
+	output->need_update = true;
 }
 
 static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
drivers/gpu/drm/virtio/virtgpu_plane.c +0 -0
index 52d24179bcec..5948031a9ce8 100644

drivers/gpu/drm/virtio/virtgpu_plane.c static void virtio_gpu_primary_plane_update(struct drm_plane *plane, · line 167

Quoted 6 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +2 -1
@@ -163,7 +163,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 	    plane->state->src_w != old_state->src_w ||
 	    plane->state->src_h != old_state->src_h ||
 	    plane->state->src_x != old_state->src_x ||
-	    plane->state->src_y != old_state->src_y) {
+	    plane->state->src_y != old_state->src_y ||
+	    output->need_update) {

Uh instead of hand-rolling what's essentially a drm_crtc_needs_modeset check, why not use that one? atomic helpers try to keep the usual suspects for state transitions already handy, to avoid every driver rolling their own. Or do I miss something here?
-Daniel

Quoted 14 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +1 -0
 		DRM_DEBUG("handle 0x%x, crtc %dx%d+%d+%d, src %dx%d+%d+%d\n",
 			  bo->hw_res_handle,
 			  plane->state->crtc_w, plane->state->crtc_h,
@@ -178,6 +179,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 					   plane->state->src_h >> 16,
 					   plane->state->src_x >> 16,
 					   plane->state->src_y >> 16);
+		output->need_update = false;
 	}
 
 	virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle,
Signature · 1 line
2.18.4
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
author maintainer
#2 lore raw

Hi,

Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_display.c +1 -0
@@ -100,6 +100,7 @@ static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
 	struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
 
 	output->enabled = true;
+	output->need_update = true;
Quoted 14 lines

drivers/gpu/drm/virtio/virtgpu_plane.c static void virtio_gpu_primary_plane_update(struct drm_plane *plane, · line 167

Quoted 9 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +2 -1
@@ -163,7 +163,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 	    plane->state->src_w != old_state->src_w ||
 	    plane->state->src_h != old_state->src_h ||
 	    plane->state->src_x != old_state->src_x ||
-	    plane->state->src_y != old_state->src_y) {
+	    plane->state->src_y != old_state->src_y ||
+	    output->need_update) {

Uh instead of hand-rolling what's essentially a drm_crtc_needs_modeset check, why not use that one? atomic helpers try to keep the usual suspects for state transitions already handy, to avoid every driver rolling their own. Or do I miss something here?

Well, the virtio-gpu virtual hardware can't do plane updates and crtc updates independant from each other. So the crtc callbacks handle disable only (we don't need a fb for that) and leave the enable to the plane update.

I suspect calling drm_atomic_crtc_needs_modeset() in plane update isn't going to fly ...

take care,
Gerd

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

author maintainer
#3 lore raw
Quoted 25 lines · Gerd Hoffmann

Hi,

Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_display.c +1 -0
@@ -100,6 +100,7 @@ static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
 	struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
 
 	output->enabled = true;
+	output->need_update = true;
Quoted 14 lines

drivers/gpu/drm/virtio/virtgpu_plane.c static void virtio_gpu_primary_plane_update(struct drm_plane *plane, · line 167

Quoted 9 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +2 -1
@@ -163,7 +163,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 	    plane->state->src_w != old_state->src_w ||
 	    plane->state->src_h != old_state->src_h ||
 	    plane->state->src_x != old_state->src_x ||
-	    plane->state->src_y != old_state->src_y) {
+	    plane->state->src_y != old_state->src_y ||
+	    output->need_update) {

Uh instead of hand-rolling what's essentially a drm_crtc_needs_modeset check, why not use that one? atomic helpers try to keep the usual suspects for state transitions already handy, to avoid every driver rolling their own. Or do I miss something here?

Quoted 7 lines

Well, the virtio-gpu virtual hardware can't do plane updates and crtc updates independant from each other. So the crtc callbacks handle disable only (we don't need a fb for that) and leave the enable to the plane update.

I suspect calling drm_atomic_crtc_needs_modeset() in plane update isn't going to fly ...

Digged a bit more, seems crtc_state->*_changed is cleared after modeset so the following plane update wouldn't see it. Which I think means there is no way around tracking that in need_update.

output->enabled is probably not needed though, seems I can replace that by either output->crtc.state->enable or ->active. Not fully sure which one, probably ->active.

take care,
Gerd

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