* [PATCH V4 1/2] drm/fb_cma_helper: Add drm_fb_cma_prepare_fb() helper @ 2016-11-14 10:07 Marek Vasut 2016-11-14 10:07 ` [PATCH V4 2/2] drm/imx: Switch to " Marek Vasut 2016-11-14 10:32 ` [PATCH V4 1/2] drm/fb_cma_helper: Add " Lucas Stach 0 siblings, 2 replies; 5+ messages in thread From: Marek Vasut @ 2016-11-14 10:07 UTC (permalink / raw) To: dri-devel; +Cc: Marek Vasut, Daniel Vetter Add new drm_fb_cma_prepare_fb() helper function extracted from the imx-drm driver. This function checks if the plane has DMABUF attached to it, extracts the exclusive fence from it and attaches it to the plane state for the atomic helper to wait on it. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Lucas Stach <l.stach@pengutronix.de> --- V2: Rename the function to drm_fb_cma_prepare_fb() and clarify the documentation (thanks to Lucas Stach) V3: - Rename the function to drm_fb_cma_prepare_fb() - Update documentation V4: Update to latest next/master (b60de3e) --- drivers/gpu/drm/drm_fb_cma_helper.c | 35 +++++++++++++++++++++++++++++++++++ include/drm/drm_fb_cma_helper.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 4c66644..7198373 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -18,13 +18,16 @@ */ #include <drm/drmP.h> +#include <drm/drm_atomic.h> #include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_fb_cma_helper.h> +#include <linux/dma-buf.h> #include <linux/dma-mapping.h> #include <linux/module.h> +#include <linux/reservation.h> #define DEFAULT_FBDEFIO_DELAY_MS 50 @@ -265,6 +268,38 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, } EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj); +/** + * drm_fb_cma_prepare_fb() - Prepare CMA framebuffer + * @plane: Which plane + * @state: Plane state attach fence to + * + * This should be put into prepare_fb hook of struct &drm_plane_helper_funcs . + * + * This function checks if the plane FB has an dma-buf attached, extracts + * the exclusive fence and attaches it to plane state for the atomic helper + * to wait on. + * + * There is no need for cleanup_fb for CMA based framebuffer drivers. + */ +int drm_fb_cma_prepare_fb(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct dma_buf *dma_buf; + struct dma_fence *fence; + + if ((plane->state->fb == state->fb) || !state->fb) + return 0; + + dma_buf = drm_fb_cma_get_gem_obj(state->fb, 0)->base.dma_buf; + if (dma_buf) { + fence = reservation_object_get_excl_rcu(dma_buf->resv); + drm_atomic_set_fence_for_plane(state, fence); + } + + return 0; +} +EXPORT_SYMBOL_GPL(drm_fb_cma_prepare_fb); + #ifdef CONFIG_DEBUG_FS static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m) { diff --git a/include/drm/drm_fb_cma_helper.h b/include/drm/drm_fb_cma_helper.h index f313211..cc82c73 100644 --- a/include/drm/drm_fb_cma_helper.h +++ b/include/drm/drm_fb_cma_helper.h @@ -41,6 +41,9 @@ struct drm_framebuffer *drm_fb_cma_create(struct drm_device *dev, struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, unsigned int plane); +int drm_fb_cma_prepare_fb(struct drm_plane *plane, + struct drm_plane_state *state); + #ifdef CONFIG_DEBUG_FS struct seq_file; -- 2.10.2 _______________________________________________ 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
* [PATCH V4 2/2] drm/imx: Switch to drm_fb_cma_prepare_fb() helper 2016-11-14 10:07 [PATCH V4 1/2] drm/fb_cma_helper: Add drm_fb_cma_prepare_fb() helper Marek Vasut @ 2016-11-14 10:07 ` Marek Vasut 2016-11-14 10:32 ` Lucas Stach 2016-11-14 10:32 ` [PATCH V4 1/2] drm/fb_cma_helper: Add " Lucas Stach 1 sibling, 1 reply; 5+ messages in thread From: Marek Vasut @ 2016-11-14 10:07 UTC (permalink / raw) To: dri-devel; +Cc: Marek Vasut, Daniel Vetter Remove the common code from the driver and use the drm_fb_cma_prepare_fb() helper instead. Moveover, call the helper from prepare_fb() plane hook . Signed-off-by: Marek Vasut <marex@denx.de> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Lucas Stach <l.stach@pengutronix.de> --- V2: - Rename the function to drm_fb_cma_extract_and_attach_fence() - Add missing newline V3: - Call drm_fb_cma_prepare_fb directly V4: - Update to latest next/master (b60de3e) --- drivers/gpu/drm/imx/imx-drm-core.c | 32 +------------------------------- drivers/gpu/drm/imx/ipuv3-plane.c | 1 + 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index a16e8b7..3340429 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -18,7 +18,6 @@ #include <linux/dma-buf.h> #include <linux/module.h> #include <linux/platform_device.h> -#include <linux/reservation.h> #include <drm/drmP.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> @@ -151,40 +150,11 @@ static int imx_drm_atomic_check(struct drm_device *dev, return ret; } -static int imx_drm_atomic_commit(struct drm_device *dev, - struct drm_atomic_state *state, - bool nonblock) -{ - struct drm_plane_state *plane_state; - struct drm_plane *plane; - struct dma_buf *dma_buf; - struct dma_fence *fence; - int i; - - /* - * If the plane fb has an dma-buf attached, fish out the exclusive - * fence for the atomic helper to wait on. - */ - for_each_plane_in_state(state, plane, plane_state, i) { - if ((plane->state->fb != plane_state->fb) && plane_state->fb) { - dma_buf = drm_fb_cma_get_gem_obj(plane_state->fb, - 0)->base.dma_buf; - if (!dma_buf) - continue; - fence = reservation_object_get_excl_rcu(dma_buf->resv); - - drm_atomic_set_fence_for_plane(plane_state, fence); - } - } - - return drm_atomic_helper_commit(dev, state, nonblock); -} - static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { .fb_create = drm_fb_cma_create, .output_poll_changed = imx_drm_output_poll_changed, .atomic_check = imx_drm_atomic_check, - .atomic_commit = imx_drm_atomic_commit, + .atomic_commit = drm_atomic_helper_commit, }; static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state) diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c index 6a97e396..e74a0ad 100644 --- a/drivers/gpu/drm/imx/ipuv3-plane.c +++ b/drivers/gpu/drm/imx/ipuv3-plane.c @@ -468,6 +468,7 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, } static const struct drm_plane_helper_funcs ipu_plane_helper_funcs = { + .prepare_fb = drm_fb_cma_prepare_fb, .atomic_check = ipu_plane_atomic_check, .atomic_disable = ipu_plane_atomic_disable, .atomic_update = ipu_plane_atomic_update, -- 2.10.2 _______________________________________________ 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 V4 2/2] drm/imx: Switch to drm_fb_cma_prepare_fb() helper 2016-11-14 10:07 ` [PATCH V4 2/2] drm/imx: Switch to " Marek Vasut @ 2016-11-14 10:32 ` Lucas Stach 2016-11-14 11:44 ` Daniel Vetter 0 siblings, 1 reply; 5+ messages in thread From: Lucas Stach @ 2016-11-14 10:32 UTC (permalink / raw) To: Marek Vasut; +Cc: Daniel Vetter, dri-devel Am Montag, den 14.11.2016, 11:07 +0100 schrieb Marek Vasut: > Remove the common code from the driver and use the > drm_fb_cma_prepare_fb() helper instead. > Moveover, call the helper from prepare_fb() plane hook . > > Signed-off-by: Marek Vasut <marex@denx.de> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch> > Cc: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Lucas Stach <l.stach@pengutronix.de> > --- > V2: - Rename the function to drm_fb_cma_extract_and_attach_fence() > - Add missing newline > V3: - Call drm_fb_cma_prepare_fb directly > V4: - Update to latest next/master (b60de3e) > --- > drivers/gpu/drm/imx/imx-drm-core.c | 32 +------------------------------- > drivers/gpu/drm/imx/ipuv3-plane.c | 1 + > 2 files changed, 2 insertions(+), 31 deletions(-) > > diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c > index a16e8b7..3340429 100644 > --- a/drivers/gpu/drm/imx/imx-drm-core.c > +++ b/drivers/gpu/drm/imx/imx-drm-core.c > @@ -18,7 +18,6 @@ > #include <linux/dma-buf.h> > #include <linux/module.h> > #include <linux/platform_device.h> > -#include <linux/reservation.h> > #include <drm/drmP.h> > #include <drm/drm_atomic.h> > #include <drm/drm_atomic_helper.h> > @@ -151,40 +150,11 @@ static int imx_drm_atomic_check(struct drm_device *dev, > return ret; > } > > -static int imx_drm_atomic_commit(struct drm_device *dev, > - struct drm_atomic_state *state, > - bool nonblock) > -{ > - struct drm_plane_state *plane_state; > - struct drm_plane *plane; > - struct dma_buf *dma_buf; > - struct dma_fence *fence; > - int i; > - > - /* > - * If the plane fb has an dma-buf attached, fish out the exclusive > - * fence for the atomic helper to wait on. > - */ > - for_each_plane_in_state(state, plane, plane_state, i) { > - if ((plane->state->fb != plane_state->fb) && plane_state->fb) { > - dma_buf = drm_fb_cma_get_gem_obj(plane_state->fb, > - 0)->base.dma_buf; > - if (!dma_buf) > - continue; > - fence = reservation_object_get_excl_rcu(dma_buf->resv); > - > - drm_atomic_set_fence_for_plane(plane_state, fence); > - } > - } > - > - return drm_atomic_helper_commit(dev, state, nonblock); > -} > - > static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { > .fb_create = drm_fb_cma_create, > .output_poll_changed = imx_drm_output_poll_changed, > .atomic_check = imx_drm_atomic_check, > - .atomic_commit = imx_drm_atomic_commit, > + .atomic_commit = drm_atomic_helper_commit, > }; > > static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state) > diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c > index 6a97e396..e74a0ad 100644 > --- a/drivers/gpu/drm/imx/ipuv3-plane.c > +++ b/drivers/gpu/drm/imx/ipuv3-plane.c > @@ -468,6 +468,7 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, > } > > static const struct drm_plane_helper_funcs ipu_plane_helper_funcs = { > + .prepare_fb = drm_fb_cma_prepare_fb, > .atomic_check = ipu_plane_atomic_check, > .atomic_disable = ipu_plane_atomic_disable, > .atomic_update = ipu_plane_atomic_update, _______________________________________________ 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
* Re: [PATCH V4 2/2] drm/imx: Switch to drm_fb_cma_prepare_fb() helper 2016-11-14 10:32 ` Lucas Stach @ 2016-11-14 11:44 ` Daniel Vetter 0 siblings, 0 replies; 5+ messages in thread From: Daniel Vetter @ 2016-11-14 11:44 UTC (permalink / raw) To: Lucas Stach; +Cc: Marek Vasut, Daniel Vetter, dri-devel On Mon, Nov 14, 2016 at 11:32:47AM +0100, Lucas Stach wrote: > Am Montag, den 14.11.2016, 11:07 +0100 schrieb Marek Vasut: > > Remove the common code from the driver and use the > > drm_fb_cma_prepare_fb() helper instead. > > Moveover, call the helper from prepare_fb() plane hook . > > > > Signed-off-by: Marek Vasut <marex@denx.de> > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch> > > Cc: Lucas Stach <l.stach@pengutronix.de> > > Reviewed-by: Lucas Stach <l.stach@pengutronix.de> Both patches applied to drm-misc, thanks. -Daniel > > > --- > > V2: - Rename the function to drm_fb_cma_extract_and_attach_fence() > > - Add missing newline > > V3: - Call drm_fb_cma_prepare_fb directly > > V4: - Update to latest next/master (b60de3e) > > --- > > drivers/gpu/drm/imx/imx-drm-core.c | 32 +------------------------------- > > drivers/gpu/drm/imx/ipuv3-plane.c | 1 + > > 2 files changed, 2 insertions(+), 31 deletions(-) > > > > diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c > > index a16e8b7..3340429 100644 > > --- a/drivers/gpu/drm/imx/imx-drm-core.c > > +++ b/drivers/gpu/drm/imx/imx-drm-core.c > > @@ -18,7 +18,6 @@ > > #include <linux/dma-buf.h> > > #include <linux/module.h> > > #include <linux/platform_device.h> > > -#include <linux/reservation.h> > > #include <drm/drmP.h> > > #include <drm/drm_atomic.h> > > #include <drm/drm_atomic_helper.h> > > @@ -151,40 +150,11 @@ static int imx_drm_atomic_check(struct drm_device *dev, > > return ret; > > } > > > > -static int imx_drm_atomic_commit(struct drm_device *dev, > > - struct drm_atomic_state *state, > > - bool nonblock) > > -{ > > - struct drm_plane_state *plane_state; > > - struct drm_plane *plane; > > - struct dma_buf *dma_buf; > > - struct dma_fence *fence; > > - int i; > > - > > - /* > > - * If the plane fb has an dma-buf attached, fish out the exclusive > > - * fence for the atomic helper to wait on. > > - */ > > - for_each_plane_in_state(state, plane, plane_state, i) { > > - if ((plane->state->fb != plane_state->fb) && plane_state->fb) { > > - dma_buf = drm_fb_cma_get_gem_obj(plane_state->fb, > > - 0)->base.dma_buf; > > - if (!dma_buf) > > - continue; > > - fence = reservation_object_get_excl_rcu(dma_buf->resv); > > - > > - drm_atomic_set_fence_for_plane(plane_state, fence); > > - } > > - } > > - > > - return drm_atomic_helper_commit(dev, state, nonblock); > > -} > > - > > static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { > > .fb_create = drm_fb_cma_create, > > .output_poll_changed = imx_drm_output_poll_changed, > > .atomic_check = imx_drm_atomic_check, > > - .atomic_commit = imx_drm_atomic_commit, > > + .atomic_commit = drm_atomic_helper_commit, > > }; > > > > static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state) > > diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c > > index 6a97e396..e74a0ad 100644 > > --- a/drivers/gpu/drm/imx/ipuv3-plane.c > > +++ b/drivers/gpu/drm/imx/ipuv3-plane.c > > @@ -468,6 +468,7 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, > > } > > > > static const struct drm_plane_helper_funcs ipu_plane_helper_funcs = { > > + .prepare_fb = drm_fb_cma_prepare_fb, > > .atomic_check = ipu_plane_atomic_check, > > .atomic_disable = ipu_plane_atomic_disable, > > .atomic_update = ipu_plane_atomic_update, > > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ 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
* Re: [PATCH V4 1/2] drm/fb_cma_helper: Add drm_fb_cma_prepare_fb() helper 2016-11-14 10:07 [PATCH V4 1/2] drm/fb_cma_helper: Add drm_fb_cma_prepare_fb() helper Marek Vasut 2016-11-14 10:07 ` [PATCH V4 2/2] drm/imx: Switch to " Marek Vasut @ 2016-11-14 10:32 ` Lucas Stach 1 sibling, 0 replies; 5+ messages in thread From: Lucas Stach @ 2016-11-14 10:32 UTC (permalink / raw) To: Marek Vasut; +Cc: Daniel Vetter, dri-devel Am Montag, den 14.11.2016, 11:07 +0100 schrieb Marek Vasut: > Add new drm_fb_cma_prepare_fb() helper function extracted from the > imx-drm driver. This function checks if the plane has DMABUF attached > to it, extracts the exclusive fence from it and attaches it to the > plane state for the atomic helper to wait on it. > > Signed-off-by: Marek Vasut <marex@denx.de> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch> > Cc: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Lucas Stach <l.stach@pengutronix.de> > --- > V2: Rename the function to drm_fb_cma_prepare_fb() > and clarify the documentation (thanks to Lucas Stach) > V3: - Rename the function to drm_fb_cma_prepare_fb() > - Update documentation > V4: Update to latest next/master (b60de3e) > --- > drivers/gpu/drm/drm_fb_cma_helper.c | 35 +++++++++++++++++++++++++++++++++++ > include/drm/drm_fb_cma_helper.h | 3 +++ > 2 files changed, 38 insertions(+) > > diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c > index 4c66644..7198373 100644 > --- a/drivers/gpu/drm/drm_fb_cma_helper.c > +++ b/drivers/gpu/drm/drm_fb_cma_helper.c > @@ -18,13 +18,16 @@ > */ > > #include <drm/drmP.h> > +#include <drm/drm_atomic.h> > #include <drm/drm_crtc.h> > #include <drm/drm_fb_helper.h> > #include <drm/drm_crtc_helper.h> > #include <drm/drm_gem_cma_helper.h> > #include <drm/drm_fb_cma_helper.h> > +#include <linux/dma-buf.h> > #include <linux/dma-mapping.h> > #include <linux/module.h> > +#include <linux/reservation.h> > > #define DEFAULT_FBDEFIO_DELAY_MS 50 > > @@ -265,6 +268,38 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, > } > EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj); > > +/** > + * drm_fb_cma_prepare_fb() - Prepare CMA framebuffer > + * @plane: Which plane > + * @state: Plane state attach fence to > + * > + * This should be put into prepare_fb hook of struct &drm_plane_helper_funcs . > + * > + * This function checks if the plane FB has an dma-buf attached, extracts > + * the exclusive fence and attaches it to plane state for the atomic helper > + * to wait on. > + * > + * There is no need for cleanup_fb for CMA based framebuffer drivers. > + */ > +int drm_fb_cma_prepare_fb(struct drm_plane *plane, > + struct drm_plane_state *state) > +{ > + struct dma_buf *dma_buf; > + struct dma_fence *fence; > + > + if ((plane->state->fb == state->fb) || !state->fb) > + return 0; > + > + dma_buf = drm_fb_cma_get_gem_obj(state->fb, 0)->base.dma_buf; > + if (dma_buf) { > + fence = reservation_object_get_excl_rcu(dma_buf->resv); > + drm_atomic_set_fence_for_plane(state, fence); > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(drm_fb_cma_prepare_fb); > + > #ifdef CONFIG_DEBUG_FS > static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m) > { > diff --git a/include/drm/drm_fb_cma_helper.h b/include/drm/drm_fb_cma_helper.h > index f313211..cc82c73 100644 > --- a/include/drm/drm_fb_cma_helper.h > +++ b/include/drm/drm_fb_cma_helper.h > @@ -41,6 +41,9 @@ struct drm_framebuffer *drm_fb_cma_create(struct drm_device *dev, > struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, > unsigned int plane); > > +int drm_fb_cma_prepare_fb(struct drm_plane *plane, > + struct drm_plane_state *state); > + > #ifdef CONFIG_DEBUG_FS > struct seq_file; > _______________________________________________ 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
end of thread, other threads:[~2016-11-14 11:44 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-11-14 10:07 [PATCH V4 1/2] drm/fb_cma_helper: Add drm_fb_cma_prepare_fb() helper Marek Vasut 2016-11-14 10:07 ` [PATCH V4 2/2] drm/imx: Switch to " Marek Vasut 2016-11-14 10:32 ` Lucas Stach 2016-11-14 11:44 ` Daniel Vetter 2016-11-14 10:32 ` [PATCH V4 1/2] drm/fb_cma_helper: Add " Lucas Stach
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.