From patchwork Tue Jan 3 16:56:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien DESSENNE X-Patchwork-Id: 9495211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A536560414 for ; Tue, 3 Jan 2017 16:57:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B56D1FEBD for ; Tue, 3 Jan 2017 16:57:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8ED3F2793A; Tue, 3 Jan 2017 16:57:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 23B101FEBD for ; Tue, 3 Jan 2017 16:57:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E1D2C6E61C; Tue, 3 Jan 2017 16:57:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 90C2D6E60A for ; Tue, 3 Jan 2017 16:57:07 +0000 (UTC) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id v03GsN7U014259; Tue, 3 Jan 2017 17:57:05 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 27p4egyk0t-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 03 Jan 2017 17:57:05 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A23FD3A; Tue, 3 Jan 2017 16:57:04 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8807E4EBC; Tue, 3 Jan 2017 16:57:04 +0000 (GMT) Received: from localhost (10.201.23.25) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 3 Jan 2017 17:57:04 +0100 From: Fabien Dessenne To: Subject: [PATCH 4/5] drm/sti: do not sync SETPROPERTY on vblank if not ATOMIC Date: Tue, 3 Jan 2017 17:56:51 +0100 Message-ID: <1483462612-29448-5-git-send-email-fabien.dessenne@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483462612-29448-1-git-send-email-fabien.dessenne@st.com> References: <1483462612-29448-1-git-send-email-fabien.dessenne@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.25] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-03_14:, , signatures=0 Cc: Vincent Abriou , kernel@stlinux.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP If the client does not set the ATOMIC capability, do not wait for vblank before returning an DRM_IOCTL_MODE_OBJ_SETPROPERTY call. In this way, a legacy framework (eg non-atomic Weston) can call several SETPROPERTY within the same Vsync cycle. This is implemented by setting the legacy_cursor_update flag, to behave the same way as DRM_IOCTL_MODE_CURSOR (not vblank synced). Change-Id: I6b6134eca57eca399bdda006ab1cb8280d4002d4 Signed-off-by: Fabien Dessenne --- drivers/gpu/drm/sti/sti_cursor.c | 2 +- drivers/gpu/drm/sti/sti_gdp.c | 2 +- drivers/gpu/drm/sti/sti_hqvdp.c | 2 +- drivers/gpu/drm/sti/sti_plane.c | 54 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_plane.h | 2 ++ 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c index ea0dbae..d7e9f8a 100644 --- a/drivers/gpu/drm/sti/sti_cursor.c +++ b/drivers/gpu/drm/sti/sti_cursor.c @@ -349,7 +349,7 @@ static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = { .update_plane = sti_plane_update_plane, .disable_plane = sti_plane_disable_plane, .destroy = sti_cursor_destroy, - .set_property = drm_atomic_helper_plane_set_property, + .set_property = sti_plane_set_property, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c index a379bbe..6fa5042 100644 --- a/drivers/gpu/drm/sti/sti_gdp.c +++ b/drivers/gpu/drm/sti/sti_gdp.c @@ -885,7 +885,7 @@ static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = { .update_plane = sti_plane_update_plane, .disable_plane = sti_plane_disable_plane, .destroy = sti_gdp_destroy, - .set_property = drm_atomic_helper_plane_set_property, + .set_property = sti_plane_set_property, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c index 65ca43f..3fd6f3a 100644 --- a/drivers/gpu/drm/sti/sti_hqvdp.c +++ b/drivers/gpu/drm/sti/sti_hqvdp.c @@ -1255,7 +1255,7 @@ static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = { .update_plane = sti_plane_update_plane, .disable_plane = sti_plane_disable_plane, .destroy = sti_hqvdp_destroy, - .set_property = drm_atomic_helper_plane_set_property, + .set_property = sti_plane_set_property, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, diff --git a/drivers/gpu/drm/sti/sti_plane.c b/drivers/gpu/drm/sti/sti_plane.c index 22cf30d..c58fe1b 100644 --- a/drivers/gpu/drm/sti/sti_plane.c +++ b/drivers/gpu/drm/sti/sti_plane.c @@ -132,6 +132,60 @@ void sti_plane_init_property(struct sti_plane *plane, plane->drm_plane.base.id, sti_plane_to_str(plane)); } +int sti_plane_set_property(struct drm_plane *plane, + struct drm_property *property, uint64_t val) +{ + /* + * Forked from drm_atomic_helper_plane_set_property(). + * Here we do not wait for vblank if the client is not atomic, so + * DRM_IOCTL_MODE_OBJ_SETPROPERTY returns before vblank. + */ + struct drm_atomic_state *state; + struct drm_plane_state *plane_state; + struct sti_private *private = plane->dev->dev_private; + int ret = 0; + + state = drm_atomic_state_alloc(plane->dev); + if (!state) + return -ENOMEM; + + /* ->set_property is always called with all locks held. */ + state->acquire_ctx = plane->dev->mode_config.acquire_ctx; +retry: + plane_state = drm_atomic_get_plane_state(state, plane); + if (IS_ERR(plane_state)) { + ret = PTR_ERR(plane_state); + goto fail; + } + + ret = drm_atomic_plane_set_property(plane, plane_state, + property, val); + if (ret) + goto fail; + + if (!private->filp->atomic) + state->legacy_cursor_update = true; + + ret = drm_atomic_commit(state); + if (ret != 0) + goto fail; + + /* Driver takes ownership of state on successful commit. */ + return 0; +fail: + if (ret == -EDEADLK) + goto backoff; + + drm_atomic_state_free(state); + + return ret; +backoff: + drm_atomic_state_clear(state); + drm_atomic_legacy_backoff(state); + + goto retry; +} + int sti_plane_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb, int crtc_x, int crtc_y, diff --git a/drivers/gpu/drm/sti/sti_plane.h b/drivers/gpu/drm/sti/sti_plane.h index 1372b9c..aa1b6ce 100644 --- a/drivers/gpu/drm/sti/sti_plane.h +++ b/drivers/gpu/drm/sti/sti_plane.h @@ -82,6 +82,8 @@ void sti_plane_update_fps(struct sti_plane *plane, void sti_plane_init_property(struct sti_plane *plane, enum drm_plane_type type); +int sti_plane_set_property(struct drm_plane *plane, + struct drm_property *property, uint64_t val); void sti_plane_reset(struct drm_plane *plane); int sti_plane_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,