/** * DOC: DMC Firmware Support * * From gen9 onwards we have newly added DMC (Display microcontroller) in display * engine to save and restore the state of display engine when it enter into * low-power state and comes back to normal.
*/
/* * New DMC additions should not use this. This is used solely to remain * compatible with systems that have not yet updated DMC blobs to use * unversioned file names.
*/ #define DMC_LEGACY_PATH(platform, major, minor) \ "i915/" \
__stringify(platform) "_dmc_ver" \
__stringify(major) "_" \
__stringify(minor) ".bin"
/* * Wa_16015201720:adl-p,dg2 * The WA requires clock gating to be disabled all the time * for pipe A and B. * For pipe C and D clock gating needs to be disabled only * during initializing the firmware.
*/ if (enable) for (pipe = PIPE_A; pipe <= PIPE_D; pipe++)
intel_de_rmw(display, CLKGATE_DIS_PSL_EXT(pipe),
0, PIPEDMC_GATING_DIS); else for (pipe = PIPE_C; pipe <= PIPE_D; pipe++)
intel_de_rmw(display, CLKGATE_DIS_PSL_EXT(pipe),
PIPEDMC_GATING_DIS, 0);
}
staticvoid mtl_pipedmc_clock_gating_wa(struct intel_display *display)
{ /* * Wa_16015201720 * The WA requires clock gating to be disabled all the time * for pipe A and B.
*/
intel_de_rmw(display, GEN9_CLKGATE_DIS_0, 0,
MTL_PIPEDMC_GATING_DIS(PIPE_A) |
MTL_PIPEDMC_GATING_DIS(PIPE_B));
}
static u32 pipedmc_interrupt_mask(struct intel_display *display)
{ /* * FIXME PIPEDMC_ERROR not enabled for now due to LNL pipe B * triggering it during the first DC state transition. Figure * out what is going on...
*/ return PIPEDMC_FLIPQ_PROG_DONE |
PIPEDMC_GTT_FAULT |
PIPEDMC_ATS_FAULT;
}
if (!is_dmc_evt_htp_reg(display, dmc_id, reg_htp)) returnfalse;
/* make sure reg_ctl and reg_htp are for the same event */ if (i915_mmio_reg_offset(reg_ctl) - i915_mmio_reg_offset(DMC_EVT_CTL(display, dmc_id, 0)) !=
i915_mmio_reg_offset(reg_htp) - i915_mmio_reg_offset(DMC_EVT_HTP(display, dmc_id, 0))) returnfalse;
/* * On ADL-S the HRR event handler is not restored after DC6. * Clear it to zero from the beginning to avoid mismatches later.
*/ if (display->platform.alderlake_s && dmc_id == DMC_FW_MAIN &&
is_event_handler(display, dmc_id, MAINDMC_EVENT_VBLANK_A, reg_ctl, *data_ctl)) {
*data_ctl = 0;
*data_htp = 0; returntrue;
}
/* keep all pipe DMC events disabled by default */ if (dmc_id != DMC_FW_MAIN) returntrue;
/* also disable the flip queue event on the main DMC on TGL */ if (display->platform.tigerlake &&
is_event_handler(display, dmc_id, MAINDMC_EVENT_CLK_MSEC, reg, data)) returntrue;
/* also disable the HRR event on the main DMC on TGL/ADLS */ if ((display->platform.tigerlake || display->platform.alderlake_s) &&
is_event_handler(display, dmc_id, MAINDMC_EVENT_VBLANK_A, reg, data)) returntrue;
for (i = 0; i < dmc->dmc_info[dmc_id].dmc_fw_size; i++) {
intel_de_write_fw(display,
DMC_PROGRAM(dmc->dmc_info[dmc_id].start_mmioaddr, i),
dmc->dmc_info[dmc_id].payload[i]);
}
if (!is_valid_dmc_id(dmc_id) || !has_dmc_id_fw(display, dmc_id)) return;
found = intel_de_read(display, DMC_PROGRAM(dmc->dmc_info[dmc_id].start_mmioaddr, 0));
expected = dmc->dmc_info[dmc_id].payload[0];
drm_WARN(display->drm, found != expected, "DMC %d program storage start incorrect (expected 0x%x, current 0x%x)\n",
dmc_id, expected, found);
for (i = 0; i < dmc->dmc_info[dmc_id].mmio_count; i++) {
i915_reg_t reg = dmc->dmc_info[dmc_id].mmioaddr[i];
found = intel_de_read(display, reg);
expected = dmc_mmiodata(display, dmc, dmc_id, i);
/* once set DMC_EVT_CTL_ENABLE can't be cleared :/ */ if (is_dmc_evt_ctl_reg(display, dmc_id, reg)) {
found &= ~DMC_EVT_CTL_ENABLE;
expected &= ~DMC_EVT_CTL_ENABLE;
}
drm_WARN(display->drm, found != expected, "DMC %d mmio[%d]/0x%x incorrect (expected 0x%x, current 0x%x)\n",
dmc_id, i, i915_mmio_reg_offset(reg), expected, found);
}
}
staticbool need_pipedmc_load_program(struct intel_display *display)
{ /* On TGL/derivatives pipe DMC state is lost when PG1 is disabled */ return DISPLAY_VER(display) == 12;
}
staticbool need_pipedmc_load_mmio(struct intel_display *display, enum pipe pipe)
{ /* * PTL: * - pipe A/B DMC doesn't need save/restore * - pipe C/D DMC is in PG0, needs manual save/restore
*/ if (DISPLAY_VER(display) == 30) return pipe >= PIPE_C;
/* * FIXME LNL unclear, main DMC firmware has the pipe DMC A/B PG0 * save/restore, but so far unable to see the loss of pipe DMC state * in action. Are we just failing to turn off PG0 due to some other * SoC level stuff?
*/ if (DISPLAY_VER(display) == 20) returnfalse;
/* * FIXME BMG untested, main DMC firmware has the * pipe DMC A/B PG0 save/restore...
*/ if (display->platform.battlemage) returnfalse;
/* * DG2: * - Pipe DMCs presumably in PG0? * - No DC6, and even DC9 doesn't seem to result * in loss of DMC state for whatever reason
*/ if (display->platform.dg2) returnfalse;
/* * ADL/MTL: * - pipe A/B DMC is in PG0, saved/restored by the main DMC * - pipe C/D DMC is in PG0, needs manual save/restore
*/ if (IS_DISPLAY_VER(display, 13, 14)) return pipe >= PIPE_C;
/* * On TGL/derivatives pipe DMC state is lost when PG1 is disabled. * Do not even enable the pipe DMC when that can happen outside * of driver control (PSR+DC5/6).
*/ if (DISPLAY_VER(display) == 12 && crtc_state->has_psr) returnfalse;
for (i = 0; i < dmc->dmc_info[dmc_id].mmio_count; i++) {
i915_reg_t reg = dmc->dmc_info[dmc_id].mmioaddr[i];
u32 data = dmc->dmc_info[dmc_id].mmiodata[i];
if (!is_event_handler(display, dmc_id, event_id, reg, data)) continue;
intel_de_write(display, reg, enable ? data : dmc_evt_ctl_disable());
num_handlers++;
}
drm_WARN_ONCE(display->drm, num_handlers != 1, "DMC %d has %d handlers for event 0x%x\n",
dmc_id, num_handlers, event_id);
}
/** * intel_dmc_block_pkgc() - block PKG C-state * @display: display instance * @pipe: pipe which register use to block * @block: block/unblock * * This interface is target for Wa_16025596647 usage. I.e. to set/clear * PIPEDMC_BLOCK_PKGC_SW_BLOCK_PKGC_ALWAYS bit in PIPEDMC_BLOCK_PKGC_SW register.
*/ void intel_dmc_block_pkgc(struct intel_display *display, enum pipe pipe, bool block)
{
intel_de_rmw(display, PIPEDMC_BLOCK_PKGC_SW(pipe),
PIPEDMC_BLOCK_PKGC_SW_BLOCK_PKGC_ALWAYS, block ?
PIPEDMC_BLOCK_PKGC_SW_BLOCK_PKGC_ALWAYS : 0);
}
/** * intel_dmc_start_pkgc_exit_at_start_of_undelayed_vblank() - start of PKG * C-state exit * @display: display instance * @pipe: pipe which register use to block * @enable: enable/disable * * This interface is target for Wa_16025596647 usage. I.e. start the package C * exit at the start of the undelayed vblank
*/ void intel_dmc_start_pkgc_exit_at_start_of_undelayed_vblank(struct intel_display *display, enum pipe pipe, bool enable)
{ enum intel_dmc_id dmc_id = PIPE_TO_DMC_ID(pipe);
/** * intel_dmc_load_program() - write the firmware from memory to register. * @display: display instance * * DMC firmware is read from a .bin file and kept in internal memory one time. * Everytime display comes back from low power state this function is called to * copy the firmware from internal memory to registers.
*/ void intel_dmc_load_program(struct intel_display *display)
{ struct i915_power_domains *power_domains = &display->power.domains; enum intel_dmc_id dmc_id;
/** * intel_dmc_disable_program() - disable the firmware * @display: display instance * * Disable all event handlers in the firmware, making sure the firmware is * inactive after the display is uninitialized.
*/ void intel_dmc_disable_program(struct intel_display *display)
{ enum intel_dmc_id dmc_id;
staticbool fw_info_matches_stepping(conststruct intel_fw_info *fw_info, conststruct stepping_info *si)
{ if ((fw_info->substepping == '*' && si->stepping == fw_info->stepping) ||
(si->stepping == fw_info->stepping && si->substepping == fw_info->substepping) || /* * If we don't find a more specific one from above two checks, we * then check for the generic one to be sure to work even with * "broken firmware"
*/
(si->stepping == '*' && si->substepping == fw_info->substepping) ||
(fw_info->stepping == '*' && fw_info->substepping == '*')) returntrue;
/* More specific versions come first, so we don't even have to * check for the stepping since we already found a previous FW * for this id.
*/ if (dmc->dmc_info[dmc_id].present) continue;
/* * Check if we can access common fields, we will checkc again below * after we have read the version
*/ if (rem_size < sizeof(struct intel_dmc_header_base)) goto error_truncated;
/* Cope with small differences between v1 and v3 */ if (dmc_header->header_ver == 3) { conststruct intel_dmc_header_v3 *v3 =
(conststruct intel_dmc_header_v3 *)dmc_header;
if (rem_size < sizeof(struct intel_dmc_header_v3)) goto error_truncated;
/* fw_size is in dwords, so multiplied by 4 to convert into bytes. */
payload_size = dmc_header->fw_size * 4; if (rem_size < payload_size) goto error_truncated;
if (payload_size > dmc->max_fw_size) {
drm_err(display->drm, "DMC FW too big (%u bytes)\n", payload_size); return 0;
}
dmc_info->dmc_fw_size = dmc_header->fw_size;
dmc_info->payload = kmalloc(payload_size, GFP_KERNEL); if (!dmc_info->payload) return 0;
/* * We should always have space for max_entries, * even if not all are used
*/
package_size += max_entries * sizeof(struct intel_fw_info); if (rem_size < package_size) goto error_truncated;
/** * intel_dmc_init() - initialize the firmware loading. * @display: display instance * * This function is called at the time of loading the display driver to read * firmware from a .bin file and copied into a internal memory.
*/ void intel_dmc_init(struct intel_display *display)
{ struct intel_dmc *dmc;
if (!HAS_DMC(display)) return;
/* * Obtain a runtime pm reference, until DMC is loaded, to avoid entering * runtime-suspend. * * On error, we return with the rpm wakeref held to prevent runtime * suspend as runtime suspend *requires* a working DMC for whatever * reason.
*/
intel_dmc_runtime_pm_get(display);
dmc = kzalloc(sizeof(*dmc), GFP_KERNEL); if (!dmc) return;
/** * intel_dmc_suspend() - prepare DMC firmware before system suspend * @display: display instance * * Prepare the DMC firmware before entering system suspend. This includes * flushing pending work items and releasing any resources acquired during * init.
*/ void intel_dmc_suspend(struct intel_display *display)
{ struct intel_dmc *dmc = display_to_dmc(display);
if (!HAS_DMC(display)) return;
if (dmc)
flush_work(&dmc->work);
/* Drop the reference held in case DMC isn't loaded. */ if (!intel_dmc_has_payload(display))
intel_dmc_runtime_pm_put(display);
}
/** * intel_dmc_resume() - init DMC firmware during system resume * @display: display instance * * Reinitialize the DMC firmware during system resume, reacquiring any * resources released in intel_dmc_suspend().
*/ void intel_dmc_resume(struct intel_display *display)
{ if (!HAS_DMC(display)) return;
/* * Reacquire the reference to keep RPM disabled in case DMC isn't * loaded.
*/ if (!intel_dmc_has_payload(display))
intel_dmc_runtime_pm_get(display);
}
/** * intel_dmc_fini() - unload the DMC firmware. * @display: display instance * * Firmmware unloading includes freeing the internal memory and reset the * firmware loading status.
*/ void intel_dmc_fini(struct intel_display *display)
{ struct intel_dmc *dmc = display_to_dmc(display); enum intel_dmc_id dmc_id;
if (tmp & PIPEDMC_FLIPQ_PROG_DONE) {
spin_lock(&display->drm->event_lock);
if (crtc->flipq_event) { /* * Update vblank counter/timestamp in case it * hasn't been done yet for this frame.
*/
drm_crtc_accurate_vblank_count(&crtc->base);
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.