Commit ac2a3fd3 authored by Rob Clark's avatar Rob Clark

drm/msm/mdp5: add skeletal mdp5_state

Add basic state duplication/apply mechanism.  Following commits will
move actual global hw state into this.

The state_lock allows multiple concurrent updates to proceed as long as
they don't both try to alter global state.  The ww_mutex mechanism will
trigger backoff in case of deadlock between multiple threads trying to
update state.
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
Reviewed-by: default avatarArchit Taneja <architt@codeaurora.org>
parent 870d738a
...@@ -72,6 +72,39 @@ static int mdp5_hw_init(struct msm_kms *kms) ...@@ -72,6 +72,39 @@ static int mdp5_hw_init(struct msm_kms *kms)
return 0; return 0;
} }
struct mdp5_state *mdp5_get_state(struct drm_atomic_state *s)
{
struct msm_drm_private *priv = s->dev->dev_private;
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
struct msm_kms_state *state = to_kms_state(s);
struct mdp5_state *new_state;
int ret;
if (state->state)
return state->state;
ret = drm_modeset_lock(&mdp5_kms->state_lock, s->acquire_ctx);
if (ret)
return ERR_PTR(ret);
new_state = kmalloc(sizeof(*mdp5_kms->state), GFP_KERNEL);
if (!new_state)
return ERR_PTR(-ENOMEM);
/* Copy state: */
/* TODO */
state->state = new_state;
return new_state;
}
static void mdp5_swap_state(struct msm_kms *kms, struct drm_atomic_state *state)
{
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
swap(to_kms_state(state)->state, mdp5_kms->state);
}
static void mdp5_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *state) static void mdp5_prepare_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));
...@@ -140,6 +173,7 @@ static const struct mdp_kms_funcs kms_funcs = { ...@@ -140,6 +173,7 @@ static const struct mdp_kms_funcs kms_funcs = {
.irq = mdp5_irq, .irq = mdp5_irq,
.enable_vblank = mdp5_enable_vblank, .enable_vblank = mdp5_enable_vblank,
.disable_vblank = mdp5_disable_vblank, .disable_vblank = mdp5_disable_vblank,
.swap_state = mdp5_swap_state,
.prepare_commit = mdp5_prepare_commit, .prepare_commit = mdp5_prepare_commit,
.complete_commit = mdp5_complete_commit, .complete_commit = mdp5_complete_commit,
.wait_for_crtc_commit_done = mdp5_wait_for_crtc_commit_done, .wait_for_crtc_commit_done = mdp5_wait_for_crtc_commit_done,
...@@ -645,6 +679,8 @@ static void mdp5_destroy(struct platform_device *pdev) ...@@ -645,6 +679,8 @@ static void mdp5_destroy(struct platform_device *pdev)
if (mdp5_kms->rpm_enabled) if (mdp5_kms->rpm_enabled)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
kfree(mdp5_kms->state);
} }
static int construct_pipes(struct mdp5_kms *mdp5_kms, int cnt, static int construct_pipes(struct mdp5_kms *mdp5_kms, int cnt,
...@@ -729,6 +765,13 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev) ...@@ -729,6 +765,13 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)
mdp5_kms->dev = dev; mdp5_kms->dev = dev;
mdp5_kms->pdev = pdev; mdp5_kms->pdev = pdev;
drm_modeset_lock_init(&mdp5_kms->state_lock);
mdp5_kms->state = kzalloc(sizeof(*mdp5_kms->state), GFP_KERNEL);
if (!mdp5_kms->state) {
ret = -ENOMEM;
goto fail;
}
mdp5_kms->mmio = msm_ioremap(pdev, "mdp_phys", "MDP5"); mdp5_kms->mmio = msm_ioremap(pdev, "mdp_phys", "MDP5");
if (IS_ERR(mdp5_kms->mmio)) { if (IS_ERR(mdp5_kms->mmio)) {
ret = PTR_ERR(mdp5_kms->mmio); ret = PTR_ERR(mdp5_kms->mmio);
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "mdp5_pipe.h" #include "mdp5_pipe.h"
#include "mdp5_smp.h" #include "mdp5_smp.h"
struct mdp5_state;
struct mdp5_kms { struct mdp5_kms {
struct mdp_kms base; struct mdp_kms base;
...@@ -40,6 +42,11 @@ struct mdp5_kms { ...@@ -40,6 +42,11 @@ struct mdp5_kms {
struct mdp5_cfg_handler *cfg; struct mdp5_cfg_handler *cfg;
uint32_t caps; /* MDP capabilities (MDP_CAP_XXX bits) */ uint32_t caps; /* MDP capabilities (MDP_CAP_XXX bits) */
/**
* Global atomic state. Do not access directly, use mdp5_get_state()
*/
struct mdp5_state *state;
struct drm_modeset_lock state_lock;
/* mapper-id used to request GEM buffer mapped for scanout: */ /* mapper-id used to request GEM buffer mapped for scanout: */
int id; int id;
...@@ -69,6 +76,21 @@ struct mdp5_kms { ...@@ -69,6 +76,21 @@ struct mdp5_kms {
}; };
#define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base) #define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base)
/* Global atomic state for tracking resources that are shared across
* multiple kms objects (planes/crtcs/etc).
*
* For atomic updates which require modifying global state,
*/
struct mdp5_state {
uint32_t dummy;
};
struct mdp5_state *__must_check
mdp5_get_state(struct drm_atomic_state *s);
/* Atomic plane state. Subclasses the base drm_plane_state in order to
* track assigned hwpipe and hw specific state.
*/
struct mdp5_plane_state { struct mdp5_plane_state {
struct drm_plane_state base; struct drm_plane_state base;
......
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