From nobody Thu May 2 02:33:58 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1579522909; cv=none; d=zohomail.com; s=zohoarc; b=WSH3LcNX5qjsKQemj718WQk4NRdDEop/ZAbtjZKSlqB4XQbP7zcZ4hyGi7+Q077qj781cXBhcge13H1Wk/0aPd84QxoD517Xa9clMI09m4za+YBcDy28vIRKCytAdNcVLyR2w5enk5KXhnS2nLps/pt1YJ62sG0600I1sAWx/dw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579522909; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Hs29jxtG0pzayb27r3IY0UGJB2E/ebEDjmyhRAu4iJ4=; b=lVybVPzzkagAjJVDSNNGTzicIhXM746wbnC5OADwf5QACP+SFXlRtBfGwADYjUUSGIxl1ltYTFVfXAbKAH1ow5vKw8p+12GIN3RX8UavK6xmci9TMEalQuWCLdccze6IAp9GECawm0R0f6hcc4+K+5lNHCFe3+lT+tVkZhx4kuA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1579522909549961.7215635937728; Mon, 20 Jan 2020 04:21:49 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itW3H-0001BA-Nq; Mon, 20 Jan 2020 12:21:07 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itW3F-0001Aw-Q8 for xen-devel@lists.xenproject.org; Mon, 20 Jan 2020 12:21:05 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4effbb73-3b7f-11ea-b95e-12813bfff9fa; Mon, 20 Jan 2020 12:20:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BEAB6AD46; Mon, 20 Jan 2020 12:20:54 +0000 (UTC) X-Inumbo-ID: 4effbb73-3b7f-11ea-b95e-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Thomas Zimmermann To: airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, hdegoede@redhat.com, david@lechnology.com, noralf@tronnes.org, sean@poorly.run, oleksandr_andrushchenko@epam.com, sam@ravnborg.org, laurent.pinchart@ideasonboard.com, emil.velikov@collabora.com Date: Mon, 20 Jan 2020 13:20:48 +0100 Message-Id: <20200120122051.25178-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200120122051.25178-1-tzimmermann@suse.de> References: <20200120122051.25178-1-tzimmermann@suse.de> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 1/4] drm: Add drm_crtc_has_vblank() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The new interface drm_crtc_has_vblank() return true if vblanking has been initialized for a certain CRTC, or false otherwise. This function will be useful for initializing CRTC state. Signed-off-by: Thomas Zimmermann Acked-by: Gerd Hoffmann --- drivers/gpu/drm/drm_vblank.c | 21 +++++++++++++++++++++ include/drm/drm_vblank.h | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 1659b13b178c..c20102899411 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -501,6 +501,27 @@ int drm_vblank_init(struct drm_device *dev, unsigned i= nt num_crtcs) } EXPORT_SYMBOL(drm_vblank_init); =20 +/** + * drm_crtc_has_vblank - test if vblanking has been initialized for + * a CRTC + * @crtc: the CRTC + * + * Drivers may call this function to test if vblank support is + * initialized for a CRTC. For most hardware this means that vblanking + * can also be enabled on the CRTC. + * + * Returns: + * True if vblanking has been initialized for the given CRTC, false + * otherwise. + */ +bool drm_crtc_has_vblank(const struct drm_crtc *crtc) +{ + struct drm_device *dev =3D crtc->dev; + + return crtc->index < dev->num_crtcs; +} +EXPORT_SYMBOL(drm_crtc_has_vblank); + /** * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC * @crtc: which CRTC's vblank waitqueue to retrieve diff --git a/include/drm/drm_vblank.h b/include/drm/drm_vblank.h index c16c44052b3d..531a6bc12b7e 100644 --- a/include/drm/drm_vblank.h +++ b/include/drm/drm_vblank.h @@ -206,6 +206,7 @@ struct drm_vblank_crtc { }; =20 int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs); +bool drm_crtc_has_vblank(const struct drm_crtc *crtc); u64 drm_crtc_vblank_count(struct drm_crtc *crtc); u64 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc, ktime_t *vblanktime); --=20 2.24.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 02:33:58 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1579522913; cv=none; d=zohomail.com; s=zohoarc; b=SE+NUm3cXaf/9FxGRVW8OGmvllAAG3V8dG4Ho3Muec1mxziolfK/qYEtVC7dhz5v6npTy5t3Rp9RfF5PhbZ4M3mXTuMUqkEPla2Nt2cAsJMhw80wK7FANMlRlNTA8h+xT+hxvVtCmg+JctRfa+Wi9ArBmTp84U0Hhm+PAyeOAc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579522913; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MCogQt3hFVPDey0OMsv3PbJusSLQAj/nw42M0FT1omM=; b=kjBD9yJ/b14ubM7IIR8RgKPO91WPJubgKhitrbkcYuWI6gruyZ1nlSpLKgKQUSYkXFxBwYzzc4WNv57KlyjwAh8LSUvDVmULhD8TWGZpXgRDy048X8NMbureWNfF3xbFHjK8LKHfTSnt28xcv3MNLbt2LeG2QdLBxFFjR2DrnyE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 157952291305720.589209619248095; Mon, 20 Jan 2020 04:21:53 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itW3I-0001BJ-0r; Mon, 20 Jan 2020 12:21:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itW3G-0001B1-4V for xen-devel@lists.xenproject.org; Mon, 20 Jan 2020 12:21:06 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4efe9dd2-3b7f-11ea-9fd7-bc764e2007e4; Mon, 20 Jan 2020 12:20:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BE049AC2F; Mon, 20 Jan 2020 12:20:54 +0000 (UTC) X-Inumbo-ID: 4efe9dd2-3b7f-11ea-9fd7-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Thomas Zimmermann To: airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, hdegoede@redhat.com, david@lechnology.com, noralf@tronnes.org, sean@poorly.run, oleksandr_andrushchenko@epam.com, sam@ravnborg.org, laurent.pinchart@ideasonboard.com, emil.velikov@collabora.com Date: Mon, 20 Jan 2020 13:20:49 +0100 Message-Id: <20200120122051.25178-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200120122051.25178-1-tzimmermann@suse.de> References: <20200120122051.25178-1-tzimmermann@suse.de> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 2/4] drm: Initialize struct drm_crtc_state.no_vblank from device settings X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the end of a commit, atomic helpers can generate a VBLANK event automatically. Originally implemented for writeback connectors, the functionality can be used by any driver and/or hardware without proper VBLANK interrupt. First of all, the patch updates the documentation to make this behaviour official: settings struct drm_crtc_state.no_vblank to true enables automatic VBLANK generation. Atomic modesetting helper set the initial value of no_vblank in drm_atomic_helper_check_modeset(). If vblanking has been initialized for a CRTC, no_blank is disabled. Otherwise it's enabled. Hence, atomic helpers will automatically send out VBLANK events with any driver that did not initialize vblanking. As drivers previously send out VBLANK events by themselves, all affected drivers have to be updated as well. Usually, deleting the driver's vblanking code is sufficient. Xen implements its own logic for generating events and therefore needs to override no_vblank with a value of false. v3: * squash all related changes patches into this patch Signed-off-by: Thomas Zimmermann Acked-by: Gerd Hoffmann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/arc/arcpgu_crtc.c | 16 -------------- drivers/gpu/drm/bochs/bochs_kms.c | 9 -------- drivers/gpu/drm/cirrus/cirrus.c | 8 ------- drivers/gpu/drm/drm_atomic_helper.c | 10 ++++++++- drivers/gpu/drm/drm_mipi_dbi.c | 9 -------- drivers/gpu/drm/drm_vblank.c | 9 ++++++++ drivers/gpu/drm/qxl/qxl_display.c | 14 ------------ 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/vboxvideo/vbox_mode.c | 12 ----------- drivers/gpu/drm/virtio/virtgpu_display.c | 8 ------- drivers/gpu/drm/xen/xen_drm_front_kms.c | 13 ++++++++++++ include/drm/drm_crtc.h | 27 ++++++++++++++++++------ include/drm/drm_simple_kms_helper.h | 7 ++++-- 16 files changed, 56 insertions(+), 122 deletions(-) diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu= _crtc.c index 8ae1e1f97a73..be7c29cec318 100644 --- a/drivers/gpu/drm/arc/arcpgu_crtc.c +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -138,24 +137,9 @@ static void arc_pgu_crtc_atomic_disable(struct drm_crt= c *crtc, ~ARCPGU_CTRL_ENABLE_MASK); } =20 -static void arc_pgu_crtc_atomic_begin(struct drm_crtc *crtc, - struct drm_crtc_state *state) -{ - struct drm_pending_vblank_event *event =3D crtc->state->event; - - if (event) { - crtc->state->event =3D NULL; - - spin_lock_irq(&crtc->dev->event_lock); - drm_crtc_send_vblank_event(crtc, event); - spin_unlock_irq(&crtc->dev->event_lock); - } -} - static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs =3D { .mode_valid =3D arc_pgu_crtc_mode_valid, .mode_set_nofb =3D arc_pgu_crtc_mode_set_nofb, - .atomic_begin =3D arc_pgu_crtc_atomic_begin, .atomic_enable =3D arc_pgu_crtc_atomic_enable, .atomic_disable =3D arc_pgu_crtc_atomic_disable, }; diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/boch= s_kms.c index 3f0006c2470d..ff275faee88d 100644 --- a/drivers/gpu/drm/bochs/bochs_kms.c +++ b/drivers/gpu/drm/bochs/bochs_kms.c @@ -7,7 +7,6 @@ #include #include #include -#include =20 #include "bochs.h" =20 @@ -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 =3D pipe->crtc.dev->dev_private; - struct drm_crtc *crtc =3D &pipe->crtc; =20 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 =3D NULL; - spin_unlock_irq(&crtc->dev->event_lock); - } } =20 static const struct drm_simple_display_pipe_funcs bochs_pipe_funcs =3D { diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirru= s.c index 248c9f765c45..a91fb0d7282c 100644 --- a/drivers/gpu/drm/cirrus/cirrus.c +++ b/drivers/gpu/drm/cirrus/cirrus.c @@ -38,7 +38,6 @@ #include #include #include -#include =20 #define DRIVER_NAME "cirrus" #define DRIVER_DESC "qemu cirrus vga" @@ -434,13 +433,6 @@ static void cirrus_pipe_update(struct drm_simple_displ= ay_pipe *pipe, =20 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 =3D NULL; - spin_unlock_irq(&crtc->dev->event_lock); - } } =20 static const struct drm_simple_display_pipe_funcs cirrus_pipe_funcs =3D { diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atom= ic_helper.c index 4511c2e07bb9..6e9c730a8919 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -583,6 +583,7 @@ mode_valid(struct drm_atomic_state *state) * &drm_crtc_state.connectors_changed is set when a connector is added or * removed from the CRTC. &drm_crtc_state.active_changed is set when * &drm_crtc_state.active changes, which is used for DPMS. + * &drm_crtc_state.no_vblank is set from the result of drm_crtc_has_vblank= (). * See also: drm_atomic_crtc_needs_modeset() * * IMPORTANT: @@ -649,6 +650,11 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, =20 return -EINVAL; } + + if (drm_crtc_has_vblank(crtc)) + new_crtc_state->no_vblank =3D false; + else + new_crtc_state->no_vblank =3D true; } =20 ret =3D handle_conflicting_encoders(state, false); @@ -2215,7 +2221,9 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies= ); * when a job is queued, and any change to the pipeline that does not touc= h 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. diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c index 16bff1be4b8a..13b753cb3f67 100644 --- a/drivers/gpu/drm/drm_mipi_dbi.c +++ b/drivers/gpu/drm/drm_mipi_dbi.c @@ -24,7 +24,6 @@ #include #include #include -#include #include