All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Anholt <eric@anholt.net>
To: Qiang Yu <yuq825@gmail.com>
Cc: dri-devel <dri-devel@lists.freedesktop.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	david.emett@broadcom.com, thomas.spurden@broadcom.com,
	Rob Herring <robh@kernel.org>
Subject: Re: [PATCH 7/7] drm/lima: Use the drm_gem_fence_array_add helpers for our deps.
Date: Tue, 02 Apr 2019 09:56:59 -0700	[thread overview]
Message-ID: <87o95o4a78.fsf@anholt.net> (raw)
In-Reply-To: <CAKGbVbvfXmwKcLX=OwKRjDNBg8d9uK8yLQUUG6KsmdMyW5zxGA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4877 bytes --]

Qiang Yu <yuq825@gmail.com> writes:

> On Tue, Apr 2, 2019 at 6:26 AM Eric Anholt <eric@anholt.net> wrote:
>>
>> I haven't tested this, but it's a pretty direct port of what I did for
>> v3d.
>>
>> Signed-off-by: Eric Anholt <eric@anholt.net>
>> ---
>>  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 <linux/kthread.h>
>>  #include <linux/slab.h>
>> +#include <linux/xarray.h>
>>
>>  #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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2019-04-02 16:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 22:26 [PATCH 0/7] DRM fence list helpers, V3D CSD support Eric Anholt
2019-04-01 22:26 ` Eric Anholt
2019-04-01 22:26 ` [PATCH 1/7] drm/v3d: Switch the type of job-> to reduce casting Eric Anholt
2019-04-01 22:26   ` Eric Anholt
2019-04-01 22:26 ` [PATCH 2/7] drm/v3d: Refactor job management Eric Anholt
2019-04-01 22:26   ` Eric Anholt
2019-04-01 22:26 ` [PATCH 3/7] drm/v3d: Add support for compute shader dispatch Eric Anholt
2019-04-01 22:26   ` Eric Anholt
2019-04-01 22:26 ` [PATCH 4/7] drm/v3d: Drop reservation of a shared slot in the dma-buf reservations Eric Anholt
2019-04-01 22:26   ` Eric Anholt
2019-04-01 22:26 ` [PATCH 5/7] drm: Add helpers for setting up an array of dma_fence dependencies Eric Anholt
2019-04-01 22:26   ` Eric Anholt
2019-04-01 22:26 ` [PATCH 6/7] drm/v3d: Add missing implicit synchronization Eric Anholt
2019-04-01 22:26   ` Eric Anholt
2019-04-01 22:26 ` [PATCH 7/7] drm/lima: Use the drm_gem_fence_array_add helpers for our deps Eric Anholt
2019-04-01 22:26   ` Eric Anholt
2019-04-02 10:22   ` Qiang Yu
2019-04-02 16:56     ` Eric Anholt [this message]
2019-04-03  0:55       ` Qiang Yu
2019-04-16 22:55         ` Eric Anholt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o95o4a78.fsf@anholt.net \
    --to=eric@anholt.net \
    --cc=david.emett@broadcom.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=thomas.spurden@broadcom.com \
    --cc=yuq825@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.