All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhoucm1 <zhoucm1@amd.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	Chunming Zhou <david1.zhou@amd.com>,
	dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org,
	"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH] drm: fix deadlock of syncobj v5
Date: Tue, 23 Oct 2018 17:09:01 +0800	[thread overview]
Message-ID: <9fa72590-68ac-898b-3f3d-f151d1dc97f0@amd.com> (raw)
In-Reply-To: <154028530909.9962.5902811056084225232@skylake-alporthouse-com>



On 2018年10月23日 17:01, Chris Wilson wrote:
> Quoting Chunming Zhou (2018-10-23 08:57:54)
>> v2:
>> add a mutex between sync_cb execution and free.
>> v3:
>> clearly separating the roles for pt_lock and cb_mutex (Chris)
>> v4:
>> the cb_mutex should be taken outside of the pt_lock around this if() block. (Chris)
>> v5:
>> fix a corner case
>>
>> Tested by syncobj_basic and syncobj_wait of igt.
>>
>> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
>> Cc: Daniel Vetter <daniel@ffwll.ch>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Christian König <christian.koenig@amd.com>
>> Cc: intel-gfx@lists.freedesktop.org
>> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>> ---
>>   drivers/gpu/drm/drm_syncobj.c | 55 +++++++++++++++++++----------------
>>   include/drm/drm_syncobj.h     |  8 +++--
>>   2 files changed, 36 insertions(+), 27 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
>> index 57bf6006394d..679a56791e34 100644
>> --- a/drivers/gpu/drm/drm_syncobj.c
>> +++ b/drivers/gpu/drm/drm_syncobj.c
>> @@ -125,23 +125,26 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj,
>>          if (!ret)
>>                  return 1;
>>   
>> -       spin_lock(&syncobj->lock);
>> +       mutex_lock(&syncobj->cb_mutex);
>>          /* We've already tried once to get a fence and failed.  Now that we
>>           * have the lock, try one more time just to be sure we don't add a
>>           * callback when a fence has already been set.
>>           */
>> +       spin_lock(&syncobj->pt_lock);
>>          if (!list_empty(&syncobj->signal_pt_list)) {
>> -               spin_unlock(&syncobj->lock);
>> +               spin_unlock(&syncobj->pt_lock);
>>                  drm_syncobj_search_fence(syncobj, 0, 0, fence);
> Hmm, just thinking of other ways of tidying this up
>
> mutex_lock(cb_lock);
> spin_lock(pt_lock);
> *fence = drm_syncobj_find_signal_pt_for_point();
> spin_unlock(pt_list);
> if (*!fence)
> 	drm_syncobj_add_callback_locked(syncobj, cb, func);
> mutex_unlock(cb_lock);
>
> i.e. get rid of the early return and we can even drop the int return here
> as it is unimportant and unused.
Yes, do you need I send v6? or you make a separate patch as a improvment?

Thanks,
David Zhou
> -Chris

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-10-23  9:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-23  7:57 [PATCH] drm: fix deadlock of syncobj v5 Chunming Zhou
2018-10-23  9:01 ` Chris Wilson
2018-10-23  9:09   ` zhoucm1 [this message]
2018-10-23  9:11     ` Chris Wilson
2018-10-23  9:27       ` Koenig, Christian
2018-10-23  9:17 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2018-10-23  9:17 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-10-23  9:34 ` ✓ Fi.CI.BAT: success " Patchwork
2018-10-23 11:37 ` ✗ Fi.CI.IGT: failure " Patchwork

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=9fa72590-68ac-898b-3f3d-f151d1dc97f0@amd.com \
    --to=zhoucm1@amd.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=christian.koenig@amd.com \
    --cc=david1.zhou@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /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.