Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,22 @@ dpu_kms_global_duplicate_state(struct drm_private_obj *obj)

__drm_atomic_helper_private_obj_duplicate_state(obj, &state->base);

/* The new state will track its own commits during commit setup. */
memset(state->pending_commits, 0, sizeof(state->pending_commits));

return &state->base;
}

static void dpu_kms_global_destroy_state(struct drm_private_obj *obj,
struct drm_private_state *state)
{
struct dpu_global_state *dpu_state = to_dpu_global_state(state);
unsigned int i;

for (i = 0; i < ARRAY_SIZE(dpu_state->pending_commits); i++) {
if (dpu_state->pending_commits[i])
drm_crtc_commit_put(dpu_state->pending_commits[i]);
}

kfree(dpu_state);
}
Expand Down Expand Up @@ -462,6 +471,77 @@ static int dpu_kms_check_mode_changed(struct msm_kms *kms, struct drm_atomic_com
return 0;
}

static int dpu_kms_atomic_commit_setup(struct msm_kms *kms,
struct drm_atomic_commit *state)
{
struct dpu_kms *dpu_kms = to_dpu_kms(kms);
struct drm_private_state *priv_state;
struct dpu_global_state *global_state;
struct drm_crtc_state *crtc_state;
struct drm_crtc *crtc;
int i;

priv_state = drm_atomic_get_new_private_obj_state(state, &dpu_kms->global_state);
if (!priv_state)
return 0;

global_state = to_dpu_global_state(priv_state);
for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
if (crtc_state->commit)
global_state->pending_commits[drm_crtc_index(crtc)] =
drm_crtc_commit_get(crtc_state->commit);
}

return 0;
}

static void dpu_kms_prepare_commit(struct msm_kms *kms, struct drm_atomic_commit *state)
{
struct dpu_kms *dpu_kms = to_dpu_kms(kms);
struct drm_private_state *priv_state;
struct dpu_global_state *global_state;
unsigned int i;
int ret;

priv_state = drm_atomic_get_old_private_obj_state(state, &dpu_kms->global_state);
if (!priv_state)
return;

global_state = to_dpu_global_state(priv_state);
/*
* Virtual planes on different CRTCs can reuse the same SSPP. The
* per-CRTC and per-plane dependencies do not cover that handoff.
* Wait for the previous resource update before programming hardware.
*/
for (i = 0; i < ARRAY_SIZE(global_state->pending_commits); i++) {
if (!global_state->pending_commits[i])
continue;

ret = drm_crtc_commit_wait(global_state->pending_commits[i]);
if (ret)
drm_err(kms->dev, "CRTC %u resource commit wait timed out\n", i);
}
}

static bool dpu_kms_can_do_async(struct msm_kms *kms, struct drm_atomic_commit *state)
{
struct dpu_kms *dpu_kms = to_dpu_kms(kms);
struct drm_private_state *old_priv_state, *new_priv_state;
const struct dpu_global_state *old_global_state, *new_global_state;

new_priv_state = drm_atomic_get_new_private_obj_state(state, &dpu_kms->global_state);
if (!new_priv_state)
return true;

old_priv_state = drm_atomic_get_old_private_obj_state(state, &dpu_kms->global_state);
old_global_state = to_dpu_global_state(old_priv_state);
new_global_state = to_dpu_global_state(new_priv_state);

return !memcmp(old_global_state->sspp_to_crtc_id,
new_global_state->sspp_to_crtc_id,
sizeof(new_global_state->sspp_to_crtc_id));
}

static void dpu_kms_flush_commit(struct msm_kms *kms, unsigned crtc_mask)
{
struct dpu_kms *dpu_kms = to_dpu_kms(kms);
Expand Down Expand Up @@ -1110,6 +1190,9 @@ static const struct msm_kms_funcs kms_funcs = {
.enable_commit = dpu_kms_enable_commit,
.disable_commit = dpu_kms_disable_commit,
.check_mode_changed = dpu_kms_check_mode_changed,
.atomic_commit_setup = dpu_kms_atomic_commit_setup,
.prepare_commit = dpu_kms_prepare_commit,
.can_do_async = dpu_kms_can_do_async,
.flush_commit = dpu_kms_flush_commit,
.wait_flush = dpu_kms_wait_flush,
.complete_commit = dpu_kms_complete_commit,
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ struct dpu_global_state {

struct dpu_rm *rm;

/* Commits updating this resource state, held until it is destroyed. */
struct drm_crtc_commit *pending_commits[MAX_CRTCS];

uint32_t pingpong_to_crtc_id[PINGPONG_MAX - PINGPONG_0];
uint32_t mixer_to_crtc_id[LM_MAX - LM_0];
uint32_t ctl_to_crtc_id[CTL_MAX - CTL_0];
Expand Down
15 changes: 12 additions & 3 deletions drivers/gpu/drm/msm/msm_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ void msm_atomic_destroy_pending_timer(struct msm_pending_timer *timer)
kthread_destroy_worker(timer->worker);
}

static bool can_do_async(struct drm_atomic_commit *state,
struct drm_crtc **async_crtc)
static bool can_do_async(struct msm_kms *kms, struct drm_atomic_commit *state,
struct drm_crtc **async_crtc)
{
struct drm_connector_state *connector_state;
struct drm_connector *connector;
Expand All @@ -163,6 +163,9 @@ static bool can_do_async(struct drm_atomic_commit *state,
*async_crtc = crtc;
}

if (kms->funcs->can_do_async && !kms->funcs->can_do_async(kms, state))
return false;

return true;
}

Expand Down Expand Up @@ -222,7 +225,7 @@ void msm_atomic_commit_tail(struct drm_atomic_commit *state)
struct msm_kms *kms = priv->kms;
struct drm_crtc *async_crtc = NULL;
unsigned crtc_mask = get_crtc_mask(state);
bool async = can_do_async(state, &async_crtc);
bool async = can_do_async(kms, state, &async_crtc);

trace_msm_atomic_commit_tail_start(async, crtc_mask);

Expand Down Expand Up @@ -332,5 +335,11 @@ void msm_atomic_commit_tail(struct drm_atomic_commit *state)

int msm_atomic_commit_setup(struct drm_atomic_commit *state)
{
struct msm_drm_private *priv = state->dev->dev_private;
struct msm_kms *kms = priv->kms;

if (kms->funcs->atomic_commit_setup)
kms->funcs->atomic_commit_setup(kms, state);

return drm_dp_mst_atomic_setup_commit(state);
}
13 changes: 13 additions & 0 deletions drivers/gpu/drm/msm/msm_kms.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ struct msm_kms_funcs {
*/
int (*check_mode_changed)(struct msm_kms *kms, struct drm_atomic_commit *state);

/**
* Track dependencies on shared resources before swapping the atomic
* state. The CRTC commit objects have already been allocated.
*/
int (*atomic_commit_setup)(struct msm_kms *kms, struct drm_atomic_commit *state);

/**
* Return whether this update may defer its flush until the pending
* timer runs. Resource changes that require hardware completion before
* another commit can reuse them must not defer the flush.
*/
bool (*can_do_async)(struct msm_kms *kms, struct drm_atomic_commit *state);

/**
* Prepare for atomic commit. This is called after any previous
* (async or otherwise) commit has completed.
Expand Down