From patchwork Mon Apr 25 22:33:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 8933141 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A85289F372 for ; Mon, 25 Apr 2016 22:34:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE03620165 for ; Mon, 25 Apr 2016 22:34:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E211C20120 for ; Mon, 25 Apr 2016 22:34:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FA306E700; Mon, 25 Apr 2016 22:34:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw0-f194.google.com (mail-yw0-f194.google.com [209.85.161.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80EB26E6CD for ; Mon, 25 Apr 2016 22:34:05 +0000 (UTC) Received: by mail-yw0-f194.google.com with SMTP id u62so1267029ywe.3 for ; Mon, 25 Apr 2016 15:34:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=81Z0+P3cP8jM95g8h22QeC6TE3fsYDrSAuI10QYJaBU=; b=JyPyRD6I/SA5tcIirJQax/A1ukoomLsVYCjBpzPtplGCEI3o50R1Z2Jqnm7NkiDrk8 cTvoQogvA/Kp3bLiWH+xIIxIXA/dfdGo1/eq865w+nwTiAdps5pRzKuviQsraorM0ncY CBtxvxx5SZziR8yLCvcR6ZCVNVoCCrc9s8PbW6J4H3Dv7MOBPDXEbqbJ6tIbGmitw7+z mW6rRXgjEygW0tvltqTdSeN7/+yxZEsBCcIF3c5SbgaQ5sEp+Q2g//UuI1i208Xxdduw S0tkPhtCAR1hqybdquA2m6ycDzFl50hf7ct1b6VvEKwnyQstk8A/2mfnYyLS6lEXPZuo cQUQ== X-Gm-Message-State: AOPr4FWjx2InDXPHZ8Iqo4zqcet66O4AFHJZq/x/CVboh25be4rLQ7CoUJ+/mSQvnf+6tQ== X-Received: by 10.129.125.70 with SMTP id y67mr5218357ywc.114.1461623644221; Mon, 25 Apr 2016 15:34:04 -0700 (PDT) Received: from jade.localdomain ([201.82.24.203]) by smtp.gmail.com with ESMTPSA id r8sm13840742ywb.20.2016.04.25.15.34.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Apr 2016 15:34:03 -0700 (PDT) From: Gustavo Padovan To: Greg Kroah-Hartman Subject: [RFC v2 7/8] drm/fence: add fence timeline to drm_crtc Date: Mon, 25 Apr 2016 19:33:27 -0300 Message-Id: <1461623608-29538-8-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1461623608-29538-1-git-send-email-gustavo@padovan.org> References: <1461623608-29538-1-git-send-email-gustavo@padovan.org> Cc: devel@driverdev.osuosl.org, Daniel Stone , Daniel Vetter , Riley Andrews , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Gustavo Padovan , John Harrison 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan Create one timeline context for each CRTC to be able to handle out-fences and signal them. It adds a few members to struct drm_crtc: fence_context, where we store the context we get from fence_context_alloc(), the fence seqno and the fence lock, that we pass in fence_init() to be used by the fence. Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/drm_crtc.c | 29 +++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 19 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 65212ce..cf9750a 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -659,6 +659,32 @@ static unsigned int drm_num_crtcs(struct drm_device *dev) return num; } +static const char *drm_crtc_fence_get_driver_name(struct fence *fence) +{ + struct drm_crtc *crtc = fence_to_crtc(fence); + + return crtc->dev->driver->name; +} + +static const char *drm_crtc_fence_get_timeline_name(struct fence *fence) +{ + struct drm_crtc *crtc = fence_to_crtc(fence); + + return crtc->name; +} + +static bool drm_crtc_fence_enable_signaling(struct fence *fence) +{ + return true; +} + +const struct fence_ops drm_crtc_fence_ops = { + .get_driver_name = drm_crtc_fence_get_driver_name, + .get_timeline_name = drm_crtc_fence_get_timeline_name, + .enable_signaling = drm_crtc_fence_enable_signaling, + .wait = fence_default_wait, +}; + /** * drm_crtc_init_with_planes - Initialise a new CRTC object with * specified primary and cursor planes. @@ -709,6 +735,9 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, return -ENOMEM; } + crtc->fence_context = fence_context_alloc(1); + spin_lock_init(&crtc->fence_lock); + crtc->base.properties = &crtc->properties; list_add_tail(&crtc->head, &config->crtc_list); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 5ba3cda..d8c32c8 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -715,6 +716,9 @@ struct drm_crtc_funcs { * @helper_private: mid-layer private data * @properties: property tracking for this CRTC * @state: current atomic state for this CRTC + * @fence_context: context for fence signalling + * @fence_lock: fence lock for the fence context + * @fence_seqno: seqno variable to create fences * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for * legacy IOCTLs * @@ -771,6 +775,11 @@ struct drm_crtc { struct drm_crtc_state *state; + /* fence timelines info for DRM out-fences */ + unsigned int fence_context; + spinlock_t fence_lock; + unsigned long fence_seqno; + /* * For legacy crtc IOCTLs so that atomic drivers can get at the locking * acquire context. @@ -778,6 +787,16 @@ struct drm_crtc { struct drm_modeset_acquire_ctx *acquire_ctx; }; +extern const struct fence_ops drm_crtc_fence_ops; + +static inline struct drm_crtc *fence_to_crtc(struct fence *fence) +{ + if (fence->ops != &drm_crtc_fence_ops) + return NULL; + + return container_of(fence->lock, struct drm_crtc, fence_lock); +} + /** * struct drm_connector_state - mutable connector state * @connector: backpointer to the connector