Skip to content

Commit

Permalink
drm/i915: Block enabling FBC until flips have been completed
Browse files Browse the repository at this point in the history
There is a small race window in which FBC can be enabled after
pre_plane_update is called, but before the page flip has been
queued or completed.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103167
Link: https://patchwork.freedesktop.org/patch/msgid/20180625163758.10871-1-maarten.lankhorst@linux.intel.com
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
  • Loading branch information
Maarten Lankhorst committed Jun 29, 2018
1 parent 9512f98 commit c9855a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/i915_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ struct intel_fbc {

bool enabled;
bool active;
bool flip_pending;

bool underrun_detected;
struct work_struct underrun_work;
Expand Down
35 changes: 11 additions & 24 deletions drivers/gpu/drm/i915/intel_fbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,13 +924,6 @@ static void intel_fbc_get_reg_params(struct intel_crtc *crtc,
32 * fbc->threshold) * 8;
}

static bool intel_fbc_reg_params_equal(struct intel_fbc_reg_params *params1,
struct intel_fbc_reg_params *params2)
{
/* We can use this since intel_fbc_get_reg_params() does a memset. */
return memcmp(params1, params2, sizeof(*params1)) == 0;
}

void intel_fbc_pre_update(struct intel_crtc *crtc,
struct intel_crtc_state *crtc_state,
struct intel_plane_state *plane_state)
Expand All @@ -953,6 +946,7 @@ void intel_fbc_pre_update(struct intel_crtc *crtc,
goto unlock;

intel_fbc_update_state_cache(crtc, crtc_state, plane_state);
fbc->flip_pending = true;

deactivate:
intel_fbc_deactivate(dev_priv, reason);
Expand Down Expand Up @@ -988,39 +982,32 @@ static void __intel_fbc_post_update(struct intel_crtc *crtc)
{
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
struct intel_fbc *fbc = &dev_priv->fbc;
struct intel_fbc_reg_params old_params;

WARN_ON(!mutex_is_locked(&fbc->lock));

if (!fbc->enabled || fbc->crtc != crtc)
return;

fbc->flip_pending = false;
WARN_ON(fbc->active);

if (!i915_modparams.enable_fbc) {
intel_fbc_deactivate(dev_priv, "disabled at runtime per module param");
__intel_fbc_disable(dev_priv);

return;
}

if (!intel_fbc_can_activate(crtc)) {
WARN_ON(fbc->active);
return;
}

old_params = fbc->params;
intel_fbc_get_reg_params(crtc, &fbc->params);

/* If the scanout has not changed, don't modify the FBC settings.
* Note that we make the fundamental assumption that the fb->obj
* cannot be unpinned (and have its GTT offset and fence revoked)
* without first being decoupled from the scanout and FBC disabled.
*/
if (fbc->active &&
intel_fbc_reg_params_equal(&old_params, &fbc->params))
if (!intel_fbc_can_activate(crtc))
return;

intel_fbc_deactivate(dev_priv, "FBC enabled (active or scheduled)");
intel_fbc_schedule_activation(crtc);
if (!fbc->busy_bits) {
intel_fbc_deactivate(dev_priv, "FBC enabled (active or scheduled)");
intel_fbc_schedule_activation(crtc);
} else
intel_fbc_deactivate(dev_priv, "frontbuffer write");
}

void intel_fbc_post_update(struct intel_crtc *crtc)
Expand Down Expand Up @@ -1085,7 +1072,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv,
(frontbuffer_bits & intel_fbc_get_frontbuffer_bit(fbc))) {
if (fbc->active)
intel_fbc_recompress(dev_priv);
else
else if (!fbc->flip_pending)
__intel_fbc_post_update(fbc->crtc);
}

Expand Down

0 comments on commit c9855a5

Please sign in to comment.