2022-06-17 12:48:16 +03:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/*
|
|
|
|
* Copyright © 2022 Intel Corporation
|
|
|
|
*
|
|
|
|
* Read out the current hardware modeset state, and sanitize it to the current
|
|
|
|
* state.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <drm/drm_atomic_state_helper.h>
|
2025-04-09 21:17:43 +03:00
|
|
|
#include <drm/drm_atomic_uapi.h>
|
|
|
|
#include <drm/drm_print.h>
|
2024-08-26 19:31:17 +03:00
|
|
|
#include <drm/drm_vblank.h>
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2022-11-09 17:35:22 +02:00
|
|
|
#include "i915_reg.h"
|
2023-02-13 21:59:57 +02:00
|
|
|
#include "i9xx_wm.h"
|
2022-06-17 12:48:16 +03:00
|
|
|
#include "intel_atomic.h"
|
|
|
|
#include "intel_bw.h"
|
2025-01-24 14:38:14 -03:00
|
|
|
#include "intel_cmtg.h"
|
2022-06-17 12:48:16 +03:00
|
|
|
#include "intel_color.h"
|
|
|
|
#include "intel_crtc.h"
|
|
|
|
#include "intel_crtc_state_dump.h"
|
|
|
|
#include "intel_ddi.h"
|
|
|
|
#include "intel_de.h"
|
|
|
|
#include "intel_display.h"
|
|
|
|
#include "intel_display_power.h"
|
2025-06-06 13:22:56 +03:00
|
|
|
#include "intel_display_regs.h"
|
2022-06-17 12:48:16 +03:00
|
|
|
#include "intel_display_types.h"
|
2023-03-01 14:29:43 +02:00
|
|
|
#include "intel_dmc.h"
|
2023-01-25 20:52:30 +02:00
|
|
|
#include "intel_fifo_underrun.h"
|
2022-06-17 12:48:16 +03:00
|
|
|
#include "intel_modeset_setup.h"
|
|
|
|
#include "intel_pch_display.h"
|
2023-06-06 23:10:32 +03:00
|
|
|
#include "intel_pmdemand.h"
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
#include "intel_tc.h"
|
2023-03-11 01:58:27 +02:00
|
|
|
#include "intel_vblank.h"
|
2025-04-17 14:44:54 +03:00
|
|
|
#include "intel_vga.h"
|
2023-02-13 21:59:59 +02:00
|
|
|
#include "intel_wm.h"
|
2022-09-08 22:16:45 +03:00
|
|
|
#include "skl_watermark.h"
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2023-05-10 13:31:22 +03:00
|
|
|
static void intel_crtc_disable_noatomic_begin(struct intel_crtc *crtc,
|
|
|
|
struct drm_modeset_acquire_ctx *ctx)
|
2022-06-17 12:48:16 +03:00
|
|
|
{
|
2025-04-09 21:17:43 +03:00
|
|
|
struct intel_display *display = to_intel_display(crtc);
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
struct intel_plane *plane;
|
|
|
|
struct drm_atomic_state *state;
|
2023-05-10 13:31:24 +03:00
|
|
|
struct intel_crtc *temp_crtc;
|
|
|
|
enum pipe pipe = crtc->pipe;
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
if (!crtc_state->hw.active)
|
|
|
|
return;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_plane_on_crtc(display->drm, crtc, plane) {
|
2022-06-17 12:48:16 +03:00
|
|
|
const struct intel_plane_state *plane_state =
|
|
|
|
to_intel_plane_state(plane->base.state);
|
|
|
|
|
|
|
|
if (plane_state->uapi.visible)
|
|
|
|
intel_plane_disable_noatomic(crtc, plane);
|
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
state = drm_atomic_state_alloc(display->drm);
|
2022-06-17 12:48:16 +03:00
|
|
|
if (!state) {
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"failed to disable [CRTC:%d:%s], out of memory",
|
|
|
|
crtc->base.base.id, crtc->base.name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
state->acquire_ctx = ctx;
|
2023-03-28 15:23:57 +03:00
|
|
|
to_intel_atomic_state(state)->internal = true;
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
/* Everything's already locked, -EDEADLK can't happen. */
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc_in_pipe_mask(display->drm, temp_crtc,
|
2023-05-10 13:31:24 +03:00
|
|
|
BIT(pipe) |
|
2024-06-03 14:25:50 +03:00
|
|
|
intel_crtc_joiner_secondary_pipes(crtc_state)) {
|
2023-05-10 13:31:24 +03:00
|
|
|
struct intel_crtc_state *temp_crtc_state =
|
|
|
|
intel_atomic_get_crtc_state(state, temp_crtc);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = drm_atomic_add_affected_connectors(state, &temp_crtc->base);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_WARN_ON(display->drm, IS_ERR(temp_crtc_state) || ret);
|
2023-05-10 13:31:24 +03:00
|
|
|
}
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
display->funcs.display->crtc_disable(to_intel_atomic_state(state), crtc);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
drm_atomic_state_put(state);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"[CRTC:%d:%s] hw state adjusted, was enabled, now disabled\n",
|
|
|
|
crtc->base.base.id, crtc->base.name);
|
|
|
|
|
|
|
|
crtc->active = false;
|
|
|
|
crtc->base.enabled = false;
|
|
|
|
|
2025-05-15 12:47:53 +05:30
|
|
|
if (crtc_state->intel_dpll)
|
2025-05-15 12:47:57 +05:30
|
|
|
intel_dpll_crtc_put(crtc,
|
|
|
|
crtc_state->intel_dpll,
|
|
|
|
&crtc_state->intel_dpll->state);
|
2023-05-10 13:31:22 +03:00
|
|
|
}
|
|
|
|
|
2023-05-10 13:31:23 +03:00
|
|
|
static void set_encoder_for_connector(struct intel_connector *connector,
|
|
|
|
struct intel_encoder *encoder)
|
|
|
|
{
|
|
|
|
struct drm_connector_state *conn_state = connector->base.state;
|
|
|
|
|
|
|
|
if (conn_state->crtc)
|
|
|
|
drm_connector_put(&connector->base);
|
|
|
|
|
|
|
|
if (encoder) {
|
|
|
|
conn_state->best_encoder = &encoder->base;
|
|
|
|
conn_state->crtc = encoder->base.crtc;
|
|
|
|
drm_connector_get(&connector->base);
|
|
|
|
} else {
|
|
|
|
conn_state->best_encoder = NULL;
|
|
|
|
conn_state->crtc = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:31:24 +03:00
|
|
|
static void reset_encoder_connector_state(struct intel_encoder *encoder)
|
|
|
|
{
|
2024-12-31 18:27:39 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2023-06-06 23:10:32 +03:00
|
|
|
struct intel_pmdemand_state *pmdemand_state =
|
2025-04-09 21:17:43 +03:00
|
|
|
to_intel_pmdemand_state(display->pmdemand.obj.state);
|
2023-05-10 13:31:24 +03:00
|
|
|
struct intel_connector *connector;
|
|
|
|
struct drm_connector_list_iter conn_iter;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_connector_list_iter_begin(display->drm, &conn_iter);
|
2023-05-10 13:31:24 +03:00
|
|
|
for_each_intel_connector_iter(connector, &conn_iter) {
|
|
|
|
if (connector->base.encoder != &encoder->base)
|
|
|
|
continue;
|
|
|
|
|
2023-06-06 23:10:32 +03:00
|
|
|
/* Clear the corresponding bit in pmdemand active phys mask */
|
2024-12-31 18:27:39 +02:00
|
|
|
intel_pmdemand_update_phys_mask(display, encoder,
|
2023-06-06 23:10:32 +03:00
|
|
|
pmdemand_state, false);
|
|
|
|
|
2023-05-10 13:31:24 +03:00
|
|
|
set_encoder_for_connector(connector, NULL);
|
|
|
|
|
|
|
|
connector->base.dpms = DRM_MODE_DPMS_OFF;
|
|
|
|
connector->base.encoder = NULL;
|
|
|
|
}
|
|
|
|
drm_connector_list_iter_end(&conn_iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void reset_crtc_encoder_state(struct intel_crtc *crtc)
|
2023-05-10 13:31:22 +03:00
|
|
|
{
|
2025-04-09 21:17:43 +03:00
|
|
|
struct intel_display *display = to_intel_display(crtc);
|
2023-05-10 13:31:22 +03:00
|
|
|
struct intel_encoder *encoder;
|
2023-05-10 13:31:24 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_encoder_on_crtc(display->drm, &crtc->base, encoder) {
|
2023-05-10 13:31:24 +03:00
|
|
|
reset_encoder_connector_state(encoder);
|
|
|
|
encoder->base.crtc = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void intel_crtc_disable_noatomic_complete(struct intel_crtc *crtc)
|
|
|
|
{
|
2024-12-31 18:27:39 +02:00
|
|
|
struct intel_display *display = to_intel_display(crtc);
|
2023-06-06 23:10:32 +03:00
|
|
|
struct intel_pmdemand_state *pmdemand_state =
|
2025-04-08 16:38:35 +03:00
|
|
|
to_intel_pmdemand_state(display->pmdemand.obj.state);
|
2023-05-10 13:31:22 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
enum pipe pipe = crtc->pipe;
|
2023-05-10 13:31:20 +03:00
|
|
|
|
|
|
|
__drm_atomic_helper_crtc_destroy_state(&crtc_state->uapi);
|
2022-06-17 12:48:16 +03:00
|
|
|
intel_crtc_free_hw_state(crtc_state);
|
2023-05-10 13:31:20 +03:00
|
|
|
intel_crtc_state_reset(crtc_state, crtc);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2023-05-10 13:31:24 +03:00
|
|
|
reset_crtc_encoder_state(crtc);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
intel_fbc_disable(crtc);
|
2025-04-08 16:38:35 +03:00
|
|
|
intel_update_watermarks(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-02-06 20:55:27 +02:00
|
|
|
intel_display_power_put_all_in_set(display, &crtc->enabled_power_domains);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-03-06 18:34:06 +02:00
|
|
|
intel_cdclk_crtc_disable_noatomic(crtc);
|
2025-03-06 18:34:07 +02:00
|
|
|
skl_wm_crtc_disable_noatomic(crtc);
|
2025-03-06 18:34:10 +02:00
|
|
|
intel_bw_crtc_disable_noatomic(crtc);
|
2023-06-06 23:10:32 +03:00
|
|
|
|
2024-12-31 18:27:39 +02:00
|
|
|
intel_pmdemand_update_port_clock(display, pmdemand_state, pipe, 0);
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|
|
|
|
|
2023-05-10 13:31:24 +03:00
|
|
|
/*
|
|
|
|
* Return all the pipes using a transcoder in @transcoder_mask.
|
2024-06-03 14:25:50 +03:00
|
|
|
* For joiner configs return only the joiner primary.
|
2023-05-10 13:31:24 +03:00
|
|
|
*/
|
2025-04-09 21:17:43 +03:00
|
|
|
static u8 get_transcoder_pipes(struct intel_display *display,
|
2023-05-10 13:31:24 +03:00
|
|
|
u8 transcoder_mask)
|
|
|
|
{
|
|
|
|
struct intel_crtc *temp_crtc;
|
|
|
|
u8 pipes = 0;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc(display->drm, temp_crtc) {
|
2023-05-10 13:31:24 +03:00
|
|
|
struct intel_crtc_state *temp_crtc_state =
|
|
|
|
to_intel_crtc_state(temp_crtc->base.state);
|
|
|
|
|
|
|
|
if (temp_crtc_state->cpu_transcoder == INVALID_TRANSCODER)
|
|
|
|
continue;
|
|
|
|
|
2024-06-03 14:25:50 +03:00
|
|
|
if (intel_crtc_is_joiner_secondary(temp_crtc_state))
|
2023-05-10 13:31:24 +03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (transcoder_mask & BIT(temp_crtc_state->cpu_transcoder))
|
|
|
|
pipes |= BIT(temp_crtc->pipe);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pipes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the port sync master and slave pipes linked to @crtc.
|
2024-06-03 14:25:50 +03:00
|
|
|
* For joiner configs return only the joiner primary pipes.
|
2023-05-10 13:31:24 +03:00
|
|
|
*/
|
|
|
|
static void get_portsync_pipes(struct intel_crtc *crtc,
|
|
|
|
u8 *master_pipe_mask, u8 *slave_pipes_mask)
|
|
|
|
{
|
2024-09-04 16:06:32 +03:00
|
|
|
struct intel_display *display = to_intel_display(crtc);
|
2023-05-10 13:31:24 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
struct intel_crtc *master_crtc;
|
|
|
|
struct intel_crtc_state *master_crtc_state;
|
|
|
|
enum transcoder master_transcoder;
|
|
|
|
|
|
|
|
if (!is_trans_port_sync_mode(crtc_state)) {
|
|
|
|
*master_pipe_mask = BIT(crtc->pipe);
|
|
|
|
*slave_pipes_mask = 0;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_trans_port_sync_master(crtc_state))
|
|
|
|
master_transcoder = crtc_state->cpu_transcoder;
|
|
|
|
else
|
|
|
|
master_transcoder = crtc_state->master_transcoder;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
*master_pipe_mask = get_transcoder_pipes(display, BIT(master_transcoder));
|
|
|
|
drm_WARN_ON(display->drm, !is_power_of_2(*master_pipe_mask));
|
2023-05-10 13:31:24 +03:00
|
|
|
|
2024-09-04 16:06:32 +03:00
|
|
|
master_crtc = intel_crtc_for_pipe(display, ffs(*master_pipe_mask) - 1);
|
2023-05-10 13:31:24 +03:00
|
|
|
master_crtc_state = to_intel_crtc_state(master_crtc->base.state);
|
2025-04-09 21:17:43 +03:00
|
|
|
*slave_pipes_mask = get_transcoder_pipes(display, master_crtc_state->sync_mode_slaves_mask);
|
2023-05-10 13:31:24 +03:00
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
static u8 get_joiner_secondary_pipes(struct intel_display *display, u8 primary_pipes_mask)
|
2023-05-10 13:31:24 +03:00
|
|
|
{
|
2024-06-03 14:25:50 +03:00
|
|
|
struct intel_crtc *primary_crtc;
|
2023-05-10 13:31:24 +03:00
|
|
|
u8 pipes = 0;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc_in_pipe_mask(display->drm, primary_crtc, primary_pipes_mask) {
|
2024-06-03 14:25:50 +03:00
|
|
|
struct intel_crtc_state *primary_crtc_state =
|
|
|
|
to_intel_crtc_state(primary_crtc->base.state);
|
2023-05-10 13:31:24 +03:00
|
|
|
|
2024-06-03 14:25:50 +03:00
|
|
|
pipes |= intel_crtc_joiner_secondary_pipes(primary_crtc_state);
|
2023-05-10 13:31:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return pipes;
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:31:22 +03:00
|
|
|
static void intel_crtc_disable_noatomic(struct intel_crtc *crtc,
|
|
|
|
struct drm_modeset_acquire_ctx *ctx)
|
|
|
|
{
|
2025-04-09 21:17:43 +03:00
|
|
|
struct intel_display *display = to_intel_display(crtc);
|
|
|
|
struct intel_crtc *temp_crtc;
|
2023-05-10 13:31:24 +03:00
|
|
|
u8 portsync_master_mask;
|
|
|
|
u8 portsync_slaves_mask;
|
2024-06-03 14:25:50 +03:00
|
|
|
u8 joiner_secondaries_mask;
|
2023-05-10 13:31:24 +03:00
|
|
|
|
|
|
|
/* TODO: Add support for MST */
|
|
|
|
get_portsync_pipes(crtc, &portsync_master_mask, &portsync_slaves_mask);
|
2025-04-09 21:17:43 +03:00
|
|
|
joiner_secondaries_mask = get_joiner_secondary_pipes(display,
|
2024-06-03 14:25:50 +03:00
|
|
|
portsync_master_mask |
|
|
|
|
portsync_slaves_mask);
|
2023-05-10 13:31:24 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_WARN_ON(display->drm,
|
2023-05-10 13:31:24 +03:00
|
|
|
portsync_master_mask & portsync_slaves_mask ||
|
2024-06-03 14:25:50 +03:00
|
|
|
portsync_master_mask & joiner_secondaries_mask ||
|
|
|
|
portsync_slaves_mask & joiner_secondaries_mask);
|
2023-05-10 13:31:24 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc_in_pipe_mask(display->drm, temp_crtc, joiner_secondaries_mask)
|
2023-05-10 13:31:24 +03:00
|
|
|
intel_crtc_disable_noatomic_begin(temp_crtc, ctx);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc_in_pipe_mask(display->drm, temp_crtc, portsync_slaves_mask)
|
2023-05-10 13:31:24 +03:00
|
|
|
intel_crtc_disable_noatomic_begin(temp_crtc, ctx);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc_in_pipe_mask(display->drm, temp_crtc, portsync_master_mask)
|
2023-05-10 13:31:24 +03:00
|
|
|
intel_crtc_disable_noatomic_begin(temp_crtc, ctx);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc_in_pipe_mask(display->drm, temp_crtc,
|
2024-06-03 14:25:50 +03:00
|
|
|
joiner_secondaries_mask |
|
2023-05-10 13:31:24 +03:00
|
|
|
portsync_slaves_mask |
|
|
|
|
portsync_master_mask)
|
|
|
|
intel_crtc_disable_noatomic_complete(temp_crtc);
|
2023-05-10 13:31:22 +03:00
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
static void intel_modeset_update_connector_atomic_state(struct intel_display *display)
|
2022-06-17 12:48:16 +03:00
|
|
|
{
|
|
|
|
struct intel_connector *connector;
|
|
|
|
struct drm_connector_list_iter conn_iter;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_connector_list_iter_begin(display->drm, &conn_iter);
|
2022-06-17 12:48:16 +03:00
|
|
|
for_each_intel_connector_iter(connector, &conn_iter) {
|
|
|
|
struct drm_connector_state *conn_state = connector->base.state;
|
|
|
|
struct intel_encoder *encoder =
|
|
|
|
to_intel_encoder(connector->base.encoder);
|
|
|
|
|
2023-05-10 13:31:23 +03:00
|
|
|
set_encoder_for_connector(connector, encoder);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
if (encoder) {
|
|
|
|
struct intel_crtc *crtc =
|
|
|
|
to_intel_crtc(encoder->base.crtc);
|
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
|
|
|
conn_state->max_bpc = (crtc_state->pipe_bpp ?: 24) / 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drm_connector_list_iter_end(&conn_iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void intel_crtc_copy_hw_to_uapi_state(struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
2025-04-09 21:17:43 +03:00
|
|
|
struct intel_display *display = to_intel_display(crtc_state);
|
2024-07-10 15:41:37 +03:00
|
|
|
|
2024-06-03 14:25:50 +03:00
|
|
|
if (intel_crtc_is_joiner_secondary(crtc_state))
|
2022-06-17 12:48:16 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
crtc_state->uapi.enable = crtc_state->hw.enable;
|
|
|
|
crtc_state->uapi.active = crtc_state->hw.active;
|
|
|
|
drm_WARN_ON(crtc_state->uapi.crtc->dev,
|
|
|
|
drm_atomic_set_mode_for_crtc(&crtc_state->uapi, &crtc_state->hw.mode) < 0);
|
|
|
|
|
|
|
|
crtc_state->uapi.adjusted_mode = crtc_state->hw.adjusted_mode;
|
|
|
|
crtc_state->uapi.scaling_filter = crtc_state->hw.scaling_filter;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
if (DISPLAY_INFO(display)->color.degamma_lut_size) {
|
2024-07-10 15:41:37 +03:00
|
|
|
/* assume 1:1 mapping */
|
|
|
|
drm_property_replace_blob(&crtc_state->hw.degamma_lut,
|
|
|
|
crtc_state->pre_csc_lut);
|
|
|
|
drm_property_replace_blob(&crtc_state->hw.gamma_lut,
|
|
|
|
crtc_state->post_csc_lut);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* ilk/snb hw may be configured for either pre_csc_lut
|
|
|
|
* or post_csc_lut, but we don't advertise degamma_lut as
|
|
|
|
* being available in the uapi since there is only one
|
|
|
|
* hardware LUT. Always assign the result of the readout
|
|
|
|
* to gamma_lut as that is the only valid source of LUTs
|
|
|
|
* in the uapi.
|
|
|
|
*/
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_WARN_ON(display->drm, crtc_state->post_csc_lut &&
|
2024-07-10 15:41:37 +03:00
|
|
|
crtc_state->pre_csc_lut);
|
|
|
|
|
|
|
|
drm_property_replace_blob(&crtc_state->hw.degamma_lut,
|
|
|
|
NULL);
|
|
|
|
drm_property_replace_blob(&crtc_state->hw.gamma_lut,
|
|
|
|
crtc_state->post_csc_lut ?:
|
|
|
|
crtc_state->pre_csc_lut);
|
|
|
|
}
|
2022-10-24 19:15:11 +03:00
|
|
|
|
2022-06-17 12:48:16 +03:00
|
|
|
drm_property_replace_blob(&crtc_state->uapi.degamma_lut,
|
|
|
|
crtc_state->hw.degamma_lut);
|
|
|
|
drm_property_replace_blob(&crtc_state->uapi.gamma_lut,
|
|
|
|
crtc_state->hw.gamma_lut);
|
|
|
|
drm_property_replace_blob(&crtc_state->uapi.ctm,
|
|
|
|
crtc_state->hw.ctm);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2025-04-09 21:17:43 +03:00
|
|
|
intel_sanitize_plane_mapping(struct intel_display *display)
|
2022-06-17 12:48:16 +03:00
|
|
|
{
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
if (DISPLAY_VER(display) >= 4)
|
2022-06-17 12:48:16 +03:00
|
|
|
return;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc(display->drm, crtc) {
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_plane *plane =
|
|
|
|
to_intel_plane(crtc->base.primary);
|
|
|
|
struct intel_crtc *plane_crtc;
|
|
|
|
enum pipe pipe;
|
|
|
|
|
|
|
|
if (!plane->get_hw_state(plane, &pipe))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (pipe == crtc->pipe)
|
|
|
|
continue;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"[PLANE:%d:%s] attached to the wrong pipe, disabling plane\n",
|
|
|
|
plane->base.base.id, plane->base.name);
|
|
|
|
|
2024-09-04 16:06:32 +03:00
|
|
|
plane_crtc = intel_crtc_for_pipe(display, pipe);
|
2022-06-17 12:48:16 +03:00
|
|
|
intel_plane_disable_noatomic(plane_crtc, plane);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool intel_crtc_has_encoders(struct intel_crtc *crtc)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = crtc->base.dev;
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
|
|
|
|
for_each_encoder_on_crtc(dev, &crtc->base, encoder)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
static bool intel_crtc_needs_link_reset(struct intel_crtc *crtc)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = crtc->base.dev;
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
|
|
|
|
for_each_encoder_on_crtc(dev, &crtc->base, encoder) {
|
|
|
|
struct intel_digital_port *dig_port = enc_to_dig_port(encoder);
|
|
|
|
|
|
|
|
if (dig_port && intel_tc_port_link_needs_reset(dig_port))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-06-17 12:48:16 +03:00
|
|
|
static struct intel_connector *intel_encoder_find_connector(struct intel_encoder *encoder)
|
|
|
|
{
|
2025-04-09 21:17:43 +03:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2022-10-20 16:16:35 +05:30
|
|
|
struct drm_connector_list_iter conn_iter;
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_connector *connector;
|
2022-10-20 16:16:35 +05:30
|
|
|
struct intel_connector *found_connector = NULL;
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_connector_list_iter_begin(display->drm, &conn_iter);
|
2022-10-20 16:16:35 +05:30
|
|
|
for_each_intel_connector_iter(connector, &conn_iter) {
|
|
|
|
if (&encoder->base == connector->base.encoder) {
|
|
|
|
found_connector = connector;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drm_connector_list_iter_end(&conn_iter);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2022-10-20 16:16:35 +05:30
|
|
|
return found_connector;
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void intel_sanitize_fifo_underrun_reporting(const struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
2025-02-12 18:36:42 +02:00
|
|
|
struct intel_display *display = to_intel_display(crtc_state);
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
|
|
|
|
|
|
|
/*
|
2023-01-25 20:52:30 +02:00
|
|
|
* We start out with underrun reporting disabled on active
|
|
|
|
* pipes to avoid races.
|
2022-06-17 12:48:16 +03:00
|
|
|
*
|
|
|
|
* Also on gmch platforms we dont have any hardware bits to
|
|
|
|
* disable the underrun reporting. Which means we need to start
|
|
|
|
* out with underrun reporting disabled also on inactive pipes,
|
|
|
|
* since otherwise we'll complain about the garbage we read when
|
|
|
|
* e.g. coming up after runtime pm.
|
|
|
|
*
|
|
|
|
* No protection against concurrent access is required - at
|
|
|
|
* worst a fifo underrun happens which also sets this to false.
|
|
|
|
*/
|
2025-02-12 18:36:42 +02:00
|
|
|
intel_init_fifo_underrun_reporting(display, crtc,
|
2023-01-25 20:52:30 +02:00
|
|
|
!crtc_state->hw.active &&
|
2025-02-12 18:36:42 +02:00
|
|
|
!HAS_GMCH(display));
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|
|
|
|
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
static bool intel_sanitize_crtc(struct intel_crtc *crtc,
|
2022-06-17 12:48:16 +03:00
|
|
|
struct drm_modeset_acquire_ctx *ctx)
|
|
|
|
{
|
2025-04-09 21:17:43 +03:00
|
|
|
struct intel_display *display = to_intel_display(crtc);
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc_state *crtc_state = to_intel_crtc_state(crtc->base.state);
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
bool needs_link_reset;
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
if (crtc_state->hw.active) {
|
|
|
|
struct intel_plane *plane;
|
|
|
|
|
|
|
|
/* Disable everything but the primary plane */
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_plane_on_crtc(display->drm, crtc, plane) {
|
2022-06-17 12:48:16 +03:00
|
|
|
const struct intel_plane_state *plane_state =
|
|
|
|
to_intel_plane_state(plane->base.state);
|
|
|
|
|
|
|
|
if (plane_state->uapi.visible &&
|
|
|
|
plane->base.type != DRM_PLANE_TYPE_PRIMARY)
|
|
|
|
intel_plane_disable_noatomic(crtc, plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable any background color/etc. set by the BIOS */
|
2024-09-30 20:04:14 +03:00
|
|
|
intel_color_commit_noarm(NULL, crtc_state);
|
|
|
|
intel_color_commit_arm(NULL, crtc_state);
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|
|
|
|
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
if (!crtc_state->hw.active ||
|
2024-06-03 14:25:50 +03:00
|
|
|
intel_crtc_is_joiner_secondary(crtc_state))
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
return false;
|
|
|
|
|
|
|
|
needs_link_reset = intel_crtc_needs_link_reset(crtc);
|
|
|
|
|
2022-06-17 12:48:16 +03:00
|
|
|
/*
|
|
|
|
* Adjust the state of the output pipe according to whether we have
|
|
|
|
* active connectors/encoders.
|
|
|
|
*/
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
if (!needs_link_reset && intel_crtc_has_encoders(crtc))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
intel_crtc_disable_noatomic(crtc, ctx);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The HPD state on other active/disconnected TC ports may be stuck in
|
|
|
|
* the connected state until this port is disabled and a ~10ms delay has
|
|
|
|
* passed, wait here for that so that sanitizing other CRTCs will see the
|
|
|
|
* up-to-date HPD state.
|
|
|
|
*/
|
|
|
|
if (needs_link_reset)
|
|
|
|
msleep(20);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
static void intel_sanitize_all_crtcs(struct intel_display *display,
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
struct drm_modeset_acquire_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
u32 crtcs_forced_off = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An active and disconnected TypeC port prevents the HPD live state
|
|
|
|
* to get updated on other active/disconnected TypeC ports, so after
|
|
|
|
* a port gets disabled the CRTCs using other TypeC ports must be
|
|
|
|
* rechecked wrt. their link status.
|
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
u32 old_mask = crtcs_forced_off;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc(display->drm, crtc) {
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
u32 crtc_mask = drm_crtc_mask(&crtc->base);
|
|
|
|
|
|
|
|
if (crtcs_forced_off & crtc_mask)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (intel_sanitize_crtc(crtc, ctx))
|
|
|
|
crtcs_forced_off |= crtc_mask;
|
|
|
|
}
|
|
|
|
if (crtcs_forced_off == old_mask)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc(display->drm, crtc) {
|
drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects
If the output on a DP-alt link with its sink disconnected is kept
enabled for too long (about 20 sec), then some IOM/TCSS firmware timeout
will cause havoc on the PCI bus, at least for other GFX devices on it
which will stop powering up. Since user space is not guaranteed to do a
disabling modeset in time, switch such disconnected but active links to
TBT mode - which is without such shortcomings - with a 2 second delay.
If the above condition is detected already during the driver load/system
resume sanitization step disable the output instead, as at that point no
user space or kernel client depends on a consistent output state yet and
because subsequent atomic modeset on such connectors - without the
actual sink capabilities available - can fail.
An active/disconnected port as above will also block the HPD status of
other active/disconnected ports to get updated (stuck in the connected
state), until the former port is disabled, its PHY is disconnected and
a ~10 ms delay has elapsed. This means the link state for all TypeC
ports/CRTCs must be rechecked after a CRTC is disabled due to the above
reason. For this disconnect the PHY synchronously after the CRTC/port is
disabled and recheck all CRTCs for the above condition whenever such a
port is disabled.
To account for a race condition during driver loading where the sink is
disconnected after the above sanitization step and before the HPD
interrupts get enabled, do an explicit check/link reset if needed from
the encoder's late_register hook, which is called after the HPD
interrupts are enabled already.
v2:
- Handle an active/disconnected port blocking the HPD state update of
another active/disconnected port.
- Cancel the delayed work resetting the link also from the encoder
enable/suspend/shutdown hooks.
- Rebase on the earlier intel_modeset_lock_ctx_retry() addition,
fixing here the missed atomic state reset in case of a retry.
- Fix handling of an error return from intel_atomic_get_crtc_state().
- Recheck if the port needs to be reset after all the atomic state
is locked and async commits are waited on.
v3:
- Add intel_crtc_needs_link_reset(), instead of open-coding it,
keep intel_crtc_has_encoders(). (Ville)
- Fix state dumping and use a bitmask to track disabled CRTCs in
intel_sanitize_all_crtcs(). (Ville)
- Set internal in intel_atomic_state right after allocating it.
(Ville)
- Recheck all CRTCs (not yet force-disabled) after a CRTC is
force-disabled for any reason (not only due to a link state)
in intel_sanitize_all_crtcs().
- Reduce delay after CRTC disabling to 20ms, and use the simpler
msleep().
- Clarify code comment about HPD behaviour in
intel_sanitize_all_crtcs().
- Move all the TC link reset logic to intel_tc.c .
- Cancel the link reset work synchronously during system suspend,
driver unload and shutdown.
v4:
- Rebased on previous patch, which allows calling the TC port
suspend/cleanup handlers without modeset locks held; remove the
display driver suspended assert from the link reset work
accordingly.
v5: (Ville)
- Remove reset work canceling from intel_ddi_pre_pll_enable().
- Track a crtc vs. pipe mask in intel_sanitize_all_crtcs().
- Add reset_link_commit() to clarify the
intel_modeset_lock_ctx_retry loop.
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5860
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512195513.2699-2-imre.deak@intel.com
2023-05-12 22:55:13 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
|
|
|
intel_crtc_state_dump(crtc_state, NULL, "setup_hw_state");
|
|
|
|
}
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool has_bogus_dpll_config(const struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
2025-04-09 21:17:43 +03:00
|
|
|
struct intel_display *display = to_intel_display(crtc_state);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Some SNB BIOSen (eg. ASUS K53SV) are known to misprogram
|
|
|
|
* the hardware when a high res displays plugged in. DPLL P
|
|
|
|
* divider is zero, and the pipe timings are bonkers. We'll
|
|
|
|
* try to disable everything in that case.
|
|
|
|
*
|
|
|
|
* FIXME would be nice to be able to sanitize this state
|
|
|
|
* without several WARNs, but for now let's take the easy
|
|
|
|
* road.
|
|
|
|
*/
|
2025-04-09 21:17:43 +03:00
|
|
|
return display->platform.sandybridge &&
|
2022-06-17 12:48:16 +03:00
|
|
|
crtc_state->hw.active &&
|
2025-05-15 12:47:53 +05:30
|
|
|
crtc_state->intel_dpll &&
|
2022-06-17 12:48:16 +03:00
|
|
|
crtc_state->port_clock == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void intel_sanitize_encoder(struct intel_encoder *encoder)
|
|
|
|
{
|
2024-12-31 18:27:39 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_connector *connector;
|
|
|
|
struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
|
|
|
|
struct intel_crtc_state *crtc_state = crtc ?
|
|
|
|
to_intel_crtc_state(crtc->base.state) : NULL;
|
2023-06-06 23:10:32 +03:00
|
|
|
struct intel_pmdemand_state *pmdemand_state =
|
2025-04-09 21:17:43 +03:00
|
|
|
to_intel_pmdemand_state(display->pmdemand.obj.state);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to check both for a crtc link (meaning that the encoder is
|
|
|
|
* active and trying to read from a pipe) and the pipe itself being
|
|
|
|
* active.
|
|
|
|
*/
|
|
|
|
bool has_active_crtc = crtc_state &&
|
|
|
|
crtc_state->hw.active;
|
|
|
|
|
|
|
|
if (crtc_state && has_bogus_dpll_config(crtc_state)) {
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"BIOS has misprogrammed the hardware. Disabling pipe %c\n",
|
|
|
|
pipe_name(crtc->pipe));
|
|
|
|
has_active_crtc = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
connector = intel_encoder_find_connector(encoder);
|
|
|
|
if (connector && !has_active_crtc) {
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"[ENCODER:%d:%s] has active connectors but no active pipe!\n",
|
|
|
|
encoder->base.base.id,
|
|
|
|
encoder->base.name);
|
|
|
|
|
2023-06-06 23:10:32 +03:00
|
|
|
/* Clear the corresponding bit in pmdemand active phys mask */
|
2024-12-31 18:27:39 +02:00
|
|
|
intel_pmdemand_update_phys_mask(display, encoder,
|
2023-06-06 23:10:32 +03:00
|
|
|
pmdemand_state, false);
|
|
|
|
|
2022-06-17 12:48:16 +03:00
|
|
|
/*
|
|
|
|
* Connector is active, but has no active pipe. This is fallout
|
|
|
|
* from our resume register restoring. Disable the encoder
|
|
|
|
* manually again.
|
|
|
|
*/
|
|
|
|
if (crtc_state) {
|
|
|
|
struct drm_encoder *best_encoder;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"[ENCODER:%d:%s] manually disabled\n",
|
|
|
|
encoder->base.base.id,
|
|
|
|
encoder->base.name);
|
|
|
|
|
|
|
|
/* avoid oopsing in case the hooks consult best_encoder */
|
|
|
|
best_encoder = connector->base.state->best_encoder;
|
|
|
|
connector->base.state->best_encoder = &encoder->base;
|
|
|
|
|
|
|
|
/* FIXME NULL atomic state passed! */
|
|
|
|
if (encoder->disable)
|
|
|
|
encoder->disable(NULL, encoder, crtc_state,
|
|
|
|
connector->base.state);
|
|
|
|
if (encoder->post_disable)
|
|
|
|
encoder->post_disable(NULL, encoder, crtc_state,
|
|
|
|
connector->base.state);
|
|
|
|
|
|
|
|
connector->base.state->best_encoder = best_encoder;
|
|
|
|
}
|
|
|
|
encoder->base.crtc = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Inconsistent output/port/pipe state happens presumably due to
|
|
|
|
* a bug in one of the get_hw_state functions. Or someplace else
|
|
|
|
* in our code, like the register restore mess on resume. Clamp
|
|
|
|
* things to off as a safer default.
|
|
|
|
*/
|
|
|
|
connector->base.dpms = DRM_MODE_DPMS_OFF;
|
|
|
|
connector->base.encoder = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* notify opregion of the sanitized encoder state */
|
|
|
|
intel_opregion_notify_encoder(encoder, connector && has_active_crtc);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
if (HAS_DDI(display))
|
2022-06-17 12:48:16 +03:00
|
|
|
intel_ddi_sanitize_encoder_pll_mapping(encoder);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME read out full plane state for all planes */
|
2025-04-09 21:17:43 +03:00
|
|
|
static void readout_plane_state(struct intel_display *display)
|
2022-06-17 12:48:16 +03:00
|
|
|
{
|
|
|
|
struct intel_plane *plane;
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_plane(display->drm, plane) {
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_plane_state *plane_state =
|
|
|
|
to_intel_plane_state(plane->base.state);
|
|
|
|
struct intel_crtc_state *crtc_state;
|
|
|
|
enum pipe pipe = PIPE_A;
|
|
|
|
bool visible;
|
|
|
|
|
|
|
|
visible = plane->get_hw_state(plane, &pipe);
|
|
|
|
|
2024-09-04 16:06:32 +03:00
|
|
|
crtc = intel_crtc_for_pipe(display, pipe);
|
2022-06-17 12:48:16 +03:00
|
|
|
crtc_state = to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
|
|
|
intel_set_plane_visible(crtc_state, plane_state, visible);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"[PLANE:%d:%s] hw state readout: %s, pipe %c\n",
|
|
|
|
plane->base.base.id, plane->base.name,
|
|
|
|
str_enabled_disabled(visible), pipe_name(pipe));
|
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc(display->drm, crtc) {
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
|
|
|
intel_plane_fixup_bitmasks(crtc_state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
static void intel_modeset_readout_hw_state(struct intel_display *display)
|
2022-06-17 12:48:16 +03:00
|
|
|
{
|
2023-06-06 23:10:32 +03:00
|
|
|
struct intel_pmdemand_state *pmdemand_state =
|
2025-04-09 21:17:43 +03:00
|
|
|
to_intel_pmdemand_state(display->pmdemand.obj.state);
|
2022-06-17 12:48:16 +03:00
|
|
|
enum pipe pipe;
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
struct intel_connector *connector;
|
|
|
|
struct drm_connector_list_iter conn_iter;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc(display->drm, crtc) {
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
|
|
|
__drm_atomic_helper_crtc_destroy_state(&crtc_state->uapi);
|
|
|
|
intel_crtc_free_hw_state(crtc_state);
|
|
|
|
intel_crtc_state_reset(crtc_state, crtc);
|
|
|
|
|
|
|
|
intel_crtc_get_pipe_config(crtc_state);
|
|
|
|
|
|
|
|
crtc_state->hw.enable = crtc_state->hw.active;
|
|
|
|
|
|
|
|
crtc->base.enabled = crtc_state->hw.enable;
|
|
|
|
crtc->active = crtc_state->hw.active;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"[CRTC:%d:%s] hw state readout: %s\n",
|
|
|
|
crtc->base.base.id, crtc->base.name,
|
|
|
|
str_enabled_disabled(crtc_state->hw.active));
|
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
readout_plane_state(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_encoder(display->drm, encoder) {
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc_state *crtc_state = NULL;
|
|
|
|
|
|
|
|
pipe = 0;
|
|
|
|
|
|
|
|
if (encoder->get_hw_state(encoder, &pipe)) {
|
2024-09-04 16:06:32 +03:00
|
|
|
crtc = intel_crtc_for_pipe(display, pipe);
|
2022-06-17 12:48:16 +03:00
|
|
|
crtc_state = to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
|
|
|
encoder->base.crtc = &crtc->base;
|
|
|
|
intel_encoder_get_config(encoder, crtc_state);
|
|
|
|
|
2024-06-03 14:25:50 +03:00
|
|
|
/* read out to secondary crtc as well for joiner */
|
2024-06-07 10:54:57 +03:00
|
|
|
if (crtc_state->joiner_pipes) {
|
2024-06-03 14:25:50 +03:00
|
|
|
struct intel_crtc *secondary_crtc;
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2024-06-03 14:25:50 +03:00
|
|
|
/* encoder should read be linked to joiner primary */
|
|
|
|
WARN_ON(intel_crtc_is_joiner_secondary(crtc_state));
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc_in_pipe_mask(display->drm, secondary_crtc,
|
2024-06-03 14:25:50 +03:00
|
|
|
intel_crtc_joiner_secondary_pipes(crtc_state)) {
|
|
|
|
struct intel_crtc_state *secondary_crtc_state;
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2024-06-03 14:25:50 +03:00
|
|
|
secondary_crtc_state = to_intel_crtc_state(secondary_crtc->base.state);
|
|
|
|
intel_encoder_get_config(encoder, secondary_crtc_state);
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|
|
|
|
}
|
2023-06-06 23:10:32 +03:00
|
|
|
|
2024-12-31 18:27:39 +02:00
|
|
|
intel_pmdemand_update_phys_mask(display, encoder,
|
2023-06-06 23:10:32 +03:00
|
|
|
pmdemand_state,
|
|
|
|
true);
|
2022-06-17 12:48:16 +03:00
|
|
|
} else {
|
2024-12-31 18:27:39 +02:00
|
|
|
intel_pmdemand_update_phys_mask(display, encoder,
|
2023-06-06 23:10:32 +03:00
|
|
|
pmdemand_state,
|
|
|
|
false);
|
|
|
|
|
2022-06-17 12:48:16 +03:00
|
|
|
encoder->base.crtc = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (encoder->sync_state)
|
|
|
|
encoder->sync_state(encoder, crtc_state);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"[ENCODER:%d:%s] hw state readout: %s, pipe %c\n",
|
|
|
|
encoder->base.base.id, encoder->base.name,
|
|
|
|
str_enabled_disabled(encoder->base.crtc),
|
|
|
|
pipe_name(pipe));
|
|
|
|
}
|
|
|
|
|
2025-02-12 13:15:38 +05:30
|
|
|
intel_dpll_readout_hw_state(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_connector_list_iter_begin(display->drm, &conn_iter);
|
2022-06-17 12:48:16 +03:00
|
|
|
for_each_intel_connector_iter(connector, &conn_iter) {
|
2024-02-05 15:26:31 +02:00
|
|
|
struct intel_crtc_state *crtc_state = NULL;
|
|
|
|
|
2022-06-17 12:48:16 +03:00
|
|
|
if (connector->get_hw_state(connector)) {
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
|
|
connector->base.dpms = DRM_MODE_DPMS_ON;
|
|
|
|
|
|
|
|
encoder = intel_attached_encoder(connector);
|
|
|
|
connector->base.encoder = &encoder->base;
|
|
|
|
|
|
|
|
crtc = to_intel_crtc(encoder->base.crtc);
|
|
|
|
crtc_state = crtc ? to_intel_crtc_state(crtc->base.state) : NULL;
|
|
|
|
|
|
|
|
if (crtc_state && crtc_state->hw.active) {
|
|
|
|
/*
|
|
|
|
* This has to be done during hardware readout
|
|
|
|
* because anything calling .crtc_disable may
|
|
|
|
* rely on the connector_mask being accurate.
|
|
|
|
*/
|
|
|
|
crtc_state->uapi.connector_mask |=
|
|
|
|
drm_connector_mask(&connector->base);
|
|
|
|
crtc_state->uapi.encoder_mask |=
|
|
|
|
drm_encoder_mask(&encoder->base);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
connector->base.dpms = DRM_MODE_DPMS_OFF;
|
|
|
|
connector->base.encoder = NULL;
|
|
|
|
}
|
2024-02-05 15:26:31 +02:00
|
|
|
|
|
|
|
if (connector->sync_state)
|
|
|
|
connector->sync_state(connector, crtc_state);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"[CONNECTOR:%d:%s] hw state readout: %s\n",
|
|
|
|
connector->base.base.id, connector->base.name,
|
|
|
|
str_enabled_disabled(connector->base.encoder));
|
|
|
|
}
|
|
|
|
drm_connector_list_iter_end(&conn_iter);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc(display->drm, crtc) {
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
struct intel_plane *plane;
|
|
|
|
|
2025-03-26 18:25:37 +02:00
|
|
|
/*
|
|
|
|
* The initial mode needs to be set in order to keep
|
|
|
|
* the atomic core happy. It wants a valid mode if the
|
|
|
|
* crtc's enabled, so we do the above call.
|
|
|
|
*
|
|
|
|
* But we don't set all the derived state fully, hence
|
|
|
|
* set a flag to indicate that a full recalculation is
|
|
|
|
* needed on the next commit.
|
|
|
|
*/
|
|
|
|
crtc_state->inherited = true;
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-03-26 18:25:37 +02:00
|
|
|
if (crtc_state->hw.active) {
|
2023-03-20 22:33:50 +02:00
|
|
|
intel_crtc_update_active_timings(crtc_state,
|
|
|
|
crtc_state->vrr.enable);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
intel_crtc_copy_hw_to_uapi_state(crtc_state);
|
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_plane_on_crtc(display->drm, crtc, plane) {
|
2022-06-17 12:48:16 +03:00
|
|
|
const struct intel_plane_state *plane_state =
|
|
|
|
to_intel_plane_state(plane->base.state);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME don't have the fb yet, so can't
|
|
|
|
* use intel_plane_data_rate() :(
|
|
|
|
*/
|
|
|
|
if (plane_state->uapi.visible)
|
|
|
|
crtc_state->data_rate[plane->id] =
|
|
|
|
4 * crtc_state->pixel_rate;
|
|
|
|
/*
|
|
|
|
* FIXME don't have the fb yet, so can't
|
|
|
|
* use plane->min_cdclk() :(
|
|
|
|
*/
|
|
|
|
if (plane_state->uapi.visible && plane->min_cdclk) {
|
2025-04-09 21:17:43 +03:00
|
|
|
if (crtc_state->double_wide || DISPLAY_VER(display) >= 10)
|
2022-06-17 12:48:16 +03:00
|
|
|
crtc_state->min_cdclk[plane->id] =
|
|
|
|
DIV_ROUND_UP(crtc_state->pixel_rate, 2);
|
|
|
|
else
|
|
|
|
crtc_state->min_cdclk[plane->id] =
|
|
|
|
crtc_state->pixel_rate;
|
|
|
|
}
|
2025-04-09 21:17:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-06-17 12:48:16 +03:00
|
|
|
"[PLANE:%d:%s] min_cdclk %d kHz\n",
|
|
|
|
plane->base.base.id, plane->base.name,
|
|
|
|
crtc_state->min_cdclk[plane->id]);
|
|
|
|
}
|
|
|
|
|
2024-12-31 18:27:39 +02:00
|
|
|
intel_pmdemand_update_port_clock(display, pmdemand_state, pipe,
|
2023-06-06 23:10:32 +03:00
|
|
|
crtc_state->port_clock);
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|
2023-06-06 23:10:32 +03:00
|
|
|
|
2025-03-06 18:34:18 +02:00
|
|
|
/* TODO move here (or even earlier?) on all platforms */
|
|
|
|
if (DISPLAY_VER(display) >= 9)
|
2025-04-08 16:38:35 +03:00
|
|
|
intel_wm_get_hw_state(display);
|
2025-03-06 18:34:18 +02:00
|
|
|
|
2025-03-06 18:34:12 +02:00
|
|
|
intel_bw_update_hw_state(display);
|
2025-03-06 18:34:11 +02:00
|
|
|
intel_cdclk_update_hw_state(display);
|
|
|
|
|
2024-12-31 18:27:39 +02:00
|
|
|
intel_pmdemand_init_pmdemand_params(display, pmdemand_state);
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2025-04-09 21:17:43 +03:00
|
|
|
get_encoder_power_domains(struct intel_display *display)
|
2022-06-17 12:48:16 +03:00
|
|
|
{
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_encoder(display->drm, encoder) {
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc_state *crtc_state;
|
|
|
|
|
|
|
|
if (!encoder->get_power_domains)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MST-primary and inactive encoders don't have a crtc state
|
|
|
|
* and neither of these require any power domain references.
|
|
|
|
*/
|
|
|
|
if (!encoder->base.crtc)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
crtc_state = to_intel_crtc_state(encoder->base.crtc->state);
|
|
|
|
encoder->get_power_domains(encoder, crtc_state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
static void intel_early_display_was(struct intel_display *display)
|
2022-06-17 12:48:16 +03:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Display WA #1185 WaDisableDARBFClkGating:glk,icl,ehl,tgl
|
|
|
|
* Also known as Wa_14010480278.
|
|
|
|
*/
|
2025-04-09 21:17:43 +03:00
|
|
|
if (IS_DISPLAY_VER(display, 10, 12))
|
|
|
|
intel_de_rmw(display, GEN9_CLKGATE_DIS_0, 0, DARBF_GATING_DIS);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2023-01-05 14:10:38 +01:00
|
|
|
/*
|
|
|
|
* WaRsPkgCStateDisplayPMReq:hsw
|
|
|
|
* System hang if this isn't done before disabling all planes!
|
|
|
|
*/
|
2025-04-09 21:17:43 +03:00
|
|
|
if (display->platform.haswell)
|
|
|
|
intel_de_rmw(display, CHICKEN_PAR1_1, 0, FORCE_ARB_IDLE_PLANES);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
if (display->platform.kabylake || display->platform.coffeelake ||
|
|
|
|
display->platform.cometlake) {
|
2022-06-17 12:48:16 +03:00
|
|
|
/* Display WA #1142:kbl,cfl,cml */
|
2025-04-09 21:17:43 +03:00
|
|
|
intel_de_rmw(display, CHICKEN_PAR1_1,
|
2022-06-17 12:48:16 +03:00
|
|
|
KBL_ARB_FILL_SPARE_22, KBL_ARB_FILL_SPARE_22);
|
2025-04-09 21:17:43 +03:00
|
|
|
intel_de_rmw(display, CHICKEN_MISC_2,
|
2022-06-17 12:48:16 +03:00
|
|
|
KBL_ARB_FILL_SPARE_13 | KBL_ARB_FILL_SPARE_14,
|
|
|
|
KBL_ARB_FILL_SPARE_14);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
void intel_modeset_setup_hw_state(struct intel_display *display,
|
2022-06-17 12:48:16 +03:00
|
|
|
struct drm_modeset_acquire_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
2025-02-06 20:55:27 +02:00
|
|
|
wakeref = intel_display_power_get(display, POWER_DOMAIN_INIT);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
intel_early_display_was(display);
|
2025-04-17 14:44:54 +03:00
|
|
|
intel_vga_disable(display);
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
intel_modeset_readout_hw_state(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
|
|
|
/* HW state is read out, now we need to sanitize this mess. */
|
2025-04-09 21:17:43 +03:00
|
|
|
get_encoder_power_domains(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-03-21 12:52:55 +02:00
|
|
|
intel_pch_sanitize(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-01-24 14:38:14 -03:00
|
|
|
intel_cmtg_sanitize(display);
|
|
|
|
|
2022-06-17 12:48:16 +03:00
|
|
|
/*
|
|
|
|
* intel_sanitize_plane_mapping() may need to do vblank
|
|
|
|
* waits, so we need vblank interrupts restored beforehand.
|
|
|
|
*/
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc(display->drm, crtc) {
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
|
|
|
intel_sanitize_fifo_underrun_reporting(crtc_state);
|
|
|
|
|
|
|
|
drm_crtc_vblank_reset(&crtc->base);
|
|
|
|
|
2023-01-02 20:33:24 +02:00
|
|
|
if (crtc_state->hw.active) {
|
2025-06-17 20:07:58 +03:00
|
|
|
intel_dmc_enable_pipe(crtc_state);
|
2022-06-17 12:48:16 +03:00
|
|
|
intel_crtc_vblank_on(crtc_state);
|
2023-01-02 20:33:24 +02:00
|
|
|
}
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
intel_fbc_sanitize(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
intel_sanitize_plane_mapping(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_encoder(display->drm, encoder)
|
2022-06-17 12:48:16 +03:00
|
|
|
intel_sanitize_encoder(encoder);
|
|
|
|
|
2023-05-10 13:31:21 +03:00
|
|
|
/*
|
|
|
|
* Sanitizing CRTCs needs their connector atomic state to be
|
|
|
|
* up-to-date, so ensure that already here.
|
|
|
|
*/
|
2025-04-09 21:17:43 +03:00
|
|
|
intel_modeset_update_connector_atomic_state(display);
|
2023-05-10 13:31:21 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
intel_sanitize_all_crtcs(display, ctx);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-02-12 13:15:38 +05:30
|
|
|
intel_dpll_sanitize_state(display);
|
2022-06-17 12:48:17 +03:00
|
|
|
|
2025-03-06 18:34:18 +02:00
|
|
|
/* TODO move earlier on all platforms */
|
|
|
|
if (DISPLAY_VER(display) < 9)
|
2025-04-08 16:38:35 +03:00
|
|
|
intel_wm_get_hw_state(display);
|
|
|
|
intel_wm_sanitize(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2025-04-09 21:17:43 +03:00
|
|
|
for_each_intel_crtc(display->drm, crtc) {
|
2022-06-17 12:48:16 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
struct intel_power_domain_mask put_domains;
|
|
|
|
|
|
|
|
intel_modeset_get_crtc_power_domains(crtc_state, &put_domains);
|
2025-04-09 21:17:43 +03:00
|
|
|
if (drm_WARN_ON(display->drm, !bitmap_empty(put_domains.bits, POWER_DOMAIN_NUM)))
|
2022-06-17 12:48:16 +03:00
|
|
|
intel_modeset_put_crtc_power_domains(crtc, &put_domains);
|
|
|
|
}
|
|
|
|
|
2025-02-06 20:55:27 +02:00
|
|
|
intel_display_power_put(display, POWER_DOMAIN_INIT, wakeref);
|
2022-06-17 12:48:16 +03:00
|
|
|
|
2024-11-28 17:38:23 +02:00
|
|
|
intel_power_domains_sanitize_state(display);
|
2022-06-17 12:48:16 +03:00
|
|
|
}
|