* [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations.
@ 2017-06-21 18:49 Eric Anholt
2017-06-21 18:50 ` [PATCH 2/4] drm/vc4: Wait for fences interruptibly in blocking mode Eric Anholt
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Eric Anholt @ 2017-06-21 18:49 UTC (permalink / raw)
To: dri-devel, Boris Brezillon; +Cc: linux-kernel, Eric Anholt
This way drm_atomic_helper_wait_for_fences() will actually do
something. The vc4_seqno_cb has been doing the fence waits on V3D
manually, so far.
Signed-off-by: Eric Anholt <eric@anholt.net>
---
drivers/gpu/drm/vc4/vc4_plane.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index fa6809d8b0fe..8853e9a4f005 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -759,9 +759,26 @@ void vc4_plane_async_set_fb(struct drm_plane *plane, struct drm_framebuffer *fb)
vc4_state->dlist[vc4_state->ptr0_offset] = addr;
}
+static int vc4_prepare_fb(struct drm_plane *plane,
+ struct drm_plane_state *state)
+{
+ struct vc4_bo *bo;
+ struct dma_fence *fence;
+
+ if ((plane->state->fb == state->fb) || !state->fb)
+ return 0;
+
+ bo = to_vc4_bo(&drm_fb_cma_get_gem_obj(state->fb, 0)->base);
+ fence = reservation_object_get_excl_rcu(bo->resv);
+ drm_atomic_set_fence_for_plane(state, fence);
+
+ return 0;
+}
+
static const struct drm_plane_helper_funcs vc4_plane_helper_funcs = {
.atomic_check = vc4_plane_atomic_check,
.atomic_update = vc4_plane_atomic_update,
+ .prepare_fb = vc4_prepare_fb,
};
static void vc4_plane_destroy(struct drm_plane *plane)
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/4] drm/vc4: Wait for fences interruptibly in blocking mode.
2017-06-21 18:49 [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations Eric Anholt
@ 2017-06-21 18:50 ` Eric Anholt
2017-06-22 7:22 ` Boris Brezillon
2017-06-21 18:50 ` [PATCH 3/4] drm/vc4: Use the atomic state's commit workqueue Eric Anholt
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Eric Anholt @ 2017-06-21 18:50 UTC (permalink / raw)
To: dri-devel, Boris Brezillon; +Cc: linux-kernel, Eric Anholt
We should allow SIGIO and things to interrupt us before we get to the
no-error stage of the commit process. This code is effectively copied
from drm_atomic_helper_commit().
Signed-off-by: Eric Anholt <eric@anholt.net>
---
drivers/gpu/drm/vc4/vc4_kms.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index bc6ecdc6f104..6b1ccea76243 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -142,6 +142,16 @@ static int vc4_atomic_commit(struct drm_device *dev,
return ret;
}
+ if (!nonblock) {
+ ret = drm_atomic_helper_wait_for_fences(dev, state, true);
+ if (ret) {
+ drm_atomic_helper_cleanup_planes(dev, state);
+ kfree(c);
+ up(&vc4->async_modeset);
+ return ret;
+ }
+ }
+
for_each_plane_in_state(state, plane, new_state, i) {
if ((plane->state->fb != new_state->fb) && new_state->fb) {
struct drm_gem_cma_object *cma_bo =
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] drm/vc4: Use the atomic state's commit workqueue.
2017-06-21 18:49 [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations Eric Anholt
2017-06-21 18:50 ` [PATCH 2/4] drm/vc4: Wait for fences interruptibly in blocking mode Eric Anholt
@ 2017-06-21 18:50 ` Eric Anholt
2017-06-22 7:16 ` Daniel Vetter
2017-06-22 8:06 ` Boris Brezillon
2017-06-21 18:50 ` [PATCH 4/4] drm/vc4: Remove dead vc4_event_pending() Eric Anholt
2017-06-22 8:03 ` [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations Boris Brezillon
3 siblings, 2 replies; 10+ messages in thread
From: Eric Anholt @ 2017-06-21 18:50 UTC (permalink / raw)
To: dri-devel, Boris Brezillon; +Cc: linux-kernel, Eric Anholt
Now that we're using the atomic helpers for fence waits, we can use
the same codepath as drm_atomic_helper_commit() does for async,
getting rid of our custom vc4_commit struct.
Signed-off-by: Eric Anholt <eric@anholt.net>
---
drivers/gpu/drm/vc4/vc4_kms.c | 71 ++++++++-----------------------------------
1 file changed, 13 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index 6b1ccea76243..b371879c3901 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -29,16 +29,9 @@ static void vc4_output_poll_changed(struct drm_device *dev)
drm_fbdev_cma_hotplug_event(vc4->fbdev);
}
-struct vc4_commit {
- struct drm_device *dev;
- struct drm_atomic_state *state;
- struct vc4_seqno_cb cb;
-};
-
static void
-vc4_atomic_complete_commit(struct vc4_commit *c)
+vc4_atomic_complete_commit(struct drm_atomic_state *state)
{
- struct drm_atomic_state *state = c->state;
struct drm_device *dev = state->dev;
struct vc4_dev *vc4 = to_vc4_dev(dev);
@@ -72,28 +65,14 @@ vc4_atomic_complete_commit(struct vc4_commit *c)
drm_atomic_state_put(state);
up(&vc4->async_modeset);
-
- kfree(c);
-}
-
-static void
-vc4_atomic_complete_commit_seqno_cb(struct vc4_seqno_cb *cb)
-{
- struct vc4_commit *c = container_of(cb, struct vc4_commit, cb);
-
- vc4_atomic_complete_commit(c);
}
-static struct vc4_commit *commit_init(struct drm_atomic_state *state)
+static void commit_work(struct work_struct *work)
{
- struct vc4_commit *c = kzalloc(sizeof(*c), GFP_KERNEL);
-
- if (!c)
- return NULL;
- c->dev = state->dev;
- c->state = state;
-
- return c;
+ struct drm_atomic_state *state = container_of(work,
+ struct drm_atomic_state,
+ commit_work);
+ vc4_atomic_complete_commit(state);
}
/**
@@ -115,29 +94,19 @@ static int vc4_atomic_commit(struct drm_device *dev,
{
struct vc4_dev *vc4 = to_vc4_dev(dev);
int ret;
- int i;
- uint64_t wait_seqno = 0;
- struct vc4_commit *c;
- struct drm_plane *plane;
- struct drm_plane_state *new_state;
-
- c = commit_init(state);
- if (!c)
- return -ENOMEM;
ret = drm_atomic_helper_setup_commit(state, nonblock);
if (ret)
return ret;
+ INIT_WORK(&state->commit_work, commit_work);
+
ret = down_interruptible(&vc4->async_modeset);
- if (ret) {
- kfree(c);
+ if (ret)
return ret;
- }
ret = drm_atomic_helper_prepare_planes(dev, state);
if (ret) {
- kfree(c);
up(&vc4->async_modeset);
return ret;
}
@@ -146,22 +115,11 @@ static int vc4_atomic_commit(struct drm_device *dev,
ret = drm_atomic_helper_wait_for_fences(dev, state, true);
if (ret) {
drm_atomic_helper_cleanup_planes(dev, state);
- kfree(c);
up(&vc4->async_modeset);
return ret;
}
}
- for_each_plane_in_state(state, plane, new_state, i) {
- if ((plane->state->fb != new_state->fb) && new_state->fb) {
- struct drm_gem_cma_object *cma_bo =
- drm_fb_cma_get_gem_obj(new_state->fb, 0);
- struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
-
- wait_seqno = max(bo->seqno, wait_seqno);
- }
- }
-
/*
* This is the point of no return - everything below never fails except
* when the hw goes bonghits. Which means we can commit the new state on
@@ -187,13 +145,10 @@ static int vc4_atomic_commit(struct drm_device *dev,
*/
drm_atomic_state_get(state);
- if (nonblock) {
- vc4_queue_seqno_cb(dev, &c->cb, wait_seqno,
- vc4_atomic_complete_commit_seqno_cb);
- } else {
- vc4_wait_for_seqno(dev, wait_seqno, ~0ull, false);
- vc4_atomic_complete_commit(c);
- }
+ if (nonblock)
+ queue_work(system_unbound_wq, &state->commit_work);
+ else
+ vc4_atomic_complete_commit(state);
return 0;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] drm/vc4: Remove dead vc4_event_pending().
2017-06-21 18:49 [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations Eric Anholt
2017-06-21 18:50 ` [PATCH 2/4] drm/vc4: Wait for fences interruptibly in blocking mode Eric Anholt
2017-06-21 18:50 ` [PATCH 3/4] drm/vc4: Use the atomic state's commit workqueue Eric Anholt
@ 2017-06-21 18:50 ` Eric Anholt
2017-06-21 19:54 ` Boris Brezillon
2017-06-22 8:03 ` [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations Boris Brezillon
3 siblings, 1 reply; 10+ messages in thread
From: Eric Anholt @ 2017-06-21 18:50 UTC (permalink / raw)
To: dri-devel, Boris Brezillon; +Cc: linux-kernel, Eric Anholt
It is no longer used as of commit 34c8ea400ff6 ("drm/vc4: Mimic
drm_atomic_helper_commit() behavior")
Signed-off-by: Eric Anholt <eric@anholt.net>
---
drivers/gpu/drm/vc4/vc4_crtc.c | 8 --------
drivers/gpu/drm/vc4/vc4_drv.h | 1 -
2 files changed, 9 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index 30a1df11e063..f20c01759c0d 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -674,14 +674,6 @@ static void vc4_disable_vblank(struct drm_crtc *crtc)
CRTC_WRITE(PV_INTEN, 0);
}
-/* Must be called with the event lock held */
-bool vc4_event_pending(struct drm_crtc *crtc)
-{
- struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
-
- return !!vc4_crtc->event;
-}
-
static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc)
{
struct drm_crtc *crtc = &vc4_crtc->base;
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index df22698d62ee..1047953216a8 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -491,7 +491,6 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
/* vc4_crtc.c */
extern struct platform_driver vc4_crtc_driver;
-bool vc4_event_pending(struct drm_crtc *crtc);
int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
bool in_vblank_irq, int *vpos, int *hpos,
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] drm/vc4: Remove dead vc4_event_pending().
2017-06-21 18:50 ` [PATCH 4/4] drm/vc4: Remove dead vc4_event_pending() Eric Anholt
@ 2017-06-21 19:54 ` Boris Brezillon
0 siblings, 0 replies; 10+ messages in thread
From: Boris Brezillon @ 2017-06-21 19:54 UTC (permalink / raw)
To: Eric Anholt; +Cc: dri-devel, linux-kernel
Le Wed, 21 Jun 2017 11:50:02 -0700,
Eric Anholt <eric@anholt.net> a écrit :
> It is no longer used as of commit 34c8ea400ff6 ("drm/vc4: Mimic
> drm_atomic_helper_commit() behavior")
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/gpu/drm/vc4/vc4_crtc.c | 8 --------
> drivers/gpu/drm/vc4/vc4_drv.h | 1 -
> 2 files changed, 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
> index 30a1df11e063..f20c01759c0d 100644
> --- a/drivers/gpu/drm/vc4/vc4_crtc.c
> +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
> @@ -674,14 +674,6 @@ static void vc4_disable_vblank(struct drm_crtc *crtc)
> CRTC_WRITE(PV_INTEN, 0);
> }
>
> -/* Must be called with the event lock held */
> -bool vc4_event_pending(struct drm_crtc *crtc)
> -{
> - struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
> -
> - return !!vc4_crtc->event;
> -}
> -
> static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc)
> {
> struct drm_crtc *crtc = &vc4_crtc->base;
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index df22698d62ee..1047953216a8 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -491,7 +491,6 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
>
> /* vc4_crtc.c */
> extern struct platform_driver vc4_crtc_driver;
> -bool vc4_event_pending(struct drm_crtc *crtc);
> int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
> bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
> bool in_vblank_irq, int *vpos, int *hpos,
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] drm/vc4: Use the atomic state's commit workqueue.
2017-06-21 18:50 ` [PATCH 3/4] drm/vc4: Use the atomic state's commit workqueue Eric Anholt
@ 2017-06-22 7:16 ` Daniel Vetter
2017-06-22 18:27 ` Eric Anholt
2017-06-22 8:06 ` Boris Brezillon
1 sibling, 1 reply; 10+ messages in thread
From: Daniel Vetter @ 2017-06-22 7:16 UTC (permalink / raw)
To: Eric Anholt; +Cc: dri-devel, Boris Brezillon, linux-kernel
On Wed, Jun 21, 2017 at 11:50:01AM -0700, Eric Anholt wrote:
> Now that we're using the atomic helpers for fence waits, we can use
> the same codepath as drm_atomic_helper_commit() does for async,
> getting rid of our custom vc4_commit struct.
\o/
On the series: Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
> ---
> drivers/gpu/drm/vc4/vc4_kms.c | 71 ++++++++-----------------------------------
> 1 file changed, 13 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
> index 6b1ccea76243..b371879c3901 100644
> --- a/drivers/gpu/drm/vc4/vc4_kms.c
> +++ b/drivers/gpu/drm/vc4/vc4_kms.c
> @@ -29,16 +29,9 @@ static void vc4_output_poll_changed(struct drm_device *dev)
> drm_fbdev_cma_hotplug_event(vc4->fbdev);
> }
>
> -struct vc4_commit {
> - struct drm_device *dev;
> - struct drm_atomic_state *state;
> - struct vc4_seqno_cb cb;
> -};
> -
> static void
> -vc4_atomic_complete_commit(struct vc4_commit *c)
> +vc4_atomic_complete_commit(struct drm_atomic_state *state)
> {
> - struct drm_atomic_state *state = c->state;
> struct drm_device *dev = state->dev;
> struct vc4_dev *vc4 = to_vc4_dev(dev);
>
> @@ -72,28 +65,14 @@ vc4_atomic_complete_commit(struct vc4_commit *c)
> drm_atomic_state_put(state);
>
> up(&vc4->async_modeset);
> -
> - kfree(c);
> -}
> -
> -static void
> -vc4_atomic_complete_commit_seqno_cb(struct vc4_seqno_cb *cb)
> -{
> - struct vc4_commit *c = container_of(cb, struct vc4_commit, cb);
> -
> - vc4_atomic_complete_commit(c);
> }
>
> -static struct vc4_commit *commit_init(struct drm_atomic_state *state)
> +static void commit_work(struct work_struct *work)
> {
> - struct vc4_commit *c = kzalloc(sizeof(*c), GFP_KERNEL);
> -
> - if (!c)
> - return NULL;
> - c->dev = state->dev;
> - c->state = state;
> -
> - return c;
> + struct drm_atomic_state *state = container_of(work,
> + struct drm_atomic_state,
> + commit_work);
> + vc4_atomic_complete_commit(state);
> }
>
> /**
> @@ -115,29 +94,19 @@ static int vc4_atomic_commit(struct drm_device *dev,
> {
> struct vc4_dev *vc4 = to_vc4_dev(dev);
> int ret;
> - int i;
> - uint64_t wait_seqno = 0;
> - struct vc4_commit *c;
> - struct drm_plane *plane;
> - struct drm_plane_state *new_state;
> -
> - c = commit_init(state);
> - if (!c)
> - return -ENOMEM;
>
> ret = drm_atomic_helper_setup_commit(state, nonblock);
> if (ret)
> return ret;
>
> + INIT_WORK(&state->commit_work, commit_work);
> +
> ret = down_interruptible(&vc4->async_modeset);
> - if (ret) {
> - kfree(c);
> + if (ret)
> return ret;
> - }
>
> ret = drm_atomic_helper_prepare_planes(dev, state);
> if (ret) {
> - kfree(c);
> up(&vc4->async_modeset);
> return ret;
> }
> @@ -146,22 +115,11 @@ static int vc4_atomic_commit(struct drm_device *dev,
> ret = drm_atomic_helper_wait_for_fences(dev, state, true);
> if (ret) {
> drm_atomic_helper_cleanup_planes(dev, state);
> - kfree(c);
> up(&vc4->async_modeset);
> return ret;
> }
> }
>
> - for_each_plane_in_state(state, plane, new_state, i) {
> - if ((plane->state->fb != new_state->fb) && new_state->fb) {
> - struct drm_gem_cma_object *cma_bo =
> - drm_fb_cma_get_gem_obj(new_state->fb, 0);
> - struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
> -
> - wait_seqno = max(bo->seqno, wait_seqno);
> - }
> - }
> -
> /*
> * This is the point of no return - everything below never fails except
> * when the hw goes bonghits. Which means we can commit the new state on
> @@ -187,13 +145,10 @@ static int vc4_atomic_commit(struct drm_device *dev,
> */
>
> drm_atomic_state_get(state);
> - if (nonblock) {
> - vc4_queue_seqno_cb(dev, &c->cb, wait_seqno,
> - vc4_atomic_complete_commit_seqno_cb);
> - } else {
> - vc4_wait_for_seqno(dev, wait_seqno, ~0ull, false);
> - vc4_atomic_complete_commit(c);
> - }
> + if (nonblock)
> + queue_work(system_unbound_wq, &state->commit_work);
> + else
> + vc4_atomic_complete_commit(state);
>
> return 0;
> }
> --
> 2.11.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/4] drm/vc4: Wait for fences interruptibly in blocking mode.
2017-06-21 18:50 ` [PATCH 2/4] drm/vc4: Wait for fences interruptibly in blocking mode Eric Anholt
@ 2017-06-22 7:22 ` Boris Brezillon
0 siblings, 0 replies; 10+ messages in thread
From: Boris Brezillon @ 2017-06-22 7:22 UTC (permalink / raw)
To: Eric Anholt; +Cc: dri-devel, linux-kernel
On Wed, 21 Jun 2017 11:50:00 -0700
Eric Anholt <eric@anholt.net> wrote:
> We should allow SIGIO and things to interrupt us before we get to the
> no-error stage of the commit process. This code is effectively copied
> from drm_atomic_helper_commit().
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/gpu/drm/vc4/vc4_kms.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
> index bc6ecdc6f104..6b1ccea76243 100644
> --- a/drivers/gpu/drm/vc4/vc4_kms.c
> +++ b/drivers/gpu/drm/vc4/vc4_kms.c
> @@ -142,6 +142,16 @@ static int vc4_atomic_commit(struct drm_device *dev,
> return ret;
> }
>
> + if (!nonblock) {
> + ret = drm_atomic_helper_wait_for_fences(dev, state, true);
> + if (ret) {
> + drm_atomic_helper_cleanup_planes(dev, state);
> + kfree(c);
> + up(&vc4->async_modeset);
> + return ret;
> + }
> + }
> +
> for_each_plane_in_state(state, plane, new_state, i) {
> if ((plane->state->fb != new_state->fb) && new_state->fb) {
> struct drm_gem_cma_object *cma_bo =
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations.
2017-06-21 18:49 [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations Eric Anholt
` (2 preceding siblings ...)
2017-06-21 18:50 ` [PATCH 4/4] drm/vc4: Remove dead vc4_event_pending() Eric Anholt
@ 2017-06-22 8:03 ` Boris Brezillon
3 siblings, 0 replies; 10+ messages in thread
From: Boris Brezillon @ 2017-06-22 8:03 UTC (permalink / raw)
To: Eric Anholt; +Cc: dri-devel, linux-kernel
On Wed, 21 Jun 2017 11:49:59 -0700
Eric Anholt <eric@anholt.net> wrote:
> This way drm_atomic_helper_wait_for_fences() will actually do
> something. The vc4_seqno_cb has been doing the fence waits on V3D
> manually, so far.
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/gpu/drm/vc4/vc4_plane.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
> index fa6809d8b0fe..8853e9a4f005 100644
> --- a/drivers/gpu/drm/vc4/vc4_plane.c
> +++ b/drivers/gpu/drm/vc4/vc4_plane.c
> @@ -759,9 +759,26 @@ void vc4_plane_async_set_fb(struct drm_plane *plane, struct drm_framebuffer *fb)
> vc4_state->dlist[vc4_state->ptr0_offset] = addr;
> }
>
> +static int vc4_prepare_fb(struct drm_plane *plane,
> + struct drm_plane_state *state)
> +{
> + struct vc4_bo *bo;
> + struct dma_fence *fence;
> +
> + if ((plane->state->fb == state->fb) || !state->fb)
> + return 0;
> +
> + bo = to_vc4_bo(&drm_fb_cma_get_gem_obj(state->fb, 0)->base);
> + fence = reservation_object_get_excl_rcu(bo->resv);
> + drm_atomic_set_fence_for_plane(state, fence);
> +
> + return 0;
> +}
> +
> static const struct drm_plane_helper_funcs vc4_plane_helper_funcs = {
> .atomic_check = vc4_plane_atomic_check,
> .atomic_update = vc4_plane_atomic_update,
> + .prepare_fb = vc4_prepare_fb,
> };
>
> static void vc4_plane_destroy(struct drm_plane *plane)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] drm/vc4: Use the atomic state's commit workqueue.
2017-06-21 18:50 ` [PATCH 3/4] drm/vc4: Use the atomic state's commit workqueue Eric Anholt
2017-06-22 7:16 ` Daniel Vetter
@ 2017-06-22 8:06 ` Boris Brezillon
1 sibling, 0 replies; 10+ messages in thread
From: Boris Brezillon @ 2017-06-22 8:06 UTC (permalink / raw)
To: Eric Anholt; +Cc: dri-devel, linux-kernel
On Wed, 21 Jun 2017 11:50:01 -0700
Eric Anholt <eric@anholt.net> wrote:
> Now that we're using the atomic helpers for fence waits, we can use
> the same codepath as drm_atomic_helper_commit() does for async,
> getting rid of our custom vc4_commit struct.
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
And with this rework, you also fix the leak I introduced in commit
34c8ea400ff6 ("drm/vc4: Mimic drm_atomic_helper_commit() behavior").
> ---
> drivers/gpu/drm/vc4/vc4_kms.c | 71 ++++++++-----------------------------------
> 1 file changed, 13 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
> index 6b1ccea76243..b371879c3901 100644
> --- a/drivers/gpu/drm/vc4/vc4_kms.c
> +++ b/drivers/gpu/drm/vc4/vc4_kms.c
> @@ -29,16 +29,9 @@ static void vc4_output_poll_changed(struct drm_device *dev)
> drm_fbdev_cma_hotplug_event(vc4->fbdev);
> }
>
> -struct vc4_commit {
> - struct drm_device *dev;
> - struct drm_atomic_state *state;
> - struct vc4_seqno_cb cb;
> -};
> -
> static void
> -vc4_atomic_complete_commit(struct vc4_commit *c)
> +vc4_atomic_complete_commit(struct drm_atomic_state *state)
> {
> - struct drm_atomic_state *state = c->state;
> struct drm_device *dev = state->dev;
> struct vc4_dev *vc4 = to_vc4_dev(dev);
>
> @@ -72,28 +65,14 @@ vc4_atomic_complete_commit(struct vc4_commit *c)
> drm_atomic_state_put(state);
>
> up(&vc4->async_modeset);
> -
> - kfree(c);
> -}
> -
> -static void
> -vc4_atomic_complete_commit_seqno_cb(struct vc4_seqno_cb *cb)
> -{
> - struct vc4_commit *c = container_of(cb, struct vc4_commit, cb);
> -
> - vc4_atomic_complete_commit(c);
> }
>
> -static struct vc4_commit *commit_init(struct drm_atomic_state *state)
> +static void commit_work(struct work_struct *work)
> {
> - struct vc4_commit *c = kzalloc(sizeof(*c), GFP_KERNEL);
> -
> - if (!c)
> - return NULL;
> - c->dev = state->dev;
> - c->state = state;
> -
> - return c;
> + struct drm_atomic_state *state = container_of(work,
> + struct drm_atomic_state,
> + commit_work);
> + vc4_atomic_complete_commit(state);
> }
>
> /**
> @@ -115,29 +94,19 @@ static int vc4_atomic_commit(struct drm_device *dev,
> {
> struct vc4_dev *vc4 = to_vc4_dev(dev);
> int ret;
> - int i;
> - uint64_t wait_seqno = 0;
> - struct vc4_commit *c;
> - struct drm_plane *plane;
> - struct drm_plane_state *new_state;
> -
> - c = commit_init(state);
> - if (!c)
> - return -ENOMEM;
>
> ret = drm_atomic_helper_setup_commit(state, nonblock);
> if (ret)
> return ret;
>
> + INIT_WORK(&state->commit_work, commit_work);
> +
> ret = down_interruptible(&vc4->async_modeset);
> - if (ret) {
> - kfree(c);
> + if (ret)
> return ret;
> - }
>
> ret = drm_atomic_helper_prepare_planes(dev, state);
> if (ret) {
> - kfree(c);
> up(&vc4->async_modeset);
> return ret;
> }
> @@ -146,22 +115,11 @@ static int vc4_atomic_commit(struct drm_device *dev,
> ret = drm_atomic_helper_wait_for_fences(dev, state, true);
> if (ret) {
> drm_atomic_helper_cleanup_planes(dev, state);
> - kfree(c);
> up(&vc4->async_modeset);
> return ret;
> }
> }
>
> - for_each_plane_in_state(state, plane, new_state, i) {
> - if ((plane->state->fb != new_state->fb) && new_state->fb) {
> - struct drm_gem_cma_object *cma_bo =
> - drm_fb_cma_get_gem_obj(new_state->fb, 0);
> - struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
> -
> - wait_seqno = max(bo->seqno, wait_seqno);
> - }
> - }
> -
> /*
> * This is the point of no return - everything below never fails except
> * when the hw goes bonghits. Which means we can commit the new state on
> @@ -187,13 +145,10 @@ static int vc4_atomic_commit(struct drm_device *dev,
> */
>
> drm_atomic_state_get(state);
> - if (nonblock) {
> - vc4_queue_seqno_cb(dev, &c->cb, wait_seqno,
> - vc4_atomic_complete_commit_seqno_cb);
> - } else {
> - vc4_wait_for_seqno(dev, wait_seqno, ~0ull, false);
> - vc4_atomic_complete_commit(c);
> - }
> + if (nonblock)
> + queue_work(system_unbound_wq, &state->commit_work);
> + else
> + vc4_atomic_complete_commit(state);
>
> return 0;
> }
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] drm/vc4: Use the atomic state's commit workqueue.
2017-06-22 7:16 ` Daniel Vetter
@ 2017-06-22 18:27 ` Eric Anholt
0 siblings, 0 replies; 10+ messages in thread
From: Eric Anholt @ 2017-06-22 18:27 UTC (permalink / raw)
To: Daniel Vetter; +Cc: dri-devel, Boris Brezillon, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 518 bytes --]
Daniel Vetter <daniel@ffwll.ch> writes:
> On Wed, Jun 21, 2017 at 11:50:01AM -0700, Eric Anholt wrote:
>> Now that we're using the atomic helpers for fence waits, we can use
>> the same codepath as drm_atomic_helper_commit() does for async,
>> getting rid of our custom vc4_commit struct.
>
> \o/
>
> On the series: Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Applied the reviews and acks and pushed.
Next, what would it take to get rid of the async_modeset semaphore so we
can use the core helpers even more?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-06-22 18:27 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21 18:49 [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations Eric Anholt
2017-06-21 18:50 ` [PATCH 2/4] drm/vc4: Wait for fences interruptibly in blocking mode Eric Anholt
2017-06-22 7:22 ` Boris Brezillon
2017-06-21 18:50 ` [PATCH 3/4] drm/vc4: Use the atomic state's commit workqueue Eric Anholt
2017-06-22 7:16 ` Daniel Vetter
2017-06-22 18:27 ` Eric Anholt
2017-06-22 8:06 ` Boris Brezillon
2017-06-21 18:50 ` [PATCH 4/4] drm/vc4: Remove dead vc4_event_pending() Eric Anholt
2017-06-21 19:54 ` Boris Brezillon
2017-06-22 8:03 ` [PATCH 1/4] drm/vc4: Hook up plane prepare_fb to lookup dma-buf reservations Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).