mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
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: CK Hu <ck.hu@mediatek.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Daniel 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
This commit is contained in:
parent
0fbbd27e5a
commit
2a11d88125
@ -38,22 +38,12 @@ static void mtk_atomic_schedule(struct mtk_drm_private *private,
|
||||
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,
|
||||
struct drm_atomic_state *state)
|
||||
{
|
||||
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
|
||||
|
@ -49,34 +49,6 @@ static struct drm_framebuffer *mtk_drm_framebuffer_init(struct drm_device *dev,
|
||||
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_file *file,
|
||||
const struct drm_mode_fb_cmd2 *cmd)
|
||||
|
@ -6,7 +6,6 @@
|
||||
#ifndef 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_file *file,
|
||||
const struct drm_mode_fb_cmd2 *cmd);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <drm/drm_atomic.h>
|
||||
#include <drm/drm_atomic_helper.h>
|
||||
#include <drm/drm_plane_helper.h>
|
||||
#include <drm/drm_gem_framebuffer_helper.h>
|
||||
|
||||
#include "mtk_drm_crtc.h"
|
||||
#include "mtk_drm_ddp_comp.h"
|
||||
@ -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 = {
|
||||
.prepare_fb = drm_gem_fb_prepare_fb,
|
||||
.atomic_check = mtk_plane_atomic_check,
|
||||
.atomic_update = mtk_plane_atomic_update,
|
||||
.atomic_disable = mtk_plane_atomic_disable,
|
||||
|
Loading…
Reference in New Issue
Block a user