All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence
@ 2017-07-28 21:29 Chris Wilson
  2017-07-29 15:18 ` Gustavo Padovan
  2017-07-30 10:47 ` ✓ Fi.CI.BAT: success for " Patchwork
  0 siblings, 2 replies; 5+ messages in thread
From: Chris Wilson @ 2017-07-28 21:29 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, drm-intel-fixes

Up until recently sync_file were create to export a single dma-fence to
userspace, and so we could canabalise a bit insie dma-fence to mark
whether or not we had enable polling for the sync_file itself. However,
with the advent of syncobj, we do allow userspace to create multiple
sync_files for a single dma-fence. (Similarly, that the sw-sync
validation framework also started returning multiple sync-files wrapping
a single dma-fence for a syncpt also triggering the problem.)

This patch reverts my suggestion in commit e24165537312
("dma-buf/sync_file: only enable fence signalling on poll()") to use a
single bit in the shared dma-fence and restores the sync_file->flags for
tracking the bits individually.

Reported-by: Gustavo Padovan <gustavo@padovan.org>
Fixes: f1e8c67123cf ("dma-buf/sw-sync: Use an rbtree to sort fences in the timeline")
Fixes: e9083420bbac ("drm: introduce sync objects (v4)")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: dri-devel@lists.freedesktop.org
Cc: <drm-intel-fixes@lists.freedesktop.org> # v4.13-rc1+
---
 drivers/dma-buf/sync_file.c | 5 +++--
 include/linux/sync_file.h   | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index d7e219d2669d..66fb40d0ebdb 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -304,7 +304,7 @@ static int sync_file_release(struct inode *inode, struct file *file)
 {
 	struct sync_file *sync_file = file->private_data;
 
-	if (test_bit(POLL_ENABLED, &sync_file->fence->flags))
+	if (test_bit(POLL_ENABLED, &sync_file->flags))
 		dma_fence_remove_callback(sync_file->fence, &sync_file->cb);
 	dma_fence_put(sync_file->fence);
 	kfree(sync_file);
@@ -318,7 +318,8 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait)
 
 	poll_wait(file, &sync_file->wq, wait);
 
-	if (!test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) {
+	if (list_empty(&sync_file->cb.node) &&
+	    !test_and_set_bit(POLL_ENABLED, &sync_file->flags)) {
 		if (dma_fence_add_callback(sync_file->fence, &sync_file->cb,
 					   fence_check_cb_func) < 0)
 			wake_up_all(&sync_file->wq);
diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h
index 5726107963b2..0ad87c434ae6 100644
--- a/include/linux/sync_file.h
+++ b/include/linux/sync_file.h
@@ -43,12 +43,13 @@ struct sync_file {
 #endif
 
 	wait_queue_head_t	wq;
+	unsigned long		flags;
 
 	struct dma_fence	*fence;
 	struct dma_fence_cb cb;
 };
 
-#define POLL_ENABLED DMA_FENCE_FLAG_USER_BITS
+#define POLL_ENABLED 0
 
 struct sync_file *sync_file_create(struct dma_fence *fence);
 struct dma_fence *sync_file_get_fence(int fd);
-- 
2.13.3

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence
  2017-07-28 21:29 [PATCH] dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence Chris Wilson
@ 2017-07-29 15:18 ` Gustavo Padovan
  2017-07-31  8:32   ` Daniel Vetter
  2017-07-30 10:47 ` ✓ Fi.CI.BAT: success for " Patchwork
  1 sibling, 1 reply; 5+ messages in thread
From: Gustavo Padovan @ 2017-07-29 15:18 UTC (permalink / raw)
  To: Chris Wilson; +Cc: drm-intel-fixes, intel-gfx, dri-devel

Hi Chris,

2017-07-28 Chris Wilson <chris@chris-wilson.co.uk>:

> Up until recently sync_file were create to export a single dma-fence to
> userspace, and so we could canabalise a bit insie dma-fence to mark
> whether or not we had enable polling for the sync_file itself. However,
> with the advent of syncobj, we do allow userspace to create multiple
> sync_files for a single dma-fence. (Similarly, that the sw-sync
> validation framework also started returning multiple sync-files wrapping
> a single dma-fence for a syncpt also triggering the problem.)
> 
> This patch reverts my suggestion in commit e24165537312
> ("dma-buf/sync_file: only enable fence signalling on poll()") to use a
> single bit in the shared dma-fence and restores the sync_file->flags for
> tracking the bits individually.
> 
> Reported-by: Gustavo Padovan <gustavo@padovan.org>
> Fixes: f1e8c67123cf ("dma-buf/sw-sync: Use an rbtree to sort fences in the timeline")
> Fixes: e9083420bbac ("drm: introduce sync objects (v4)")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Sumit Semwal <sumit.semwal@linaro.org>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: Gustavo Padovan <gustavo@padovan.org>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <drm-intel-fixes@lists.freedesktop.org> # v4.13-rc1+
> ---
>  drivers/dma-buf/sync_file.c | 5 +++--
>  include/linux/sync_file.h   | 3 ++-
>  2 files changed, 5 insertions(+), 3 deletions(-)

I confirm the patch fixes the sync kselftests for me. Pushed to
drm-misc-next.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* ✓ Fi.CI.BAT: success for dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence
  2017-07-28 21:29 [PATCH] dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence Chris Wilson
  2017-07-29 15:18 ` Gustavo Padovan
@ 2017-07-30 10:47 ` Patchwork
  1 sibling, 0 replies; 5+ messages in thread
From: Patchwork @ 2017-07-30 10:47 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence
URL   : https://patchwork.freedesktop.org/series/28064/
State : success

== Summary ==

Series 28064v1 dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence
https://patchwork.freedesktop.org/api/1.0/series/28064/revisions/1/mbox/

fi-bdw-5557u     total:280  pass:269  dwarn:0   dfail:0   fail:0   skip:11  time:442s
fi-bdw-gvtdvm    total:280  pass:266  dwarn:0   dfail:0   fail:0   skip:14  time:433s
fi-blb-e6850     total:280  pass:225  dwarn:1   dfail:0   fail:0   skip:54  time:367s
fi-bsw-n3050     total:280  pass:244  dwarn:0   dfail:0   fail:0   skip:36  time:536s
fi-bxt-j4205     total:280  pass:261  dwarn:0   dfail:0   fail:0   skip:19  time:515s
fi-byt-j1900     total:280  pass:255  dwarn:1   dfail:0   fail:0   skip:24  time:493s
fi-byt-n2820     total:280  pass:251  dwarn:1   dfail:0   fail:0   skip:28  time:493s
fi-glk-2a        total:280  pass:261  dwarn:0   dfail:0   fail:0   skip:19  time:607s
fi-hsw-4770      total:280  pass:264  dwarn:0   dfail:0   fail:0   skip:16  time:433s
fi-hsw-4770r     total:280  pass:264  dwarn:0   dfail:0   fail:0   skip:16  time:416s
fi-ilk-650       total:280  pass:230  dwarn:0   dfail:0   fail:0   skip:50  time:418s
fi-ivb-3520m     total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:507s
fi-ivb-3770      total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:477s
fi-kbl-7500u     total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:475s
fi-kbl-7560u     total:280  pass:270  dwarn:0   dfail:0   fail:0   skip:10  time:575s
fi-kbl-r         total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:582s
fi-pnv-d510      total:280  pass:224  dwarn:1   dfail:0   fail:0   skip:55  time:567s
fi-skl-6260u     total:280  pass:270  dwarn:0   dfail:0   fail:0   skip:10  time:461s
fi-skl-6700hq    total:280  pass:263  dwarn:0   dfail:0   fail:0   skip:17  time:584s
fi-skl-6700k     total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:468s
fi-skl-6770hq    total:280  pass:270  dwarn:0   dfail:0   fail:0   skip:10  time:488s
fi-skl-gvtdvm    total:280  pass:267  dwarn:0   dfail:0   fail:0   skip:13  time:431s
fi-skl-x1585l    total:280  pass:269  dwarn:0   dfail:0   fail:0   skip:11  time:485s
fi-snb-2520m     total:280  pass:252  dwarn:0   dfail:0   fail:0   skip:28  time:553s
fi-snb-2600      total:280  pass:251  dwarn:0   dfail:0   fail:0   skip:29  time:405s

520e660a206f68917780f87db4e77e28e0b2a6f6 drm-tip: 2017y-07m-28d-12h-24m-40s UTC integration manifest
3b1213e0f434 dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5296/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence
  2017-07-29 15:18 ` Gustavo Padovan
@ 2017-07-31  8:32   ` Daniel Vetter
  2017-07-31 15:34     ` Gustavo Padovan
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Vetter @ 2017-07-31  8:32 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: intel-gfx, drm-intel-fixes, dri-devel

On Sat, Jul 29, 2017 at 12:18:32PM -0300, Gustavo Padovan wrote:
> Hi Chris,
> 
> 2017-07-28 Chris Wilson <chris@chris-wilson.co.uk>:
> 
> > Up until recently sync_file were create to export a single dma-fence to
> > userspace, and so we could canabalise a bit insie dma-fence to mark
> > whether or not we had enable polling for the sync_file itself. However,
> > with the advent of syncobj, we do allow userspace to create multiple
> > sync_files for a single dma-fence. (Similarly, that the sw-sync
> > validation framework also started returning multiple sync-files wrapping
> > a single dma-fence for a syncpt also triggering the problem.)
> > 
> > This patch reverts my suggestion in commit e24165537312
> > ("dma-buf/sync_file: only enable fence signalling on poll()") to use a
> > single bit in the shared dma-fence and restores the sync_file->flags for
> > tracking the bits individually.
> > 
> > Reported-by: Gustavo Padovan <gustavo@padovan.org>
> > Fixes: f1e8c67123cf ("dma-buf/sw-sync: Use an rbtree to sort fences in the timeline")
> > Fixes: e9083420bbac ("drm: introduce sync objects (v4)")
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Sumit Semwal <sumit.semwal@linaro.org>
> > Cc: Sean Paul <seanpaul@chromium.org>
> > Cc: Gustavo Padovan <gustavo@padovan.org>
> > Cc: dri-devel@lists.freedesktop.org
> > Cc: <drm-intel-fixes@lists.freedesktop.org> # v4.13-rc1+
> > ---
> >  drivers/dma-buf/sync_file.c | 5 +++--
> >  include/linux/sync_file.h   | 3 ++-
> >  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> I confirm the patch fixes the sync kselftests for me. Pushed to
> drm-misc-next.

You need to cherry-pick this to drm-misc-fixes (using cherry-pick -x to
make it clear we applied this twice), since the bug is in 4.13.
drm-misc-next is for stuff that's only needed in 4.14.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence
  2017-07-31  8:32   ` Daniel Vetter
@ 2017-07-31 15:34     ` Gustavo Padovan
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo Padovan @ 2017-07-31 15:34 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx, drm-intel-fixes, dri-devel

2017-07-31 Daniel Vetter <daniel@ffwll.ch>:

> On Sat, Jul 29, 2017 at 12:18:32PM -0300, Gustavo Padovan wrote:
> > Hi Chris,
> > 
> > 2017-07-28 Chris Wilson <chris@chris-wilson.co.uk>:
> > 
> > > Up until recently sync_file were create to export a single dma-fence to
> > > userspace, and so we could canabalise a bit insie dma-fence to mark
> > > whether or not we had enable polling for the sync_file itself. However,
> > > with the advent of syncobj, we do allow userspace to create multiple
> > > sync_files for a single dma-fence. (Similarly, that the sw-sync
> > > validation framework also started returning multiple sync-files wrapping
> > > a single dma-fence for a syncpt also triggering the problem.)
> > > 
> > > This patch reverts my suggestion in commit e24165537312
> > > ("dma-buf/sync_file: only enable fence signalling on poll()") to use a
> > > single bit in the shared dma-fence and restores the sync_file->flags for
> > > tracking the bits individually.
> > > 
> > > Reported-by: Gustavo Padovan <gustavo@padovan.org>
> > > Fixes: f1e8c67123cf ("dma-buf/sw-sync: Use an rbtree to sort fences in the timeline")
> > > Fixes: e9083420bbac ("drm: introduce sync objects (v4)")
> > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > Cc: Sumit Semwal <sumit.semwal@linaro.org>
> > > Cc: Sean Paul <seanpaul@chromium.org>
> > > Cc: Gustavo Padovan <gustavo@padovan.org>
> > > Cc: dri-devel@lists.freedesktop.org
> > > Cc: <drm-intel-fixes@lists.freedesktop.org> # v4.13-rc1+
> > > ---
> > >  drivers/dma-buf/sync_file.c | 5 +++--
> > >  include/linux/sync_file.h   | 3 ++-
> > >  2 files changed, 5 insertions(+), 3 deletions(-)
> > 
> > I confirm the patch fixes the sync kselftests for me. Pushed to
> > drm-misc-next.
> 
> You need to cherry-pick this to drm-misc-fixes (using cherry-pick -x to
> make it clear we applied this twice), since the bug is in 4.13.
> drm-misc-next is for stuff that's only needed in 4.14.
> -Daniel

Pushed to drm-misc-fixes now.

	Gustavo
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-31 15:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28 21:29 [PATCH] dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence Chris Wilson
2017-07-29 15:18 ` Gustavo Padovan
2017-07-31  8:32   ` Daniel Vetter
2017-07-31 15:34     ` Gustavo Padovan
2017-07-30 10:47 ` ✓ Fi.CI.BAT: success for " Patchwork

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.