Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1853910yba; Tue, 2 Apr 2019 17:56:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPWyOnlGxWBF4KDpCGHRxzM/MHVNCoJJs9bRD0GGeg3JKx5nZqCPbs/4mAQsLH2EFX0c7z X-Received: by 2002:a63:750c:: with SMTP id q12mr36722153pgc.133.1554252967352; Tue, 02 Apr 2019 17:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554252967; cv=none; d=google.com; s=arc-20160816; b=qO3dN6akJPvG5bULhCeO+/Iz9ha9cHAR/+3iGy7CyBYb0pTdhok75tCNeJ6X9hVdwI 9FBzgxvyLcIchONersBvsN8TyL17g/DH5x0UxpqwdMVQN9rAAZ0KYnYPkxKqqp2earvT ndeMez3gOV4zjb2WpBYZD7SUgGZ9EEj23XIJ0Q/GE8NcSmY8ah5lMpJU/UfDt9PcrXPj aBN9xVwu/pnIwN9XkNWq/dWQKz5KyaazkioLOcoUtJ23N0buBBUyAT9msoN63zxZYlsA X7QzzlVuiwRhxaPBrKaf5zpae5GjDvDPhalY56zuTU1TSjzrMwYtM9bjK7vs07VAZzSp dCbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5f23IKH86kUzuSwD9zAKGYIocV0wFxjx8LkFB8K+zk8=; b=Mo9b615h1Drb/EQkRdULQB7GnVaWzi+CyDdxDOeo+T8fRBVyIfH+NFDR097yJUSFQ5 ltGWf9TKuhdUY6ooZJi4oPiOOeNb/eqSRyV2UVKDwTTj6hDVbh8BZK2rHtF7dF9TBoYs aTfuKtH39Wk4/gMvfOD4kggsRoFBjs0NS43qa0h+AHsEr8aLYsCvSt1TXg6Wi0GdWIsi h3auZrcigNbmlJxFJfWcudHaIIBPpKA49pI9Fr7/72zi2BmfPvDBAXAA53OaPNMp6vgT ttRzsnuD30eIjlBZ6cKF+vAjcFMEqP+ptKgzE+Cvm9pSHkMctqslFsF3fafZmk0ZknYB LM4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TBytd01s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m68si13302221pfb.33.2019.04.02.17.55.51; Tue, 02 Apr 2019 17:56:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TBytd01s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbfDCAzP (ORCPT + 99 others); Tue, 2 Apr 2019 20:55:15 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:40887 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbfDCAzP (ORCPT ); Tue, 2 Apr 2019 20:55:15 -0400 Received: by mail-io1-f68.google.com with SMTP id d201so12620111iof.7 for ; Tue, 02 Apr 2019 17:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5f23IKH86kUzuSwD9zAKGYIocV0wFxjx8LkFB8K+zk8=; b=TBytd01sr4PGil494fh2PWCcvkaU34f6/guQHPQboR2rJvX7nUQcF1HOEjByxosSt1 4V6pTSvqxkx7LqZOS25Eq46fMXTDNsumg0Rm57pkb5SBD5NYOhaXO5K7XV4x4sVePs4I 495kS4WELqoSCA65sRVEQKps7aas3OYgQWp+I9t0zFzkP/9ISZRHpGCpOWKtaztKQeJi 4p5FiZ04YLShhVM1tSTvOzUqKWktKUs8qyyksa+QCOoljOa2Fmz+2tqcpr1wn0oUF13N VSXgGcOo4iIYPpI30/+jN7DtyE64r5/OqTWm2ehSxwLIFTPd2KDA3tu8mn132eAh3YhS GxSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5f23IKH86kUzuSwD9zAKGYIocV0wFxjx8LkFB8K+zk8=; b=FbC2o+89rJ2YFl/WwUOr9ELeEOW6tdARMkBzWLwshoewrO0mRNCjdj/rJxPGMWZLlY dlaO1WGwTO/gEiyZsI2pkr171vzuTBmHwSRu3hineoJoBlEc4MtjN51/V74hCsxsbWWH xHhvBGB7r0BfyzaXf359ZZLdE4Cz4KZcRane8yd4mQ1Eg9MbRKn6igNvGidyiC23EJrl FrRk+qhI94R/hCdP3QNw+KYyT+OI2P6fMhKcumPmrSUADgEuqTR8AGrUr0MYXB+tQobe RXjlXcWf8S5lb2Mv8WvzWGGYtFKOVxWusHyJ8dO4wnuCZV/eRFy1NoEXjzfei5jenH11 e2bg== X-Gm-Message-State: APjAAAWNdAJ52+Dhxtpz7DsB4y+YmmNl9GiSEY/Vt2DJbRD9MWC3JyjJ ixpWj3gvz97oubsexKIRfRLsWxdvDE8qHY9M0OQ= X-Received: by 2002:a6b:8d87:: with SMTP id p129mr50348937iod.10.1554252914219; Tue, 02 Apr 2019 17:55:14 -0700 (PDT) MIME-Version: 1.0 References: <20190401222635.25013-1-eric@anholt.net> <20190401222635.25013-8-eric@anholt.net> <87o95o4a78.fsf@anholt.net> In-Reply-To: <87o95o4a78.fsf@anholt.net> From: Qiang Yu Date: Wed, 3 Apr 2019 08:55:03 +0800 Message-ID: Subject: Re: [PATCH 7/7] drm/lima: Use the drm_gem_fence_array_add helpers for our deps. To: Eric Anholt Cc: dri-devel , Linux Kernel Mailing List , david.emett@broadcom.com, thomas.spurden@broadcom.com, Rob Herring Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Indeed not that important, so patch 5&7 is: Reviewed-and-tested-by: Qiang Yu Regards, Qiang On Wed, Apr 3, 2019 at 12:57 AM Eric Anholt wrote: > > Qiang Yu writes: > > > On Tue, Apr 2, 2019 at 6:26 AM Eric Anholt wrote: > >> > >> I haven't tested this, but it's a pretty direct port of what I did for > >> v3d. > >> > >> Signed-off-by: Eric Anholt > >> --- > >> drivers/gpu/drm/lima/lima_gem.c | 37 +---------------- > >> drivers/gpu/drm/lima/lima_sched.c | 66 ++++++------------------------- > >> drivers/gpu/drm/lima/lima_sched.h | 6 +-- > >> 3 files changed, 16 insertions(+), 93 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c > >> index 2d3cf96f6c58..8f80286c80b4 100644 > >> --- a/drivers/gpu/drm/lima/lima_gem.c > >> +++ b/drivers/gpu/drm/lima/lima_gem.c > >> @@ -144,40 +144,7 @@ static int lima_gem_sync_bo(struct lima_sched_task *task, struct lima_bo *bo, > >> if (explicit) > >> return 0; > >> > >> - /* implicit sync use bo fence in resv obj */ > >> - if (write) { > >> - unsigned nr_fences; > >> - struct dma_fence **fences; > >> - int i; > >> - > >> - err = reservation_object_get_fences_rcu( > >> - bo->gem.resv, NULL, &nr_fences, &fences); > >> - if (err || !nr_fences) > >> - return err; > >> - > >> - for (i = 0; i < nr_fences; i++) { > >> - err = lima_sched_task_add_dep(task, fences[i]); > >> - if (err) > >> - break; > >> - } > >> - > >> - /* for error case free remaining fences */ > >> - for ( ; i < nr_fences; i++) > >> - dma_fence_put(fences[i]); > >> - > >> - kfree(fences); > >> - } else { > >> - struct dma_fence *fence; > >> - > >> - fence = reservation_object_get_excl_rcu(bo->gem.resv); > >> - if (fence) { > >> - err = lima_sched_task_add_dep(task, fence); > >> - if (err) > >> - dma_fence_put(fence); > >> - } > >> - } > >> - > >> - return err; > >> + return drm_gem_fence_array_add_implicit(&task->deps, &bo->gem, write); > >> } > >> > >> static int lima_gem_lock_bos(struct lima_bo **bos, u32 nr_bos, > >> @@ -250,7 +217,7 @@ static int lima_gem_add_deps(struct drm_file *file, struct lima_submit *submit) > >> if (err) > >> return err; > >> > >> - err = lima_sched_task_add_dep(submit->task, fence); > >> + err = drm_gem_fence_array_add(&submit->task->deps, fence); > >> if (err) { > >> dma_fence_put(fence); > >> return err; > >> diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c > >> index 97bd9c1deb87..e253d031fb3d 100644 > >> --- a/drivers/gpu/drm/lima/lima_sched.c > >> +++ b/drivers/gpu/drm/lima/lima_sched.c > >> @@ -3,6 +3,7 @@ > >> > >> #include > >> #include > >> +#include > >> > >> #include "lima_drv.h" > >> #include "lima_sched.h" > >> @@ -126,19 +127,24 @@ int lima_sched_task_init(struct lima_sched_task *task, > >> > >> task->num_bos = num_bos; > >> task->vm = lima_vm_get(vm); > >> + > >> + xa_init_flags(&task->deps, XA_FLAGS_ALLOC); > >> + > >> return 0; > >> } > >> > >> void lima_sched_task_fini(struct lima_sched_task *task) > >> { > >> + struct dma_fence *fence; > >> + unsigned long index; > >> int i; > >> > >> drm_sched_job_cleanup(&task->base); > >> > >> - for (i = 0; i < task->num_dep; i++) > >> - dma_fence_put(task->dep[i]); > >> - > >> - kfree(task->dep); > >> + xa_for_each(&task->deps, index, fence) { > >> + dma_fence_put(fence); > >> + } > >> + xa_destroy(&task->deps); > >> > >> if (task->bos) { > >> for (i = 0; i < task->num_bos; i++) > >> @@ -149,42 +155,6 @@ void lima_sched_task_fini(struct lima_sched_task *task) > >> lima_vm_put(task->vm); > >> } > >> > >> -int lima_sched_task_add_dep(struct lima_sched_task *task, struct dma_fence *fence) > >> -{ > >> - int i, new_dep = 4; > >> - > >> - /* same context's fence is definitly earlier then this task */ > >> - if (fence->context == task->base.s_fence->finished.context) { > >> - dma_fence_put(fence); > >> - return 0; > >> - } > > > > Seems you dropped this check in the drm_gem_fence_array_add, no bug if we > > don't have this, but redundant fence will be added in the deps array. Maybe we > > can add a context parameter to drm_gem_fence_array_add and > > drm_gem_fence_array_add_implicit to filter out fences from same > > drm_sched_entity. > > Does this feel important to you? To me, one extra slot in the array and > a trip through the top of drm_sched_entity_add_dependency_cb() doesn't > like it's feel worth making the API clumsier.