The atomic_create_state callback allocates a pristine, initialized, state for the object it is called on, without any side effect.
The upcoming DRM_MODE_ATOMIC_RESET flag of the atomic ioctl relies on it to bring the whole device back to its default state, by filling a commit with such states through drm_atomic_commit_fill_with_defaults(). Both the reset itself and the DRM_CAP_ATOMIC_RESET capability reporting are gated on drm_atomic_implements_create_state(), which requires every plane, CRTC and connector of the device to implement the hook: without it, the reset is rejected with -EOPNOTSUPP. The other atomic_create_state() users don't apply to i915: it reads the state the firmware left behind out of the hardware at probe time, so it never goes through drm_mode_config_create_initial_state() nor the hardware state readout helpers. The atomic reset is thus the only user the hook enables here. The i915 CRTC functions don't implement it, relying on intel_crtc_state_alloc() being called directly instead. Since intel_crtc_state_alloc() already allocates and resets a state, wrap it in an atomic_create_state implementation and assign it to the CRTC functions. Signed-off-by: Maxime Ripard <[email protected]> --- drivers/gpu/drm/i915/display/intel_crtc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c index 10ed9bdfee76..7bb3caf91310 100644 --- a/drivers/gpu/drm/i915/display/intel_crtc.c +++ b/drivers/gpu/drm/i915/display/intel_crtc.c @@ -175,10 +175,21 @@ struct intel_crtc_state *intel_crtc_state_alloc(struct intel_crtc *crtc) intel_crtc_state_reset(crtc_state, crtc); return crtc_state; } +static struct drm_crtc_state *intel_crtc_create_state(struct drm_crtc *crtc) +{ + struct intel_crtc_state *crtc_state; + + crtc_state = intel_crtc_state_alloc(to_intel_crtc(crtc)); + if (!crtc_state) + return ERR_PTR(-ENOMEM); + + return &crtc_state->uapi; +} + void intel_crtc_state_reset(struct intel_crtc_state *crtc_state, struct intel_crtc *crtc) { memset(crtc_state, 0, sizeof(*crtc_state)); @@ -241,10 +252,11 @@ static int intel_crtc_late_register(struct drm_crtc *crtc) #define INTEL_CRTC_FUNCS \ .set_config = drm_atomic_helper_set_config, \ .destroy = intel_crtc_destroy, \ .page_flip = drm_atomic_helper_page_flip, \ + .atomic_create_state = intel_crtc_create_state, \ .atomic_duplicate_state = intel_crtc_duplicate_state, \ .atomic_destroy_state = intel_crtc_destroy_state, \ .set_crc_source = intel_crtc_set_crc_source, \ .verify_crc_source = intel_crtc_verify_crc_source, \ .get_crc_sources = intel_crtc_get_crc_sources, \ -- 2.56.1
