From patchwork Tue Oct 23 23:12:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lyude Paul X-Patchwork-Id: 10653883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B122C14BB for ; Tue, 23 Oct 2018 23:13:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 998152862A for ; Tue, 23 Oct 2018 23:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AFF528999; Tue, 23 Oct 2018 23:13:38 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 3E81F2862A for ; Tue, 23 Oct 2018 23:13:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 528E86E101; Tue, 23 Oct 2018 23:13:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2C52B6E0F2; Tue, 23 Oct 2018 23:13:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5BAB3084295; Tue, 23 Oct 2018 23:13:07 +0000 (UTC) Received: from malachite.bss.redhat.com (dhcp-10-20-1-11.bss.redhat.com [10.20.1.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B9AF60C60; Tue, 23 Oct 2018 23:13:07 +0000 (UTC) From: Lyude Paul To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Subject: [PATCH 3/6] drm/atomic: Add ->atomic_check() hook for private objects Date: Tue, 23 Oct 2018 19:12:48 -0400 Message-Id: <20181023231251.16883-4-lyude@redhat.com> In-Reply-To: <20181023231251.16883-1-lyude@redhat.com> References: <20181023231251.16883-1-lyude@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 23 Oct 2018 23:13:07 +0000 (UTC) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently; private objects are mostly used just for driver-specific atomic state, but not entirely. MST also uses private objects for holding it's atomic state, but in order to make our MST helpers safer for atomic we need to be able to check that state after the driver has performed it's own checks on the atomic state. So, add an optional ->atomic_check() callback into drm_private_state_funcs that gets called after the driver's atomic checks. Signed-off-by: Lyude Paul Cc: Daniel Vetter --- drivers/gpu/drm/drm_atomic.c | 14 ++++++++++++++ include/drm/drm_atomic.h | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 3dbfbddae7e6..2db9f219732b 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -966,6 +966,8 @@ int drm_atomic_check_only(struct drm_atomic_state *state) struct drm_crtc_state *crtc_state; struct drm_connector *conn; struct drm_connector_state *conn_state; + struct drm_private_obj *priv_obj; + struct drm_private_state *priv_state; int i, ret = 0; DRM_DEBUG_ATOMIC("checking %p\n", state); @@ -1007,6 +1009,18 @@ int drm_atomic_check_only(struct drm_atomic_state *state) } } + for_each_new_private_obj_in_state(state, priv_obj, priv_state, i) { + if (!priv_obj->funcs->atomic_check) + continue; + + ret = priv_obj->funcs->atomic_check(priv_obj, priv_state); + if (ret) { + DRM_DEBUG_ATOMIC("[PRIVATE:%p] atomic check on state %p failed\n", + priv_obj, priv_state); + return ret; + } + } + if (!state->allow_modeset) { for_each_new_crtc_in_state(state, crtc, crtc_state, i) { if (drm_atomic_crtc_needs_modeset(crtc_state)) { diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index f9b35834c45d..3e504eeb1122 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@ -216,6 +216,22 @@ struct drm_private_state_funcs { */ void (*atomic_destroy_state)(struct drm_private_obj *obj, struct drm_private_state *state); + + /** + * @atomic_check: + * + * Perform a check of the current state of the private object to + * ensure that it's valid. This is an optional callback. If + * implemented, it will be called after atomic checks have been + * performed on all of the planes, CRTCs, connectors, and the new + * &drm_mode_config in the atomic state. + * + * RETURNS: + * + * 0 on success, negative error code on failure. + */ + int (*atomic_check)(struct drm_private_obj *obj, + struct drm_private_state *state); }; /**