Commit 7907a0d7 authored by Archit Taneja's avatar Archit Taneja Committed by Rob Clark

drm/msm/mdp5: Use the new private_obj state

This replaces the usage of the subclassed atomic state (mdp5_state)
with a private_obj state embedded within drm_atomic_state. The latter
method is the preferred approach, since it's simpler to implement
and less prone to errors.

The new API replaces the older and equivalent mdp5_state usage in the
following pattern:
- References to "mdp5_kms->state" (i.e, the old/existing state) is
  replaced with mdp5_get_existing_global_state(). In the atomic_check
  path, this should be called with the glob_state_lock drm_modeset_lock
  alredy taken.
- References to "mdp5_get_state()" are replaced with
  mdp5_get_global_state(). This acquires glob_state_lock and uses
  drm_atomic_get_private_obj_state() to create a new duplicated state.

Changes in v3:
- Acquire glob_state_lock in mdp5_smp.c
- Added to the msm atomic helper patch set
Changes in v4:
- None
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
parent 8d58ef34
...@@ -190,20 +190,26 @@ static void mdp5_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *st ...@@ -190,20 +190,26 @@ static void mdp5_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *st
{ {
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms)); struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
struct device *dev = &mdp5_kms->pdev->dev; struct device *dev = &mdp5_kms->pdev->dev;
struct mdp5_global_state *global_state;
global_state = mdp5_get_existing_global_state(mdp5_kms);
pm_runtime_get_sync(dev); pm_runtime_get_sync(dev);
if (mdp5_kms->smp) if (mdp5_kms->smp)
mdp5_smp_prepare_commit(mdp5_kms->smp, &mdp5_kms->state->smp); mdp5_smp_prepare_commit(mdp5_kms->smp, &global_state->smp);
} }
static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state) static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state)
{ {
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms)); struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
struct device *dev = &mdp5_kms->pdev->dev; struct device *dev = &mdp5_kms->pdev->dev;
struct mdp5_global_state *global_state;
global_state = mdp5_get_existing_global_state(mdp5_kms);
if (mdp5_kms->smp) if (mdp5_kms->smp)
mdp5_smp_complete_commit(mdp5_kms->smp, &mdp5_kms->state->smp); mdp5_smp_complete_commit(mdp5_kms->smp, &global_state->smp);
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
} }
......
...@@ -52,14 +52,14 @@ int mdp5_mixer_assign(struct drm_atomic_state *s, struct drm_crtc *crtc, ...@@ -52,14 +52,14 @@ int mdp5_mixer_assign(struct drm_atomic_state *s, struct drm_crtc *crtc,
{ {
struct msm_drm_private *priv = s->dev->dev_private; struct msm_drm_private *priv = s->dev->dev_private;
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms)); struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
struct mdp5_state *state = mdp5_get_state(s); struct mdp5_global_state *global_state = mdp5_get_global_state(s);
struct mdp5_hw_mixer_state *new_state; struct mdp5_hw_mixer_state *new_state;
int i; int i;
if (IS_ERR(state)) if (IS_ERR(global_state))
return PTR_ERR(state); return PTR_ERR(global_state);
new_state = &state->hwmixer; new_state = &global_state->hwmixer;
for (i = 0; i < mdp5_kms->num_hwmixers; i++) { for (i = 0; i < mdp5_kms->num_hwmixers; i++) {
struct mdp5_hw_mixer *cur = mdp5_kms->hwmixers[i]; struct mdp5_hw_mixer *cur = mdp5_kms->hwmixers[i];
...@@ -129,8 +129,8 @@ int mdp5_mixer_assign(struct drm_atomic_state *s, struct drm_crtc *crtc, ...@@ -129,8 +129,8 @@ int mdp5_mixer_assign(struct drm_atomic_state *s, struct drm_crtc *crtc,
void mdp5_mixer_release(struct drm_atomic_state *s, struct mdp5_hw_mixer *mixer) void mdp5_mixer_release(struct drm_atomic_state *s, struct mdp5_hw_mixer *mixer)
{ {
struct mdp5_state *state = mdp5_get_state(s); struct mdp5_global_state *global_state = mdp5_get_global_state(s);
struct mdp5_hw_mixer_state *new_state = &state->hwmixer; struct mdp5_hw_mixer_state *new_state = &global_state->hwmixer;
if (!mixer) if (!mixer)
return; return;
......
...@@ -24,17 +24,19 @@ int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane, ...@@ -24,17 +24,19 @@ int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
{ {
struct msm_drm_private *priv = s->dev->dev_private; struct msm_drm_private *priv = s->dev->dev_private;
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms)); struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
struct mdp5_state *state; struct mdp5_global_state *new_global_state, *old_global_state;
struct mdp5_hw_pipe_state *old_state, *new_state; struct mdp5_hw_pipe_state *old_state, *new_state;
int i, j; int i, j;
state = mdp5_get_state(s); new_global_state = mdp5_get_global_state(s);
if (IS_ERR(state)) if (IS_ERR(new_global_state))
return PTR_ERR(state); return PTR_ERR(new_global_state);
/* grab old_state after mdp5_get_state(), since now we hold lock: */ /* grab old_state after mdp5_get_global_state(), since now we hold lock: */
old_state = &mdp5_kms->state->hwpipe; old_global_state = mdp5_get_existing_global_state(mdp5_kms);
new_state = &state->hwpipe;
old_state = &old_global_state->hwpipe;
new_state = &new_global_state->hwpipe;
for (i = 0; i < mdp5_kms->num_hwpipes; i++) { for (i = 0; i < mdp5_kms->num_hwpipes; i++) {
struct mdp5_hw_pipe *cur = mdp5_kms->hwpipes[i]; struct mdp5_hw_pipe *cur = mdp5_kms->hwpipes[i];
...@@ -107,7 +109,7 @@ int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane, ...@@ -107,7 +109,7 @@ int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
WARN_ON(r_hwpipe); WARN_ON(r_hwpipe);
DBG("%s: alloc SMP blocks", (*hwpipe)->name); DBG("%s: alloc SMP blocks", (*hwpipe)->name);
ret = mdp5_smp_assign(mdp5_kms->smp, &state->smp, ret = mdp5_smp_assign(mdp5_kms->smp, &new_global_state->smp,
(*hwpipe)->pipe, blkcfg); (*hwpipe)->pipe, blkcfg);
if (ret) if (ret)
return -ENOMEM; return -ENOMEM;
...@@ -132,7 +134,7 @@ void mdp5_pipe_release(struct drm_atomic_state *s, struct mdp5_hw_pipe *hwpipe) ...@@ -132,7 +134,7 @@ void mdp5_pipe_release(struct drm_atomic_state *s, struct mdp5_hw_pipe *hwpipe)
{ {
struct msm_drm_private *priv = s->dev->dev_private; struct msm_drm_private *priv = s->dev->dev_private;
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms)); struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
struct mdp5_state *state = mdp5_get_state(s); struct mdp5_global_state *state = mdp5_get_global_state(s);
struct mdp5_hw_pipe_state *new_state = &state->hwpipe; struct mdp5_hw_pipe_state *new_state = &state->hwpipe;
if (!hwpipe) if (!hwpipe)
......
...@@ -340,17 +340,20 @@ void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p) ...@@ -340,17 +340,20 @@ void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p)
struct mdp5_kms *mdp5_kms = get_kms(smp); struct mdp5_kms *mdp5_kms = get_kms(smp);
struct mdp5_hw_pipe_state *hwpstate; struct mdp5_hw_pipe_state *hwpstate;
struct mdp5_smp_state *state; struct mdp5_smp_state *state;
struct mdp5_global_state *global_state;
int total = 0, i, j; int total = 0, i, j;
drm_printf(p, "name\tinuse\tplane\n"); drm_printf(p, "name\tinuse\tplane\n");
drm_printf(p, "----\t-----\t-----\n"); drm_printf(p, "----\t-----\t-----\n");
if (drm_can_sleep()) if (drm_can_sleep())
drm_modeset_lock(&mdp5_kms->state_lock, NULL); drm_modeset_lock(&mdp5_kms->glob_state_lock, NULL);
global_state = mdp5_get_existing_global_state(mdp5_kms);
/* grab these *after* we hold the state_lock */ /* grab these *after* we hold the state_lock */
hwpstate = &mdp5_kms->state->hwpipe; hwpstate = &global_state->hwpipe;
state = &mdp5_kms->state->smp; state = &global_state->smp;
for (i = 0; i < mdp5_kms->num_hwpipes; i++) { for (i = 0; i < mdp5_kms->num_hwpipes; i++) {
struct mdp5_hw_pipe *hwpipe = mdp5_kms->hwpipes[i]; struct mdp5_hw_pipe *hwpipe = mdp5_kms->hwpipes[i];
...@@ -374,7 +377,7 @@ void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p) ...@@ -374,7 +377,7 @@ void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p)
bitmap_weight(state->state, smp->blk_cnt)); bitmap_weight(state->state, smp->blk_cnt));
if (drm_can_sleep()) if (drm_can_sleep())
drm_modeset_unlock(&mdp5_kms->state_lock); drm_modeset_unlock(&mdp5_kms->glob_state_lock);
} }
void mdp5_smp_destroy(struct mdp5_smp *smp) void mdp5_smp_destroy(struct mdp5_smp *smp)
...@@ -384,7 +387,8 @@ void mdp5_smp_destroy(struct mdp5_smp *smp) ...@@ -384,7 +387,8 @@ void mdp5_smp_destroy(struct mdp5_smp *smp)
struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms, const struct mdp5_smp_block *cfg) struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms, const struct mdp5_smp_block *cfg)
{ {
struct mdp5_smp_state *state = &mdp5_kms->state->smp; struct mdp5_smp_state *state;
struct mdp5_global_state *global_state;
struct mdp5_smp *smp = NULL; struct mdp5_smp *smp = NULL;
int ret; int ret;
...@@ -398,6 +402,9 @@ struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms, const struct mdp5_smp_ ...@@ -398,6 +402,9 @@ struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms, const struct mdp5_smp_
smp->blk_cnt = cfg->mmb_count; smp->blk_cnt = cfg->mmb_count;
smp->blk_size = cfg->mmb_size; smp->blk_size = cfg->mmb_size;
global_state = mdp5_get_existing_global_state(mdp5_kms);
state = &global_state->smp;
/* statically tied MMBs cannot be re-allocated: */ /* statically tied MMBs cannot be re-allocated: */
bitmap_copy(state->state, cfg->reserved_state, smp->blk_cnt); bitmap_copy(state->state, cfg->reserved_state, smp->blk_cnt);
memcpy(smp->reserved, cfg->reserved, sizeof(smp->reserved)); memcpy(smp->reserved, cfg->reserved, sizeof(smp->reserved));
......
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