Use no_vblank property for drivers without VBLANK
Subsystems (9)
Thomas Zimmermann
maintainerv2 cover Use no_vblank property for drivers without VBLANK
Instead of faking VBLANK events by themselves, drivers without VBLANK support can enable drm_crtc_vblank.no_vblank and let DRM do the rest. The patchset makes this official and converts over several drivers.
Ast already uses the functionality and just needs a cleanup. Cirrus can be converted easily by setting the field in the check() callback and removing the existing VBLANK code. For most other simple-KMS drivers without enable_vblank() and check(), simple-KMS helpers can enable the faked VBLANK by default. The only exception is Xen, which comes with its own VBLANK logic and should rather to disable no_vblank.
v2:
* document functionality (Daniel)
* cleanup ast (Daniel)
* let simple-kms handle no_vblank where possible
Thomas Zimmermann (4):
drm: Document struct drm_crtc_state.no_vblank for faking VBLANK events drm/ast: Set struct drm_crtc_state.no_vblank in atomic_check() drm/cirrus: Let DRM core send VBLANK events drm/simple-kms: Let DRM core send VBLANK events by default
drivers/gpu/drm/ast/ast_mode.c | 4 ++-- drivers/gpu/drm/bochs/bochs_kms.c | 9 --------- drivers/gpu/drm/cirrus/cirrus.c | 10 ++-------- drivers/gpu/drm/drm_atomic_helper.c | 4 +++- drivers/gpu/drm/drm_mipi_dbi.c | 9 --------- drivers/gpu/drm/drm_simple_kms_helper.c | 19 +++++++++++++++---- drivers/gpu/drm/tiny/gm12u320.c | 9 --------- drivers/gpu/drm/tiny/ili9225.c | 9 --------- drivers/gpu/drm/tiny/repaper.c | 9 --------- drivers/gpu/drm/tiny/st7586.c | 9 --------- drivers/gpu/drm/udl/udl_modeset.c | 11 ----------- drivers/gpu/drm/xen/xen_drm_front_kms.c | 13 +++++++++++++ include/drm/drm_crtc.h | 9 +++++++-- include/drm/drm_simple_kms_helper.h | 7 +++++-- 14 files changed, 47 insertions(+), 84 deletions(-)
--
2.24.1
Thomas Zimmermann
maintainerPATCH v2 1/4 drm: Document struct drm_crtc_state.no_vblank for faking VBLANK events
Drivers for CRTC hardware without support for VBLANK interrupts can set struct drm_crtc_state.no_vblank and let DRM's atomic commit helpers generate the VBLANK events automatically. Document this in order to make it official.
--- drivers/gpu/drm/drm_atomic_helper.c | 4 +++- include/drm/drm_crtc.h | 9 +++++++-- include/drm/drm_simple_kms_helper.h | 7 +++++-- 3 files changed, 15 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +3 -1
@@ -2215,7 +2215,9 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);* when a job is queued, and any change to the pipeline that does not touch the * connector is leading to timeouts when calling * drm_atomic_helper_wait_for_vblanks() or -* drm_atomic_helper_wait_for_flip_done(). +* drm_atomic_helper_wait_for_flip_done(). In addition to writeback +* connectors, this function can also fake VBLANK events for CRTCs without +* VBLANK interrupt. * * This is part of the atomic helper support for nonblocking commits, see * drm_atomic_helper_setup_commit() for an overview.
include/drm/drm_crtc.h +7 -2
@@ -179,7 +179,9 @@ struct drm_crtc_state {* In this case the VBLANK event is only generated when a job is queued * to the writeback connector, and we want the core to fake VBLANK * events when this part of the pipeline hasn't changed but others had -* or when the CRTC and connectors are being disabled. +* or when the CRTC and connectors are being disabled. In addition to +* writeback connectors, this function can also fake VBLANK events for +* CRTCs without VBLANK interrupt. * * __drm_atomic_helper_crtc_duplicate_state() will not reset the value * from the current state, the CRTC driver is then responsible for
@@ -335,7 +337,10 @@ struct drm_crtc_state {* - Events for disabled CRTCs are not allowed, and drivers can ignore * that case. * -* This can be handled by the drm_crtc_send_vblank_event() function, +* For very simple hardware without VBLANK interrupt, enabling +* &struct drm_crtc_state.no_vblank makes DRM's atomic commit helpers +* send the event at an appropriate time. For more complex hardware this +* can be handled by the drm_crtc_send_vblank_event() function, * which the driver should call on the provided event upon completion of * the atomic commit. Note that if the driver supports vblank signalling * and timestamping the vblank counters and timestamps must agree with
include/drm/drm_simple_kms_helper.h +5 -2
@@ -100,8 +100,11 @@ struct drm_simple_display_pipe_funcs {* This is the function drivers should submit the * &drm_pending_vblank_event from. Using either * drm_crtc_arm_vblank_event(), when the driver supports vblank -* interrupt handling, or drm_crtc_send_vblank_event() directly in case -* the hardware lacks vblank support entirely. +* interrupt handling, or drm_crtc_send_vblank_event() for more +* complex case. In case the hardware lacks vblank support entirely, +* drivers can set &struct drm_crtc_state.no_vblank in +* &struct drm_simple_display_pipe_funcs.check and let DRM's +* atomic helper fake a vblank event. */ void (*update)(struct drm_simple_display_pipe *pipe,struct drm_plane_state *old_plane_state);
Signature · 1 line
2.24.1
Thomas Zimmermann
maintainerPATCH v2 2/4 drm/ast: Set struct drm_crtc_state.no_vblank in atomic_check()
In reply to Thomas ZimmermannCRTC state properties should be computed in atomic_check(). Do so for the no_vblank field.
--- drivers/gpu/drm/ast/ast_mode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +2 -2
@@ -800,6 +800,8 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } + state->no_vblank = true; + ast_state =to_ast_crtc_state (state); format = ast_state->format;
@@ -833,8 +835,6 @@ static void ast_crtc_helper_atomic_flush(struct drm_crtc *crtc,struct ast_vbios_mode_info *vbios_mode_info;struct drm_display_mode *adjusted_mode; - crtc->state->no_vblank = true; - ast_state =to_ast_crtc_state (crtc->state); format = ast_state->format;
Signature · 1 line
2.24.1
Thomas Zimmermann
maintainerPATCH v2 3/4 drm/cirrus: Let DRM core send VBLANK events
In reply to Thomas ZimmermannIn 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.
v2:
* set struct_drm_crtc_state.no_vblank in cirrus_pipe_check()
--- drivers/gpu/drm/cirrus/cirrus.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/gpu/drm/cirrus/cirrus.c +2 -8
@@ -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"
@@ -404,6 +403,8 @@ static int cirrus_pipe_check(struct drm_simple_display_pipe *pipe, {struct drm_framebuffer *fb = plane_state->fb; + crtc_state->no_vblank = true; +if (!fb)return 0 ;return cirrus_check_size (fb->width, fb->height, 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
Thomas Zimmermann
maintainerPATCH v2 4/4 drm/simple-kms: Let DRM core send VBLANK events by default
In reply to Thomas ZimmermannIn drm_atomic_helper_fake_vblank() the DRM core sends out VBLANK events if struct drm_crtc_state.no_vblank is enabled in the check() callbacks.
For drivers that have neither an enable_vblank() callback nor a check() callback, the simple-KMS helpers enable VBLANK generation by default. This simplifies bochs, udl, several tiny drivers, and drivers based upon MIPI DPI helpers. The driver for Xen explicitly disables no_vblank, as it has its own logic for sending these events.
--- drivers/gpu/drm/bochs/bochs_kms.c | 9 --------- drivers/gpu/drm/drm_mipi_dbi.c | 9 --------- drivers/gpu/drm/drm_simple_kms_helper.c | 19 +++++++++++++++---- drivers/gpu/drm/tiny/gm12u320.c | 9 --------- drivers/gpu/drm/tiny/ili9225.c | 9 --------- drivers/gpu/drm/tiny/repaper.c | 9 --------- drivers/gpu/drm/tiny/st7586.c | 9 --------- drivers/gpu/drm/udl/udl_modeset.c | 11 ----------- drivers/gpu/drm/xen/xen_drm_front_kms.c | 13 +++++++++++++ 9 files changed, 28 insertions(+), 69 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -9
@@ -7,7 +7,6 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_vblank.h> #include "bochs.h"
@@ -57,16 +56,8 @@ static void bochs_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *old_state) {struct bochs_device *bochs = pipe->crtc.dev->dev_private; -struct drm_crtc *crtc = &pipe->crtc;bochs_plane_update (bochs, pipe->plane.state); - -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 bochs_pipe_funcs = {
drivers/gpu/drm/drm_mipi_dbi.c +0 -9
@@ -24,7 +24,6 @@#include <drm/drm_modes.h> #include <drm/drm_probe_helper.h> #include <drm/drm_rect.h> -#include <drm/drm_vblank.h> #include <video/mipi_display.h> #define MIPI_DBI_MAX_SPI_READ_SPEED 2000000/* 2MHz */
@@ -299,18 +298,10 @@ void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *old_state) {struct drm_plane_state *state = pipe->plane.state; -struct drm_crtc *crtc = &pipe->crtc;struct drm_rect rect;if (drm_atomic_helper_damage_merged (old_state, state, &rect))mipi_dbi_fb_dirty (state->fb, &rect); - -if (crtc->state->event) { -spin_lock_irq (&crtc->dev->event_lock); -drm_crtc_send_vblank_event (crtc, crtc->state->event); -spin_unlock_irq (&crtc->dev->event_lock); - crtc->state->event =NULL ; - } }EXPORT_SYMBOL (mipi_dbi_pipe_update);
drivers/gpu/drm/drm_simple_kms_helper.c +15 -4
@@ -146,10 +146,21 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,if (!plane_state->visible)return 0 ; -if (!pipe->funcs || !pipe->funcs->check) -return 0 ; - -return pipe->funcs->check (pipe, plane_state, crtc_state); +if (pipe->funcs) { +if (pipe->funcs->check) +return pipe->funcs->check (pipe, plane_state, + crtc_state); +if (pipe->funcs->enable_vblank) +return 0 ; + } + +/* Drivers without VBLANK support have to fake VBLANK events. As +* there's no check() callback to enable this, set the no_vblank +* field by default. +*/ + crtc_state->no_vblank = true; + +return 0 ; } static void drm_simple_kms_plane_atomic_update(struct drm_plane *plane,
drivers/gpu/drm/tiny/gm12u320.c +0 -9
@@ -22,7 +22,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> static bool eco_mode;module_param (eco_mode, bool,0644 );
@@ -610,18 +609,10 @@ static void gm12u320_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *old_state) {struct drm_plane_state *state = pipe->plane.state; -struct drm_crtc *crtc = &pipe->crtc;struct drm_rect rect;if (drm_atomic_helper_damage_merged (old_state, state, &rect))gm12u320_fb_mark_dirty (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 gm12u320_pipe_funcs = {
drivers/gpu/drm/tiny/ili9225.c +0 -9
@@ -26,7 +26,6 @@#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_mipi_dbi.h> #include <drm/drm_rect.h> -#include <drm/drm_vblank.h> #define ILI9225_DRIVER_READ_CODE 0x00#define ILI9225_DRIVER_OUTPUT_CONTROL 0x01
@@ -165,18 +164,10 @@ static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *old_state) {struct drm_plane_state *state = pipe->plane.state; -struct drm_crtc *crtc = &pipe->crtc;struct drm_rect rect;if (drm_atomic_helper_damage_merged (old_state, state, &rect))ili9225_fb_dirty (state->fb, &rect); - -if (crtc->state->event) { -spin_lock_irq (&crtc->dev->event_lock); -drm_crtc_send_vblank_event (crtc, crtc->state->event); -spin_unlock_irq (&crtc->dev->event_lock); - crtc->state->event =NULL ; - } } static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
drivers/gpu/drm/tiny/repaper.c +0 -9
@@ -33,7 +33,6 @@#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modes.h> #include <drm/drm_rect.h> -#include <drm/drm_vblank.h> #include <drm/drm_probe_helper.h> #include <drm/drm_simple_kms_helper.h>
@@ -856,18 +855,10 @@ static void repaper_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *old_state) {struct drm_plane_state *state = pipe->plane.state; -struct drm_crtc *crtc = &pipe->crtc;struct drm_rect rect;if (drm_atomic_helper_damage_merged (old_state, state, &rect))repaper_fb_dirty (state->fb); - -if (crtc->state->event) { -spin_lock_irq (&crtc->dev->event_lock); -drm_crtc_send_vblank_event (crtc, crtc->state->event); -spin_unlock_irq (&crtc->dev->event_lock); - crtc->state->event =NULL ; - } }static const struct drm_simple_display_pipe_funcs repaper_pipe_funcs = {
drivers/gpu/drm/tiny/st7586.c +0 -9
@@ -23,7 +23,6 @@#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_mipi_dbi.h> #include <drm/drm_rect.h> -#include <drm/drm_vblank.h> /* controller-specific commands */ #define ST7586_DISP_MODE_GRAY 0x38
@@ -159,18 +158,10 @@ static void st7586_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *old_state) {struct drm_plane_state *state = pipe->plane.state; -struct drm_crtc *crtc = &pipe->crtc;struct drm_rect rect;if (drm_atomic_helper_damage_merged (old_state, state, &rect))st7586_fb_dirty (state->fb, &rect); - -if (crtc->state->event) { -spin_lock_irq (&crtc->dev->event_lock); -drm_crtc_send_vblank_event (crtc, crtc->state->event); -spin_unlock_irq (&crtc->dev->event_lock); - crtc->state->event =NULL ; - } } static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
drivers/gpu/drm/udl/udl_modeset.c +0 -11
@@ -375,8 +375,6 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,char *wrptr;int color_depth =UDL_COLOR_DEPTH_16BPP ; - crtc_state->no_vblank = true; - buf = (char *)udl->mode_buf;/* This first section has to do with setting the base address on the
@@ -428,14 +426,6 @@ udl_simple_display_pipe_disable(struct drm_simple_display_pipe *pipe)udl_submit_urb (dev, urb, buf - (char *)urb->transfer_buffer); } -static int -udl_simple_display_pipe_check (struct drm_simple_display_pipe *pipe, -struct drm_plane_state *plane_state, -struct drm_crtc_state *crtc_state) -{ -return 0 ; -} -static void udl_simple_display_pipe_update (struct drm_simple_display_pipe *pipe,struct drm_plane_state *old_plane_state)
@@ -457,7 +447,6 @@ struct drm_simple_display_pipe_funcs udl_simple_display_pipe_funcs = { .mode_valid = udl_simple_display_pipe_mode_valid, .enable = udl_simple_display_pipe_enable, .disable = udl_simple_display_pipe_disable, - .check = udl_simple_display_pipe_check, .update = udl_simple_display_pipe_update, .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, };
drivers/gpu/drm/xen/xen_drm_front_kms.c +13 -0
@@ -220,6 +220,18 @@ static bool display_send_page_flip(struct drm_simple_display_pipe *pipe,return false; } +static int display_check (struct drm_simple_display_pipe *pipe, +struct drm_plane_state *plane_state, +struct drm_crtc_state *crtc_state) +{ +/* Make sure the simple DRM helpers don't enable VBLANK +* generation. Xen has it's own logic to do so. +*/ + crtc_state->no_vblank = false; + +return 0 ; +} +static void display_update (struct drm_simple_display_pipe *pipe,struct drm_plane_state *old_plane_state) {
@@ -284,6 +296,7 @@ static const struct drm_simple_display_pipe_funcs display_funcs = { .enable = display_enable, .disable = display_disable, .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, + .check = display_check, .update = display_update, };
Signature · 1 line
2.24.1