Skip to content

Commit

Permalink
drm/msm: Move implicit sync handling to prepare_fb
Browse files Browse the repository at this point in the history
In preparation for moving to atomic helpers, move the implicit sync
fence handling out of atomic commit and into the plane->prepare_fb()
hook. While we're at it, de-duplicate the mdp*_prepare_fb functions.

Changes in v4:
- Added

Reported-by: Rob Clark <[email protected]>
Signed-off-by: Sean Paul <[email protected]>
Signed-off-by: Rob Clark <[email protected]>
  • Loading branch information
atseanpaul authored and robclark committed Jun 4, 2018
1 parent 347b90b commit db8f4d5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 31 deletions.
17 changes: 1 addition & 16 deletions drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,6 @@ static const struct drm_plane_funcs mdp4_plane_funcs = {
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
};

static int mdp4_plane_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *new_state)
{
struct mdp4_plane *mdp4_plane = to_mdp4_plane(plane);
struct mdp4_kms *mdp4_kms = get_kms(plane);
struct msm_kms *kms = &mdp4_kms->base.base;
struct drm_framebuffer *fb = new_state->fb;

if (!fb)
return 0;

DBG("%s: prepare: FB[%u]", mdp4_plane->name, fb->base.id);
return msm_framebuffer_prepare(fb, kms->aspace);
}

static void mdp4_plane_cleanup_fb(struct drm_plane *plane,
struct drm_plane_state *old_state)
{
Expand Down Expand Up @@ -152,7 +137,7 @@ static void mdp4_plane_atomic_update(struct drm_plane *plane,
}

static const struct drm_plane_helper_funcs mdp4_plane_helper_funcs = {
.prepare_fb = mdp4_plane_prepare_fb,
.prepare_fb = msm_atomic_prepare_fb,
.cleanup_fb = mdp4_plane_cleanup_fb,
.atomic_check = mdp4_plane_atomic_check,
.atomic_update = mdp4_plane_atomic_update,
Expand Down
16 changes: 1 addition & 15 deletions drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,6 @@ static const struct drm_plane_funcs mdp5_plane_funcs = {
.atomic_print_state = mdp5_plane_atomic_print_state,
};

static int mdp5_plane_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *new_state)
{
struct mdp5_kms *mdp5_kms = get_kms(plane);
struct msm_kms *kms = &mdp5_kms->base.base;
struct drm_framebuffer *fb = new_state->fb;

if (!new_state->fb)
return 0;

DBG("%s: prepare: FB[%u]", plane->name, fb->base.id);
return msm_framebuffer_prepare(fb, kms->aspace);
}

static void mdp5_plane_cleanup_fb(struct drm_plane *plane,
struct drm_plane_state *old_state)
{
Expand Down Expand Up @@ -543,7 +529,7 @@ static void mdp5_plane_atomic_async_update(struct drm_plane *plane,
}

static const struct drm_plane_helper_funcs mdp5_plane_helper_funcs = {
.prepare_fb = mdp5_plane_prepare_fb,
.prepare_fb = msm_atomic_prepare_fb,
.cleanup_fb = mdp5_plane_cleanup_fb,
.atomic_check = mdp5_plane_atomic_check,
.atomic_update = mdp5_plane_atomic_update,
Expand Down
22 changes: 22 additions & 0 deletions drivers/gpu/drm/msm/msm_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "msm_drv.h"
#include "msm_gem.h"
#include "msm_kms.h"
#include "msm_gem.h"
#include "msm_fence.h"
Expand Down Expand Up @@ -97,6 +98,27 @@ static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
}
}

int msm_atomic_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *new_state)
{
struct msm_drm_private *priv = plane->dev->dev_private;
struct msm_kms *kms = priv->kms;
struct drm_gem_object *obj;
struct msm_gem_object *msm_obj;
struct dma_fence *fence;

if (!new_state->fb)
return 0;

obj = msm_framebuffer_bo(new_state->fb, 0);
msm_obj = to_msm_bo(obj);
fence = reservation_object_get_excl_rcu(msm_obj->resv);

drm_atomic_set_fence_for_plane(new_state, fence);

return msm_framebuffer_prepare(new_state->fb, kms->aspace);
}

static void msm_atomic_commit_tail(struct drm_atomic_state *state)
{
struct drm_device *dev = state->dev;
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/msm/msm_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ struct msm_format {
uint32_t pixel_format;
};

int msm_atomic_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *new_state);
int msm_atomic_commit(struct drm_device *dev,
struct drm_atomic_state *state, bool nonblock);
struct drm_atomic_state *msm_atomic_state_alloc(struct drm_device *dev);
Expand Down

0 comments on commit db8f4d5

Please sign in to comment.