diff mbox series

[2/3] dma-fence: use default wait function for mock fences

Message ID 20200511091142.208787-2-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Daniel Vetter May 11, 2020, 9:11 a.m. UTC
No need to micro-optmize when we're waiting in a mocked object ...

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: linux-media@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
---
 drivers/dma-buf/st-dma-fence.c | 41 ----------------------------------
 1 file changed, 41 deletions(-)

Comments

Chris Wilson May 11, 2020, 9:41 a.m. UTC | #1
Quoting Daniel Vetter (2020-05-11 10:11:41)
> No need to micro-optmize when we're waiting in a mocked object ...

It's setting up the expected return values for the test.
-Chris
Daniel Vetter May 11, 2020, 10:12 a.m. UTC | #2
On Mon, May 11, 2020 at 10:41:03AM +0100, Chris Wilson wrote:
> Quoting Daniel Vetter (2020-05-11 10:11:41)
> > No need to micro-optmize when we're waiting in a mocked object ...
> 
> It's setting up the expected return values for the test.

Drat, I suspect something like that but didn't spot it. Kinda wondering
whether we should maybe lift the -ETIME special case to the generic
version. But that's not really a safe thing to do there, drivers might
actually use it for funny stuff.

Anyway motivation is that I'm pondering some extensions of dma_fence_wait
and removing as many of the ->wait hooks as possible would have helped.
But there's some nastier stuff like the legacy nouvea and radeon ones.
-Daniel
Michael J. Ruhl May 11, 2020, 6:13 p.m. UTC | #3
>-----Original Message-----
>From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of
>Daniel Vetter
>Sent: Monday, May 11, 2020 5:12 AM
>To: LKML <linux-kernel@vger.kernel.org>
>Cc: Daniel Vetter <daniel.vetter@ffwll.ch>; Intel Graphics Development
><intel-gfx@lists.freedesktop.org>; DRI Development <dri-
>devel@lists.freedesktop.org>; linaro-mm-sig@lists.linaro.org; Vetter, Daniel
><daniel.vetter@intel.com>; Sumit Semwal <sumit.semwal@linaro.org>; linux-
>media@vger.kernel.org
>Subject: [Intel-gfx] [PATCH 2/3] dma-fence: use default wait function for
>mock fences
>
>No need to micro-optmize when we're waiting in a mocked object ...

Makes sense to me.

Acked-by: Michael J. Ruhl <michael.j.ruhl@intel.com>

M

>Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>Cc: Sumit Semwal <sumit.semwal@linaro.org>
>Cc: linux-media@vger.kernel.org
>Cc: linaro-mm-sig@lists.linaro.org
>---
> drivers/dma-buf/st-dma-fence.c | 41 ----------------------------------
> 1 file changed, 41 deletions(-)
>
>diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-
>fence.c
>index e593064341c8..8166d2984702 100644
>--- a/drivers/dma-buf/st-dma-fence.c
>+++ b/drivers/dma-buf/st-dma-fence.c
>@@ -33,50 +33,9 @@ static void mock_fence_release(struct dma_fence *f)
> 	kmem_cache_free(slab_fences, to_mock_fence(f));
> }
>
>-struct wait_cb {
>-	struct dma_fence_cb cb;
>-	struct task_struct *task;
>-};
>-
>-static void mock_wakeup(struct dma_fence *f, struct dma_fence_cb *cb)
>-{
>-	wake_up_process(container_of(cb, struct wait_cb, cb)->task);
>-}
>-
>-static long mock_wait(struct dma_fence *f, bool intr, long timeout)
>-{
>-	const int state = intr ? TASK_INTERRUPTIBLE :
>TASK_UNINTERRUPTIBLE;
>-	struct wait_cb cb = { .task = current };
>-
>-	if (dma_fence_add_callback(f, &cb.cb, mock_wakeup))
>-		return timeout;
>-
>-	while (timeout) {
>-		set_current_state(state);
>-
>-		if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &f->flags))
>-			break;
>-
>-		if (signal_pending_state(state, current))
>-			break;
>-
>-		timeout = schedule_timeout(timeout);
>-	}
>-	__set_current_state(TASK_RUNNING);
>-
>-	if (!dma_fence_remove_callback(f, &cb.cb))
>-		return timeout;
>-
>-	if (signal_pending_state(state, current))
>-		return -ERESTARTSYS;
>-
>-	return -ETIME;
>-}
>-
> static const struct dma_fence_ops mock_ops = {
> 	.get_driver_name = mock_name,
> 	.get_timeline_name = mock_name,
>-	.wait = mock_wait,
> 	.release = mock_fence_release,
> };
>
>--
>2.26.2
>
>_______________________________________________
>Intel-gfx mailing list
>Intel-gfx@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Michael J. Ruhl May 11, 2020, 6:17 p.m. UTC | #4
>-----Original Message-----
>From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of
>Ruhl, Michael J
>Sent: Monday, May 11, 2020 2:13 PM
>To: Daniel Vetter <daniel.vetter@ffwll.ch>; LKML <linux-
>kernel@vger.kernel.org>
>Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; DRI
>Development <dri-devel@lists.freedesktop.org>; linaro-mm-
>sig@lists.linaro.org; Vetter, Daniel <daniel.vetter@intel.com>; linux-
>media@vger.kernel.org
>Subject: RE: [Intel-gfx] [PATCH 2/3] dma-fence: use default wait function for
>mock fences
>
>>-----Original Message-----
>>From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of
>>Daniel Vetter
>>Sent: Monday, May 11, 2020 5:12 AM
>>To: LKML <linux-kernel@vger.kernel.org>
>>Cc: Daniel Vetter <daniel.vetter@ffwll.ch>; Intel Graphics Development
>><intel-gfx@lists.freedesktop.org>; DRI Development <dri-
>>devel@lists.freedesktop.org>; linaro-mm-sig@lists.linaro.org; Vetter, Daniel
>><daniel.vetter@intel.com>; Sumit Semwal <sumit.semwal@linaro.org>;
>linux-
>>media@vger.kernel.org
>>Subject: [Intel-gfx] [PATCH 2/3] dma-fence: use default wait function for
>>mock fences
>>
>>No need to micro-optmize when we're waiting in a mocked object ...
>
>Makes sense to me.

/sigh.

Reading Chris comment, I am no longer sure it make sense... 

Un-ack?

m

>Acked-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
>
>M
>
>>Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>>Cc: Sumit Semwal <sumit.semwal@linaro.org>
>>Cc: linux-media@vger.kernel.org
>>Cc: linaro-mm-sig@lists.linaro.org
>>---
>> drivers/dma-buf/st-dma-fence.c | 41 ----------------------------------
>> 1 file changed, 41 deletions(-)
>>
>>diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-
>>fence.c
>>index e593064341c8..8166d2984702 100644
>>--- a/drivers/dma-buf/st-dma-fence.c
>>+++ b/drivers/dma-buf/st-dma-fence.c
>>@@ -33,50 +33,9 @@ static void mock_fence_release(struct dma_fence *f)
>> 	kmem_cache_free(slab_fences, to_mock_fence(f));
>> }
>>
>>-struct wait_cb {
>>-	struct dma_fence_cb cb;
>>-	struct task_struct *task;
>>-};
>>-
>>-static void mock_wakeup(struct dma_fence *f, struct dma_fence_cb *cb)
>>-{
>>-	wake_up_process(container_of(cb, struct wait_cb, cb)->task);
>>-}
>>-
>>-static long mock_wait(struct dma_fence *f, bool intr, long timeout)
>>-{
>>-	const int state = intr ? TASK_INTERRUPTIBLE :
>>TASK_UNINTERRUPTIBLE;
>>-	struct wait_cb cb = { .task = current };
>>-
>>-	if (dma_fence_add_callback(f, &cb.cb, mock_wakeup))
>>-		return timeout;
>>-
>>-	while (timeout) {
>>-		set_current_state(state);
>>-
>>-		if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &f->flags))
>>-			break;
>>-
>>-		if (signal_pending_state(state, current))
>>-			break;
>>-
>>-		timeout = schedule_timeout(timeout);
>>-	}
>>-	__set_current_state(TASK_RUNNING);
>>-
>>-	if (!dma_fence_remove_callback(f, &cb.cb))
>>-		return timeout;
>>-
>>-	if (signal_pending_state(state, current))
>>-		return -ERESTARTSYS;
>>-
>>-	return -ETIME;
>>-}
>>-
>> static const struct dma_fence_ops mock_ops = {
>> 	.get_driver_name = mock_name,
>> 	.get_timeline_name = mock_name,
>>-	.wait = mock_wait,
>> 	.release = mock_fence_release,
>> };
>>
>>--
>>2.26.2
>>
>>_______________________________________________
>>Intel-gfx mailing list
>>Intel-gfx@lists.freedesktop.org
>>https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>_______________________________________________
>dri-devel mailing list
>dri-devel@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-fence.c
index e593064341c8..8166d2984702 100644
--- a/drivers/dma-buf/st-dma-fence.c
+++ b/drivers/dma-buf/st-dma-fence.c
@@ -33,50 +33,9 @@  static void mock_fence_release(struct dma_fence *f)
 	kmem_cache_free(slab_fences, to_mock_fence(f));
 }
 
-struct wait_cb {
-	struct dma_fence_cb cb;
-	struct task_struct *task;
-};
-
-static void mock_wakeup(struct dma_fence *f, struct dma_fence_cb *cb)
-{
-	wake_up_process(container_of(cb, struct wait_cb, cb)->task);
-}
-
-static long mock_wait(struct dma_fence *f, bool intr, long timeout)
-{
-	const int state = intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;
-	struct wait_cb cb = { .task = current };
-
-	if (dma_fence_add_callback(f, &cb.cb, mock_wakeup))
-		return timeout;
-
-	while (timeout) {
-		set_current_state(state);
-
-		if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &f->flags))
-			break;
-
-		if (signal_pending_state(state, current))
-			break;
-
-		timeout = schedule_timeout(timeout);
-	}
-	__set_current_state(TASK_RUNNING);
-
-	if (!dma_fence_remove_callback(f, &cb.cb))
-		return timeout;
-
-	if (signal_pending_state(state, current))
-		return -ERESTARTSYS;
-
-	return -ETIME;
-}
-
 static const struct dma_fence_ops mock_ops = {
 	.get_driver_name = mock_name,
 	.get_timeline_name = mock_name,
-	.wait = mock_wait,
 	.release = mock_fence_release,
 };