From patchwork Wed Apr 4 16:40:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10322915 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 C48E26032A for ; Wed, 4 Apr 2018 16:41:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B503928791 for ; Wed, 4 Apr 2018 16:41:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA02528F7F; Wed, 4 Apr 2018 16:41:36 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 2164A28791 for ; Wed, 4 Apr 2018 16:41:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E0A76E4E8; Wed, 4 Apr 2018 16:41:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb0-x244.google.com (mail-yb0-x244.google.com [IPv6:2607:f8b0:4002:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id BDF8289622 for ; Wed, 4 Apr 2018 16:40:55 +0000 (UTC) Received: by mail-yb0-x244.google.com with SMTP id u5-v6so8775584ybf.4 for ; Wed, 04 Apr 2018 09:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0SJUy+mkUBR10c6HoNGGdJFCT8FFZwwWd4oYAoOM5Uc=; b=Wx3Hxsjji2JAuLTXd8+X5pCLIAIv5kVfboJKGPQLbRc90jZ+yTrlkh5ilai20dcr1V /Db7xt9KU99sUOUW3QHW5uKwbDwSnhxeM4w+8rG9U213e1n7BKW9nkp+JxHvPfgiF1ks I5FyT6f2LfFCIN7+9whlC46Srm7IGjI6R+Nrk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0SJUy+mkUBR10c6HoNGGdJFCT8FFZwwWd4oYAoOM5Uc=; b=Wbz5RPbcg0F4xcSK70eTURUS1H+FICsGvuuSVZMSjRvWfYesrmMDmL0hkpoiAwBlWf KRwGKFuLCPEP580T+DbuJ9zNtXxlvCVTQA72VKhSI4t1Yht9AJvBULlFyzuEOpXN93O1 AfwpnPSWsi6fcBpL4K5LfCuSi1ebMvkBq92cambWrW/094Zze9gRWDjyxYNNSlqkx/yv JbtxWeI1+rIAHsjQsDJP2MQ11E+Sp1vPPcu6Pi4bsLvOb4taCXAZbyIHKdm7BWXwKpFM Djz8IjyMtFTMLA5ZcInWa/D25dT6bT5TadieIP2wYEiDxmzZiaeTjUi6B1Rh3M4EIQUN hH2g== X-Gm-Message-State: ALQs6tAcmoMBflz9XPO/pdIN2oJxNCfBwSPb1qdmHI/r/JOewuk+OfpO GF2ocuoCuSuLw8vOErCdQptZZg== X-Google-Smtp-Source: AIpwx4/Jcrsig4+bA4WVQY4Vw0LbTrn4B/YDOqGLOv14hdHRaZj5NnkBhgAvZMY/QwVoRw5Lr/3Uyw== X-Received: by 10.129.198.7 with SMTP id l7mr2546926ywi.150.1522860054816; Wed, 04 Apr 2018 09:40:54 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id p124sm2221027ywf.20.2018.04.04.09.40.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Apr 2018 09:40:54 -0700 (PDT) From: Sean Paul To: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v4 5/9] drm/msm: Move implicit sync handling to prepare_fb Date: Wed, 4 Apr 2018 12:40:44 -0400 Message-Id: <20180404164048.42126-6-seanpaul@chromium.org> X-Mailer: git-send-email 2.17.0.484.g0c8726318c-goog In-Reply-To: <20180404164048.42126-1-seanpaul@chromium.org> References: <20180404164048.42126-1-seanpaul@chromium.org> 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: abhinavk@codeaurora.org, hoegsberg@chromium.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP In preparation for moving to atomic helpers, move the implicit sync fence handling out of atomic commit and into the plane->prepare_fb() hook. While we're at it, de-duplicate the mdp*_prepare_fb functions. Changes in v4: - Added Reported-by: Rob Clark Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 17 +---------------- drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 16 +--------------- drivers/gpu/drm/msm/msm_atomic.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/msm/msm_drv.h | 2 ++ 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c index 7a1ad3af08e3..20e956e14c21 100644 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c @@ -98,21 +98,6 @@ static const struct drm_plane_funcs mdp4_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; -static int mdp4_plane_prepare_fb(struct drm_plane *plane, - struct drm_plane_state *new_state) -{ - struct mdp4_plane *mdp4_plane = to_mdp4_plane(plane); - struct mdp4_kms *mdp4_kms = get_kms(plane); - struct msm_kms *kms = &mdp4_kms->base.base; - struct drm_framebuffer *fb = new_state->fb; - - if (!fb) - return 0; - - DBG("%s: prepare: FB[%u]", mdp4_plane->name, fb->base.id); - return msm_framebuffer_prepare(fb, kms->aspace); -} - static void mdp4_plane_cleanup_fb(struct drm_plane *plane, struct drm_plane_state *old_state) { @@ -152,7 +137,7 @@ static void mdp4_plane_atomic_update(struct drm_plane *plane, } static const struct drm_plane_helper_funcs mdp4_plane_helper_funcs = { - .prepare_fb = mdp4_plane_prepare_fb, + .prepare_fb = msm_atomic_prepare_fb, .cleanup_fb = mdp4_plane_cleanup_fb, .atomic_check = mdp4_plane_atomic_check, .atomic_update = mdp4_plane_atomic_update, diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c index 5dc42d89b588..d1006ed69aad 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c @@ -245,20 +245,6 @@ static const struct drm_plane_funcs mdp5_plane_funcs = { .atomic_print_state = mdp5_plane_atomic_print_state, }; -static int mdp5_plane_prepare_fb(struct drm_plane *plane, - struct drm_plane_state *new_state) -{ - struct mdp5_kms *mdp5_kms = get_kms(plane); - struct msm_kms *kms = &mdp5_kms->base.base; - struct drm_framebuffer *fb = new_state->fb; - - if (!new_state->fb) - return 0; - - DBG("%s: prepare: FB[%u]", plane->name, fb->base.id); - return msm_framebuffer_prepare(fb, kms->aspace); -} - static void mdp5_plane_cleanup_fb(struct drm_plane *plane, struct drm_plane_state *old_state) { @@ -553,7 +539,7 @@ static void mdp5_plane_atomic_async_update(struct drm_plane *plane, } static const struct drm_plane_helper_funcs mdp5_plane_helper_funcs = { - .prepare_fb = mdp5_plane_prepare_fb, + .prepare_fb = msm_atomic_prepare_fb, .cleanup_fb = mdp5_plane_cleanup_fb, .atomic_check = mdp5_plane_atomic_check, .atomic_update = mdp5_plane_atomic_update, diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c index c18f0bee20d4..94f9c3e0e7bf 100644 --- a/drivers/gpu/drm/msm/msm_atomic.c +++ b/drivers/gpu/drm/msm/msm_atomic.c @@ -16,6 +16,7 @@ */ #include "msm_drv.h" +#include "msm_gem.h" #include "msm_kms.h" #include "msm_gem.h" #include "msm_fence.h" @@ -97,6 +98,27 @@ static void msm_atomic_wait_for_commit_done(struct drm_device *dev, } } +int msm_atomic_prepare_fb(struct drm_plane *plane, + struct drm_plane_state *new_state) +{ + struct msm_drm_private *priv = plane->dev->dev_private; + struct msm_kms *kms = priv->kms; + struct drm_gem_object *obj; + struct msm_gem_object *msm_obj; + struct dma_fence *fence; + + if (!new_state->fb) + return 0; + + obj = msm_framebuffer_bo(new_state->fb, 0); + msm_obj = to_msm_bo(obj); + fence = reservation_object_get_excl_rcu(msm_obj->resv); + + drm_atomic_set_fence_for_plane(new_state, fence); + + return msm_framebuffer_prepare(new_state->fb, kms->aspace); +} + static void msm_atomic_commit_tail(struct drm_atomic_state *state) { struct drm_device *dev = state->dev; diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 48ed5b9a8580..98e82230b904 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -160,6 +160,8 @@ struct msm_format { uint32_t pixel_format; }; +int msm_atomic_prepare_fb(struct drm_plane *plane, + struct drm_plane_state *new_state); int msm_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state, bool nonblock); struct drm_atomic_state *msm_atomic_state_alloc(struct drm_device *dev);