Commit 2a11d881 authored by Daniel Vetter's avatar Daniel Vetter

drm/mediatek: Use drm_atomic_helper_wait_for_fences

If we use the gem fb helper as the prepare_fb hook, plus the
drm_prime.c import helpers now automatically setting obj->resv, we can
use the shared helpers to wait for fences instead of rolling our own.
Note that this relies on mtk setting drm_fb->obj, which is already
done in mtk_drm_framebuffer_init().

Aside: Probably can use the default commit_tail with this again, but I
didn't check for that.
Reviewed-by: default avatarCK Hu <ck.hu@mediatek.com>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Cc: CK Hu <ck.hu@mediatek.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Link: https://patchwork.freedesktop.org/patch/msgid/20190614203615.12639-45-daniel.vetter@ffwll.ch
parent 0fbbd27e
...@@ -38,22 +38,12 @@ static void mtk_atomic_schedule(struct mtk_drm_private *private, ...@@ -38,22 +38,12 @@ static void mtk_atomic_schedule(struct mtk_drm_private *private,
schedule_work(&private->commit.work); schedule_work(&private->commit.work);
} }
static void mtk_atomic_wait_for_fences(struct drm_atomic_state *state)
{
struct drm_plane *plane;
struct drm_plane_state *new_plane_state;
int i;
for_each_new_plane_in_state(state, plane, new_plane_state, i)
mtk_fb_wait(new_plane_state->fb);
}
static void mtk_atomic_complete(struct mtk_drm_private *private, static void mtk_atomic_complete(struct mtk_drm_private *private,
struct drm_atomic_state *state) struct drm_atomic_state *state)
{ {
struct drm_device *drm = private->drm; struct drm_device *drm = private->drm;
mtk_atomic_wait_for_fences(state); drm_atomic_helper_wait_for_fences(drm, state, false);
/* /*
* Mediatek drm supports runtime PM, so plane registers cannot be * Mediatek drm supports runtime PM, so plane registers cannot be
......
...@@ -49,34 +49,6 @@ static struct drm_framebuffer *mtk_drm_framebuffer_init(struct drm_device *dev, ...@@ -49,34 +49,6 @@ static struct drm_framebuffer *mtk_drm_framebuffer_init(struct drm_device *dev,
return fb; return fb;
} }
/*
* Wait for any exclusive fence in fb's gem object's reservation object.
*
* Returns -ERESTARTSYS if interrupted, else 0.
*/
int mtk_fb_wait(struct drm_framebuffer *fb)
{
struct drm_gem_object *gem;
struct reservation_object *resv;
long ret;
if (!fb)
return 0;
gem = fb->obj[0];
if (!gem || !gem->dma_buf || !gem->dma_buf->resv)
return 0;
resv = gem->dma_buf->resv;
ret = reservation_object_wait_timeout_rcu(resv, false, true,
MAX_SCHEDULE_TIMEOUT);
/* MAX_SCHEDULE_TIMEOUT on success, -ERESTARTSYS if interrupted */
if (WARN_ON(ret < 0))
return ret;
return 0;
}
struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev, struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
struct drm_file *file, struct drm_file *file,
const struct drm_mode_fb_cmd2 *cmd) const struct drm_mode_fb_cmd2 *cmd)
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#ifndef MTK_DRM_FB_H #ifndef MTK_DRM_FB_H
#define MTK_DRM_FB_H #define MTK_DRM_FB_H
int mtk_fb_wait(struct drm_framebuffer *fb);
struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev, struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
struct drm_file *file, struct drm_file *file,
const struct drm_mode_fb_cmd2 *cmd); const struct drm_mode_fb_cmd2 *cmd);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <drm/drm_atomic.h> #include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_plane_helper.h> #include <drm/drm_plane_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include "mtk_drm_crtc.h" #include "mtk_drm_crtc.h"
#include "mtk_drm_ddp_comp.h" #include "mtk_drm_ddp_comp.h"
...@@ -146,6 +147,7 @@ static void mtk_plane_atomic_disable(struct drm_plane *plane, ...@@ -146,6 +147,7 @@ static void mtk_plane_atomic_disable(struct drm_plane *plane,
} }
static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = { static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = {
.prepare_fb = drm_gem_fb_prepare_fb,
.atomic_check = mtk_plane_atomic_check, .atomic_check = mtk_plane_atomic_check,
.atomic_update = mtk_plane_atomic_update, .atomic_update = mtk_plane_atomic_update,
.atomic_disable = mtk_plane_atomic_disable, .atomic_disable = mtk_plane_atomic_disable,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment