Skip to contentSkip to conversation

drm/cirrus: Let DRM core send VBLANK events

PATCH In review Thomas Zimmermann 2 participants 4 messages Jan 10, 2020 – Jan 14, 2020

Subsystems (3)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

PATCH 1/1 drm/cirrus: Let DRM core send VBLANK events

In drm_atomic_helper_fake_vblank() the DRM core sends out VBLANK events if struct drm_crtc_state.no_vblank is enabled. Replace cirrus' VBLANK events with the DRM core's functionality.

---
 drivers/gpu/drm/cirrus/cirrus.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/gpu/drm/cirrus/cirrus.c +2 -8
index 248c9f765c45..4a1729aa7e53 100644
@@ -38,7 +38,6 @@
 #include <drm/drm_modeset_helper_vtables.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-#include <drm/drm_vblank.h>
 
 #define DRIVER_NAME "cirrus"
 #define DRIVER_DESC "qemu cirrus vga"
@@ -415,6 +414,8 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 {
 	struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
 
+	crtc_state->no_vblank = true;
+
 	cirrus_mode_set(cirrus, &crtc_state->mode, plane_state->fb);
 	cirrus_fb_blit_fullscreen(plane_state->fb);
 }
@@ -434,13 +435,6 @@ static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe,
 
 	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
 		cirrus_fb_blit_rect(pipe->plane.state->fb, &rect);
-
-	if (crtc->state->event) {
-		spin_lock_irq(&crtc->dev->event_lock);
-		drm_crtc_send_vblank_event(crtc, crtc->state->event);
-		crtc->state->event = NULL;
-		spin_unlock_irq(&crtc->dev->event_lock);
-	}
 }
 
 static const struct drm_simple_display_pipe_funcs cirrus_pipe_funcs = {
Signature · 6 lines
2.24.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 22 lines · Thomas Zimmermann

In drm_atomic_helper_fake_vblank() the DRM core sends out VBLANK events if struct drm_crtc_state.no_vblank is enabled. Replace cirrus' VBLANK events with the DRM core's functionality.

---
 drivers/gpu/drm/cirrus/cirrus.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/gpu/drm/cirrus/cirrus.c +0 -1
index 248c9f765c45..4a1729aa7e53 100644
@@ -38,7 +38,6 @@
 #include <drm/drm_modeset_helper_vtables.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-#include <drm/drm_vblank.h>
 
 #define DRIVER_NAME "cirrus"
 #define DRIVER_DESC "qemu cirrus vga"

drivers/gpu/drm/cirrus/cirrus.c static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe, · line 417

Quoted 4 lines
drivers/gpu/drm/cirrus/cirrus.c +1 -0
@@ -415,6 +414,8 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 {
 	struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
 
+	crtc_state->no_vblank = true;

Huh, nice untended use of this stuff ... We've added this for writeback, but I guess it can be used for anything that's a virtual connector ...

I've also spotted that you've done this same trick for ast & udl already. But I think before we roll this out massively we should make this official. Can you pls do a patch to update the kerneldoc for @no_vblank that virtual hw can also use this stuff?

Also, computing state values in atomic_commit code is kinda uncool and fraught with peril - design assumption is that with some very few exceptions (which are kinda awkward, would be nice to make state pointers const) all the core and helper codes that state structures stay unchanged after atomic_check completed. This should be computed in atomic_check (like vc4 does). Can you pls also include patches to update ast and udl in this series?

Thanks, Daniel

Quoted 21 lines
drivers/gpu/drm/cirrus/cirrus.c +1 -7
+
 	cirrus_mode_set(cirrus, &crtc_state->mode, plane_state->fb);
 	cirrus_fb_blit_fullscreen(plane_state->fb);
 }
@@ -434,13 +435,6 @@ static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe,
 
 	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
 		cirrus_fb_blit_rect(pipe->plane.state->fb, &rect);
-
-	if (crtc->state->event) {
-		spin_lock_irq(&crtc->dev->event_lock);
-		drm_crtc_send_vblank_event(crtc, crtc->state->event);
-		crtc->state->event = NULL;
-		spin_unlock_irq(&crtc->dev->event_lock);
-	}
 }
 
 static const struct drm_simple_display_pipe_funcs cirrus_pipe_funcs = {
Signature · 1 line
2.24.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
author maintainer
#2 lore raw

Hi

Am 13.01.20 um 00:00 schrieb Daniel Vetter:

Quoted 26 lines · Thomas Zimmermann
Quoted 25 lines

In drm_atomic_helper_fake_vblank() the DRM core sends out VBLANK events if struct drm_crtc_state.no_vblank is enabled. Replace cirrus' VBLANK events with the DRM core's functionality.

---
 drivers/gpu/drm/cirrus/cirrus.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/gpu/drm/cirrus/cirrus.c +0 -1
index 248c9f765c45..4a1729aa7e53 100644
@@ -38,7 +38,6 @@
 #include <drm/drm_modeset_helper_vtables.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-#include <drm/drm_vblank.h>
 
 #define DRIVER_NAME "cirrus"
 #define DRIVER_DESC "qemu cirrus vga"
@@ -415,6 +414,8 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 {
 	struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
 
Quoted 4 lines

drivers/gpu/drm/cirrus/cirrus.c static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe, · line 417

Quoted 1 line
drivers/gpu/drm/cirrus/cirrus.c +1 -0
+	crtc_state->no_vblank = true;

Huh, nice untended use of this stuff ... We've added this for writeback, but I guess it can be used for anything that's a virtual connector ...

Oh, 'improved by accident'.

I'm not quite sure what you mean by virtual connector, but it should work with any CRTC without VBLANK support. At least I've never seen any problem with ast and udl. I'll update the docs accordingly.

Best regards
Thomas

Quoted 39 lines

I've also spotted that you've done this same trick for ast & udl already. But I think before we roll this out massively we should make this official. Can you pls do a patch to update the kerneldoc for @no_vblank that virtual hw can also use this stuff?

Also, computing state values in atomic_commit code is kinda uncool and fraught with peril - design assumption is that with some very few exceptions (which are kinda awkward, would be nice to make state pointers const) all the core and helper codes that state structures stay unchanged after atomic_check completed. This should be computed in atomic_check (like vc4 does). Can you pls also include patches to update ast and udl in this series?

Thanks, Daniel

Quoted 21 lines
drivers/gpu/drm/cirrus/cirrus.c +1 -7
+
 	cirrus_mode_set(cirrus, &crtc_state->mode, plane_state->fb);
 	cirrus_fb_blit_fullscreen(plane_state->fb);
 }
@@ -434,13 +435,6 @@ static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe,
 
 	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
 		cirrus_fb_blit_rect(pipe->plane.state->fb, &rect);
-
-	if (crtc->state->event) {
-		spin_lock_irq(&crtc->dev->event_lock);
-		drm_crtc_send_vblank_event(crtc, crtc->state->event);
-		crtc->state->event = NULL;
-		spin_unlock_irq(&crtc->dev->event_lock);
-	}
 }
 
 static const struct drm_simple_display_pipe_funcs cirrus_pipe_funcs = {
Signature · 1 line
2.24.1
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw
Quoted 35 lines · Thomas Zimmermann

Hi

Am 13.01.20 um 00:00 schrieb Daniel Vetter:

Quoted 26 lines · Thomas Zimmermann
Quoted 25 lines

In drm_atomic_helper_fake_vblank() the DRM core sends out VBLANK events if struct drm_crtc_state.no_vblank is enabled. Replace cirrus' VBLANK events with the DRM core's functionality.

---
 drivers/gpu/drm/cirrus/cirrus.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/gpu/drm/cirrus/cirrus.c +0 -1
index 248c9f765c45..4a1729aa7e53 100644
@@ -38,7 +38,6 @@
 #include <drm/drm_modeset_helper_vtables.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-#include <drm/drm_vblank.h>
 
 #define DRIVER_NAME "cirrus"
 #define DRIVER_DESC "qemu cirrus vga"
@@ -415,6 +414,8 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 {
     struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
 
Quoted 4 lines

drivers/gpu/drm/cirrus/cirrus.c static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe, · line 417

Quoted 1 line
drivers/gpu/drm/cirrus/cirrus.c +1 -0
+    crtc_state->no_vblank = true;

Huh, nice untended use of this stuff ... We've added this for writeback, but I guess it can be used for anything that's a virtual connector ...

Quoted 5 lines

Oh, 'improved by accident'.

I'm not quite sure what you mean by virtual connector, but it should work with any CRTC without VBLANK support. At least I've never seen any problem with ast and udl. I'll update the docs accordingly.

There's a pretty huge difference between "real vblank support", which means the various vblank/crtc_sequence ioctls work, and the fake vblank even stuff we send out for all drivers right away to fulfill the atomic uapi event requirements. We'll need to highlight that stuff in the documentation I think ... On second thought, maybe we could change the atomic helpers to automatically set no_vblank when the driver/crtc doesn't support real vblanks. But is even more involved (but I think might also be the even neater soluation, but hard to be sure without typing it all up). Oh and because hilarious historical accents "no real vblank" = drm_dev->num_crtcs == 0, which we might want to put into a helper if we leak this out of the drm_vblank.c source files.

Cheers, Daniel

Quoted 52 lines

Best regards
Thomas

Quoted 34 lines

I've also spotted that you've done this same trick for ast & udl already. But I think before we roll this out massively we should make this official. Can you pls do a patch to update the kerneldoc for @no_vblank that virtual hw can also use this stuff?

Also, computing state values in atomic_commit code is kinda uncool and fraught with peril - design assumption is that with some very few exceptions (which are kinda awkward, would be nice to make state pointers const) all the core and helper codes that state structures stay unchanged after atomic_check completed. This should be computed in atomic_check (like vc4 does). Can you pls also include patches to update ast and udl in this series?

Thanks, Daniel

Quoted 17 lines
drivers/gpu/drm/cirrus/cirrus.c +1 -7
+
     cirrus_mode_set(cirrus, &crtc_state->mode, plane_state->fb);
     cirrus_fb_blit_fullscreen(plane_state->fb);
 }
@@ -434,13 +435,6 @@ static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe,
 
     if (drm_atomic_helper_damage_merged(old_state, state, &rect))
             cirrus_fb_blit_rect(pipe->plane.state->fb, &rect);
-
-    if (crtc->state->event) {
-            spin_lock_irq(&crtc->dev->event_lock);
-            drm_crtc_send_vblank_event(crtc, crtc->state->event);
-            crtc->state->event = NULL;
-            spin_unlock_irq(&crtc->dev->event_lock);
-    }
 }
 
Quoted 5 lines
Quoted 4 lines
drivers/gpu/drm/cirrus/cirrus.c +0 -1
 static const struct drm_simple_display_pipe_funcs cirrus_pipe_funcs = {
--

2.24.1

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

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