/* * Save all Gunit registers that may be lost after a D3 and a subsequent * S0i[R123] transition. The list of registers needing a save/restore is * defined in the VLV2_S0IXRegs document. This documents marks all Gunit * registers in the following way: * - Driver: saved/restored by the driver * - Punit : saved/restored by the Punit firmware * - No, w/o marking: no need to save/restore, since the register is R/O or * used internally by the HW in a way that doesn't depend * keeping the content across a suspend/resume. * - Debug : used for debugging * * We save/restore all registers marked with 'Driver', with the following * exceptions: * - Registers out of use, including also registers marked with 'Debug'. * These have no effect on the driver's operation, so we don't save/restore * them to reduce the overhead. * - Registers that are fully setup by an initialization function called from * the resume path. For example many clock gating and RPS/RC6 registers. * - Registers that provide the right functionality with their reset defaults. * * TODO: Except for registers that based on the above 3 criteria can be safely * ignored, we save/restore all others, practically treating the HW context as * a black-box for the driver. Further investigation is needed to reduce the * saved/restored registers even further, by following the same 3 criteria.
*/ staticvoid vlv_save_gunit_s0ix_state(struct drm_i915_private *i915)
{ struct vlv_s0ix_state *s = i915->vlv_s0ix_state; struct intel_uncore *uncore = &i915->uncore; int i;
for (i = 0; i < ARRAY_SIZE(s->gt_scratch); i++)
intel_uncore_write(uncore, GEN7_GT_SCRATCH(i), s->gt_scratch[i]);
/* GT SA CZ domain, 0x100000-0x138124 */
intel_uncore_write(uncore, TILECTL, s->tilectl);
intel_uncore_write(uncore, GTFIFOCTL, s->gt_fifoctl); /* * Preserve the GT allow wake and GFX force clock bit, they are not * be restored, as they are used to control the s0ix suspend/resume * sequence by the caller.
*/
intel_uncore_rmw(uncore, VLV_GTLC_WAKE_CTRL, ~VLV_GTLC_ALLOWWAKEREQ,
s->gtlc_wake_ctrl & ~VLV_GTLC_ALLOWWAKEREQ);
/* The HW does not like us polling for PW_STATUS frequently, so * use the sleeping loop rather than risk the busy spin within * intel_wait_for_register(). * * Transitioning between RC6 states should be at most 2ms (see * valleyview_enable_rps) so use a 3ms timeout.
*/
ret = wait_for(((reg_value =
intel_uncore_read_notrace(&i915->uncore, reg)) & mask)
== val, 3);
/* just trace the final value */
trace_i915_reg_rw(false, reg, reg_value, sizeof(reg_value), true);
/* * RC6 transitioning can be delayed up to 2 msec (see * valleyview_enable_rps), use 3 msec for safety. * * This can fail to turn off the rc6 if the GPU is stuck after a failed * reset and we are trying to force the machine to sleep.
*/ if (vlv_wait_for_pw_status(dev_priv, mask, val))
drm_dbg(&dev_priv->drm, "timeout waiting for GT wells to go %s\n",
str_on_off(wait_for_on));
}
err = vlv_force_gfx_clock(dev_priv, true); if (err) goto err1;
err = vlv_allow_gt_wake(dev_priv, false); if (err) goto err2;
vlv_save_gunit_s0ix_state(dev_priv);
err = vlv_force_gfx_clock(dev_priv, false); if (err) goto err2;
return 0;
err2: /* For safety always re-enable waking and disable gfx clock forcing */
vlv_allow_gt_wake(dev_priv, true);
err1:
vlv_force_gfx_clock(dev_priv, false);
return err;
}
int vlv_resume_prepare(struct drm_i915_private *dev_priv, bool rpm_resume)
{ int err; int ret;
if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) return 0;
/* * If any of the steps fail just try to continue, that's the best we * can do at this point. Return the first error code (which will also * leave RPM permanently disabled).
*/
ret = vlv_force_gfx_clock(dev_priv, true);
vlv_restore_gunit_s0ix_state(dev_priv);
err = vlv_allow_gt_wake(dev_priv, true); if (!ret)
ret = err;
err = vlv_force_gfx_clock(dev_priv, false); if (!ret)
ret = err;
vlv_check_no_gt_access(dev_priv);
if (rpm_resume)
intel_clock_gating_init(dev_priv);
return ret;
}
int vlv_suspend_init(struct drm_i915_private *i915)
{ if (!IS_VALLEYVIEW(i915)) return 0;
/* we write all the values in the struct, so no need to zero it out */
i915->vlv_s0ix_state = kmalloc(sizeof(*i915->vlv_s0ix_state),
GFP_KERNEL); if (!i915->vlv_s0ix_state) return -ENOMEM;
return 0;
}
void vlv_suspend_cleanup(struct drm_i915_private *i915)
{ if (!i915->vlv_s0ix_state) return;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.