From patchwork Tue Dec 6 17:47:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9463003 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 B1EDE60236 for ; Tue, 6 Dec 2016 17:47:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6B9128468 for ; Tue, 6 Dec 2016 17:47:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99ACE28487; Tue, 6 Dec 2016 17:47:41 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM 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 293302848E for ; Tue, 6 Dec 2016 17:47:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EFB046E3E3; Tue, 6 Dec 2016 17:47:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ua0-f194.google.com (mail-ua0-f194.google.com [209.85.217.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DE276E3E3 for ; Tue, 6 Dec 2016 17:47:25 +0000 (UTC) Received: by mail-ua0-f194.google.com with SMTP id 12so36230214uas.3 for ; Tue, 06 Dec 2016 09:47:25 -0800 (PST) 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; bh=yMaHhda1tVC3HzpPtRJBSIQvzc4xZivdPyDIrt/WlXc=; b=MpUVxuy7u96u/NOKn3wSMfQLPZiYZx1AweewA7fEwB1we5o4lFrXgeLbDBBfwRQC62 sotvK7J3nxHwHPu2RKxRSC6MHVpp+sHkeFbkhoHS50cKAT9tdtONDWWc+K2QDAflJLXy ZSoaBUal7NenHwb/LRdLNWYW/OEI6BbxYQZ4yesVA6GMqILNziqktpuFMU94ymyuaTFR 85IohlHAgnyLXjrSvl5gwkjmQ38y9Vujz6Z6nGtKD5Ve/6SlbIwbN4uOekvBUQhs93ks rRChZgvxrNlGHHXNwLdOrQrGsGGoyIwQ7JuxeBtyWt1XKY2LJCT/0Bq3RBjn+V/CgnGX xVyQ== X-Gm-Message-State: AKaTC03nOieEad8e5dsUcK6KjpIO6LVjP/fYET/FCB5j1yqayQhjY9Oi2RqIgXrS3npoYg== X-Received: by 10.159.48.145 with SMTP id j17mr38622205uab.43.1481046444223; Tue, 06 Dec 2016 09:47:24 -0800 (PST) Received: from jade.localdomain ([187.64.235.185]) by smtp.gmail.com with ESMTPSA id t123sm5541099vkg.26.2016.12.06.09.47.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 09:47:23 -0800 (PST) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/fence: add drm_crtc_create_fence() Date: Tue, 6 Dec 2016 15:47:17 -0200 Message-Id: <1481046437-18778-1-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 Cc: Gustavo Padovan 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-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan Instead of dealing with crtc details inside drm_atomic.c we should just export a function that creates a new crtc fence for us and use that. Suggested-by: Chris Wilson Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_atomic.c | 16 +--------------- drivers/gpu/drm/drm_crtc.c | 18 +++++++++++++++++- drivers/gpu/drm/drm_crtc_internal.h | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 19d7bcb..72fa5b2 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1864,20 +1864,6 @@ EXPORT_SYMBOL(drm_atomic_clean_old_fb); * helpers and for the DRM event handling for existing userspace. */ -static struct dma_fence *get_crtc_fence(struct drm_crtc *crtc) -{ - struct dma_fence *fence; - - fence = kzalloc(sizeof(*fence), GFP_KERNEL); - if (!fence) - return NULL; - - dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock, - crtc->fence_context, ++crtc->fence_seqno); - - return fence; -} - struct drm_out_fence_state { s64 __user *out_fence_ptr; struct sync_file *sync_file; @@ -1959,7 +1945,7 @@ static int prepare_crtc_signaling(struct drm_device *dev, f[*num_fences].out_fence_ptr = fence_ptr; *fence_state = f; - fence = get_crtc_fence(crtc); + fence = drm_crtc_create_fence(crtc); if (!fence) return -ENOMEM; diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 90931e0..e75f62c 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -152,6 +152,8 @@ static void drm_crtc_crc_fini(struct drm_crtc *crtc) #endif } +static const struct dma_fence_ops drm_crtc_fence_ops; + static struct drm_crtc *fence_to_crtc(struct dma_fence *fence) { BUG_ON(fence->ops != &drm_crtc_fence_ops); @@ -177,13 +179,27 @@ static bool drm_crtc_fence_enable_signaling(struct dma_fence *fence) return true; } -const struct dma_fence_ops drm_crtc_fence_ops = { +static const struct dma_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 = dma_fence_default_wait, }; +struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc) +{ + struct dma_fence *fence; + + fence = kzalloc(sizeof(*fence), GFP_KERNEL); + if (!fence) + return NULL; + + dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock, + crtc->fence_context, ++crtc->fence_seqno); + + return fence; +} + /** * drm_crtc_init_with_planes - Initialise a new CRTC object with * specified primary and cursor planes. diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h index 33b17d0..cdf6860 100644 --- a/drivers/gpu/drm/drm_crtc_internal.h +++ b/drivers/gpu/drm/drm_crtc_internal.h @@ -43,7 +43,7 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc, int drm_crtc_register_all(struct drm_device *dev); void drm_crtc_unregister_all(struct drm_device *dev); -extern const struct dma_fence_ops drm_crtc_fence_ops; +struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc); /* IOCTLs */ int drm_mode_getcrtc(struct drm_device *dev,