[PATCH 023/108] drm/i915/dp_link_training: Allocate atomic state for autoretrain modeset

Imre Deak
2026-04-28T12:53:27Z

Allocate a local atomic state for the autoretrain modeset. This
prepares for a follow-up change that needs to access the state after
the modeset for sending userspace notifications.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
.../gpu/drm/i915/display/intel_dp_link_training.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.c b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
index cbabf01d4b670..b446a3523b94c 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -27,6 +27,7 @@
#include <drm/display/drm_dp_helper.h>
#include <drm/drm_print.h>

+#include "intel_display.h"
#include "intel_display_core.h"
#include "intel_display_jiffies.h"
#include "intel_display_types.h"
@@ -2157,6 +2158,8 @@ static int intel_dp_retrain_link(struct intel_encoder *encoder,
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
struct intel_dp_link_training *link_training =
intel_dp->link.training;
+ struct intel_atomic_state *state;
+ struct drm_atomic_state *_state;
u8 pipe_mask;
int ret;

@@ -2186,9 +2189,15 @@ static int intel_dp_retrain_link(struct intel_encoder *encoder,
encoder->base.base.id, encoder->base.name,
str_yes_no(intel_dp_link_training_get_force_retrain(link_training)));

- ret = intel_modeset_commit_pipes(display, pipe_mask, ctx);
+ _state = drm_atomic_state_alloc(display->drm);
+ if (!_state)
+ return -ENOMEM;
+
+ state = to_intel_atomic_state(_state);
+
+ ret = intel_modeset_commit_pipes_for_atomic_state(state, pipe_mask, ctx);
if (ret == -EDEADLK)
- return ret;
+ goto out;

intel_dp_link_training_set_force_retrain(link_training, false);

@@ -2197,6 +2206,8 @@ static int intel_dp_retrain_link(struct intel_encoder *encoder,
"[ENCODER:%d:%s] link retraining failed: %pe\n",
encoder->base.base.id, encoder->base.name,
ERR_PTR(ret));
+out:
+ drm_atomic_state_put(&state->base);

return ret;
}
--
2.49.1