From: Daniel Vetter <daniel-/w4YWyX8dFk@public.gmane.org>
To: christian.koenig-5C7GfCeVMHo@public.gmane.org
Cc: dri-devel
<dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
intel-gfx
<intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
amd-gfx list
<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
Daniel Vetter <daniel-/w4YWyX8dFk@public.gmane.org>
Subject: Re: [Intel-gfx] [PATCH 1/6] dma-buf: add dynamic DMA-buf handling v12
Date: Tue, 25 Jun 2019 17:26:44 +0200 [thread overview]
Message-ID: <20190625152644.GZ12905@phenom.ffwll.local> (raw)
In-Reply-To: <6fdde041-89f8-ff12-d237-3e280f0af21c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Tue, Jun 25, 2019 at 05:13:42PM +0200, Christian König wrote:
> Am 25.06.19 um 17:07 schrieb Daniel Vetter:
> > On Tue, Jun 25, 2019 at 4:45 PM Christian König
> > <ckoenig.leichtzumerken@gmail.com> wrote:
> > > > > - if (attach->sgt)
> > > > > + if (attach->sgt) {
> > > > > + if (dma_buf_is_dynamic(attach->dmabuf))
> > > > > + reservation_object_lock(attach->dmabuf->resv, NULL);
> > > > > +
> > > > > dmabuf->ops->unmap_dma_buf(attach, attach->sgt, attach->dir);
> > > > >
> > > > > + if (dma_buf_is_dynamic(attach->dmabuf)) {
> > > > > + dma_buf_unpin(attach);
> > > > > + reservation_object_unlock(attach->dmabuf->resv);
> > > > > + }
> > > > > + }
> > > > > +
> > > > > mutex_lock(&dmabuf->lock);
> > > > Time to ditch dmabuf->lock in favour of the reservation obj? We have a
> > > > fallback resv_obj in struct dma_buf already, so this is never null, and I
> > > > think would clean up the code a bit.
> > > Yeah, thought about that as well. But then decided against it for now.
> > >
> > > Key point is that exporters currently doesn't care about dmabuf->lock,
> > > but they do care about the reservation lock.
> > >
> > > So we will probably have a bunch of cases where we have to fix up
> > > exporters because they will try to grab the reservation lock as well.
> > >
> > > On the other hand we maybe not need a lock at all here if we just can
> > > live with multiple attach/detach callbacks running in parallel.
> > Well looking through the code I thought that all the places you grab
> > dmabuf->resv we also grab dmabuf->lock, so seemed fully redundant. But
> > I didn't check completely.
>
> The difference is that I didn't call attach/detach with the lock held yet.
>
> And we could actually drop locking the reservation object while manipulating
> the list of attachments since we no longer use that workaround.
>
> Going to fix that up tomorrow as well,
You rely on the reservation lock for walking the list when calling
move_notify. So that lock is definitely needed there. If you'd put it in
there then lockdep would splat about locking inversions.
In general dmabuf->lock not being a ww_mutex kinda gets in the way and
just needless complicates the hierarchy. Atm its even outside of the
reservation lock, so anywhere where we expect callers to hold the
reservation lock already we can't take it.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2019-06-25 15:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 12:46 [PATCH 1/6] dma-buf: add dynamic DMA-buf handling v12 Christian König
2019-06-25 12:46 ` [PATCH 2/6] drm/ttm: remove the backing store if no placement is given Christian König
2019-06-25 12:46 ` [PATCH 3/6] drm/ttm: use the parent resv for ghost objects v2 Christian König
[not found] ` <20190625124654.122364-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-06-25 12:46 ` [PATCH 4/6] drm/amdgpu: use allowed_domains for exported DMA-bufs Christian König
2019-06-25 12:46 ` [PATCH 5/6] drm/amdgpu: add independent DMA-buf export v6 Christian König
2019-06-25 12:46 ` [PATCH 6/6] drm/amdgpu: add independent DMA-buf import v7 Christian König
2019-06-25 16:05 ` [Intel-gfx] [PATCH 1/6] dma-buf: add dynamic DMA-buf handling v12 Daniel Vetter
[not found] ` <20190625160539.GB12905-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-06-26 7:49 ` Christian König
[not found] ` <819ef4bd-e862-6390-d2e3-60f9d6c9cab4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-06-26 8:17 ` Daniel Vetter
[not found] ` <20190626081711.GH12905-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-06-26 9:28 ` Koenig, Christian
2019-06-26 10:57 ` Daniel Vetter
[not found] ` <CAKMK7uH9SmCw-pcRvMrf1OL=jYDOJ5WSR8U8hOK+Amm6bjhnkg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-06-26 11:53 ` Christian König
[not found] ` <24916a7e-e0b5-d2ed-5a7a-0d816690a063-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-06-26 12:15 ` Daniel Vetter
2019-06-25 13:07 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/6] " Patchwork
2019-06-25 13:08 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-06-25 13:41 ` ✓ Fi.CI.BAT: success " Patchwork
2019-06-25 14:35 ` [PATCH 1/6] " Daniel Vetter
[not found] ` <20190625143548.GX12905-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-06-25 14:45 ` [Intel-gfx] " Christian König
2019-06-25 15:07 ` Daniel Vetter
2019-06-25 15:13 ` Christian König
[not found] ` <6fdde041-89f8-ff12-d237-3e280f0af21c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-06-25 15:26 ` Daniel Vetter [this message]
2019-06-25 14:51 ` ✓ Fi.CI.IGT: success for series starting with [1/6] " Patchwork
2019-06-26 12:34 ` ✗ Fi.CI.BAT: failure for series starting with [1/6] dma-buf: add dynamic DMA-buf handling v12 (rev2) 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=20190625152644.GZ12905@phenom.ffwll.local \
--to=daniel-/w4ywyx8dfk@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox