From patchwork Fri Dec 1 10:36:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 10086861 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 7423F6037E for ; Fri, 1 Dec 2017 10:58:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7087E2A421 for ; Fri, 1 Dec 2017 10:58:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 655132A435; Fri, 1 Dec 2017 10:58:43 +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 1BA7F2A421 for ; Fri, 1 Dec 2017 10:58:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5414E6ECC9; Fri, 1 Dec 2017 10:58:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.ORG Delivered-To: dri-devel@lists.freedesktop.ORG Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 76FA96ECC9 for ; Fri, 1 Dec 2017 10:58:40 +0000 (UTC) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.84_2) (envelope-from ) id 1eKigE-0004JB-Ck; Fri, 01 Dec 2017 11:36:26 +0100 From: Lucas Stach To: etnaviv@lists.freedesktop.org Subject: [PATCH 25/27] drm/etnaviv: move GPU active handling to bo pin/unpin Date: Fri, 1 Dec 2017 11:36:22 +0100 Message-Id: <20171201103624.6565-26-l.stach@pengutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171201103624.6565-1-l.stach@pengutronix.de> References: <20171201103624.6565-1-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org Cc: patchwork-lst@pengutronix.de, kernel@pengutronix.de, dri-devel@lists.freedesktop.org, Russell King 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 The active count is used to check if the BO is idle, where idle is defined as not active on the GPU and all VM mappings and reference counts dropped to the initial state. As the idling of the mappings and references now only happens in the submit cleanup, the active state handling must be moved to the same location in order to keep the userspace semantics. Signed-off-by: Lucas Stach --- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 4 ++++ drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 10 ---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index db40cd1c14fd..5a351b0f1087 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c @@ -229,6 +229,7 @@ static int submit_pin_objects(struct etnaviv_gem_submit *submit) ret = PTR_ERR(mapping); break; } + atomic_inc(&etnaviv_obj->gpu_active); submit->bos[i].flags |= BO_PINNED; submit->bos[i].mapping = mapping; @@ -363,6 +364,7 @@ static void submit_cleanup(struct kref *kref) /* unpin all objects */ if (submit->bos[i].flags & BO_PINNED) { etnaviv_gem_mapping_unreference(submit->bos[i].mapping); + atomic_dec(&etnaviv_obj->gpu_active); submit->bos[i].mapping = NULL; submit->bos[i].flags &= ~BO_PINNED; } @@ -372,6 +374,8 @@ static void submit_cleanup(struct kref *kref) drm_gem_object_put_unlocked(&etnaviv_obj->base); } + wake_up_all(&submit->gpu->fence_event); + if (submit->in_fence) dma_fence_put(submit->in_fence); if (submit->out_fence) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index 93b9d2541502..b0f4c0e68645 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1201,7 +1201,6 @@ static void retire_worker(struct work_struct *work) retire_work); u32 fence = gpu->completed_fence; struct etnaviv_gem_submit *submit, *tmp; - unsigned int i; mutex_lock(&gpu->lock); list_for_each_entry_safe(submit, tmp, &gpu->active_submit_list, node) { @@ -1210,9 +1209,6 @@ static void retire_worker(struct work_struct *work) list_del(&submit->node); - for (i = 0; i < submit->nr_bos; i++) - atomic_dec(&submit->bos[i].obj->gpu_active); - etnaviv_submit_put(submit); /* * We need to balance the runtime PM count caused by @@ -1227,8 +1223,6 @@ static void retire_worker(struct work_struct *work) gpu->retired_fence = fence; mutex_unlock(&gpu->lock); - - wake_up_all(&gpu->fence_event); } int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, @@ -1429,10 +1423,6 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu, /* We're committed to adding this command buffer, hold a PM reference */ pm_runtime_get_noresume(gpu->dev); - for (i = 0; i < submit->nr_bos; i++) { - struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj; - atomic_inc(&etnaviv_obj->gpu_active); - } hangcheck_timer_reset(gpu); ret = 0;