* [PATCH 0/6] drm/i915: Support DRM_MODE_ATOMIC_RESET
@ 2026-11-24 10:59 Maxime Ripard
2026-11-24 10:59 ` [PATCH 1/6] drm/atomic-state-helper: Provide more STATE_CHECK_* variants Maxime Ripard
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Maxime Ripard @ 2026-11-24 10:59 UTC (permalink / raw)
To: Maxime Ripard, Jani Nikula, Thomas Zimmermann, Maarten Lankhorst,
Tvrtko Ursulin, David Airlie, Simona Vetter, Joonas Lahtinen,
Rodrigo Vivi
Cc: intel-xe, intel-gfx, dri-devel
Hi,
i915 objects didn't implement the reset callback, allocating their state
when they are registered instead, so the atomic_create_state conversion
had nothing to convert and left i915 out. The new DRM_MODE_ATOMIC_RESET
flag builds its commits out of states created through that hook, and is
only reported and accepted when every plane, CRTC and connector of the
device implements it: i915 therefore rejects the reset with -EOPNOTSUPP
and doesn't report DRM_CAP_ATOMIC_RESET.
This series implements atomic_create_state for the i915 CRTCs, planes
and connectors, and carries the current state over the created ones,
like other drivers had to: a CRTC that stays enabled across a reset
takes the nomodeset path of intel_atomic_check(), which relies on the
state a duplicate carries over.
The pipe configuration comparison is also moved to the STATE_CHECK_*
macros, with the u8, u16 hexadecimal and enum variants the i915 state
needs fed back into the framework, giving every compared field
compile-time type checking to start consolidating with the new atomic
SRO infrastructure.
Built with LLVM=1 and checkpatch'd, the new macros come with kunit
tests, IGT runs are still to be done.
Let me know what you think,
Maxime
Test-with: 20261112162147.766264-1-mripard@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
Maxime Ripard (6):
drm/atomic-state-helper: Provide more STATE_CHECK_* variants
drm/i915: Use the STATE_CHECK_* macros in the pipe config comparison
drm/i915: Implement CRTC atomic_create_state
drm/i915: Implement plane atomic_create_state
drm/i915: Implement connector atomic_create_state
drm/i915: Carry the current state over created states
drivers/gpu/drm/i915/display/i9xx_plane.c | 2 +
drivers/gpu/drm/i915/display/icl_dsi.c | 1 +
drivers/gpu/drm/i915/display/intel_atomic.c | 23 +
drivers/gpu/drm/i915/display/intel_atomic.h | 2 +
drivers/gpu/drm/i915/display/intel_connector.c | 23 +-
drivers/gpu/drm/i915/display/intel_crt.c | 1 +
drivers/gpu/drm/i915/display/intel_crtc.c | 12 +
drivers/gpu/drm/i915/display/intel_cursor.c | 1 +
drivers/gpu/drm/i915/display/intel_display.c | 607 ++++++++++++---------
drivers/gpu/drm/i915/display/intel_dp.c | 1 +
drivers/gpu/drm/i915/display/intel_dp_mst.c | 1 +
drivers/gpu/drm/i915/display/intel_dvo.c | 1 +
drivers/gpu/drm/i915/display/intel_hdmi.c | 1 +
drivers/gpu/drm/i915/display/intel_lvds.c | 1 +
drivers/gpu/drm/i915/display/intel_plane.c | 25 +-
drivers/gpu/drm/i915/display/intel_plane.h | 1 +
drivers/gpu/drm/i915/display/intel_sdvo.c | 26 +-
drivers/gpu/drm/i915/display/intel_sprite.c | 3 +
drivers/gpu/drm/i915/display/intel_tv.c | 15 +
drivers/gpu/drm/i915/display/skl_universal_plane.c | 3 +
drivers/gpu/drm/i915/display/vlv_dsi.c | 1 +
.../gpu/drm/tests/drm_atomic_state_readout_test.c | 99 ++++
include/drm/drm_atomic_state_readout_helper.h | 66 +++
23 files changed, 638 insertions(+), 278 deletions(-)
---
base-commit: e6e635c4407e5bb8ddc6017a2e9825c17240e799
change-id: 20261124-drm-i915-conversion-state-readout-3086a6aa1265
prerequisite-change-id: 20260708-drm-reset-state-flag-2fb2b5711f97:v12
prerequisite-patch-id: eb7ef1bbf930a321d43086788e29a61899cabea9
prerequisite-patch-id: 69cb59e0e1800c71f284adf63ca98641df772975
prerequisite-patch-id: 794b3f9689e1eb474d90535b43d8c8de58ec5e48
prerequisite-patch-id: af7dfeb5128254a2368b8c3abd54c778caeea1fe
prerequisite-patch-id: d7baa4aaf5b686cef8a7762f6ec46e517505a7d2
prerequisite-patch-id: 3e4d1a009d6a944b20b2675d87436fb2acec2750
prerequisite-patch-id: cac360557a737dffdfec293c4c08608e327fd6fd
prerequisite-patch-id: 8e64689f12166016a371aaa15ec0e6691546c794
prerequisite-patch-id: 118c8beb0d45f5476c8814f82b79c90a4ea48e05
prerequisite-change-id: 20250730-drm-state-readout-108f089c1c30:v9
prerequisite-patch-id: f8c3385d46e2be7cba68c715e31f1b3ea80a45eb
prerequisite-patch-id: f04cf40e8c62005a0b5a928a68d394be2079a202
prerequisite-patch-id: cd09f9e502efc35aa22ede9d3c3b46e064466d22
prerequisite-patch-id: eb0a00c943fd93a555c0ef044d4008f5f83edd08
prerequisite-patch-id: a277ed9151f84539ec40ecfe630c18ff482e022c
prerequisite-patch-id: ae6b7f40f2b9002bf0eea54b1c41281db2adcde7
prerequisite-patch-id: e755bcd2e58f79d14e246446864ff204699d1a87
prerequisite-patch-id: 90687ec829c655bcfe4d81b12e24bccca7bd4833
prerequisite-patch-id: ef67b1cd0911021331844861ae0f2fad84b270fc
prerequisite-patch-id: e92f85eb974b4f507692da4fd0909cf272366b23
prerequisite-patch-id: dfe3ca8ddf643420beb99e613492ac319b2266b0
prerequisite-patch-id: fd825bcbb5b262926dca7139f759e9ad19a057de
prerequisite-patch-id: ad586d955ee4d48bc8bb935041602dfbe0fa0a8a
prerequisite-patch-id: 92a1b99d84487fc35457542f408cf3ceb40f2200
prerequisite-patch-id: f1605fb5ed653b35443647422bc348bdc3f03060
prerequisite-patch-id: aa65022cdfedaad2cedf6b5be5bf7a403d23a0cc
prerequisite-patch-id: 3f9fc15f5d3ef94c1026b020ffe08e0ff1504243
prerequisite-patch-id: 3d1e451d302dd742bec53cb1aa50643aa71ebf4c
prerequisite-patch-id: ba5c149130eb1a23094d507281bfadc444bd0b2f
prerequisite-patch-id: c89f59e3aa7165d77d1a616ab87d2ab4207ccae4
prerequisite-patch-id: 94873fa437500fc6a377875fca01ab35cb545382
prerequisite-patch-id: 66ff18129c8f0e1df1c4b899513a70f591c51eb4
prerequisite-patch-id: 08da79b7e93e614f918d0c65d3e015d7d62e0a2a
prerequisite-patch-id: 81e5473c19b1df4d76e0854305295277722b84a0
prerequisite-patch-id: 9ad81f0921c7ff7121244dfa81e8625eef2872ef
prerequisite-patch-id: 91b87c9dfd4f94ea8612d35ba0a59e734ea13478
prerequisite-patch-id: 25fbe2804e1a162e75cc083e8cb45fc01efca01b
prerequisite-patch-id: 9ef0dc76a9b0f998ea8e568849568648d4d859ea
prerequisite-patch-id: dd1b97b1854cfa5dbf7b794732e6fd7fdbab8e74
prerequisite-patch-id: a2c2d019cc44d5a7c5c64aa13039ca0502150dfe
prerequisite-patch-id: 8adda3ba9ca95ad041acfd258a31e4fe03d0c0e0
prerequisite-patch-id: 7b38fa633f4dec44d54037f1754f9d1e1c003e4d
prerequisite-patch-id: f8ff07c5ff81332c3e131c6e98532a83eab77304
prerequisite-patch-id: 3c12b1bf7245bb8ca3d98854a69c4e3eb3cc6c4e
prerequisite-patch-id: 28f453e6b4a60111c4f452bf1f470c965940df2d
prerequisite-patch-id: 5af22c10f16b8ba0920a4c9a942016982557df52
prerequisite-patch-id: f2667f1c8010b2147be6cbccdc7b4e8c8c90ca78
prerequisite-patch-id: 4b5c8d9aaa88af62ee71cdbf7581115ae8d2108e
prerequisite-patch-id: c13d82cab1c523a7589723b12a9d9c674d1b548c
prerequisite-patch-id: dc3f630e2f48e07c4287920da256f81fde29afbd
prerequisite-patch-id: e94aa17d17ba8fdbd935c455fd2ae52df3bb4d68
prerequisite-patch-id: a4f0694c3c6da19f47e160e6bed1b8b8b42c8180
prerequisite-patch-id: 732d43e26eff2f092a61d52950377bbee8d05186
Best regards,
--
Maxime Ripard <mripard@kernel.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/6] drm/atomic-state-helper: Provide more STATE_CHECK_* variants
2026-11-24 10:59 [PATCH 0/6] drm/i915: Support DRM_MODE_ATOMIC_RESET Maxime Ripard
@ 2026-11-24 10:59 ` Maxime Ripard
2026-11-24 10:59 ` [PATCH 2/6] drm/i915: Use the STATE_CHECK_* macros in the pipe config comparison Maxime Ripard
` (4 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2026-11-24 10:59 UTC (permalink / raw)
To: Maxime Ripard, Jani Nikula, Thomas Zimmermann, Maarten Lankhorst,
Tvrtko Ursulin, David Airlie, Simona Vetter, Joonas Lahtinen,
Rodrigo Vivi
Cc: intel-xe, intel-gfx, dri-devel
The STATE_CHECK_* macros cover the field types the core state
structures hold, but driver private states also rely on enums and on
integer types smaller than an int, none of which the typed variants
accept: STATE_CHECK_S32() and its counterparts assert on the exact
field type, and there is no u8 variant at all.
Provide STATE_CHECK_U8(), STATE_CHECK_U8_X() and STATE_CHECK_U16_X()
to complete the set of fixed width integer variants, and
STATE_CHECK_ENUM() for the enum fields: their underlying type is
chosen by the compiler, so they can't be matched to a fixed width
variant, and whether they end up signed depends on their enumerators.
The i915 pipe configuration state compares close to two hundred
fields spread over all of those types.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
.../gpu/drm/tests/drm_atomic_state_readout_test.c | 99 ++++++++++++++++++++++
include/drm/drm_atomic_state_readout_helper.h | 66 +++++++++++++++
2 files changed, 165 insertions(+)
diff --git a/drivers/gpu/drm/tests/drm_atomic_state_readout_test.c b/drivers/gpu/drm/tests/drm_atomic_state_readout_test.c
index 289187ec4359..a2d18d44e76c 100644
--- a/drivers/gpu/drm/tests/drm_atomic_state_readout_test.c
+++ b/drivers/gpu/drm/tests/drm_atomic_state_readout_test.c
@@ -1753,10 +1753,107 @@ static void drm_test_sro_compare_bridge_mismatch(struct kunit *test)
priv->bridge.funcs->atomic_destroy_state(&priv->bridge, state1);
priv->bridge.funcs->atomic_destroy_state(&priv->bridge, state2);
}
+/*
+ * A state with plain integer fields, to exercise the STATE_CHECK_*
+ * macros on the types the base state structures don't hold but driver
+ * private states commonly do: enums, whose signedness the compiler
+ * picks, and integers smaller than an int.
+ */
+enum state_check_enum {
+ STATE_CHECK_FIRST,
+ STATE_CHECK_SECOND,
+};
+
+struct state_check_state {
+ int s32;
+ enum state_check_enum enumerated;
+ u8 decimal_u8;
+ u8 hex_u8;
+ u16 decimal_u16;
+ u16 hex_u16;
+ u32 decimal_u32;
+ u32 hex_u32;
+};
+
+static bool
+state_check_state_compare(struct drm_printer *p,
+ const struct state_check_state *a,
+ const struct state_check_state *b)
+{
+ bool ret = true;
+
+ STATE_CHECK_S32(ret, p, "test", a, b, s32);
+ STATE_CHECK_ENUM(ret, p, "test", a, b, enumerated);
+ STATE_CHECK_U8(ret, p, "test", a, b, decimal_u8);
+ STATE_CHECK_U8_X(ret, p, "test", a, b, hex_u8);
+ STATE_CHECK_U16(ret, p, "test", a, b, decimal_u16);
+ STATE_CHECK_U16_X(ret, p, "test", a, b, hex_u16);
+ STATE_CHECK_U32(ret, p, "test", a, b, decimal_u32);
+ STATE_CHECK_U32_X(ret, p, "test", a, b, hex_u32);
+
+ return ret;
+}
+
+/*
+ * Test that the STATE_CHECK_* macros report states whose enum, u8,
+ * u16 and u32 fields all match as identical.
+ */
+static void drm_test_sro_compare_macros_identical(struct kunit *test)
+{
+ struct state_check_state a = {}, b = {};
+ struct drm_printer *p;
+
+ p = drm_kunit_helper_printer(test, LOGLEVEL_ERR);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, p);
+
+ a.s32 = b.s32 = -42;
+ a.enumerated = b.enumerated = STATE_CHECK_SECOND;
+ a.decimal_u8 = b.decimal_u8 = 3;
+ a.hex_u8 = b.hex_u8 = 0xa5;
+ a.decimal_u16 = b.decimal_u16 = 1000;
+ a.hex_u16 = b.hex_u16 = 0x5a5a;
+ a.decimal_u32 = b.decimal_u32 = 100000;
+ a.hex_u32 = b.hex_u32 = 0xdeadbeef;
+
+ KUNIT_EXPECT_TRUE(test, state_check_state_compare(p, &a, &b));
+}
+
+/*
+ * Test that the STATE_CHECK_* macros report states differing in any
+ * of their enum, u8, u16 and u32 fields as non-identical.
+ */
+static void drm_test_sro_compare_macros_mismatch(struct kunit *test)
+{
+ struct state_check_state a = {}, b = {};
+ struct drm_printer *p;
+
+ p = drm_kunit_helper_printer(test, LOGLEVEL_ERR);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, p);
+
+ a.s32 = -1;
+ b.s32 = -2;
+ a.enumerated = STATE_CHECK_FIRST;
+ b.enumerated = STATE_CHECK_SECOND;
+ a.decimal_u8 = 1;
+ b.decimal_u8 = 2;
+ a.hex_u8 = 0xf0;
+ b.hex_u8 = 0x0d;
+ a.decimal_u16 = 1;
+ b.decimal_u16 = 2;
+ a.hex_u16 = 0x1234;
+ b.hex_u16 = 0x4321;
+ a.decimal_u32 = 1;
+ b.decimal_u32 = 2;
+ a.hex_u32 = 0xf00d;
+ b.hex_u32 = 0xbeef;
+
+ KUNIT_EXPECT_FALSE(test, state_check_state_compare(p, &a, &b));
+}
+
static struct kunit_case drm_atomic_sro_compare_tests[] = {
KUNIT_CASE(drm_test_sro_compare_plane_identical),
KUNIT_CASE(drm_test_sro_compare_plane_mismatch),
KUNIT_CASE(drm_test_sro_compare_plane_cropped),
KUNIT_CASE(drm_test_sro_compare_crtc_identical),
@@ -1764,10 +1861,12 @@ static struct kunit_case drm_atomic_sro_compare_tests[] = {
KUNIT_CASE(drm_test_sro_compare_crtc_active_mismatch),
KUNIT_CASE(drm_test_sro_compare_connector_identical),
KUNIT_CASE(drm_test_sro_compare_connector_mismatch),
KUNIT_CASE(drm_test_sro_compare_bridge_identical),
KUNIT_CASE(drm_test_sro_compare_bridge_mismatch),
+ KUNIT_CASE(drm_test_sro_compare_macros_identical),
+ KUNIT_CASE(drm_test_sro_compare_macros_mismatch),
{ }
};
static struct kunit_suite drm_atomic_sro_compare_test_suite = {
.name = "drm_atomic_sro_compare",
diff --git a/include/drm/drm_atomic_state_readout_helper.h b/include/drm/drm_atomic_state_readout_helper.h
index 6125ea668fa8..628222274aff 100644
--- a/include/drm/drm_atomic_state_readout_helper.h
+++ b/include/drm/drm_atomic_state_readout_helper.h
@@ -198,10 +198,60 @@ drm_atomic_helper_print_state_mismatch(struct drm_printer *p,
sa->f, sb->f); \
r = false; \
} \
} while (0)
+#define STATE_CHECK_ENUM(r, p, n, sa, sb, f) \
+ do { \
+ static_assert(__same_type(sa->f, sb->f), \
+ __stringify(f) " field types don't match"); \
+ static_assert(!__same_type(sa->f, bool), \
+ __stringify(f) " is a bool"); \
+ static_assert(sizeof(sa->f) <= sizeof(int), \
+ __stringify(f) " doesn't fit in an int"); \
+ if (sa->f != sb->f) { \
+ drm_atomic_helper_print_state_mismatch(p, \
+ n, \
+ __stringify(f), \
+ "expected %d, got %d", \
+ sa->f, sb->f); \
+ r = false; \
+ } \
+ } while (0)
+
+#define STATE_CHECK_U8(r, p, n, sa, sb, f) \
+ do { \
+ static_assert(__same_type(sa->f, sb->f), \
+ __stringify(f) " field types don't match"); \
+ static_assert(__same_type(sa->f, (u8)0), \
+ __stringify(f) " is not a u8"); \
+ if (sa->f != sb->f) { \
+ drm_atomic_helper_print_state_mismatch(p, \
+ n, \
+ __stringify(f), \
+ "expected %u, got %u", \
+ sa->f, sb->f); \
+ r = false; \
+ } \
+ } while (0)
+
+#define STATE_CHECK_U8_X(r, p, n, sa, sb, f) \
+ do { \
+ static_assert(__same_type(sa->f, sb->f), \
+ __stringify(f) " field types don't match"); \
+ static_assert(__same_type(sa->f, (u8)0), \
+ __stringify(f) " is not a u8"); \
+ if (sa->f != sb->f) { \
+ drm_atomic_helper_print_state_mismatch(p, \
+ n, \
+ __stringify(f), \
+ "expected %02x, got %02x", \
+ sa->f, sb->f); \
+ r = false; \
+ } \
+ } while (0)
+
#define STATE_CHECK_U16(r, p, n, sa, sb, f) \
do { \
static_assert(__same_type(sa->f, sb->f), \
__stringify(f) " field types don't match"); \
static_assert(__same_type(sa->f, (u16)0), \
@@ -214,10 +264,26 @@ drm_atomic_helper_print_state_mismatch(struct drm_printer *p,
sa->f, sb->f); \
r = false; \
} \
} while (0)
+#define STATE_CHECK_U16_X(r, p, n, sa, sb, f) \
+ do { \
+ static_assert(__same_type(sa->f, sb->f), \
+ __stringify(f) " field types don't match"); \
+ static_assert(__same_type(sa->f, (u16)0), \
+ __stringify(f) " is not a u16"); \
+ if (sa->f != sb->f) { \
+ drm_atomic_helper_print_state_mismatch(p, \
+ n, \
+ __stringify(f), \
+ "expected %04x, got %04x", \
+ sa->f, sb->f); \
+ r = false; \
+ } \
+ } while (0)
+
#define STATE_CHECK_U32(r, p, n, sa, sb, f) \
do { \
static_assert(__same_type(sa->f, sb->f), \
__stringify(f) " field types don't match"); \
static_assert(__same_type(sa->f, (u32)0), \
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/6] drm/i915: Use the STATE_CHECK_* macros in the pipe config comparison
2026-11-24 10:59 [PATCH 0/6] drm/i915: Support DRM_MODE_ATOMIC_RESET Maxime Ripard
2026-11-24 10:59 ` [PATCH 1/6] drm/atomic-state-helper: Provide more STATE_CHECK_* variants Maxime Ripard
@ 2026-11-24 10:59 ` Maxime Ripard
2026-11-24 11:23 ` Jani Nikula
2026-11-24 10:59 ` [PATCH 3/6] drm/i915: Implement CRTC atomic_create_state Maxime Ripard
` (3 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Maxime Ripard @ 2026-11-24 10:59 UTC (permalink / raw)
To: Maxime Ripard, Jani Nikula, Thomas Zimmermann, Maarten Lankhorst,
Tvrtko Ursulin, David Airlie, Simona Vetter, Joonas Lahtinen,
Rodrigo Vivi
Cc: intel-xe, intel-gfx, dri-devel
The state readout framework provides the STATE_CHECK_* macros and
drm_atomic_helper_print_state_mismatch() to compare two state
instances field by field and report the mismatches through a drm
printer.
intel_pipe_config_compare() implements the very same thing with its
own set of PIPE_CONF_CHECK_* macros printing through the
pipe_config_mismatch() helper, duplicating the framework.
Rework the plain field checks on top of the STATE_CHECK_* macros,
sorting every PIPE_CONF_CHECK_I() and PIPE_CONF_CHECK_X() call site
onto the variant matching its field type: STATE_CHECK_BOOL(), _S32(),
_ENUM(), _U8(), _U16(), _U32(), _U64() and _PTR(), along with the
_U8_X(), _U16_X() and _U32_X() hexadecimal counterparts. The
static_assert() of each macro then checks the field type at compile
time, which the untyped PIPE_CONF_CHECK_I() and _X() macros couldn't
do, and PIPE_CONF_CHECK_LLI() becomes a STATE_CHECK_U64() based check
that also prints its u64 fields properly.
The checks without a framework counterpart, namely the masked, flags,
M/N, DPLL, timings, rectangle, infoframe, DP SDP, ELD buffer, color
LUT and CSC ones, along with the infoframe, SDP, buffer and PLL
mismatch reporters, print their header through
drm_atomic_helper_print_state_mismatch() instead.
pipe_config_mismatch() isn't needed anymore and gets removed.
The mismatch messages change format in the process, from
[CRTC:31:pipe A] fastset requirement not met in hw.enable (expected yes, found no)
to
pipe A configuration mismatch in hw.enable (expected yes, got no)
The fastset and state checker invocations are still told apart by
their printer, drm_dbg_kms() for the former and drm_err() for the
latter, and the infoframe, SDP, buffer and PLL reporters keep dumping
both instances. The CRTC id is dropped from the messages, but the
i915 CRTC names are unique on their own.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/i915/display/intel_display.c | 493 +++++++++++++--------------
1 file changed, 241 insertions(+), 252 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index f79caeb5a82e..1172e48daf23 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -34,10 +34,11 @@
#include <drm/display/drm_dp_helper.h>
#include <drm/display/drm_dp_tunnel.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
+#include <drm/drm_atomic_state_readout_helper.h>
#include <drm/drm_atomic_uapi.h>
#include <drm/drm_damage_helper.h>
#include <drm/drm_edid.h>
#include <drm/drm_fixed.h>
#include <drm/drm_fourcc.h>
@@ -5038,32 +5039,10 @@ static bool
intel_compare_buffer(const u8 *a, const u8 *b, size_t len)
{
return memcmp(a, b, len) == 0;
}
-static void __printf(5, 6)
-pipe_config_mismatch(struct drm_printer *p, bool fastset,
- const struct intel_crtc *crtc,
- const char *name, const char *format, ...)
-{
- struct va_format vaf;
- va_list args;
-
- va_start(args, format);
- vaf.fmt = format;
- vaf.va = &args;
-
- if (fastset)
- drm_printf(p, "[CRTC:%d:%s] fastset requirement not met in %s %pV\n",
- crtc->base.base.id, crtc->base.name, name, &vaf);
- else
- drm_printf(p, "[CRTC:%d:%s] mismatch in %s %pV\n",
- crtc->base.base.id, crtc->base.name, name, &vaf);
-
- va_end(args);
-}
-
static void
pipe_config_infoframe_mismatch(struct drm_printer *p, bool fastset,
const struct intel_crtc *crtc,
const char *name,
const union hdmi_infoframe *a,
@@ -5079,41 +5058,44 @@ pipe_config_infoframe_mismatch(struct drm_printer *p, bool fastset,
loglevel = KERN_DEBUG;
} else {
loglevel = KERN_ERR;
}
- pipe_config_mismatch(p, fastset, crtc, name, "infoframe");
+ drm_atomic_helper_print_state_mismatch(p, crtc->base.name,
+ name, "infoframe");
drm_printf(p, "expected:\n");
hdmi_infoframe_log(loglevel, display->drm->dev, a);
drm_printf(p, "found:\n");
hdmi_infoframe_log(loglevel, display->drm->dev, b);
}
static void
-pipe_config_dp_vsc_sdp_mismatch(struct drm_printer *p, bool fastset,
+pipe_config_dp_vsc_sdp_mismatch(struct drm_printer *p,
const struct intel_crtc *crtc,
const char *name,
const struct drm_dp_vsc_sdp *a,
const struct drm_dp_vsc_sdp *b)
{
- pipe_config_mismatch(p, fastset, crtc, name, "dp vsc sdp");
+ drm_atomic_helper_print_state_mismatch(p, crtc->base.name,
+ name, "dp vsc sdp");
drm_printf(p, "expected:\n");
drm_dp_vsc_sdp_log(p, a);
drm_printf(p, "found:\n");
drm_dp_vsc_sdp_log(p, b);
}
static void
-pipe_config_dp_as_sdp_mismatch(struct drm_printer *p, bool fastset,
+pipe_config_dp_as_sdp_mismatch(struct drm_printer *p,
const struct intel_crtc *crtc,
const char *name,
const struct drm_dp_as_sdp *a,
const struct drm_dp_as_sdp *b)
{
- pipe_config_mismatch(p, fastset, crtc, name, "dp as sdp");
+ drm_atomic_helper_print_state_mismatch(p, crtc->base.name,
+ name, "dp as sdp");
drm_printf(p, "expected:\n");
drm_dp_as_sdp_log(p, a);
drm_printf(p, "found:\n");
drm_dp_as_sdp_log(p, b);
@@ -5132,34 +5114,36 @@ memcmp_diff_len(const u8 *a, const u8 *b, size_t len)
return 0;
}
static void
-pipe_config_buffer_mismatch(struct drm_printer *p, bool fastset,
+pipe_config_buffer_mismatch(struct drm_printer *p,
const struct intel_crtc *crtc,
const char *name,
const u8 *a, const u8 *b, size_t len)
{
- pipe_config_mismatch(p, fastset, crtc, name, "buffer");
+ drm_atomic_helper_print_state_mismatch(p, crtc->base.name,
+ name, "buffer");
/* only dump up to the last difference */
len = memcmp_diff_len(a, b, len);
drm_print_hex_dump(p, "expected: ", a, len);
drm_print_hex_dump(p, "found: ", b, len);
}
static void
-pipe_config_pll_mismatch(struct drm_printer *p, bool fastset,
+pipe_config_pll_mismatch(struct drm_printer *p,
const struct intel_crtc *crtc,
const char *name,
const struct intel_dpll_hw_state *a,
const struct intel_dpll_hw_state *b)
{
struct intel_display *display = to_intel_display(crtc);
- pipe_config_mismatch(p, fastset, crtc, name, " "); /* stupid -Werror=format-zero-length */
+ /* stupid -Werror=format-zero-length */
+ drm_atomic_helper_print_state_mismatch(p, crtc->base.name, name, " ");
drm_printf(p, "expected:\n");
intel_dpll_dump_hw_state(display, p, a);
drm_printf(p, "found:\n");
intel_dpll_dump_hw_state(display, p, b);
@@ -5198,179 +5182,169 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
if (fastset)
p = drm_dbg_printer(display->drm, DRM_UT_KMS, NULL);
else
p = drm_err_printer(display->drm, NULL);
-#define PIPE_CONF_CHECK_X(name) do { \
- if (current_config->name != pipe_config->name) { \
- BUILD_BUG_ON_MSG(__same_type(current_config->name, bool), \
- __stringify(name) " is bool"); \
- pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
- "(expected 0x%08x, found 0x%08x)", \
- current_config->name, \
- pipe_config->name); \
+#define PIPE_CONF_CHECK_BOOL(field) \
+ STATE_CHECK_BOOL(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_S32(field) \
+ STATE_CHECK_S32(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_ENUM(field) \
+ STATE_CHECK_ENUM(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_U8(field) \
+ STATE_CHECK_U8(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_U16(field) \
+ STATE_CHECK_U16(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_U32(field) \
+ STATE_CHECK_U32(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_U64(field) \
+ STATE_CHECK_U64(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_P(field) \
+ STATE_CHECK_PTR(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_U8_X(field) \
+ STATE_CHECK_U8_X(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_U16_X(field) \
+ STATE_CHECK_U16_X(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_U32_X(field) \
+ STATE_CHECK_U32_X(ret, &p, crtc->base.name, \
+ current_config, pipe_config, field)
+
+#define PIPE_CONF_CHECK_X_WITH_MASK(field, mask) do { \
+ if ((current_config->field & (mask)) != (pipe_config->field & (mask))) { \
+ drm_atomic_helper_print_state_mismatch(&p, crtc->base.name, \
+ __stringify(field), \
+ "expected %x, got %x", \
+ current_config->field & (mask), \
+ pipe_config->field & (mask)); \
ret = false; \
} \
} while (0)
-#define PIPE_CONF_CHECK_X_WITH_MASK(name, mask) do { \
- if ((current_config->name & (mask)) != (pipe_config->name & (mask))) { \
- BUILD_BUG_ON_MSG(__same_type(current_config->name, bool), \
- __stringify(name) " is bool"); \
- pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
- "(expected 0x%08x, found 0x%08x)", \
- current_config->name & (mask), \
- pipe_config->name & (mask)); \
+#define PIPE_CONF_CHECK_M_N(field) do { \
+ if (!intel_compare_link_m_n(¤t_config->field, \
+ &pipe_config->field)) { \
+ drm_atomic_helper_print_state_mismatch(&p, crtc->base.name, \
+ __stringify(field), \
+ "expected tu %i data %i/%i link %i/%i, " \
+ "got tu %i data %i/%i link %i/%i", \
+ current_config->field.tu, \
+ current_config->field.data_m, \
+ current_config->field.data_n, \
+ current_config->field.link_m, \
+ current_config->field.link_n, \
+ pipe_config->field.tu, \
+ pipe_config->field.data_m, \
+ pipe_config->field.data_n, \
+ pipe_config->field.link_m, \
+ pipe_config->field.link_n); \
ret = false; \
} \
} while (0)
-#define PIPE_CONF_CHECK_I(name) do { \
- if (current_config->name != pipe_config->name) { \
- BUILD_BUG_ON_MSG(__same_type(current_config->name, bool), \
- __stringify(name) " is bool"); \
- pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
- "(expected %i, found %i)", \
- current_config->name, \
- pipe_config->name); \
- ret = false; \
- } \
-} while (0)
-
-#define PIPE_CONF_CHECK_LLI(name) do { \
- if (current_config->name != pipe_config->name) { \
- pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
- "(expected %lli, found %lli)", \
- current_config->name, \
- pipe_config->name); \
- ret = false; \
- } \
-} while (0)
-
-#define PIPE_CONF_CHECK_BOOL(name) do { \
- if (current_config->name != pipe_config->name) { \
- BUILD_BUG_ON_MSG(!__same_type(current_config->name, bool), \
- __stringify(name) " is not bool"); \
- pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
- "(expected %s, found %s)", \
- str_yes_no(current_config->name), \
- str_yes_no(pipe_config->name)); \
- ret = false; \
- } \
-} while (0)
-
-#define PIPE_CONF_CHECK_P(name) do { \
- if (current_config->name != pipe_config->name) { \
- pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
- "(expected %p, found %p)", \
- current_config->name, \
- pipe_config->name); \
- ret = false; \
- } \
-} while (0)
-
-#define PIPE_CONF_CHECK_M_N(name) do { \
- if (!intel_compare_link_m_n(¤t_config->name, \
- &pipe_config->name)) { \
- pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
- "(expected tu %i data %i/%i link %i/%i, " \
- "found tu %i, data %i/%i link %i/%i)", \
- current_config->name.tu, \
- current_config->name.data_m, \
- current_config->name.data_n, \
- current_config->name.link_m, \
- current_config->name.link_n, \
- pipe_config->name.tu, \
- pipe_config->name.data_m, \
- pipe_config->name.data_n, \
- pipe_config->name.link_m, \
- pipe_config->name.link_n); \
- ret = false; \
- } \
-} while (0)
-
-#define PIPE_CONF_CHECK_PLL(name) do { \
- if (!intel_dpll_compare_hw_state(display, ¤t_config->name, \
- &pipe_config->name)) { \
- pipe_config_pll_mismatch(&p, fastset, crtc, __stringify(name), \
- ¤t_config->name, \
- &pipe_config->name); \
+#define PIPE_CONF_CHECK_PLL(field) do { \
+ if (!intel_dpll_compare_hw_state(display, ¤t_config->field, \
+ &pipe_config->field)) { \
+ pipe_config_pll_mismatch(&p, crtc, __stringify(field), \
+ ¤t_config->field, \
+ &pipe_config->field); \
ret = false; \
} \
} while (0)
#define PIPE_CONF_CHECK_TIMINGS(name) do { \
- PIPE_CONF_CHECK_I(name.crtc_hdisplay); \
- PIPE_CONF_CHECK_I(name.crtc_htotal); \
- PIPE_CONF_CHECK_I(name.crtc_hblank_start); \
- PIPE_CONF_CHECK_I(name.crtc_hblank_end); \
- PIPE_CONF_CHECK_I(name.crtc_hsync_start); \
- PIPE_CONF_CHECK_I(name.crtc_hsync_end); \
- PIPE_CONF_CHECK_I(name.crtc_vdisplay); \
+ PIPE_CONF_CHECK_U16(name.crtc_hdisplay); \
+ PIPE_CONF_CHECK_U16(name.crtc_htotal); \
+ PIPE_CONF_CHECK_U16(name.crtc_hblank_start); \
+ PIPE_CONF_CHECK_U16(name.crtc_hblank_end); \
+ PIPE_CONF_CHECK_U16(name.crtc_hsync_start); \
+ PIPE_CONF_CHECK_U16(name.crtc_hsync_end); \
+ PIPE_CONF_CHECK_U16(name.crtc_vdisplay); \
if (!fastset || !allow_vblank_delay_fastset(current_config)) \
- PIPE_CONF_CHECK_I(name.crtc_vblank_start); \
+ PIPE_CONF_CHECK_U16(name.crtc_vblank_start); \
if (!fastset || !pipe_config->update_lrr) { \
- PIPE_CONF_CHECK_I(name.crtc_vsync_start); \
- PIPE_CONF_CHECK_I(name.crtc_vsync_end); \
- PIPE_CONF_CHECK_I(name.crtc_vtotal); \
- PIPE_CONF_CHECK_I(name.crtc_vblank_end); \
+ PIPE_CONF_CHECK_U16(name.crtc_vsync_start); \
+ PIPE_CONF_CHECK_U16(name.crtc_vsync_end); \
+ PIPE_CONF_CHECK_U16(name.crtc_vtotal); \
+ PIPE_CONF_CHECK_U16(name.crtc_vblank_end); \
} \
} while (0)
#define PIPE_CONF_CHECK_RECT(name) do { \
- PIPE_CONF_CHECK_I(name.x1); \
- PIPE_CONF_CHECK_I(name.x2); \
- PIPE_CONF_CHECK_I(name.y1); \
- PIPE_CONF_CHECK_I(name.y2); \
+ PIPE_CONF_CHECK_S32(name.x1); \
+ PIPE_CONF_CHECK_S32(name.x2); \
+ PIPE_CONF_CHECK_S32(name.y1); \
+ PIPE_CONF_CHECK_S32(name.y2); \
} while (0)
-#define PIPE_CONF_CHECK_FLAGS(name, mask) do { \
- if ((current_config->name ^ pipe_config->name) & (mask)) { \
- pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
- "(%x) (expected %i, found %i)", \
- (mask), \
- current_config->name & (mask), \
- pipe_config->name & (mask)); \
+#define PIPE_CONF_CHECK_FLAGS(field, mask) do { \
+ if ((current_config->field ^ pipe_config->field) & (mask)) { \
+ drm_atomic_helper_print_state_mismatch(&p, crtc->base.name, \
+ __stringify(field), \
+ "(%x) expected %i, got %i", \
+ (mask), \
+ current_config->field & (mask), \
+ pipe_config->field & (mask)); \
ret = false; \
} \
} while (0)
#define PIPE_CONF_CHECK_INFOFRAME(name) do { \
if (!intel_compare_infoframe(¤t_config->infoframes.name, \
&pipe_config->infoframes.name)) { \
- pipe_config_infoframe_mismatch(&p, fastset, crtc, __stringify(name), \
+ pipe_config_infoframe_mismatch(&p, fastset, crtc, \
+ __stringify(name), \
¤t_config->infoframes.name, \
&pipe_config->infoframes.name); \
ret = false; \
} \
} while (0)
#define PIPE_CONF_CHECK_DP_VSC_SDP(name) do { \
if (!intel_compare_dp_vsc_sdp(¤t_config->infoframes.name, \
&pipe_config->infoframes.name)) { \
- pipe_config_dp_vsc_sdp_mismatch(&p, fastset, crtc, __stringify(name), \
+ pipe_config_dp_vsc_sdp_mismatch(&p, crtc, __stringify(name), \
¤t_config->infoframes.name, \
&pipe_config->infoframes.name); \
ret = false; \
} \
} while (0)
#define PIPE_CONF_CHECK_DP_AS_SDP(name) do { \
if (!intel_compare_dp_as_sdp(¤t_config->infoframes.name, \
&pipe_config->infoframes.name)) { \
- pipe_config_dp_as_sdp_mismatch(&p, fastset, crtc, __stringify(name), \
+ pipe_config_dp_as_sdp_mismatch(&p, crtc, __stringify(name), \
¤t_config->infoframes.name, \
&pipe_config->infoframes.name); \
ret = false; \
} \
} while (0)
#define PIPE_CONF_CHECK_BUFFER(name, len) do { \
BUILD_BUG_ON(sizeof(current_config->name) != (len)); \
BUILD_BUG_ON(sizeof(pipe_config->name) != (len)); \
if (!intel_compare_buffer(current_config->name, pipe_config->name, (len))) { \
- pipe_config_buffer_mismatch(&p, fastset, crtc, __stringify(name), \
+ pipe_config_buffer_mismatch(&p, crtc, __stringify(name), \
current_config->name, \
pipe_config->name, \
(len)); \
ret = false; \
} \
@@ -5379,69 +5353,70 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
#define PIPE_CONF_CHECK_COLOR_LUT(lut, is_pre_csc_lut) do { \
if (current_config->gamma_mode == pipe_config->gamma_mode && \
!intel_color_lut_equal(current_config, \
current_config->lut, pipe_config->lut, \
is_pre_csc_lut)) { \
- pipe_config_mismatch(&p, fastset, crtc, __stringify(lut), \
- "hw_state doesn't match sw_state"); \
+ drm_atomic_helper_print_state_mismatch(&p, crtc->base.name, \
+ __stringify(lut), \
+ "hw_state doesn't match sw_state"); \
ret = false; \
} \
} while (0)
-#define PIPE_CONF_CHECK_CSC(name) do { \
- PIPE_CONF_CHECK_X(name.preoff[0]); \
- PIPE_CONF_CHECK_X(name.preoff[1]); \
- PIPE_CONF_CHECK_X(name.preoff[2]); \
- PIPE_CONF_CHECK_X(name.coeff[0]); \
- PIPE_CONF_CHECK_X(name.coeff[1]); \
- PIPE_CONF_CHECK_X(name.coeff[2]); \
- PIPE_CONF_CHECK_X(name.coeff[3]); \
- PIPE_CONF_CHECK_X(name.coeff[4]); \
- PIPE_CONF_CHECK_X(name.coeff[5]); \
- PIPE_CONF_CHECK_X(name.coeff[6]); \
- PIPE_CONF_CHECK_X(name.coeff[7]); \
- PIPE_CONF_CHECK_X(name.coeff[8]); \
- PIPE_CONF_CHECK_X(name.postoff[0]); \
- PIPE_CONF_CHECK_X(name.postoff[1]); \
- PIPE_CONF_CHECK_X(name.postoff[2]); \
+#define PIPE_CONF_CHECK_CSC(field) do { \
+ PIPE_CONF_CHECK_U16_X(field.preoff[0]); \
+ PIPE_CONF_CHECK_U16_X(field.preoff[1]); \
+ PIPE_CONF_CHECK_U16_X(field.preoff[2]); \
+ PIPE_CONF_CHECK_U16_X(field.coeff[0]); \
+ PIPE_CONF_CHECK_U16_X(field.coeff[1]); \
+ PIPE_CONF_CHECK_U16_X(field.coeff[2]); \
+ PIPE_CONF_CHECK_U16_X(field.coeff[3]); \
+ PIPE_CONF_CHECK_U16_X(field.coeff[4]); \
+ PIPE_CONF_CHECK_U16_X(field.coeff[5]); \
+ PIPE_CONF_CHECK_U16_X(field.coeff[6]); \
+ PIPE_CONF_CHECK_U16_X(field.coeff[7]); \
+ PIPE_CONF_CHECK_U16_X(field.coeff[8]); \
+ PIPE_CONF_CHECK_U16_X(field.postoff[0]); \
+ PIPE_CONF_CHECK_U16_X(field.postoff[1]); \
+ PIPE_CONF_CHECK_U16_X(field.postoff[2]); \
} while (0)
#define PIPE_CONF_QUIRK(quirk) \
((current_config->quirks | pipe_config->quirks) & (quirk))
PIPE_CONF_CHECK_BOOL(hw.enable);
PIPE_CONF_CHECK_BOOL(hw.active);
- PIPE_CONF_CHECK_I(cpu_transcoder);
- PIPE_CONF_CHECK_I(mst_master_transcoder);
+ PIPE_CONF_CHECK_ENUM(cpu_transcoder);
+ PIPE_CONF_CHECK_ENUM(mst_master_transcoder);
PIPE_CONF_CHECK_BOOL(has_pch_encoder);
- PIPE_CONF_CHECK_I(fdi_lanes);
+ PIPE_CONF_CHECK_S32(fdi_lanes);
PIPE_CONF_CHECK_M_N(fdi_m_n);
- PIPE_CONF_CHECK_I(lane_count);
- PIPE_CONF_CHECK_X(lane_lat_optim_mask);
+ PIPE_CONF_CHECK_U8(lane_count);
+ PIPE_CONF_CHECK_U8_X(lane_lat_optim_mask);
- PIPE_CONF_CHECK_I(min_hblank);
+ PIPE_CONF_CHECK_S32(min_hblank);
if (HAS_DOUBLE_BUFFERED_M_N(display)) {
if (!fastset || !pipe_config->update_m_n)
PIPE_CONF_CHECK_M_N(dp_m_n);
} else {
PIPE_CONF_CHECK_M_N(dp_m_n);
PIPE_CONF_CHECK_M_N(dp_m2_n2);
}
- PIPE_CONF_CHECK_X(output_types);
+ PIPE_CONF_CHECK_U32_X(output_types);
- PIPE_CONF_CHECK_I(framestart_delay);
- PIPE_CONF_CHECK_I(msa_timing_delay);
+ PIPE_CONF_CHECK_U8(framestart_delay);
+ PIPE_CONF_CHECK_U8(msa_timing_delay);
PIPE_CONF_CHECK_TIMINGS(hw.pipe_mode);
PIPE_CONF_CHECK_TIMINGS(hw.adjusted_mode);
- PIPE_CONF_CHECK_I(pixel_multiplier);
+ PIPE_CONF_CHECK_U32(pixel_multiplier);
PIPE_CONF_CHECK_FLAGS(hw.adjusted_mode.flags,
DRM_MODE_FLAG_INTERLACE);
if (!PIPE_CONF_QUIRK(PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS)) {
@@ -5453,11 +5428,11 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
DRM_MODE_FLAG_PVSYNC);
PIPE_CONF_CHECK_FLAGS(hw.adjusted_mode.flags,
DRM_MODE_FLAG_NVSYNC);
}
- PIPE_CONF_CHECK_I(output_format);
+ PIPE_CONF_CHECK_ENUM(output_format);
PIPE_CONF_CHECK_BOOL(has_hdmi_sink);
if ((DISPLAY_VER(display) < 8 && !display->platform.haswell) ||
display->platform.valleyview || display->platform.cherryview)
PIPE_CONF_CHECK_BOOL(limited_color_range);
@@ -5470,15 +5445,15 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
if (!fastset) {
PIPE_CONF_CHECK_BOOL(has_audio);
PIPE_CONF_CHECK_BUFFER(eld, MAX_ELD_BYTES);
}
- PIPE_CONF_CHECK_X(gmch_pfit.control);
+ PIPE_CONF_CHECK_U32_X(gmch_pfit.control);
/* pfit ratios are autocomputed by the hw on gen4+ */
if (DISPLAY_VER(display) < 4)
- PIPE_CONF_CHECK_X(gmch_pfit.pgm_ratios);
- PIPE_CONF_CHECK_X(gmch_pfit.lvds_border_bits);
+ PIPE_CONF_CHECK_U32_X(gmch_pfit.pgm_ratios);
+ PIPE_CONF_CHECK_U32_X(gmch_pfit.lvds_border_bits);
/*
* Changing the EDP transcoder input mux
* (A_ONOFF vs. A_ON) requires a full modeset.
*/
@@ -5488,30 +5463,30 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
PIPE_CONF_CHECK_RECT(pipe_src);
PIPE_CONF_CHECK_BOOL(pch_pfit.enabled);
PIPE_CONF_CHECK_RECT(pch_pfit.dst);
PIPE_CONF_CHECK_BOOL(pch_pfit.casf.enable);
- PIPE_CONF_CHECK_I(pch_pfit.casf.win_size);
- PIPE_CONF_CHECK_I(pch_pfit.casf.strength);
+ PIPE_CONF_CHECK_U8(pch_pfit.casf.win_size);
+ PIPE_CONF_CHECK_U8(pch_pfit.casf.strength);
- PIPE_CONF_CHECK_I(scaler_state.scaler_id);
- PIPE_CONF_CHECK_I(pixel_rate_cdclk);
- PIPE_CONF_CHECK_I(pixel_rate);
+ PIPE_CONF_CHECK_S32(scaler_state.scaler_id);
+ PIPE_CONF_CHECK_U32(pixel_rate_cdclk);
+ PIPE_CONF_CHECK_U32(pixel_rate);
- PIPE_CONF_CHECK_X(gamma_mode);
+ PIPE_CONF_CHECK_U32_X(gamma_mode);
if (display->platform.cherryview)
- PIPE_CONF_CHECK_X(cgm_mode);
+ PIPE_CONF_CHECK_U32_X(cgm_mode);
else
- PIPE_CONF_CHECK_X(csc_mode);
+ PIPE_CONF_CHECK_U32_X(csc_mode);
PIPE_CONF_CHECK_BOOL(gamma_enable);
- PIPE_CONF_CHECK_X(hw.background_color);
+ PIPE_CONF_CHECK_U32_X(hw.background_color);
PIPE_CONF_CHECK_BOOL(csc_enable);
PIPE_CONF_CHECK_BOOL(wgc_enable);
- PIPE_CONF_CHECK_I(linetime);
- PIPE_CONF_CHECK_I(ips_linetime);
+ PIPE_CONF_CHECK_U16(linetime);
+ PIPE_CONF_CHECK_U16(ips_linetime);
PIPE_CONF_CHECK_COLOR_LUT(pre_csc_lut, true);
PIPE_CONF_CHECK_COLOR_LUT(post_csc_lut, false);
PIPE_CONF_CHECK_CSC(csc);
@@ -5525,123 +5500,137 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
/* FIXME convert everything over the dpll_mgr */
if (display->dpll.mgr || HAS_GMCH(display))
PIPE_CONF_CHECK_PLL(dpll_hw_state);
- PIPE_CONF_CHECK_X(dsi_pll.ctrl);
- PIPE_CONF_CHECK_X(dsi_pll.div);
+ PIPE_CONF_CHECK_U32_X(dsi_pll.ctrl);
+ PIPE_CONF_CHECK_U32_X(dsi_pll.div);
if (display->platform.g4x || DISPLAY_VER(display) >= 5)
- PIPE_CONF_CHECK_I(pipe_bpp);
+ PIPE_CONF_CHECK_S32(pipe_bpp);
if (!fastset || !pipe_config->update_m_n) {
- PIPE_CONF_CHECK_I(hw.pipe_mode.crtc_clock);
- PIPE_CONF_CHECK_I(hw.adjusted_mode.crtc_clock);
+ PIPE_CONF_CHECK_S32(hw.pipe_mode.crtc_clock);
+ PIPE_CONF_CHECK_S32(hw.adjusted_mode.crtc_clock);
}
- PIPE_CONF_CHECK_I(port_clock);
+ PIPE_CONF_CHECK_S32(port_clock);
- PIPE_CONF_CHECK_I(min_voltage_level);
+ PIPE_CONF_CHECK_U8(min_voltage_level);
if (current_config->has_psr || pipe_config->has_psr)
exclude_infoframes |= intel_hdmi_infoframe_enable(DP_SDP_VSC);
if (current_config->vrr.enable || pipe_config->vrr.enable)
exclude_infoframes |= intel_hdmi_infoframe_enable(DP_SDP_ADAPTIVE_SYNC);
PIPE_CONF_CHECK_X_WITH_MASK(infoframes.enable, ~exclude_infoframes);
- PIPE_CONF_CHECK_X(infoframes.gcp);
+ PIPE_CONF_CHECK_U32_X(infoframes.gcp);
PIPE_CONF_CHECK_INFOFRAME(avi);
PIPE_CONF_CHECK_INFOFRAME(spd);
PIPE_CONF_CHECK_INFOFRAME(hdmi);
if (!fastset) {
PIPE_CONF_CHECK_INFOFRAME(drm);
PIPE_CONF_CHECK_DP_AS_SDP(as_sdp);
}
PIPE_CONF_CHECK_DP_VSC_SDP(vsc);
- PIPE_CONF_CHECK_X(sync_mode_slaves_mask);
- PIPE_CONF_CHECK_I(master_transcoder);
- PIPE_CONF_CHECK_X(joiner_pipes);
+ PIPE_CONF_CHECK_U16_X(sync_mode_slaves_mask);
+ PIPE_CONF_CHECK_ENUM(master_transcoder);
+ PIPE_CONF_CHECK_U8_X(joiner_pipes);
PIPE_CONF_CHECK_BOOL(dsc.config.block_pred_enable);
PIPE_CONF_CHECK_BOOL(dsc.config.convert_rgb);
PIPE_CONF_CHECK_BOOL(dsc.config.simple_422);
PIPE_CONF_CHECK_BOOL(dsc.config.native_422);
PIPE_CONF_CHECK_BOOL(dsc.config.native_420);
PIPE_CONF_CHECK_BOOL(dsc.config.vbr_enable);
- PIPE_CONF_CHECK_I(dsc.config.line_buf_depth);
- PIPE_CONF_CHECK_I(dsc.config.bits_per_component);
- PIPE_CONF_CHECK_I(dsc.config.pic_width);
- PIPE_CONF_CHECK_I(dsc.config.pic_height);
- PIPE_CONF_CHECK_I(dsc.config.slice_width);
- PIPE_CONF_CHECK_I(dsc.config.slice_height);
- PIPE_CONF_CHECK_I(dsc.config.initial_dec_delay);
- PIPE_CONF_CHECK_I(dsc.config.initial_xmit_delay);
- PIPE_CONF_CHECK_I(dsc.config.scale_decrement_interval);
- PIPE_CONF_CHECK_I(dsc.config.scale_increment_interval);
- PIPE_CONF_CHECK_I(dsc.config.initial_scale_value);
- PIPE_CONF_CHECK_I(dsc.config.first_line_bpg_offset);
- PIPE_CONF_CHECK_I(dsc.config.flatness_min_qp);
- PIPE_CONF_CHECK_I(dsc.config.flatness_max_qp);
- PIPE_CONF_CHECK_I(dsc.config.slice_bpg_offset);
- PIPE_CONF_CHECK_I(dsc.config.nfl_bpg_offset);
- PIPE_CONF_CHECK_I(dsc.config.initial_offset);
- PIPE_CONF_CHECK_I(dsc.config.final_offset);
- PIPE_CONF_CHECK_I(dsc.config.rc_model_size);
- PIPE_CONF_CHECK_I(dsc.config.rc_quant_incr_limit0);
- PIPE_CONF_CHECK_I(dsc.config.rc_quant_incr_limit1);
- PIPE_CONF_CHECK_I(dsc.config.slice_chunk_size);
- PIPE_CONF_CHECK_I(dsc.config.second_line_bpg_offset);
- PIPE_CONF_CHECK_I(dsc.config.nsl_bpg_offset);
+ PIPE_CONF_CHECK_U8(dsc.config.line_buf_depth);
+ PIPE_CONF_CHECK_U8(dsc.config.bits_per_component);
+ PIPE_CONF_CHECK_U16(dsc.config.pic_width);
+ PIPE_CONF_CHECK_U16(dsc.config.pic_height);
+ PIPE_CONF_CHECK_U16(dsc.config.slice_width);
+ PIPE_CONF_CHECK_U16(dsc.config.slice_height);
+ PIPE_CONF_CHECK_U16(dsc.config.initial_dec_delay);
+ PIPE_CONF_CHECK_U16(dsc.config.initial_xmit_delay);
+ PIPE_CONF_CHECK_U16(dsc.config.scale_decrement_interval);
+ PIPE_CONF_CHECK_U16(dsc.config.scale_increment_interval);
+ PIPE_CONF_CHECK_U8(dsc.config.initial_scale_value);
+ PIPE_CONF_CHECK_U8(dsc.config.first_line_bpg_offset);
+ PIPE_CONF_CHECK_U8(dsc.config.flatness_min_qp);
+ PIPE_CONF_CHECK_U8(dsc.config.flatness_max_qp);
+ PIPE_CONF_CHECK_U16(dsc.config.slice_bpg_offset);
+ PIPE_CONF_CHECK_U16(dsc.config.nfl_bpg_offset);
+ PIPE_CONF_CHECK_U16(dsc.config.initial_offset);
+ PIPE_CONF_CHECK_U16(dsc.config.final_offset);
+ PIPE_CONF_CHECK_U16(dsc.config.rc_model_size);
+ PIPE_CONF_CHECK_U8(dsc.config.rc_quant_incr_limit0);
+ PIPE_CONF_CHECK_U8(dsc.config.rc_quant_incr_limit1);
+ PIPE_CONF_CHECK_U16(dsc.config.slice_chunk_size);
+ PIPE_CONF_CHECK_U8(dsc.config.second_line_bpg_offset);
+ PIPE_CONF_CHECK_U16(dsc.config.nsl_bpg_offset);
PIPE_CONF_CHECK_BOOL(dsc.compression_enable);
- PIPE_CONF_CHECK_I(dsc.slice_config.streams_per_pipe);
- PIPE_CONF_CHECK_I(dsc.compressed_bpp_x16);
+ PIPE_CONF_CHECK_S32(dsc.slice_config.streams_per_pipe);
+ PIPE_CONF_CHECK_U16(dsc.compressed_bpp_x16);
PIPE_CONF_CHECK_BOOL(splitter.enable);
- PIPE_CONF_CHECK_I(splitter.link_count);
- PIPE_CONF_CHECK_I(splitter.pixel_overlap);
+ PIPE_CONF_CHECK_U8(splitter.link_count);
+ PIPE_CONF_CHECK_U8(splitter.pixel_overlap);
if (!fastset) {
PIPE_CONF_CHECK_BOOL(vrr.enable);
- PIPE_CONF_CHECK_I(vrr.vmin);
- PIPE_CONF_CHECK_I(vrr.vmax);
- PIPE_CONF_CHECK_I(vrr.flipline);
- PIPE_CONF_CHECK_I(vrr.vsync_start);
- PIPE_CONF_CHECK_I(vrr.vsync_end);
- PIPE_CONF_CHECK_LLI(vrr.cmrr.cmrr_m);
- PIPE_CONF_CHECK_LLI(vrr.cmrr.cmrr_n);
+ PIPE_CONF_CHECK_U16(vrr.vmin);
+ PIPE_CONF_CHECK_U16(vrr.vmax);
+ PIPE_CONF_CHECK_U16(vrr.flipline);
+ PIPE_CONF_CHECK_U32(vrr.vsync_start);
+ PIPE_CONF_CHECK_U32(vrr.vsync_end);
+ PIPE_CONF_CHECK_U64(vrr.cmrr.cmrr_m);
+ PIPE_CONF_CHECK_U64(vrr.cmrr.cmrr_n);
PIPE_CONF_CHECK_BOOL(vrr.cmrr.enable);
- PIPE_CONF_CHECK_I(vrr.dc_balance.vmin);
- PIPE_CONF_CHECK_I(vrr.dc_balance.vmax);
- PIPE_CONF_CHECK_I(vrr.dc_balance.guardband);
- PIPE_CONF_CHECK_I(vrr.dc_balance.slope);
- PIPE_CONF_CHECK_I(vrr.dc_balance.max_increase);
- PIPE_CONF_CHECK_I(vrr.dc_balance.max_decrease);
- PIPE_CONF_CHECK_I(vrr.dc_balance.vblank_target);
- PIPE_CONF_CHECK_I(dip.emp_as_sdp_tl);
- PIPE_CONF_CHECK_I(dip.gmp_sdp_tl);
- PIPE_CONF_CHECK_I(dip.pps_sdp_tl);
- PIPE_CONF_CHECK_I(dip.vsc_sdp_tl);
- PIPE_CONF_CHECK_I(dip.vsc_ext_sdp_tl);
- PIPE_CONF_CHECK_I(dip.cmn_sdp_tl);
+ PIPE_CONF_CHECK_U16(vrr.dc_balance.vmin);
+ PIPE_CONF_CHECK_U16(vrr.dc_balance.vmax);
+ PIPE_CONF_CHECK_U16(vrr.dc_balance.guardband);
+ PIPE_CONF_CHECK_U16(vrr.dc_balance.slope);
+ PIPE_CONF_CHECK_U16(vrr.dc_balance.max_increase);
+ PIPE_CONF_CHECK_U16(vrr.dc_balance.max_decrease);
+ PIPE_CONF_CHECK_U16(vrr.dc_balance.vblank_target);
+ PIPE_CONF_CHECK_U16(dip.emp_as_sdp_tl);
+ PIPE_CONF_CHECK_U16(dip.gmp_sdp_tl);
+ PIPE_CONF_CHECK_U16(dip.pps_sdp_tl);
+ PIPE_CONF_CHECK_U16(dip.vsc_sdp_tl);
+ PIPE_CONF_CHECK_U16(dip.vsc_ext_sdp_tl);
+ PIPE_CONF_CHECK_U16(dip.cmn_sdp_tl);
}
if (!fastset || intel_vrr_always_use_vrr_tg(display)) {
- PIPE_CONF_CHECK_I(vrr.pipeline_full);
- PIPE_CONF_CHECK_I(vrr.guardband);
+ PIPE_CONF_CHECK_U8(vrr.pipeline_full);
+ PIPE_CONF_CHECK_U16(vrr.guardband);
}
- PIPE_CONF_CHECK_I(set_context_latency);
+ PIPE_CONF_CHECK_U16(set_context_latency);
-#undef PIPE_CONF_CHECK_X
-#undef PIPE_CONF_CHECK_I
-#undef PIPE_CONF_CHECK_LLI
#undef PIPE_CONF_CHECK_BOOL
+#undef PIPE_CONF_CHECK_S32
+#undef PIPE_CONF_CHECK_ENUM
+#undef PIPE_CONF_CHECK_U8
+#undef PIPE_CONF_CHECK_U16
+#undef PIPE_CONF_CHECK_U32
+#undef PIPE_CONF_CHECK_U64
#undef PIPE_CONF_CHECK_P
+#undef PIPE_CONF_CHECK_U8_X
+#undef PIPE_CONF_CHECK_U16_X
+#undef PIPE_CONF_CHECK_U32_X
+#undef PIPE_CONF_CHECK_X_WITH_MASK
+#undef PIPE_CONF_CHECK_M_N
+#undef PIPE_CONF_CHECK_PLL
#undef PIPE_CONF_CHECK_FLAGS
+#undef PIPE_CONF_CHECK_INFOFRAME
+#undef PIPE_CONF_CHECK_DP_VSC_SDP
+#undef PIPE_CONF_CHECK_DP_AS_SDP
+#undef PIPE_CONF_CHECK_BUFFER
#undef PIPE_CONF_CHECK_COLOR_LUT
+#undef PIPE_CONF_CHECK_CSC
#undef PIPE_CONF_CHECK_TIMINGS
#undef PIPE_CONF_CHECK_RECT
#undef PIPE_CONF_QUIRK
return ret;
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/6] drm/i915: Implement CRTC atomic_create_state
2026-11-24 10:59 [PATCH 0/6] drm/i915: Support DRM_MODE_ATOMIC_RESET Maxime Ripard
2026-11-24 10:59 ` [PATCH 1/6] drm/atomic-state-helper: Provide more STATE_CHECK_* variants Maxime Ripard
2026-11-24 10:59 ` [PATCH 2/6] drm/i915: Use the STATE_CHECK_* macros in the pipe config comparison Maxime Ripard
@ 2026-11-24 10:59 ` Maxime Ripard
2026-11-24 11:26 ` sashiko-bot
2026-11-24 10:59 ` [PATCH 4/6] drm/i915: Implement plane atomic_create_state Maxime Ripard
` (2 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Maxime Ripard @ 2026-11-24 10:59 UTC (permalink / raw)
To: Maxime Ripard, Jani Nikula, Thomas Zimmermann, Maarten Lankhorst,
Tvrtko Ursulin, David Airlie, Simona Vetter, Joonas Lahtinen,
Rodrigo Vivi
Cc: intel-xe, intel-gfx, dri-devel
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 <mripard@kernel.org>
---
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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/6] drm/i915: Implement plane atomic_create_state
2026-11-24 10:59 [PATCH 0/6] drm/i915: Support DRM_MODE_ATOMIC_RESET Maxime Ripard
` (2 preceding siblings ...)
2026-11-24 10:59 ` [PATCH 3/6] drm/i915: Implement CRTC atomic_create_state Maxime Ripard
@ 2026-11-24 10:59 ` Maxime Ripard
2026-11-24 11:19 ` sashiko-bot
2026-11-24 10:59 ` [PATCH 5/6] drm/i915: Implement connector atomic_create_state Maxime Ripard
2026-11-24 10:59 ` [PATCH 6/6] drm/i915: Carry the current state over created states Maxime Ripard
5 siblings, 1 reply; 14+ messages in thread
From: Maxime Ripard @ 2026-11-24 10:59 UTC (permalink / raw)
To: Maxime Ripard, Jani Nikula, Thomas Zimmermann, Maarten Lankhorst,
Tvrtko Ursulin, David Airlie, Simona Vetter, Joonas Lahtinen,
Rodrigo Vivi
Cc: intel-xe, intel-gfx, dri-devel
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 plane functions don't implement it, relying on
intel_plane_alloc() initializing the state inline instead.
Provide an intel_plane_create_state() function allocating and
resetting a pristine state, have intel_plane_alloc() rely on it, and
assign it to all the plane functions.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/i915/display/i9xx_plane.c | 2 ++
drivers/gpu/drm/i915/display/intel_cursor.c | 1 +
drivers/gpu/drm/i915/display/intel_plane.c | 25 ++++++++++++++++------
drivers/gpu/drm/i915/display/intel_plane.h | 1 +
drivers/gpu/drm/i915/display/intel_sprite.c | 3 +++
drivers/gpu/drm/i915/display/skl_universal_plane.c | 3 +++
6 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/i9xx_plane.c b/drivers/gpu/drm/i915/display/i9xx_plane.c
index 0902b17d0269..bfaa74a669d3 100644
--- a/drivers/gpu/drm/i915/display/i9xx_plane.c
+++ b/drivers/gpu/drm/i915/display/i9xx_plane.c
@@ -882,10 +882,11 @@ static unsigned int i9xx_plane_min_alignment(struct intel_plane *plane,
static const struct drm_plane_funcs i965_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = intel_plane_destroy,
+ .atomic_create_state = intel_plane_create_state,
.atomic_duplicate_state = intel_plane_duplicate_state,
.atomic_destroy_state = intel_plane_destroy_state,
.format_mod_supported = i965_plane_format_mod_supported,
.format_mod_supported_async = intel_plane_format_mod_supported_async,
DRM_PANIC_PLANE_FUNCS,
@@ -893,10 +894,11 @@ static const struct drm_plane_funcs i965_plane_funcs = {
static const struct drm_plane_funcs i8xx_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = intel_plane_destroy,
+ .atomic_create_state = intel_plane_create_state,
.atomic_duplicate_state = intel_plane_duplicate_state,
.atomic_destroy_state = intel_plane_destroy_state,
.format_mod_supported = i8xx_plane_format_mod_supported,
.format_mod_supported_async = intel_plane_format_mod_supported_async,
DRM_PANIC_PLANE_FUNCS,
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c
index 4afd275de86e..b20c1259284c 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -1124,10 +1124,11 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
static const struct drm_plane_funcs intel_cursor_plane_funcs = {
.update_plane = intel_legacy_cursor_update,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = intel_plane_destroy,
+ .atomic_create_state = intel_plane_create_state,
.atomic_duplicate_state = intel_plane_duplicate_state,
.atomic_destroy_state = intel_plane_destroy_state,
.format_mod_supported = intel_cursor_format_mod_supported,
.format_mod_supported_async = intel_plane_format_mod_supported_async,
};
diff --git a/drivers/gpu/drm/i915/display/intel_plane.c b/drivers/gpu/drm/i915/display/intel_plane.c
index d23de0f34e4b..7cc2d9e96052 100644
--- a/drivers/gpu/drm/i915/display/intel_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_plane.c
@@ -71,28 +71,39 @@ static void intel_plane_state_reset(struct intel_plane_state *plane_state,
plane_state->scaler_id = -1;
plane_state->fence_id = -1;
}
-struct intel_plane *intel_plane_alloc(void)
+struct drm_plane_state *intel_plane_create_state(struct drm_plane *plane)
{
struct intel_plane_state *plane_state;
+
+ plane_state = kzalloc_obj(*plane_state);
+ if (!plane_state)
+ return ERR_PTR(-ENOMEM);
+
+ intel_plane_state_reset(plane_state, to_intel_plane(plane));
+
+ return &plane_state->uapi;
+}
+
+struct intel_plane *intel_plane_alloc(void)
+{
+ struct drm_plane_state *plane_state;
struct intel_plane *plane;
plane = kzalloc_obj(*plane);
if (!plane)
return ERR_PTR(-ENOMEM);
- plane_state = kzalloc_obj(*plane_state);
- if (!plane_state) {
+ plane_state = intel_plane_create_state(&plane->base);
+ if (IS_ERR(plane_state)) {
kfree(plane);
- return ERR_PTR(-ENOMEM);
+ return ERR_CAST(plane_state);
}
- intel_plane_state_reset(plane_state, plane);
-
- plane->base.state = &plane_state->uapi;
+ plane->base.state = plane_state;
return plane;
}
void intel_plane_free(struct intel_plane *plane)
diff --git a/drivers/gpu/drm/i915/display/intel_plane.h b/drivers/gpu/drm/i915/display/intel_plane.h
index dba2be24aae2..23595e0a6af7 100644
--- a/drivers/gpu/drm/i915/display/intel_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_plane.h
@@ -61,10 +61,11 @@ void intel_plane_disable_arm(struct intel_dsb *dsb,
struct intel_plane *plane,
const struct intel_crtc_state *crtc_state);
struct intel_plane *intel_plane_alloc(void);
void intel_plane_free(struct intel_plane *plane);
void intel_plane_destroy(struct drm_plane *plane);
+struct drm_plane_state *intel_plane_create_state(struct drm_plane *plane);
struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
void intel_plane_destroy_state(struct drm_plane *plane,
struct drm_plane_state *state);
void intel_crtc_planes_update_noarm(struct intel_dsb *dsb,
struct intel_atomic_state *state,
diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c b/drivers/gpu/drm/i915/display/intel_sprite.c
index 2321bfbb8630..971495f23deb 100644
--- a/drivers/gpu/drm/i915/display/intel_sprite.c
+++ b/drivers/gpu/drm/i915/display/intel_sprite.c
@@ -1562,30 +1562,33 @@ static bool vlv_sprite_format_mod_supported(struct drm_plane *_plane,
static const struct drm_plane_funcs g4x_sprite_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = intel_plane_destroy,
+ .atomic_create_state = intel_plane_create_state,
.atomic_duplicate_state = intel_plane_duplicate_state,
.atomic_destroy_state = intel_plane_destroy_state,
.format_mod_supported = g4x_sprite_format_mod_supported,
.format_mod_supported_async = intel_plane_format_mod_supported_async,
};
static const struct drm_plane_funcs snb_sprite_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = intel_plane_destroy,
+ .atomic_create_state = intel_plane_create_state,
.atomic_duplicate_state = intel_plane_duplicate_state,
.atomic_destroy_state = intel_plane_destroy_state,
.format_mod_supported = snb_sprite_format_mod_supported,
.format_mod_supported_async = intel_plane_format_mod_supported_async,
};
static const struct drm_plane_funcs vlv_sprite_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = intel_plane_destroy,
+ .atomic_create_state = intel_plane_create_state,
.atomic_duplicate_state = intel_plane_duplicate_state,
.atomic_destroy_state = intel_plane_destroy_state,
.format_mod_supported = vlv_sprite_format_mod_supported,
.format_mod_supported_async = intel_plane_format_mod_supported_async,
};
diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
index 8bdf1b8a0229..74f53774a6b2 100644
--- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
+++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
@@ -2712,10 +2712,11 @@ static bool tgl_plane_format_mod_supported(struct drm_plane *_plane,
static const struct drm_plane_funcs skl_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = intel_plane_destroy,
+ .atomic_create_state = intel_plane_create_state,
.atomic_duplicate_state = intel_plane_duplicate_state,
.atomic_destroy_state = intel_plane_destroy_state,
.format_mod_supported = skl_plane_format_mod_supported,
.format_mod_supported_async = intel_plane_format_mod_supported_async,
DRM_PANIC_PLANE_FUNCS,
@@ -2723,10 +2724,11 @@ static const struct drm_plane_funcs skl_plane_funcs = {
static const struct drm_plane_funcs icl_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = intel_plane_destroy,
+ .atomic_create_state = intel_plane_create_state,
.atomic_duplicate_state = intel_plane_duplicate_state,
.atomic_destroy_state = intel_plane_destroy_state,
.format_mod_supported = icl_plane_format_mod_supported,
.format_mod_supported_async = intel_plane_format_mod_supported_async,
DRM_PANIC_PLANE_FUNCS,
@@ -2734,10 +2736,11 @@ static const struct drm_plane_funcs icl_plane_funcs = {
static const struct drm_plane_funcs tgl_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = intel_plane_destroy,
+ .atomic_create_state = intel_plane_create_state,
.atomic_duplicate_state = intel_plane_duplicate_state,
.atomic_destroy_state = intel_plane_destroy_state,
.format_mod_supported = tgl_plane_format_mod_supported,
.format_mod_supported_async = intel_plane_format_mod_supported_async,
DRM_PANIC_PLANE_FUNCS,
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/6] drm/i915: Implement connector atomic_create_state
2026-11-24 10:59 [PATCH 0/6] drm/i915: Support DRM_MODE_ATOMIC_RESET Maxime Ripard
` (3 preceding siblings ...)
2026-11-24 10:59 ` [PATCH 4/6] drm/i915: Implement plane atomic_create_state Maxime Ripard
@ 2026-11-24 10:59 ` Maxime Ripard
2026-11-24 11:21 ` sashiko-bot
2026-11-24 10:59 ` [PATCH 6/6] drm/i915: Carry the current state over created states Maxime Ripard
5 siblings, 1 reply; 14+ messages in thread
From: Maxime Ripard @ 2026-11-24 10:59 UTC (permalink / raw)
To: Maxime Ripard, Jani Nikula, Thomas Zimmermann, Maarten Lankhorst,
Tvrtko Ursulin, David Airlie, Simona Vetter, Joonas Lahtinen,
Rodrigo Vivi
Cc: intel-xe, intel-gfx, dri-devel
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 connector functions don't implement it, relying on the
connector initialization functions allocating and initializing the
state inline instead.
Provide an intel_digital_connector_create_state() function allocating
and initializing a pristine digital connector state, have
intel_connector_init() and the SDVO counterpart rely on it, and assign
atomic_create_state implementations to all the connector functions:
the digital connectors use the new function, the CRT and DVO
connectors use the default helper since they only rely on the base
connector state, and the TV and SDVO connectors get their own since
they subclass it.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/i915/display/icl_dsi.c | 1 +
drivers/gpu/drm/i915/display/intel_atomic.c | 23 +++++++++++++++++++++++
drivers/gpu/drm/i915/display/intel_atomic.h | 2 ++
drivers/gpu/drm/i915/display/intel_connector.c | 23 +++++++++++------------
drivers/gpu/drm/i915/display/intel_crt.c | 1 +
drivers/gpu/drm/i915/display/intel_dp.c | 1 +
drivers/gpu/drm/i915/display/intel_dp_mst.c | 1 +
drivers/gpu/drm/i915/display/intel_dvo.c | 1 +
drivers/gpu/drm/i915/display/intel_hdmi.c | 1 +
drivers/gpu/drm/i915/display/intel_lvds.c | 1 +
drivers/gpu/drm/i915/display/intel_sdvo.c | 26 +++++++++++++++++++-------
drivers/gpu/drm/i915/display/intel_tv.c | 15 +++++++++++++++
drivers/gpu/drm/i915/display/vlv_dsi.c | 1 +
13 files changed, 78 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/icl_dsi.c b/drivers/gpu/drm/i915/display/icl_dsi.c
index ea0cdb7822f3..a95ded302ec2 100644
--- a/drivers/gpu/drm/i915/display/icl_dsi.c
+++ b/drivers/gpu/drm/i915/display/icl_dsi.c
@@ -1791,10 +1791,11 @@ static const struct drm_connector_funcs gen11_dsi_connector_funcs = {
.early_unregister = intel_connector_unregister,
.destroy = intel_connector_destroy,
.fill_modes = drm_helper_probe_single_connector_modes,
.atomic_get_property = intel_digital_connector_atomic_get_property,
.atomic_set_property = intel_digital_connector_atomic_set_property,
+ .atomic_create_state = intel_digital_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = intel_digital_connector_duplicate_state,
};
static const struct drm_connector_helper_funcs gen11_dsi_connector_helper_funcs = {
diff --git a/drivers/gpu/drm/i915/display/intel_atomic.c b/drivers/gpu/drm/i915/display/intel_atomic.c
index b66c2d4ba2b3..e752bbdda494 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic.c
@@ -168,10 +168,33 @@ intel_digital_connector_duplicate_state(struct drm_connector *connector)
__drm_atomic_helper_connector_duplicate_state(connector, &state->base);
return &state->base;
}
+/**
+ * intel_digital_connector_create_state - allocate a pristine connector state
+ * @connector: digital connector
+ *
+ * Allocates and initializes a pristine &struct intel_digital_connector_state.
+ *
+ * Returns: The newly allocated connector state, or an error pointer on
+ * failure.
+ */
+struct drm_connector_state *
+intel_digital_connector_create_state(struct drm_connector *connector)
+{
+ struct intel_digital_connector_state *conn_state;
+
+ conn_state = kzalloc_obj(*conn_state);
+ if (!conn_state)
+ return ERR_PTR(-ENOMEM);
+
+ __drm_atomic_helper_connector_state_init(&conn_state->base, connector);
+
+ return &conn_state->base;
+}
+
/**
* intel_connector_needs_modeset - check if connector needs a modeset
* @state: the atomic state corresponding to this modeset
* @connector: the connector
*/
diff --git a/drivers/gpu/drm/i915/display/intel_atomic.h b/drivers/gpu/drm/i915/display/intel_atomic.h
index 4dc5205a4733..50fbfe62071d 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic.h
@@ -30,10 +30,12 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,
u64 val);
int intel_digital_connector_atomic_check(struct drm_connector *conn,
struct drm_atomic_commit *state);
struct drm_connector_state *
intel_digital_connector_duplicate_state(struct drm_connector *connector);
+struct drm_connector_state *
+intel_digital_connector_create_state(struct drm_connector *connector);
bool intel_connector_needs_modeset(struct intel_atomic_state *state,
struct drm_connector *connector);
bool intel_any_crtc_needs_modeset(struct intel_atomic_state *state);
struct intel_digital_connector_state *
intel_atomic_get_digital_connector_state(struct intel_atomic_state *state,
diff --git a/drivers/gpu/drm/i915/display/intel_connector.c b/drivers/gpu/drm/i915/display/intel_connector.c
index 388911850b03..22fde377fdd9 100644
--- a/drivers/gpu/drm/i915/display/intel_connector.c
+++ b/drivers/gpu/drm/i915/display/intel_connector.c
@@ -30,10 +30,11 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_edid.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
+#include "intel_atomic.h"
#include "intel_connector.h"
#include "intel_display_core.h"
#include "intel_display_debugfs.h"
#include "intel_display_types.h"
#include "intel_hdcp.h"
@@ -77,26 +78,24 @@ void intel_connector_cancel_modeset_retry_work(struct intel_connector *connector
drm_connector_put(&connector->base);
}
static int intel_connector_init(struct intel_connector *connector)
{
- struct intel_digital_connector_state *conn_state;
+ struct drm_connector_state *conn_state;
/*
- * Allocate enough memory to hold intel_digital_connector_state,
- * This might be a few bytes too many, but for connectors that don't
- * need it we'll free the state and allocate a smaller one on the first
- * successful commit anyway.
+ * Allocate a state large enough to hold
+ * intel_digital_connector_state. This might be a few bytes too
+ * many, but for connectors that don't need it we'll free the
+ * state and allocate a smaller one on the first successful
+ * commit anyway.
*/
- conn_state = kzalloc_obj(*conn_state);
- if (!conn_state)
- return -ENOMEM;
+ conn_state = intel_digital_connector_create_state(&connector->base);
+ if (IS_ERR(conn_state))
+ return PTR_ERR(conn_state);
- __drm_atomic_helper_connector_state_init(&conn_state->base,
- &connector->base);
-
- connector->base.state = &conn_state->base;
+ connector->base.state = conn_state;
intel_panel_init_alloc(connector);
INIT_WORK(&connector->modeset_retry_work,
intel_connector_modeset_retry_work_fn);
diff --git a/drivers/gpu/drm/i915/display/intel_crt.c b/drivers/gpu/drm/i915/display/intel_crt.c
index 5b8968197fbc..f8e3ddb5dbec 100644
--- a/drivers/gpu/drm/i915/display/intel_crt.c
+++ b/drivers/gpu/drm/i915/display/intel_crt.c
@@ -993,10 +993,11 @@ void intel_crt_reset(struct drm_encoder *encoder)
static const struct drm_connector_funcs intel_crt_connector_funcs = {
.fill_modes = drm_helper_probe_single_connector_modes,
.late_register = intel_connector_register,
.early_unregister = intel_connector_unregister,
.destroy = intel_connector_destroy,
+ .atomic_create_state = drm_atomic_helper_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
};
static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = {
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 47741957935a..7da515a6fe3b 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -6871,10 +6871,11 @@ static const struct drm_connector_funcs intel_dp_connector_funcs = {
.atomic_get_property = intel_digital_connector_atomic_get_property,
.atomic_set_property = intel_digital_connector_atomic_set_property,
.late_register = intel_dp_connector_register,
.early_unregister = intel_dp_connector_unregister,
.destroy = intel_connector_destroy,
+ .atomic_create_state = intel_digital_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = intel_digital_connector_duplicate_state,
.oob_hotplug_event = intel_dp_oob_hotplug_event,
};
diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
index 7023619aaaba..2d3bf9a8ca50 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
@@ -1493,10 +1493,11 @@ static const struct drm_connector_funcs mst_connector_funcs = {
.atomic_get_property = intel_digital_connector_atomic_get_property,
.atomic_set_property = intel_digital_connector_atomic_set_property,
.late_register = mst_connector_late_register,
.early_unregister = mst_connector_early_unregister,
.destroy = intel_connector_destroy,
+ .atomic_create_state = intel_digital_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = intel_digital_connector_duplicate_state,
};
static int mst_connector_get_modes(struct drm_connector *_connector)
diff --git a/drivers/gpu/drm/i915/display/intel_dvo.c b/drivers/gpu/drm/i915/display/intel_dvo.c
index f157699a7c4c..f9c481d8b6de 100644
--- a/drivers/gpu/drm/i915/display/intel_dvo.c
+++ b/drivers/gpu/drm/i915/display/intel_dvo.c
@@ -347,10 +347,11 @@ static const struct drm_connector_funcs intel_dvo_connector_funcs = {
.detect = intel_dvo_detect,
.late_register = intel_connector_register,
.early_unregister = intel_connector_unregister,
.destroy = intel_connector_destroy,
.fill_modes = drm_helper_probe_single_connector_modes,
+ .atomic_create_state = drm_atomic_helper_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
};
static const struct drm_connector_helper_funcs intel_dvo_connector_helper_funcs = {
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index b6fa1a1558b8..a965ad2ca3b9 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -2684,10 +2684,11 @@ static const struct drm_connector_funcs intel_hdmi_connector_funcs = {
.atomic_get_property = intel_digital_connector_atomic_get_property,
.atomic_set_property = intel_digital_connector_atomic_set_property,
.late_register = intel_hdmi_connector_register,
.early_unregister = intel_hdmi_connector_unregister,
.destroy = intel_connector_destroy,
+ .atomic_create_state = intel_digital_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = intel_digital_connector_duplicate_state,
};
static int intel_hdmi_connector_atomic_check(struct drm_connector *_connector,
diff --git a/drivers/gpu/drm/i915/display/intel_lvds.c b/drivers/gpu/drm/i915/display/intel_lvds.c
index 872753478cf2..e7d6e8e8337a 100644
--- a/drivers/gpu/drm/i915/display/intel_lvds.c
+++ b/drivers/gpu/drm/i915/display/intel_lvds.c
@@ -510,10 +510,11 @@ static const struct drm_connector_funcs intel_lvds_connector_funcs = {
.atomic_get_property = intel_digital_connector_atomic_get_property,
.atomic_set_property = intel_digital_connector_atomic_set_property,
.late_register = intel_connector_register,
.early_unregister = intel_connector_unregister,
.destroy = intel_connector_destroy,
+ .atomic_create_state = intel_digital_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = intel_digital_connector_duplicate_state,
};
static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
diff --git a/drivers/gpu/drm/i915/display/intel_sdvo.c b/drivers/gpu/drm/i915/display/intel_sdvo.c
index 7b97f531acbf..e276f00f74c5 100644
--- a/drivers/gpu/drm/i915/display/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/display/intel_sdvo.c
@@ -2503,18 +2503,33 @@ intel_sdvo_connector_duplicate_state(struct drm_connector *connector)
__drm_atomic_helper_connector_duplicate_state(connector, &state->base.base);
return &state->base.base;
}
+static struct drm_connector_state *
+intel_sdvo_connector_create_state(struct drm_connector *connector)
+{
+ struct intel_sdvo_connector_state *state;
+
+ state = kzalloc_obj(*state);
+ if (!state)
+ return ERR_PTR(-ENOMEM);
+
+ __drm_atomic_helper_connector_state_init(&state->base.base, connector);
+
+ return &state->base.base;
+}
+
static const struct drm_connector_funcs intel_sdvo_connector_funcs = {
.detect = intel_sdvo_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.atomic_get_property = intel_sdvo_connector_atomic_get_property,
.atomic_set_property = intel_sdvo_connector_atomic_set_property,
.late_register = intel_connector_register,
.early_unregister = intel_connector_unregister,
.destroy = intel_connector_destroy,
+ .atomic_create_state = intel_sdvo_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = intel_sdvo_connector_duplicate_state,
};
static int intel_sdvo_atomic_check(struct drm_connector *conn,
@@ -2775,27 +2790,24 @@ intel_sdvo_add_hdmi_properties(struct intel_sdvo *intel_sdvo,
intel_attach_aspect_ratio_property(&connector->base.base);
}
static struct intel_sdvo_connector *intel_sdvo_connector_alloc(void)
{
+ struct drm_connector_state *conn_state;
struct intel_sdvo_connector *sdvo_connector;
- struct intel_sdvo_connector_state *conn_state;
sdvo_connector = kzalloc_obj(*sdvo_connector);
if (!sdvo_connector)
return NULL;
- conn_state = kzalloc_obj(*conn_state);
- if (!conn_state) {
+ conn_state = intel_sdvo_connector_create_state(&sdvo_connector->base.base);
+ if (IS_ERR(conn_state)) {
kfree(sdvo_connector);
return NULL;
}
- __drm_atomic_helper_connector_state_init(&conn_state->base.base,
- &sdvo_connector->base.base);
-
- sdvo_connector->base.base.state = &conn_state->base.base;
+ sdvo_connector->base.base.state = conn_state;
intel_panel_init_alloc(&sdvo_connector->base);
return sdvo_connector;
}
diff --git a/drivers/gpu/drm/i915/display/intel_tv.c b/drivers/gpu/drm/i915/display/intel_tv.c
index 840e1dcdc2d0..d40a8d2c4185 100644
--- a/drivers/gpu/drm/i915/display/intel_tv.c
+++ b/drivers/gpu/drm/i915/display/intel_tv.c
@@ -900,10 +900,24 @@ intel_tv_connector_duplicate_state(struct drm_connector *connector)
__drm_atomic_helper_connector_duplicate_state(connector, &state->base);
return &state->base;
}
+static struct drm_connector_state *
+intel_tv_connector_create_state(struct drm_connector *connector)
+{
+ struct intel_tv_connector_state *state;
+
+ state = kzalloc_obj(*state);
+ if (!state)
+ return ERR_PTR(-ENOMEM);
+
+ __drm_atomic_helper_connector_state_init(&state->base, connector);
+
+ return &state->base;
+}
+
static struct intel_tv *enc_to_tv(struct intel_encoder *encoder)
{
return container_of(encoder, struct intel_tv, base);
}
@@ -1839,10 +1853,11 @@ intel_tv_get_modes(struct drm_connector *connector)
static const struct drm_connector_funcs intel_tv_connector_funcs = {
.late_register = intel_connector_register,
.early_unregister = intel_connector_unregister,
.destroy = intel_connector_destroy,
.fill_modes = drm_helper_probe_single_connector_modes,
+ .atomic_create_state = intel_tv_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = intel_tv_connector_duplicate_state,
};
static int intel_tv_atomic_check(struct drm_connector *connector,
diff --git a/drivers/gpu/drm/i915/display/vlv_dsi.c b/drivers/gpu/drm/i915/display/vlv_dsi.c
index 8829f365592e..29c205910b32 100644
--- a/drivers/gpu/drm/i915/display/vlv_dsi.c
+++ b/drivers/gpu/drm/i915/display/vlv_dsi.c
@@ -1563,10 +1563,11 @@ static const struct drm_connector_funcs intel_dsi_connector_funcs = {
.early_unregister = intel_connector_unregister,
.destroy = intel_connector_destroy,
.fill_modes = drm_helper_probe_single_connector_modes,
.atomic_get_property = intel_digital_connector_atomic_get_property,
.atomic_set_property = intel_digital_connector_atomic_set_property,
+ .atomic_create_state = intel_digital_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = intel_digital_connector_duplicate_state,
};
static void vlv_dsi_add_properties(struct intel_connector *connector)
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 6/6] drm/i915: Carry the current state over created states
2026-11-24 10:59 [PATCH 0/6] drm/i915: Support DRM_MODE_ATOMIC_RESET Maxime Ripard
` (4 preceding siblings ...)
2026-11-24 10:59 ` [PATCH 5/6] drm/i915: Implement connector atomic_create_state Maxime Ripard
@ 2026-11-24 10:59 ` Maxime Ripard
2026-11-24 11:40 ` sashiko-bot
2026-11-24 13:29 ` Ville Syrjälä
5 siblings, 2 replies; 14+ messages in thread
From: Maxime Ripard @ 2026-11-24 10:59 UTC (permalink / raw)
To: Maxime Ripard, Jani Nikula, Thomas Zimmermann, Maarten Lankhorst,
Tvrtko Ursulin, David Airlie, Simona Vetter, Joonas Lahtinen,
Rodrigo Vivi
Cc: intel-xe, intel-gfx, dri-devel
The states of an atomic commit usually come from
intel_crtc_duplicate_state(), which carries the whole current state
over. The upcoming DRM_MODE_ATOMIC_RESET flag of the atomic ioctl
builds its commits out of states created through atomic_create_state()
instead: those come pristine, with only the uapi properties userspace
applied on top of the defaults.
A CRTC that stays enabled across such a commit, because userspace
re-applies the same configuration, takes the nomodeset path of
intel_atomic_check(): that path only updates the color management
part of the hw state and relies on everything else having been carried
over by the duplicate. Without the carry-over, the pipe mode, the
transcoder, the DPLL, the scaler bookkeeping and all the other derived
state would be zeroed on a CRTC the hardware keeps driving, and the
scaler staging would fail to find a free scaler for the planes still
using one.
Carry the current state over the created ones like a duplicate would,
keeping the uapi state userspace just configured. A created state is
told apart from a duplicated one through its invalid transcoder: the
state of an active CRTC always holds a valid one, a duplicate carries
it over, and a created state comes reset.
The planes get the same treatment for their scaler assignment: the
scaler staging frees the scaler of a plane through the new state, and
assigns it one when it still needs scaling, both of which need the
assignment the current state holds. Carry the scaler id over when the
current state has one and the new state doesn't.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/i915/display/intel_display.c | 114 +++++++++++++++++++++++++++
1 file changed, 114 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 1172e48daf23..d645203104a7 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -6517,10 +6517,120 @@ static int intel_atomic_check_config_and_link(struct intel_atomic_state *state)
break;
}
return ret;
}
+/*
+ * intel_atomic_carry_over_state - carry the current state over created states
+ * @state: atomic state
+ *
+ * The states of a commit usually come from intel_crtc_duplicate_state(),
+ * which carries the whole current state over. The upcoming
+ * DRM_MODE_ATOMIC_RESET flag of the atomic ioctl builds its commits out
+ * of states created through atomic_create_state() instead: those come
+ * pristine, with only the uapi properties userspace applied on top of
+ * the defaults.
+ *
+ * A CRTC that stays enabled across such a commit, because userspace
+ * re-applies the same configuration, takes the nomodeset path of
+ * intel_atomic_check(): that path only updates the color management
+ * part of the hw state and relies on everything else having been
+ * carried over by the duplicate. Take the current state over like a
+ * duplicate would, keeping the uapi state userspace just configured:
+ * without it, the pipe mode, the transcoder, the DPLL, the scaler
+ * bookkeeping and all the other derived state would be zeroed on a
+ * CRTC the hardware keeps driving.
+ *
+ * A created state is told apart from a duplicated one through its
+ * invalid transcoder: the state of an active CRTC always holds a valid
+ * one, a duplicate carries it over, and a created state comes reset.
+ *
+ * The planes need the same for their scaler assignment: the scaler
+ * staging frees the scaler of a plane through the new state, and
+ * assigns it one when it still needs scaling, both of which need the
+ * assignment the current state holds. A created plane state comes with
+ * none, and with the scaler still marked in use in the carried CRTC
+ * state, it could neither be freed nor replaced.
+ */
+static int intel_atomic_carry_over_state(struct intel_atomic_state *state)
+{
+ struct intel_crtc_state *old_crtc_state, *new_crtc_state;
+ struct intel_plane_state *old_plane_state, *new_plane_state;
+ struct intel_crtc *crtc;
+ struct intel_plane *plane;
+ int i;
+
+ for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
+ new_crtc_state) {
+ struct intel_crtc_state *carried_state;
+
+ if (new_crtc_state->cpu_transcoder != INVALID_TRANSCODER ||
+ !old_crtc_state->hw.active)
+ continue;
+
+ carried_state = kmemdup(old_crtc_state, sizeof(*carried_state),
+ GFP_KERNEL);
+ if (!carried_state)
+ return -ENOMEM;
+
+ /* Keep the uapi state userspace just configured. */
+ carried_state->uapi = new_crtc_state->uapi;
+
+ intel_crtc_free_hw_state(new_crtc_state);
+ if (new_crtc_state->dp_tunnel_ref.tunnel)
+ drm_dp_tunnel_ref_put(&new_crtc_state->dp_tunnel_ref);
+
+ memcpy(new_crtc_state, carried_state, sizeof(*new_crtc_state));
+ kfree(carried_state);
+
+ /* Take the references a duplicated state would carry. */
+ if (new_crtc_state->hw.degamma_lut)
+ drm_property_blob_get(new_crtc_state->hw.degamma_lut);
+ if (new_crtc_state->hw.ctm)
+ drm_property_blob_get(new_crtc_state->hw.ctm);
+ if (new_crtc_state->hw.gamma_lut)
+ drm_property_blob_get(new_crtc_state->hw.gamma_lut);
+
+ if (new_crtc_state->pre_csc_lut)
+ drm_property_blob_get(new_crtc_state->pre_csc_lut);
+ if (new_crtc_state->post_csc_lut)
+ drm_property_blob_get(new_crtc_state->post_csc_lut);
+
+ if (new_crtc_state->dp_tunnel_ref.tunnel)
+ drm_dp_tunnel_ref_get(new_crtc_state->dp_tunnel_ref.tunnel,
+ &new_crtc_state->dp_tunnel_ref);
+
+ /* Clear the transient flags, like a duplicate would. */
+ new_crtc_state->update_pipe = false;
+ new_crtc_state->update_m_n = false;
+ new_crtc_state->update_lrr = false;
+ new_crtc_state->disable_cxsr = false;
+ new_crtc_state->update_wm_pre = false;
+ new_crtc_state->update_wm_post = false;
+ new_crtc_state->fifo_changed = false;
+ new_crtc_state->preload_luts = false;
+ new_crtc_state->wm.need_postvbl_update = false;
+ new_crtc_state->do_async_flip = false;
+ new_crtc_state->fb_bits = 0;
+ new_crtc_state->update_planes = 0;
+ new_crtc_state->dsb_color = NULL;
+ new_crtc_state->dsb_commit = NULL;
+ new_crtc_state->use_dsb = false;
+ new_crtc_state->use_flipq = false;
+ }
+
+ for_each_oldnew_intel_plane_in_state(state, plane, old_plane_state,
+ new_plane_state, i) {
+ if (new_plane_state->scaler_id < 0 &&
+ old_plane_state->scaler_id >= 0)
+ new_plane_state->scaler_id =
+ old_plane_state->scaler_id;
+ }
+
+ return 0;
+}
+
/**
* intel_atomic_check - validate state object
* @dev: drm device
* @_state: state to validate
*/
@@ -6534,10 +6644,14 @@ int intel_atomic_check(struct drm_device *dev,
int ret;
if (!intel_display_driver_check_access(display))
return -ENODEV;
+ ret = intel_atomic_carry_over_state(state);
+ if (ret)
+ goto fail;
+
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state) {
/*
* crtc's state no longer considered to be inherited
* after the first userspace/client initiated commit.
*/
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 4/6] drm/i915: Implement plane atomic_create_state
2026-11-24 10:59 ` [PATCH 4/6] drm/i915: Implement plane atomic_create_state Maxime Ripard
@ 2026-11-24 11:19 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-24 11:19 UTC (permalink / raw)
To: Maxime Ripard; +Cc: intel-xe, intel-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/i915: UAF and VMA leak in drm_mode_config_reset() via
atomic_create_state
--
commit 464346083e71e6c63fc65d310b5b8531a2b40785
Author: Maxime Ripard <mripard@kernel.org>
drm/i915: Implement plane atomic_create_state
This commit adds intel_plane_create_state() and wires it up to
.atomic_create_state on all i915/xe plane function tables.
> diff --git a/drivers/gpu/drm/i915/display/i9xx_plane.c b/drivers/gpu/drm/i915/display/i9xx_plane.c
> index 0902b17d02693..bfaa74a669d34 100644
> --- a/drivers/gpu/drm/i915/display/i9xx_plane.c
> +++ b/drivers/gpu/drm/i915/display/i9xx_plane.c
> @@ -884,6 +884,7 @@ static const struct drm_plane_funcs i965_plane_funcs = {
> .update_plane = drm_atomic_helper_update_plane,
> .disable_plane = drm_atomic_helper_disable_plane,
> .destroy = intel_plane_destroy,
> + .atomic_create_state = intel_plane_create_state,
> .atomic_duplicate_state = intel_plane_duplicate_state,
> .atomic_destroy_state = intel_plane_destroy_state,
> .format_mod_supported = i965_plane_format_mod_supported,
[Severity: High]
Can populating .atomic_create_state cause a use-after-free and double free
of old_plane_state when drm_mode_config_reset() runs during D3cold resume?
drm_mode_config_reset() is also a caller of .atomic_create_state: when a
plane implements this hook, drm_mode_config_plane_reset_with_create_state()
destroys the existing plane->state via .atomic_destroy_state() and replaces
it with a newly allocated default state.
In xe, xe_display_disable_d3cold() calls drm_mode_config_reset() on runtime
PM resume from D3cold. When an atomic commit runs while the device is in
D3cold, drm_atomic_get_plane_state() captures state->planes[i].old_state =
plane->state before intel_atomic_commit() wakes the device via
intel_display_rpm_get() -> xe_display_disable_d3cold() ->
drm_mode_config_reset(). That reset frees plane->state while it is still
referenced as old_plane_state, after which intel_atomic_prepare_commit()
and intel_atomic_swap_state() read and swap the freed old_plane_state and
queue it to be freed a second time.
Even outside an atomic commit, exiting D3cold while a plane holds a pinned
framebuffer on a DPMS-off CRTC destroys plane->state without calling
intel_cleanup_plane_fb(), triggering the ggtt_vma/dpt_vma warnings in
intel_plane_destroy_state(), leaking the pinned VMAs, and wiping the plane
software state.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-drm-i915-conversion-state-readout-v1-0-b7132f72644d@kernel.org?part=4
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/6] drm/i915: Implement connector atomic_create_state
2026-11-24 10:59 ` [PATCH 5/6] drm/i915: Implement connector atomic_create_state Maxime Ripard
@ 2026-11-24 11:21 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-24 11:21 UTC (permalink / raw)
To: Maxime Ripard; +Cc: intel-xe, intel-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/i915: uninitialized max_bpc in
intel_digital_connector_create_state()
- [High] drm/i915: uninitialized scaling_mode in
intel_digital_connector_create_state()
- [High] drm/i915: drm_mode_config_reset() wipes connector->state on PM
resume
- [Medium] drm/i915: missing TV defaults in TV and SDVO
atomic_create_state callbacks
--
commit 2bdba76f9c13d7e52d75cab97754e24fd12b8cea
Author: Maxime Ripard <mripard@kernel.org>
drm/i915: Implement connector atomic_create_state
This commit implements the .atomic_create_state hook for all i915
connectors to support DRM_MODE_ATOMIC_RESET.
> 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.
[Severity: High]
Does wiring up connector->funcs->atomic_create_state also cause
drm_mode_config_reset() to destroy and recreate connector->state on PM
resume?
drm_mode_config_reset() calls
drm_mode_config_connector_reset_with_create_state() whenever a connector
implements atomic_create_state:
drivers/gpu/drm/drm_mode_config.c:drm_mode_config_reset() {
...
drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) {
if (connector->funcs->atomic_create_state)
drm_mode_config_connector_reset_with_create_state(connector);
}
drm_connector_list_iter_end(&conn_iter);
}
Both i915_drm_resume() and Xe's xe_display_pm_resume() and
xe_display_disable_d3cold() call drm_mode_config_reset(). On Xe runtime
PM exit from D3cold, xe_display_disable_d3cold() runs without saving or
restoring atomic state and without holding modeset locks, so every D3cold
wakeup replaces each connector->state with a fresh default state and
wipes out existing property values and routing.
[ ... ]
> diff --git a/drivers/gpu/drm/i915/display/intel_atomic.c b/drivers/gpu/drm/i915/display/intel_atomic.c
> index b66c2d4ba2b3f..e752bbdda494c 100644
> --- a/drivers/gpu/drm/i915/display/intel_atomic.c
> +++ b/drivers/gpu/drm/i915/display/intel_atomic.c
> @@ -170,6 +170,29 @@ intel_digital_connector_duplicate_state(struct drm_connector *connector)
> return &state->base;
> }
>
> +/**
> + * intel_digital_connector_create_state - allocate a pristine connector state
> + * @connector: digital connector
> + *
> + * Allocates and initializes a pristine &struct intel_digital_connector_state.
> + *
> + * Returns: The newly allocated connector state, or an error pointer on
> + * failure.
> + */
> +struct drm_connector_state *
> +intel_digital_connector_create_state(struct drm_connector *connector)
> +{
> + struct intel_digital_connector_state *conn_state;
> +
> + conn_state = kzalloc_obj(*conn_state);
> + if (!conn_state)
> + return ERR_PTR(-ENOMEM);
> +
> + __drm_atomic_helper_connector_state_init(&conn_state->base, connector);
> +
> + return &conn_state->base;
> +}
[Severity: High]
Does intel_digital_connector_create_state() leave
conn_state->base.max_requested_bpc and conn_state->base.max_bpc as 0 on
DP, DP MST and HDMI connectors?
At connector init, drm_connector_attach_max_bpc_property() attaches
connector->max_bpc_property and initializes max_requested_bpc and max_bpc
on the initial state, whereas __drm_atomic_helper_connector_state_init()
only sets conn_state->connector. When DRM_MODE_ATOMIC_RESET creates a
fresh state without userspace explicitly supplying the "max bpc"
property, drm_atomic_connector_check() clamps state->max_bpc to
min(state->max_bpc, state->max_requested_bpc), which is 0. During
modeset check, compute_sink_pipe_bpp() passes conn_state->max_bpc to
bpc_to_bpp(0), hitting MISSING_CASE(0) (a kernel WARN) and failing the
commit with -EINVAL.
[Severity: High]
Does intel_digital_connector_create_state() also leave
conn_state->base.scaling_mode at 0 (DRM_MODE_SCALE_NONE) on eDP, LVDS and
DSI panel connectors?
intel_attach_scaling_mode_property() attaches
connector->scaling_mode_property without DRM_MODE_SCALE_NONE in the
supported mask and sets the default connector->state->scaling_mode to
DRM_MODE_SCALE_ASPECT. When DRM_MODE_ATOMIC_RESET allocates a zeroed
state, scaling_mode becomes DRM_MODE_SCALE_NONE, which forces
crtc_state->mode_changed in intel_digital_connector_atomic_check(). On a
non-native panel mode, gmch_panel_fitting() hits
MISSING_CASE(conn_state->scaling_mode) and fails with -EINVAL, while
pch_panel_fitting() triggers two WARN_ON() splats and falls through to
DRM_MODE_SCALE_FULLSCREEN instead of preserving the aspect ratio.
[ ... ]
> diff --git a/drivers/gpu/drm/i915/display/intel_sdvo.c b/drivers/gpu/drm/i915/display/intel_sdvo.c
> index 7b97f531acbfb..e276f00f74c58 100644
> --- a/drivers/gpu/drm/i915/display/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/display/intel_sdvo.c
> @@ -2505,6 +2505,20 @@ intel_sdvo_connector_duplicate_state(struct drm_connector *connector)
> return &state->base.base;
> }
>
> +static struct drm_connector_state *
> +intel_sdvo_connector_create_state(struct drm_connector *connector)
> +{
> + struct intel_sdvo_connector_state *state;
> +
> + state = kzalloc_obj(*state);
> + if (!state)
> + return ERR_PTR(-ENOMEM);
> +
> + __drm_atomic_helper_connector_state_init(&state->base.base, connector);
> +
> + return &state->base.base;
> +}
[ ... ]
> diff --git a/drivers/gpu/drm/i915/display/intel_tv.c b/drivers/gpu/drm/i915/display/intel_tv.c
> index 840e1dcdc2d0f..d40a8d2c41858 100644
> --- a/drivers/gpu/drm/i915/display/intel_tv.c
> +++ b/drivers/gpu/drm/i915/display/intel_tv.c
> @@ -902,6 +902,20 @@ intel_tv_connector_duplicate_state(struct drm_connector *connector)
> return &state->base;
> }
>
> +static struct drm_connector_state *
> +intel_tv_connector_create_state(struct drm_connector *connector)
> +{
> + struct intel_tv_connector_state *state;
> +
> + state = kzalloc_obj(*state);
> + if (!state)
> + return ERR_PTR(-ENOMEM);
> +
> + __drm_atomic_helper_connector_state_init(&state->base, connector);
> +
> + return &state->base;
> +}
[Severity: Medium]
Do intel_sdvo_connector_create_state() and
intel_tv_connector_create_state() drop the connector default TV format,
enhancement and margin values populated during connector initialization?
On SDVO TV/LVDS connectors, intel_sdvo_tv_create_property() initializes
connector->state->tv.legacy_mode to
intel_sdvo_connector->tv_format_supported[0], and
intel_sdvo_create_enhance_property_tv() and
intel_sdvo_create_enhance_property_lvds() populate the default enhancement
values queried from hardware. Leaving state->base.base.tv.legacy_mode as
0 in intel_sdvo_connector_create_state() triggers
drm_WARN_ON(connector->dev, 1) in
intel_sdvo_connector_atomic_get_property() whenever format 0 is not in
tv_format_supported[], and zeroes all hardware enhancement defaults.
Similarly, intel_tv_connector_create_state() leaves
state->base.tv.margins zeroed instead of restoring the BIOS default
margins (54, 36, 46, 37) configured in intel_tv_add_properties().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-drm-i915-conversion-state-readout-v1-0-b7132f72644d@kernel.org?part=5
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/6] drm/i915: Use the STATE_CHECK_* macros in the pipe config comparison
2026-11-24 10:59 ` [PATCH 2/6] drm/i915: Use the STATE_CHECK_* macros in the pipe config comparison Maxime Ripard
@ 2026-11-24 11:23 ` Jani Nikula
2026-11-24 13:18 ` Maxime Ripard
0 siblings, 1 reply; 14+ messages in thread
From: Jani Nikula @ 2026-11-24 11:23 UTC (permalink / raw)
To: Maxime Ripard, Maxime Ripard, Thomas Zimmermann,
Maarten Lankhorst, Tvrtko Ursulin, David Airlie, Simona Vetter,
Joonas Lahtinen, Rodrigo Vivi
Cc: intel-xe, intel-gfx, dri-devel, Syrjala, Ville
On Tue, 24 Nov 2026, Maxime Ripard <mripard@kernel.org> wrote:
> The state readout framework provides the STATE_CHECK_* macros and
> drm_atomic_helper_print_state_mismatch() to compare two state
> instances field by field and report the mismatches through a drm
> printer.
>
> intel_pipe_config_compare() implements the very same thing with its
> own set of PIPE_CONF_CHECK_* macros printing through the
> pipe_config_mismatch() helper, duplicating the framework.
>
> Rework the plain field checks on top of the STATE_CHECK_* macros,
> sorting every PIPE_CONF_CHECK_I() and PIPE_CONF_CHECK_X() call site
> onto the variant matching its field type: STATE_CHECK_BOOL(), _S32(),
> _ENUM(), _U8(), _U16(), _U32(), _U64() and _PTR(), along with the
> _U8_X(), _U16_X() and _U32_X() hexadecimal counterparts. The
> static_assert() of each macro then checks the field type at compile
> time, which the untyped PIPE_CONF_CHECK_I() and _X() macros couldn't
> do, and PIPE_CONF_CHECK_LLI() becomes a STATE_CHECK_U64() based check
> that also prints its u64 fields properly.
>
> The checks without a framework counterpart, namely the masked, flags,
> M/N, DPLL, timings, rectangle, infoframe, DP SDP, ELD buffer, color
> LUT and CSC ones, along with the infoframe, SDP, buffer and PLL
> mismatch reporters, print their header through
> drm_atomic_helper_print_state_mismatch() instead.
> pipe_config_mismatch() isn't needed anymore and gets removed.
>
> The mismatch messages change format in the process, from
>
> [CRTC:31:pipe A] fastset requirement not met in hw.enable (expected yes, found no)
>
> to
>
> pipe A configuration mismatch in hw.enable (expected yes, got no)
I think the "fastset requirement not met" vs. "mismatch" distinction has
been a useful one. People tend to think a "mismatch" is always an error,
regardless of the loglevel. We know, because we deliberately added the
distinction about three years ago to unconfuse people...
We've also put in a lot of effort to have a fairly uniform drm object
logging prefix all over the place. It would be a shame to lose it,
because over time you get used to searching the dmesg with that format.
BR,
Jani.
>
> The fastset and state checker invocations are still told apart by
> their printer, drm_dbg_kms() for the former and drm_err() for the
> latter, and the infoframe, SDP, buffer and PLL reporters keep dumping
> both instances. The CRTC id is dropped from the messages, but the
> i915 CRTC names are unique on their own.
>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
> drivers/gpu/drm/i915/display/intel_display.c | 493 +++++++++++++--------------
> 1 file changed, 241 insertions(+), 252 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index f79caeb5a82e..1172e48daf23 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -34,10 +34,11 @@
>
> #include <drm/display/drm_dp_helper.h>
> #include <drm/display/drm_dp_tunnel.h>
> #include <drm/drm_atomic.h>
> #include <drm/drm_atomic_helper.h>
> +#include <drm/drm_atomic_state_readout_helper.h>
> #include <drm/drm_atomic_uapi.h>
> #include <drm/drm_damage_helper.h>
> #include <drm/drm_edid.h>
> #include <drm/drm_fixed.h>
> #include <drm/drm_fourcc.h>
> @@ -5038,32 +5039,10 @@ static bool
> intel_compare_buffer(const u8 *a, const u8 *b, size_t len)
> {
> return memcmp(a, b, len) == 0;
> }
>
> -static void __printf(5, 6)
> -pipe_config_mismatch(struct drm_printer *p, bool fastset,
> - const struct intel_crtc *crtc,
> - const char *name, const char *format, ...)
> -{
> - struct va_format vaf;
> - va_list args;
> -
> - va_start(args, format);
> - vaf.fmt = format;
> - vaf.va = &args;
> -
> - if (fastset)
> - drm_printf(p, "[CRTC:%d:%s] fastset requirement not met in %s %pV\n",
> - crtc->base.base.id, crtc->base.name, name, &vaf);
> - else
> - drm_printf(p, "[CRTC:%d:%s] mismatch in %s %pV\n",
> - crtc->base.base.id, crtc->base.name, name, &vaf);
> -
> - va_end(args);
> -}
> -
> static void
> pipe_config_infoframe_mismatch(struct drm_printer *p, bool fastset,
> const struct intel_crtc *crtc,
> const char *name,
> const union hdmi_infoframe *a,
> @@ -5079,41 +5058,44 @@ pipe_config_infoframe_mismatch(struct drm_printer *p, bool fastset,
> loglevel = KERN_DEBUG;
> } else {
> loglevel = KERN_ERR;
> }
>
> - pipe_config_mismatch(p, fastset, crtc, name, "infoframe");
> + drm_atomic_helper_print_state_mismatch(p, crtc->base.name,
> + name, "infoframe");
>
> drm_printf(p, "expected:\n");
> hdmi_infoframe_log(loglevel, display->drm->dev, a);
> drm_printf(p, "found:\n");
> hdmi_infoframe_log(loglevel, display->drm->dev, b);
> }
>
> static void
> -pipe_config_dp_vsc_sdp_mismatch(struct drm_printer *p, bool fastset,
> +pipe_config_dp_vsc_sdp_mismatch(struct drm_printer *p,
> const struct intel_crtc *crtc,
> const char *name,
> const struct drm_dp_vsc_sdp *a,
> const struct drm_dp_vsc_sdp *b)
> {
> - pipe_config_mismatch(p, fastset, crtc, name, "dp vsc sdp");
> + drm_atomic_helper_print_state_mismatch(p, crtc->base.name,
> + name, "dp vsc sdp");
>
> drm_printf(p, "expected:\n");
> drm_dp_vsc_sdp_log(p, a);
> drm_printf(p, "found:\n");
> drm_dp_vsc_sdp_log(p, b);
> }
>
> static void
> -pipe_config_dp_as_sdp_mismatch(struct drm_printer *p, bool fastset,
> +pipe_config_dp_as_sdp_mismatch(struct drm_printer *p,
> const struct intel_crtc *crtc,
> const char *name,
> const struct drm_dp_as_sdp *a,
> const struct drm_dp_as_sdp *b)
> {
> - pipe_config_mismatch(p, fastset, crtc, name, "dp as sdp");
> + drm_atomic_helper_print_state_mismatch(p, crtc->base.name,
> + name, "dp as sdp");
>
> drm_printf(p, "expected:\n");
> drm_dp_as_sdp_log(p, a);
> drm_printf(p, "found:\n");
> drm_dp_as_sdp_log(p, b);
> @@ -5132,34 +5114,36 @@ memcmp_diff_len(const u8 *a, const u8 *b, size_t len)
>
> return 0;
> }
>
> static void
> -pipe_config_buffer_mismatch(struct drm_printer *p, bool fastset,
> +pipe_config_buffer_mismatch(struct drm_printer *p,
> const struct intel_crtc *crtc,
> const char *name,
> const u8 *a, const u8 *b, size_t len)
> {
> - pipe_config_mismatch(p, fastset, crtc, name, "buffer");
> + drm_atomic_helper_print_state_mismatch(p, crtc->base.name,
> + name, "buffer");
>
> /* only dump up to the last difference */
> len = memcmp_diff_len(a, b, len);
>
> drm_print_hex_dump(p, "expected: ", a, len);
> drm_print_hex_dump(p, "found: ", b, len);
> }
>
> static void
> -pipe_config_pll_mismatch(struct drm_printer *p, bool fastset,
> +pipe_config_pll_mismatch(struct drm_printer *p,
> const struct intel_crtc *crtc,
> const char *name,
> const struct intel_dpll_hw_state *a,
> const struct intel_dpll_hw_state *b)
> {
> struct intel_display *display = to_intel_display(crtc);
>
> - pipe_config_mismatch(p, fastset, crtc, name, " "); /* stupid -Werror=format-zero-length */
> + /* stupid -Werror=format-zero-length */
> + drm_atomic_helper_print_state_mismatch(p, crtc->base.name, name, " ");
>
> drm_printf(p, "expected:\n");
> intel_dpll_dump_hw_state(display, p, a);
> drm_printf(p, "found:\n");
> intel_dpll_dump_hw_state(display, p, b);
> @@ -5198,179 +5182,169 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
> if (fastset)
> p = drm_dbg_printer(display->drm, DRM_UT_KMS, NULL);
> else
> p = drm_err_printer(display->drm, NULL);
>
> -#define PIPE_CONF_CHECK_X(name) do { \
> - if (current_config->name != pipe_config->name) { \
> - BUILD_BUG_ON_MSG(__same_type(current_config->name, bool), \
> - __stringify(name) " is bool"); \
> - pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
> - "(expected 0x%08x, found 0x%08x)", \
> - current_config->name, \
> - pipe_config->name); \
> +#define PIPE_CONF_CHECK_BOOL(field) \
> + STATE_CHECK_BOOL(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_S32(field) \
> + STATE_CHECK_S32(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_ENUM(field) \
> + STATE_CHECK_ENUM(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_U8(field) \
> + STATE_CHECK_U8(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_U16(field) \
> + STATE_CHECK_U16(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_U32(field) \
> + STATE_CHECK_U32(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_U64(field) \
> + STATE_CHECK_U64(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_P(field) \
> + STATE_CHECK_PTR(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_U8_X(field) \
> + STATE_CHECK_U8_X(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_U16_X(field) \
> + STATE_CHECK_U16_X(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_U32_X(field) \
> + STATE_CHECK_U32_X(ret, &p, crtc->base.name, \
> + current_config, pipe_config, field)
> +
> +#define PIPE_CONF_CHECK_X_WITH_MASK(field, mask) do { \
> + if ((current_config->field & (mask)) != (pipe_config->field & (mask))) { \
> + drm_atomic_helper_print_state_mismatch(&p, crtc->base.name, \
> + __stringify(field), \
> + "expected %x, got %x", \
> + current_config->field & (mask), \
> + pipe_config->field & (mask)); \
> ret = false; \
> } \
> } while (0)
>
> -#define PIPE_CONF_CHECK_X_WITH_MASK(name, mask) do { \
> - if ((current_config->name & (mask)) != (pipe_config->name & (mask))) { \
> - BUILD_BUG_ON_MSG(__same_type(current_config->name, bool), \
> - __stringify(name) " is bool"); \
> - pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
> - "(expected 0x%08x, found 0x%08x)", \
> - current_config->name & (mask), \
> - pipe_config->name & (mask)); \
> +#define PIPE_CONF_CHECK_M_N(field) do { \
> + if (!intel_compare_link_m_n(¤t_config->field, \
> + &pipe_config->field)) { \
> + drm_atomic_helper_print_state_mismatch(&p, crtc->base.name, \
> + __stringify(field), \
> + "expected tu %i data %i/%i link %i/%i, " \
> + "got tu %i data %i/%i link %i/%i", \
> + current_config->field.tu, \
> + current_config->field.data_m, \
> + current_config->field.data_n, \
> + current_config->field.link_m, \
> + current_config->field.link_n, \
> + pipe_config->field.tu, \
> + pipe_config->field.data_m, \
> + pipe_config->field.data_n, \
> + pipe_config->field.link_m, \
> + pipe_config->field.link_n); \
> ret = false; \
> } \
> } while (0)
>
> -#define PIPE_CONF_CHECK_I(name) do { \
> - if (current_config->name != pipe_config->name) { \
> - BUILD_BUG_ON_MSG(__same_type(current_config->name, bool), \
> - __stringify(name) " is bool"); \
> - pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
> - "(expected %i, found %i)", \
> - current_config->name, \
> - pipe_config->name); \
> - ret = false; \
> - } \
> -} while (0)
> -
> -#define PIPE_CONF_CHECK_LLI(name) do { \
> - if (current_config->name != pipe_config->name) { \
> - pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
> - "(expected %lli, found %lli)", \
> - current_config->name, \
> - pipe_config->name); \
> - ret = false; \
> - } \
> -} while (0)
> -
> -#define PIPE_CONF_CHECK_BOOL(name) do { \
> - if (current_config->name != pipe_config->name) { \
> - BUILD_BUG_ON_MSG(!__same_type(current_config->name, bool), \
> - __stringify(name) " is not bool"); \
> - pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
> - "(expected %s, found %s)", \
> - str_yes_no(current_config->name), \
> - str_yes_no(pipe_config->name)); \
> - ret = false; \
> - } \
> -} while (0)
> -
> -#define PIPE_CONF_CHECK_P(name) do { \
> - if (current_config->name != pipe_config->name) { \
> - pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
> - "(expected %p, found %p)", \
> - current_config->name, \
> - pipe_config->name); \
> - ret = false; \
> - } \
> -} while (0)
> -
> -#define PIPE_CONF_CHECK_M_N(name) do { \
> - if (!intel_compare_link_m_n(¤t_config->name, \
> - &pipe_config->name)) { \
> - pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
> - "(expected tu %i data %i/%i link %i/%i, " \
> - "found tu %i, data %i/%i link %i/%i)", \
> - current_config->name.tu, \
> - current_config->name.data_m, \
> - current_config->name.data_n, \
> - current_config->name.link_m, \
> - current_config->name.link_n, \
> - pipe_config->name.tu, \
> - pipe_config->name.data_m, \
> - pipe_config->name.data_n, \
> - pipe_config->name.link_m, \
> - pipe_config->name.link_n); \
> - ret = false; \
> - } \
> -} while (0)
> -
> -#define PIPE_CONF_CHECK_PLL(name) do { \
> - if (!intel_dpll_compare_hw_state(display, ¤t_config->name, \
> - &pipe_config->name)) { \
> - pipe_config_pll_mismatch(&p, fastset, crtc, __stringify(name), \
> - ¤t_config->name, \
> - &pipe_config->name); \
> +#define PIPE_CONF_CHECK_PLL(field) do { \
> + if (!intel_dpll_compare_hw_state(display, ¤t_config->field, \
> + &pipe_config->field)) { \
> + pipe_config_pll_mismatch(&p, crtc, __stringify(field), \
> + ¤t_config->field, \
> + &pipe_config->field); \
> ret = false; \
> } \
> } while (0)
>
> #define PIPE_CONF_CHECK_TIMINGS(name) do { \
> - PIPE_CONF_CHECK_I(name.crtc_hdisplay); \
> - PIPE_CONF_CHECK_I(name.crtc_htotal); \
> - PIPE_CONF_CHECK_I(name.crtc_hblank_start); \
> - PIPE_CONF_CHECK_I(name.crtc_hblank_end); \
> - PIPE_CONF_CHECK_I(name.crtc_hsync_start); \
> - PIPE_CONF_CHECK_I(name.crtc_hsync_end); \
> - PIPE_CONF_CHECK_I(name.crtc_vdisplay); \
> + PIPE_CONF_CHECK_U16(name.crtc_hdisplay); \
> + PIPE_CONF_CHECK_U16(name.crtc_htotal); \
> + PIPE_CONF_CHECK_U16(name.crtc_hblank_start); \
> + PIPE_CONF_CHECK_U16(name.crtc_hblank_end); \
> + PIPE_CONF_CHECK_U16(name.crtc_hsync_start); \
> + PIPE_CONF_CHECK_U16(name.crtc_hsync_end); \
> + PIPE_CONF_CHECK_U16(name.crtc_vdisplay); \
> if (!fastset || !allow_vblank_delay_fastset(current_config)) \
> - PIPE_CONF_CHECK_I(name.crtc_vblank_start); \
> + PIPE_CONF_CHECK_U16(name.crtc_vblank_start); \
> if (!fastset || !pipe_config->update_lrr) { \
> - PIPE_CONF_CHECK_I(name.crtc_vsync_start); \
> - PIPE_CONF_CHECK_I(name.crtc_vsync_end); \
> - PIPE_CONF_CHECK_I(name.crtc_vtotal); \
> - PIPE_CONF_CHECK_I(name.crtc_vblank_end); \
> + PIPE_CONF_CHECK_U16(name.crtc_vsync_start); \
> + PIPE_CONF_CHECK_U16(name.crtc_vsync_end); \
> + PIPE_CONF_CHECK_U16(name.crtc_vtotal); \
> + PIPE_CONF_CHECK_U16(name.crtc_vblank_end); \
> } \
> } while (0)
>
> #define PIPE_CONF_CHECK_RECT(name) do { \
> - PIPE_CONF_CHECK_I(name.x1); \
> - PIPE_CONF_CHECK_I(name.x2); \
> - PIPE_CONF_CHECK_I(name.y1); \
> - PIPE_CONF_CHECK_I(name.y2); \
> + PIPE_CONF_CHECK_S32(name.x1); \
> + PIPE_CONF_CHECK_S32(name.x2); \
> + PIPE_CONF_CHECK_S32(name.y1); \
> + PIPE_CONF_CHECK_S32(name.y2); \
> } while (0)
>
> -#define PIPE_CONF_CHECK_FLAGS(name, mask) do { \
> - if ((current_config->name ^ pipe_config->name) & (mask)) { \
> - pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
> - "(%x) (expected %i, found %i)", \
> - (mask), \
> - current_config->name & (mask), \
> - pipe_config->name & (mask)); \
> +#define PIPE_CONF_CHECK_FLAGS(field, mask) do { \
> + if ((current_config->field ^ pipe_config->field) & (mask)) { \
> + drm_atomic_helper_print_state_mismatch(&p, crtc->base.name, \
> + __stringify(field), \
> + "(%x) expected %i, got %i", \
> + (mask), \
> + current_config->field & (mask), \
> + pipe_config->field & (mask)); \
> ret = false; \
> } \
> } while (0)
>
> #define PIPE_CONF_CHECK_INFOFRAME(name) do { \
> if (!intel_compare_infoframe(¤t_config->infoframes.name, \
> &pipe_config->infoframes.name)) { \
> - pipe_config_infoframe_mismatch(&p, fastset, crtc, __stringify(name), \
> + pipe_config_infoframe_mismatch(&p, fastset, crtc, \
> + __stringify(name), \
> ¤t_config->infoframes.name, \
> &pipe_config->infoframes.name); \
> ret = false; \
> } \
> } while (0)
>
> #define PIPE_CONF_CHECK_DP_VSC_SDP(name) do { \
> if (!intel_compare_dp_vsc_sdp(¤t_config->infoframes.name, \
> &pipe_config->infoframes.name)) { \
> - pipe_config_dp_vsc_sdp_mismatch(&p, fastset, crtc, __stringify(name), \
> + pipe_config_dp_vsc_sdp_mismatch(&p, crtc, __stringify(name), \
> ¤t_config->infoframes.name, \
> &pipe_config->infoframes.name); \
> ret = false; \
> } \
> } while (0)
>
> #define PIPE_CONF_CHECK_DP_AS_SDP(name) do { \
> if (!intel_compare_dp_as_sdp(¤t_config->infoframes.name, \
> &pipe_config->infoframes.name)) { \
> - pipe_config_dp_as_sdp_mismatch(&p, fastset, crtc, __stringify(name), \
> + pipe_config_dp_as_sdp_mismatch(&p, crtc, __stringify(name), \
> ¤t_config->infoframes.name, \
> &pipe_config->infoframes.name); \
> ret = false; \
> } \
> } while (0)
>
> #define PIPE_CONF_CHECK_BUFFER(name, len) do { \
> BUILD_BUG_ON(sizeof(current_config->name) != (len)); \
> BUILD_BUG_ON(sizeof(pipe_config->name) != (len)); \
> if (!intel_compare_buffer(current_config->name, pipe_config->name, (len))) { \
> - pipe_config_buffer_mismatch(&p, fastset, crtc, __stringify(name), \
> + pipe_config_buffer_mismatch(&p, crtc, __stringify(name), \
> current_config->name, \
> pipe_config->name, \
> (len)); \
> ret = false; \
> } \
> @@ -5379,69 +5353,70 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
> #define PIPE_CONF_CHECK_COLOR_LUT(lut, is_pre_csc_lut) do { \
> if (current_config->gamma_mode == pipe_config->gamma_mode && \
> !intel_color_lut_equal(current_config, \
> current_config->lut, pipe_config->lut, \
> is_pre_csc_lut)) { \
> - pipe_config_mismatch(&p, fastset, crtc, __stringify(lut), \
> - "hw_state doesn't match sw_state"); \
> + drm_atomic_helper_print_state_mismatch(&p, crtc->base.name, \
> + __stringify(lut), \
> + "hw_state doesn't match sw_state"); \
> ret = false; \
> } \
> } while (0)
>
> -#define PIPE_CONF_CHECK_CSC(name) do { \
> - PIPE_CONF_CHECK_X(name.preoff[0]); \
> - PIPE_CONF_CHECK_X(name.preoff[1]); \
> - PIPE_CONF_CHECK_X(name.preoff[2]); \
> - PIPE_CONF_CHECK_X(name.coeff[0]); \
> - PIPE_CONF_CHECK_X(name.coeff[1]); \
> - PIPE_CONF_CHECK_X(name.coeff[2]); \
> - PIPE_CONF_CHECK_X(name.coeff[3]); \
> - PIPE_CONF_CHECK_X(name.coeff[4]); \
> - PIPE_CONF_CHECK_X(name.coeff[5]); \
> - PIPE_CONF_CHECK_X(name.coeff[6]); \
> - PIPE_CONF_CHECK_X(name.coeff[7]); \
> - PIPE_CONF_CHECK_X(name.coeff[8]); \
> - PIPE_CONF_CHECK_X(name.postoff[0]); \
> - PIPE_CONF_CHECK_X(name.postoff[1]); \
> - PIPE_CONF_CHECK_X(name.postoff[2]); \
> +#define PIPE_CONF_CHECK_CSC(field) do { \
> + PIPE_CONF_CHECK_U16_X(field.preoff[0]); \
> + PIPE_CONF_CHECK_U16_X(field.preoff[1]); \
> + PIPE_CONF_CHECK_U16_X(field.preoff[2]); \
> + PIPE_CONF_CHECK_U16_X(field.coeff[0]); \
> + PIPE_CONF_CHECK_U16_X(field.coeff[1]); \
> + PIPE_CONF_CHECK_U16_X(field.coeff[2]); \
> + PIPE_CONF_CHECK_U16_X(field.coeff[3]); \
> + PIPE_CONF_CHECK_U16_X(field.coeff[4]); \
> + PIPE_CONF_CHECK_U16_X(field.coeff[5]); \
> + PIPE_CONF_CHECK_U16_X(field.coeff[6]); \
> + PIPE_CONF_CHECK_U16_X(field.coeff[7]); \
> + PIPE_CONF_CHECK_U16_X(field.coeff[8]); \
> + PIPE_CONF_CHECK_U16_X(field.postoff[0]); \
> + PIPE_CONF_CHECK_U16_X(field.postoff[1]); \
> + PIPE_CONF_CHECK_U16_X(field.postoff[2]); \
> } while (0)
>
> #define PIPE_CONF_QUIRK(quirk) \
> ((current_config->quirks | pipe_config->quirks) & (quirk))
>
> PIPE_CONF_CHECK_BOOL(hw.enable);
> PIPE_CONF_CHECK_BOOL(hw.active);
>
> - PIPE_CONF_CHECK_I(cpu_transcoder);
> - PIPE_CONF_CHECK_I(mst_master_transcoder);
> + PIPE_CONF_CHECK_ENUM(cpu_transcoder);
> + PIPE_CONF_CHECK_ENUM(mst_master_transcoder);
>
> PIPE_CONF_CHECK_BOOL(has_pch_encoder);
> - PIPE_CONF_CHECK_I(fdi_lanes);
> + PIPE_CONF_CHECK_S32(fdi_lanes);
> PIPE_CONF_CHECK_M_N(fdi_m_n);
>
> - PIPE_CONF_CHECK_I(lane_count);
> - PIPE_CONF_CHECK_X(lane_lat_optim_mask);
> + PIPE_CONF_CHECK_U8(lane_count);
> + PIPE_CONF_CHECK_U8_X(lane_lat_optim_mask);
>
> - PIPE_CONF_CHECK_I(min_hblank);
> + PIPE_CONF_CHECK_S32(min_hblank);
>
> if (HAS_DOUBLE_BUFFERED_M_N(display)) {
> if (!fastset || !pipe_config->update_m_n)
> PIPE_CONF_CHECK_M_N(dp_m_n);
> } else {
> PIPE_CONF_CHECK_M_N(dp_m_n);
> PIPE_CONF_CHECK_M_N(dp_m2_n2);
> }
>
> - PIPE_CONF_CHECK_X(output_types);
> + PIPE_CONF_CHECK_U32_X(output_types);
>
> - PIPE_CONF_CHECK_I(framestart_delay);
> - PIPE_CONF_CHECK_I(msa_timing_delay);
> + PIPE_CONF_CHECK_U8(framestart_delay);
> + PIPE_CONF_CHECK_U8(msa_timing_delay);
>
> PIPE_CONF_CHECK_TIMINGS(hw.pipe_mode);
> PIPE_CONF_CHECK_TIMINGS(hw.adjusted_mode);
>
> - PIPE_CONF_CHECK_I(pixel_multiplier);
> + PIPE_CONF_CHECK_U32(pixel_multiplier);
>
> PIPE_CONF_CHECK_FLAGS(hw.adjusted_mode.flags,
> DRM_MODE_FLAG_INTERLACE);
>
> if (!PIPE_CONF_QUIRK(PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS)) {
> @@ -5453,11 +5428,11 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
> DRM_MODE_FLAG_PVSYNC);
> PIPE_CONF_CHECK_FLAGS(hw.adjusted_mode.flags,
> DRM_MODE_FLAG_NVSYNC);
> }
>
> - PIPE_CONF_CHECK_I(output_format);
> + PIPE_CONF_CHECK_ENUM(output_format);
> PIPE_CONF_CHECK_BOOL(has_hdmi_sink);
> if ((DISPLAY_VER(display) < 8 && !display->platform.haswell) ||
> display->platform.valleyview || display->platform.cherryview)
> PIPE_CONF_CHECK_BOOL(limited_color_range);
>
> @@ -5470,15 +5445,15 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
> if (!fastset) {
> PIPE_CONF_CHECK_BOOL(has_audio);
> PIPE_CONF_CHECK_BUFFER(eld, MAX_ELD_BYTES);
> }
>
> - PIPE_CONF_CHECK_X(gmch_pfit.control);
> + PIPE_CONF_CHECK_U32_X(gmch_pfit.control);
> /* pfit ratios are autocomputed by the hw on gen4+ */
> if (DISPLAY_VER(display) < 4)
> - PIPE_CONF_CHECK_X(gmch_pfit.pgm_ratios);
> - PIPE_CONF_CHECK_X(gmch_pfit.lvds_border_bits);
> + PIPE_CONF_CHECK_U32_X(gmch_pfit.pgm_ratios);
> + PIPE_CONF_CHECK_U32_X(gmch_pfit.lvds_border_bits);
>
> /*
> * Changing the EDP transcoder input mux
> * (A_ONOFF vs. A_ON) requires a full modeset.
> */
> @@ -5488,30 +5463,30 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
> PIPE_CONF_CHECK_RECT(pipe_src);
>
> PIPE_CONF_CHECK_BOOL(pch_pfit.enabled);
> PIPE_CONF_CHECK_RECT(pch_pfit.dst);
> PIPE_CONF_CHECK_BOOL(pch_pfit.casf.enable);
> - PIPE_CONF_CHECK_I(pch_pfit.casf.win_size);
> - PIPE_CONF_CHECK_I(pch_pfit.casf.strength);
> + PIPE_CONF_CHECK_U8(pch_pfit.casf.win_size);
> + PIPE_CONF_CHECK_U8(pch_pfit.casf.strength);
>
> - PIPE_CONF_CHECK_I(scaler_state.scaler_id);
> - PIPE_CONF_CHECK_I(pixel_rate_cdclk);
> - PIPE_CONF_CHECK_I(pixel_rate);
> + PIPE_CONF_CHECK_S32(scaler_state.scaler_id);
> + PIPE_CONF_CHECK_U32(pixel_rate_cdclk);
> + PIPE_CONF_CHECK_U32(pixel_rate);
>
> - PIPE_CONF_CHECK_X(gamma_mode);
> + PIPE_CONF_CHECK_U32_X(gamma_mode);
> if (display->platform.cherryview)
> - PIPE_CONF_CHECK_X(cgm_mode);
> + PIPE_CONF_CHECK_U32_X(cgm_mode);
> else
> - PIPE_CONF_CHECK_X(csc_mode);
> + PIPE_CONF_CHECK_U32_X(csc_mode);
> PIPE_CONF_CHECK_BOOL(gamma_enable);
>
> - PIPE_CONF_CHECK_X(hw.background_color);
> + PIPE_CONF_CHECK_U32_X(hw.background_color);
> PIPE_CONF_CHECK_BOOL(csc_enable);
> PIPE_CONF_CHECK_BOOL(wgc_enable);
>
> - PIPE_CONF_CHECK_I(linetime);
> - PIPE_CONF_CHECK_I(ips_linetime);
> + PIPE_CONF_CHECK_U16(linetime);
> + PIPE_CONF_CHECK_U16(ips_linetime);
>
> PIPE_CONF_CHECK_COLOR_LUT(pre_csc_lut, true);
> PIPE_CONF_CHECK_COLOR_LUT(post_csc_lut, false);
>
> PIPE_CONF_CHECK_CSC(csc);
> @@ -5525,123 +5500,137 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>
> /* FIXME convert everything over the dpll_mgr */
> if (display->dpll.mgr || HAS_GMCH(display))
> PIPE_CONF_CHECK_PLL(dpll_hw_state);
>
> - PIPE_CONF_CHECK_X(dsi_pll.ctrl);
> - PIPE_CONF_CHECK_X(dsi_pll.div);
> + PIPE_CONF_CHECK_U32_X(dsi_pll.ctrl);
> + PIPE_CONF_CHECK_U32_X(dsi_pll.div);
>
> if (display->platform.g4x || DISPLAY_VER(display) >= 5)
> - PIPE_CONF_CHECK_I(pipe_bpp);
> + PIPE_CONF_CHECK_S32(pipe_bpp);
>
> if (!fastset || !pipe_config->update_m_n) {
> - PIPE_CONF_CHECK_I(hw.pipe_mode.crtc_clock);
> - PIPE_CONF_CHECK_I(hw.adjusted_mode.crtc_clock);
> + PIPE_CONF_CHECK_S32(hw.pipe_mode.crtc_clock);
> + PIPE_CONF_CHECK_S32(hw.adjusted_mode.crtc_clock);
> }
> - PIPE_CONF_CHECK_I(port_clock);
> + PIPE_CONF_CHECK_S32(port_clock);
>
> - PIPE_CONF_CHECK_I(min_voltage_level);
> + PIPE_CONF_CHECK_U8(min_voltage_level);
>
> if (current_config->has_psr || pipe_config->has_psr)
> exclude_infoframes |= intel_hdmi_infoframe_enable(DP_SDP_VSC);
>
> if (current_config->vrr.enable || pipe_config->vrr.enable)
> exclude_infoframes |= intel_hdmi_infoframe_enable(DP_SDP_ADAPTIVE_SYNC);
>
> PIPE_CONF_CHECK_X_WITH_MASK(infoframes.enable, ~exclude_infoframes);
> - PIPE_CONF_CHECK_X(infoframes.gcp);
> + PIPE_CONF_CHECK_U32_X(infoframes.gcp);
> PIPE_CONF_CHECK_INFOFRAME(avi);
> PIPE_CONF_CHECK_INFOFRAME(spd);
> PIPE_CONF_CHECK_INFOFRAME(hdmi);
> if (!fastset) {
> PIPE_CONF_CHECK_INFOFRAME(drm);
> PIPE_CONF_CHECK_DP_AS_SDP(as_sdp);
> }
> PIPE_CONF_CHECK_DP_VSC_SDP(vsc);
>
> - PIPE_CONF_CHECK_X(sync_mode_slaves_mask);
> - PIPE_CONF_CHECK_I(master_transcoder);
> - PIPE_CONF_CHECK_X(joiner_pipes);
> + PIPE_CONF_CHECK_U16_X(sync_mode_slaves_mask);
> + PIPE_CONF_CHECK_ENUM(master_transcoder);
> + PIPE_CONF_CHECK_U8_X(joiner_pipes);
>
> PIPE_CONF_CHECK_BOOL(dsc.config.block_pred_enable);
> PIPE_CONF_CHECK_BOOL(dsc.config.convert_rgb);
> PIPE_CONF_CHECK_BOOL(dsc.config.simple_422);
> PIPE_CONF_CHECK_BOOL(dsc.config.native_422);
> PIPE_CONF_CHECK_BOOL(dsc.config.native_420);
> PIPE_CONF_CHECK_BOOL(dsc.config.vbr_enable);
> - PIPE_CONF_CHECK_I(dsc.config.line_buf_depth);
> - PIPE_CONF_CHECK_I(dsc.config.bits_per_component);
> - PIPE_CONF_CHECK_I(dsc.config.pic_width);
> - PIPE_CONF_CHECK_I(dsc.config.pic_height);
> - PIPE_CONF_CHECK_I(dsc.config.slice_width);
> - PIPE_CONF_CHECK_I(dsc.config.slice_height);
> - PIPE_CONF_CHECK_I(dsc.config.initial_dec_delay);
> - PIPE_CONF_CHECK_I(dsc.config.initial_xmit_delay);
> - PIPE_CONF_CHECK_I(dsc.config.scale_decrement_interval);
> - PIPE_CONF_CHECK_I(dsc.config.scale_increment_interval);
> - PIPE_CONF_CHECK_I(dsc.config.initial_scale_value);
> - PIPE_CONF_CHECK_I(dsc.config.first_line_bpg_offset);
> - PIPE_CONF_CHECK_I(dsc.config.flatness_min_qp);
> - PIPE_CONF_CHECK_I(dsc.config.flatness_max_qp);
> - PIPE_CONF_CHECK_I(dsc.config.slice_bpg_offset);
> - PIPE_CONF_CHECK_I(dsc.config.nfl_bpg_offset);
> - PIPE_CONF_CHECK_I(dsc.config.initial_offset);
> - PIPE_CONF_CHECK_I(dsc.config.final_offset);
> - PIPE_CONF_CHECK_I(dsc.config.rc_model_size);
> - PIPE_CONF_CHECK_I(dsc.config.rc_quant_incr_limit0);
> - PIPE_CONF_CHECK_I(dsc.config.rc_quant_incr_limit1);
> - PIPE_CONF_CHECK_I(dsc.config.slice_chunk_size);
> - PIPE_CONF_CHECK_I(dsc.config.second_line_bpg_offset);
> - PIPE_CONF_CHECK_I(dsc.config.nsl_bpg_offset);
> + PIPE_CONF_CHECK_U8(dsc.config.line_buf_depth);
> + PIPE_CONF_CHECK_U8(dsc.config.bits_per_component);
> + PIPE_CONF_CHECK_U16(dsc.config.pic_width);
> + PIPE_CONF_CHECK_U16(dsc.config.pic_height);
> + PIPE_CONF_CHECK_U16(dsc.config.slice_width);
> + PIPE_CONF_CHECK_U16(dsc.config.slice_height);
> + PIPE_CONF_CHECK_U16(dsc.config.initial_dec_delay);
> + PIPE_CONF_CHECK_U16(dsc.config.initial_xmit_delay);
> + PIPE_CONF_CHECK_U16(dsc.config.scale_decrement_interval);
> + PIPE_CONF_CHECK_U16(dsc.config.scale_increment_interval);
> + PIPE_CONF_CHECK_U8(dsc.config.initial_scale_value);
> + PIPE_CONF_CHECK_U8(dsc.config.first_line_bpg_offset);
> + PIPE_CONF_CHECK_U8(dsc.config.flatness_min_qp);
> + PIPE_CONF_CHECK_U8(dsc.config.flatness_max_qp);
> + PIPE_CONF_CHECK_U16(dsc.config.slice_bpg_offset);
> + PIPE_CONF_CHECK_U16(dsc.config.nfl_bpg_offset);
> + PIPE_CONF_CHECK_U16(dsc.config.initial_offset);
> + PIPE_CONF_CHECK_U16(dsc.config.final_offset);
> + PIPE_CONF_CHECK_U16(dsc.config.rc_model_size);
> + PIPE_CONF_CHECK_U8(dsc.config.rc_quant_incr_limit0);
> + PIPE_CONF_CHECK_U8(dsc.config.rc_quant_incr_limit1);
> + PIPE_CONF_CHECK_U16(dsc.config.slice_chunk_size);
> + PIPE_CONF_CHECK_U8(dsc.config.second_line_bpg_offset);
> + PIPE_CONF_CHECK_U16(dsc.config.nsl_bpg_offset);
>
> PIPE_CONF_CHECK_BOOL(dsc.compression_enable);
> - PIPE_CONF_CHECK_I(dsc.slice_config.streams_per_pipe);
> - PIPE_CONF_CHECK_I(dsc.compressed_bpp_x16);
> + PIPE_CONF_CHECK_S32(dsc.slice_config.streams_per_pipe);
> + PIPE_CONF_CHECK_U16(dsc.compressed_bpp_x16);
>
> PIPE_CONF_CHECK_BOOL(splitter.enable);
> - PIPE_CONF_CHECK_I(splitter.link_count);
> - PIPE_CONF_CHECK_I(splitter.pixel_overlap);
> + PIPE_CONF_CHECK_U8(splitter.link_count);
> + PIPE_CONF_CHECK_U8(splitter.pixel_overlap);
>
> if (!fastset) {
> PIPE_CONF_CHECK_BOOL(vrr.enable);
> - PIPE_CONF_CHECK_I(vrr.vmin);
> - PIPE_CONF_CHECK_I(vrr.vmax);
> - PIPE_CONF_CHECK_I(vrr.flipline);
> - PIPE_CONF_CHECK_I(vrr.vsync_start);
> - PIPE_CONF_CHECK_I(vrr.vsync_end);
> - PIPE_CONF_CHECK_LLI(vrr.cmrr.cmrr_m);
> - PIPE_CONF_CHECK_LLI(vrr.cmrr.cmrr_n);
> + PIPE_CONF_CHECK_U16(vrr.vmin);
> + PIPE_CONF_CHECK_U16(vrr.vmax);
> + PIPE_CONF_CHECK_U16(vrr.flipline);
> + PIPE_CONF_CHECK_U32(vrr.vsync_start);
> + PIPE_CONF_CHECK_U32(vrr.vsync_end);
> + PIPE_CONF_CHECK_U64(vrr.cmrr.cmrr_m);
> + PIPE_CONF_CHECK_U64(vrr.cmrr.cmrr_n);
> PIPE_CONF_CHECK_BOOL(vrr.cmrr.enable);
> - PIPE_CONF_CHECK_I(vrr.dc_balance.vmin);
> - PIPE_CONF_CHECK_I(vrr.dc_balance.vmax);
> - PIPE_CONF_CHECK_I(vrr.dc_balance.guardband);
> - PIPE_CONF_CHECK_I(vrr.dc_balance.slope);
> - PIPE_CONF_CHECK_I(vrr.dc_balance.max_increase);
> - PIPE_CONF_CHECK_I(vrr.dc_balance.max_decrease);
> - PIPE_CONF_CHECK_I(vrr.dc_balance.vblank_target);
> - PIPE_CONF_CHECK_I(dip.emp_as_sdp_tl);
> - PIPE_CONF_CHECK_I(dip.gmp_sdp_tl);
> - PIPE_CONF_CHECK_I(dip.pps_sdp_tl);
> - PIPE_CONF_CHECK_I(dip.vsc_sdp_tl);
> - PIPE_CONF_CHECK_I(dip.vsc_ext_sdp_tl);
> - PIPE_CONF_CHECK_I(dip.cmn_sdp_tl);
> + PIPE_CONF_CHECK_U16(vrr.dc_balance.vmin);
> + PIPE_CONF_CHECK_U16(vrr.dc_balance.vmax);
> + PIPE_CONF_CHECK_U16(vrr.dc_balance.guardband);
> + PIPE_CONF_CHECK_U16(vrr.dc_balance.slope);
> + PIPE_CONF_CHECK_U16(vrr.dc_balance.max_increase);
> + PIPE_CONF_CHECK_U16(vrr.dc_balance.max_decrease);
> + PIPE_CONF_CHECK_U16(vrr.dc_balance.vblank_target);
> + PIPE_CONF_CHECK_U16(dip.emp_as_sdp_tl);
> + PIPE_CONF_CHECK_U16(dip.gmp_sdp_tl);
> + PIPE_CONF_CHECK_U16(dip.pps_sdp_tl);
> + PIPE_CONF_CHECK_U16(dip.vsc_sdp_tl);
> + PIPE_CONF_CHECK_U16(dip.vsc_ext_sdp_tl);
> + PIPE_CONF_CHECK_U16(dip.cmn_sdp_tl);
> }
>
> if (!fastset || intel_vrr_always_use_vrr_tg(display)) {
> - PIPE_CONF_CHECK_I(vrr.pipeline_full);
> - PIPE_CONF_CHECK_I(vrr.guardband);
> + PIPE_CONF_CHECK_U8(vrr.pipeline_full);
> + PIPE_CONF_CHECK_U16(vrr.guardband);
> }
>
> - PIPE_CONF_CHECK_I(set_context_latency);
> + PIPE_CONF_CHECK_U16(set_context_latency);
>
> -#undef PIPE_CONF_CHECK_X
> -#undef PIPE_CONF_CHECK_I
> -#undef PIPE_CONF_CHECK_LLI
> #undef PIPE_CONF_CHECK_BOOL
> +#undef PIPE_CONF_CHECK_S32
> +#undef PIPE_CONF_CHECK_ENUM
> +#undef PIPE_CONF_CHECK_U8
> +#undef PIPE_CONF_CHECK_U16
> +#undef PIPE_CONF_CHECK_U32
> +#undef PIPE_CONF_CHECK_U64
> #undef PIPE_CONF_CHECK_P
> +#undef PIPE_CONF_CHECK_U8_X
> +#undef PIPE_CONF_CHECK_U16_X
> +#undef PIPE_CONF_CHECK_U32_X
> +#undef PIPE_CONF_CHECK_X_WITH_MASK
> +#undef PIPE_CONF_CHECK_M_N
> +#undef PIPE_CONF_CHECK_PLL
> #undef PIPE_CONF_CHECK_FLAGS
> +#undef PIPE_CONF_CHECK_INFOFRAME
> +#undef PIPE_CONF_CHECK_DP_VSC_SDP
> +#undef PIPE_CONF_CHECK_DP_AS_SDP
> +#undef PIPE_CONF_CHECK_BUFFER
> #undef PIPE_CONF_CHECK_COLOR_LUT
> +#undef PIPE_CONF_CHECK_CSC
> #undef PIPE_CONF_CHECK_TIMINGS
> #undef PIPE_CONF_CHECK_RECT
> #undef PIPE_CONF_QUIRK
>
> return ret;
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/6] drm/i915: Implement CRTC atomic_create_state
2026-11-24 10:59 ` [PATCH 3/6] drm/i915: Implement CRTC atomic_create_state Maxime Ripard
@ 2026-11-24 11:26 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-24 11:26 UTC (permalink / raw)
To: Maxime Ripard; +Cc: intel-xe, intel-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/i915: intel_crtc_create_state() causes UAF in
drm_mode_config_reset()
--
commit c5121c9ae2a50c81961f73b900dacfb69a94085f
Author: Maxime Ripard <mripard@kernel.org>
drm/i915: Implement CRTC atomic_create_state
This commit adds an atomic_create_state callback for i915 CRTCs by
wrapping intel_crtc_state_alloc() and wiring it into INTEL_CRTC_FUNCS.
> diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
> index 10ed9bdfee763..7bb3caf913106 100644
> --- a/drivers/gpu/drm/i915/display/intel_crtc.c
> +++ b/drivers/gpu/drm/i915/display/intel_crtc.c
> @@ -177,6 +177,17 @@ struct intel_crtc_state *intel_crtc_state_alloc(struct intel_crtc *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)
> {
> @@ -243,6 +254,7 @@ static int intel_crtc_late_register(struct drm_crtc *crtc)
> .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, \
[Severity: High]
Does wiring up .atomic_create_state cause a use-after-free of
struct intel_crtc_state when drm_mode_config_reset() runs on resume or
Xe D3cold exit?
When crtc->funcs->atomic_create_state is populated,
drm_mode_config_reset() calls
drm_mode_config_crtc_reset_with_create_state(), which destroys
crtc->state via atomic_destroy_state() and replaces it with a new state
from atomic_create_state(). Both i915 and Xe call
drm_mode_config_reset() in i915_drm_resume(), xe_display_pm_resume(),
and xe_display_disable_d3cold(), where INTEL_CRTC_FUNCS previously had
neither .reset nor .atomic_create_state.
First, replacing crtc->base.state without updating intel_crtc->config
leaves crtc->config as a dangling pointer to the freed state. During
intel_modeset_setup_hw_state() on system resume,
intel_modeset_readout_hw_state() resets crtc->base.state in place and
paths such as bxt_dsi_get_config() or
intel_crtc_disable_noatomic_complete() -> intel_update_watermarks() ->
intel_crtc_active() dereference the freed crtc->config before
intel_atomic_commit_tail() updates it.
Second, on Xe D3cold exit, an atomic commit records
state->crtcs[i].old_state = crtc->state before intel_atomic_commit()
calls intel_display_rpm_get(), which wakes the device and runs
xe_display_disable_d3cold() -> drm_mode_config_reset(). That frees
old_crtc_state mid-commit, so intel_atomic_setup_commit() and
drm_atomic_helper_swap_state() read and write freed memory, hit
WARN_ON(crtc->state != old_crtc_state), leak the newly allocated state,
and double free old_crtc_state when the commit is put. Even outside an
atomic commit, xe_display_disable_d3cold() runs unlocked without state
restoration and wipes active CRTC state.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-drm-i915-conversion-state-readout-v1-0-b7132f72644d@kernel.org?part=3
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 6/6] drm/i915: Carry the current state over created states
2026-11-24 10:59 ` [PATCH 6/6] drm/i915: Carry the current state over created states Maxime Ripard
@ 2026-11-24 11:40 ` sashiko-bot
2026-11-24 13:29 ` Ville Syrjälä
1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-24 11:40 UTC (permalink / raw)
To: Maxime Ripard; +Cc: intel-xe, intel-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/i915: intel_atomic_carry_over_state() skips enabled
DPMS-off CRTCs
- [High] drm/i915: uninitialized max_requested_bpc and scaling_mode on
created states
- [Medium] drm/i915: missing NV12 link carry-over in
intel_atomic_carry_over_state()
--
commit 1fe4500ef10219b7da036ae0e043737aa33211ff
Author: Maxime Ripard <mripard@kernel.org>
drm/i915: Carry the current state over created states
This commit adds intel_atomic_carry_over_state() to copy the current CRTC
hardware state and plane scaler assignment into newly created states during
DRM_MODE_ATOMIC_RESET commits.
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 1172e48daf235..d645203104a77 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -6519,6 +6519,116 @@ static int intel_atomic_check_config_and_link(struct intel_atomic_state *state)
>
> return ret;
> }
[ ... ]
> +static int intel_atomic_carry_over_state(struct intel_atomic_state *state)
> +{
> + struct intel_crtc_state *old_crtc_state, *new_crtc_state;
> + struct intel_plane_state *old_plane_state, *new_plane_state;
> + struct intel_crtc *crtc;
> + struct intel_plane *plane;
> + int i;
> +
> + for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
> + new_crtc_state) {
> + struct intel_crtc_state *carried_state;
> +
> + if (new_crtc_state->cpu_transcoder != INVALID_TRANSCODER ||
> + !old_crtc_state->hw.active)
> + continue;
[Severity: High]
Does checking !old_crtc_state->hw.active skip CRTCs that are enabled with
DPMS off (old_crtc_state->hw.enable == true, hw.active == false)?
In i915, pipe configuration, cpu_transcoder, DPLL reservations, DP tunnel
bandwidth, joiner pipes, and plane scalers are all allocated and tracked
whenever crtc_state->hw.enable is true, even while hw.active is false.
When a DRM_MODE_ATOMIC_RESET commit hits an enabled but inactive CRTC,
skipping the carry-over drops intel_dpll and icl_port_dplls without
releasing them (leaking the shared DPLL reservation in
dpll_state->pipe_mask and triggering a WARN in intel_dpll_crtc_get() on
later modesets), loses dp_tunnel_ref and joiner_pipes, and leaves
new_crtc_state->scaler_state empty while the plane loop below still copies
old_plane_state->scaler_id >= 0 into new_plane_state->scaler_id, allowing
intel_atomic_setup_scaler() to assign the same hardware scaler ID twice.
On G4X/VLV/CHV, intel_crtc_prepare_cleared_state() also preserves
crtc_state->wm even on disabled CRTCs.
[ ... ]
> + for_each_oldnew_intel_plane_in_state(state, plane, old_plane_state,
> + new_plane_state, i) {
> + if (new_plane_state->scaler_id < 0 &&
> + old_plane_state->scaler_id >= 0)
> + new_plane_state->scaler_id =
> + old_plane_state->scaler_id;
> + }
[Severity: Medium]
Should this plane loop also carry over old_plane_state->planar_linked_plane
and old_plane_state->is_y_plane?
On DISPLAY_VER >= 11, scanning out a planar YUV framebuffer links the
visible UV plane to an internal Y plane whose uapi.crtc is NULL, so the Y
plane is not in crtc->state->plane_mask. When a DRM_MODE_ATOMIC_RESET
commit does not initially include the internal Y plane (for example, from
a DRM lease covering only the primary/UV plane) or switches the UV plane
to a non-planar format, intel_joiner_affected_planes() and
unlink_nv12_plane() rely on new_plane_state->planar_linked_plane and
is_y_plane to pull in and unlink the Y plane:
drivers/gpu/drm/i915/display/intel_plane.c:unlink_nv12_plane() {
if (!plane_state->planar_linked_plane)
return;
plane_state->planar_linked_plane = NULL;
if (!plane_state->is_y_plane)
return;
...
crtc_state->enabled_planes &= ~BIT(plane->id);
crtc_state->active_planes &= ~BIT(plane->id);
}
Because created plane states have planar_linked_plane == NULL and
is_y_plane == false, BIT(y_plane->id) remains set in
new_crtc_state->enabled_planes and active_planes, leaving the Y plane
programmed in hardware or causing icl_check_nv12_planes() to run out of
free Y planes and fail with -EINVAL.
> +
> + return 0;
> +}
[Severity: High]
Does intel_atomic_carry_over_state() also need to restore connector state
defaults such as max_requested_bpc, max_bpc, and scaling_mode on created
connector states?
At init time, drm_connector_attach_max_bpc_property() initializes
state->max_requested_bpc and state->max_bpc to the connector maximum, and
intel_attach_scaling_mode_property() sets state->scaling_mode to
DRM_MODE_SCALE_ASPECT. During DRM_MODE_ATOMIC_RESET,
intel_digital_connector_create_state() zero-allocates the connector state
and calls __drm_atomic_helper_connector_state_init(), leaving
max_requested_bpc, max_bpc, and scaling_mode at 0 whenever userspace does
not explicitly set those properties in the reset commit.
As a result, drm_atomic_helper_check_modeset() and
intel_digital_connector_atomic_check() see max_requested_bpc and
scaling_mode change from their previous values and force a modeset on
active CRTCs instead of taking the nomodeset path, and the modeset then
hits MISSING_CASE(0) WARNs and returns -EINVAL in
compute_sink_pipe_bpp() -> bpc_to_bpp() and gmch_panel_fitting().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-drm-i915-conversion-state-readout-v1-0-b7132f72644d@kernel.org?part=6
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/6] drm/i915: Use the STATE_CHECK_* macros in the pipe config comparison
2026-11-24 11:23 ` Jani Nikula
@ 2026-11-24 13:18 ` Maxime Ripard
0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2026-11-24 13:18 UTC (permalink / raw)
To: Jani Nikula
Cc: Thomas Zimmermann, Maarten Lankhorst, Tvrtko Ursulin,
David Airlie, Simona Vetter, Joonas Lahtinen, Rodrigo Vivi,
intel-xe, intel-gfx, dri-devel, Syrjala, Ville
[-- Attachment #1: Type: text/plain, Size: 2662 bytes --]
Hi Jani,
On Tue, Nov 24, 2026 at 01:23:51PM +0200, Jani Nikula wrote:
> On Tue, 24 Nov 2026, Maxime Ripard <mripard@kernel.org> wrote:
> > The state readout framework provides the STATE_CHECK_* macros and
> > drm_atomic_helper_print_state_mismatch() to compare two state
> > instances field by field and report the mismatches through a drm
> > printer.
> >
> > intel_pipe_config_compare() implements the very same thing with its
> > own set of PIPE_CONF_CHECK_* macros printing through the
> > pipe_config_mismatch() helper, duplicating the framework.
> >
> > Rework the plain field checks on top of the STATE_CHECK_* macros,
> > sorting every PIPE_CONF_CHECK_I() and PIPE_CONF_CHECK_X() call site
> > onto the variant matching its field type: STATE_CHECK_BOOL(), _S32(),
> > _ENUM(), _U8(), _U16(), _U32(), _U64() and _PTR(), along with the
> > _U8_X(), _U16_X() and _U32_X() hexadecimal counterparts. The
> > static_assert() of each macro then checks the field type at compile
> > time, which the untyped PIPE_CONF_CHECK_I() and _X() macros couldn't
> > do, and PIPE_CONF_CHECK_LLI() becomes a STATE_CHECK_U64() based check
> > that also prints its u64 fields properly.
> >
> > The checks without a framework counterpart, namely the masked, flags,
> > M/N, DPLL, timings, rectangle, infoframe, DP SDP, ELD buffer, color
> > LUT and CSC ones, along with the infoframe, SDP, buffer and PLL
> > mismatch reporters, print their header through
> > drm_atomic_helper_print_state_mismatch() instead.
> > pipe_config_mismatch() isn't needed anymore and gets removed.
> >
> > The mismatch messages change format in the process, from
> >
> > [CRTC:31:pipe A] fastset requirement not met in hw.enable (expected yes, found no)
> >
> > to
> >
> > pipe A configuration mismatch in hw.enable (expected yes, got no)
>
> I think the "fastset requirement not met" vs. "mismatch" distinction has
> been a useful one. People tend to think a "mismatch" is always an error,
> regardless of the loglevel. We know, because we deliberately added the
> distinction about three years ago to unconfuse people...
>
> We've also put in a lot of effort to have a fairly uniform drm object
> logging prefix all over the place. It would be a shame to lose it,
> because over time you get used to searching the dmesg with that format.
So I guess your preference would be for the new framework code to follow
the same convention?
And it looks like the "fastset" path doesn't really translate to
anything (yet?) in the helpers, so maybe we could only convert the
pipe_config_mismatch() path for now?
How does that sound?
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 6/6] drm/i915: Carry the current state over created states
2026-11-24 10:59 ` [PATCH 6/6] drm/i915: Carry the current state over created states Maxime Ripard
2026-11-24 11:40 ` sashiko-bot
@ 2026-11-24 13:29 ` Ville Syrjälä
1 sibling, 0 replies; 14+ messages in thread
From: Ville Syrjälä @ 2026-11-24 13:29 UTC (permalink / raw)
To: Maxime Ripard
Cc: Jani Nikula, Thomas Zimmermann, Maarten Lankhorst, Tvrtko Ursulin,
David Airlie, Simona Vetter, Joonas Lahtinen, Rodrigo Vivi,
intel-xe, intel-gfx, dri-devel
On Tue, Nov 24, 2026 at 11:59:56AM +0100, Maxime Ripard wrote:
> The states of an atomic commit usually come from
> intel_crtc_duplicate_state(), which carries the whole current state
> over. The upcoming DRM_MODE_ATOMIC_RESET flag of the atomic ioctl
> builds its commits out of states created through atomic_create_state()
> instead: those come pristine, with only the uapi properties userspace
> applied on top of the defaults.
>
> A CRTC that stays enabled across such a commit, because userspace
> re-applies the same configuration, takes the nomodeset path of
> intel_atomic_check(): that path only updates the color management
> part of the hw state and relies on everything else having been carried
> over by the duplicate. Without the carry-over, the pipe mode, the
> transcoder, the DPLL, the scaler bookkeeping and all the other derived
> state would be zeroed on a CRTC the hardware keeps driving, and the
> scaler staging would fail to find a free scaler for the planes still
> using one.
I think you'll just want to force a full state recomputation for
a commit that resets everything.
>
> Carry the current state over the created ones like a duplicate would,
> keeping the uapi state userspace just configured. A created state is
> told apart from a duplicated one through its invalid transcoder: the
> state of an active CRTC always holds a valid one, a duplicate carries
> it over, and a created state comes reset.
>
> The planes get the same treatment for their scaler assignment: the
> scaler staging frees the scaler of a plane through the new state, and
> assigns it one when it still needs scaling, both of which need the
> assignment the current state holds. Carry the scaler id over when the
> current state has one and the new state doesn't.
>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
> drivers/gpu/drm/i915/display/intel_display.c | 114 +++++++++++++++++++++++++++
> 1 file changed, 114 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 1172e48daf23..d645203104a7 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -6517,10 +6517,120 @@ static int intel_atomic_check_config_and_link(struct intel_atomic_state *state)
> break;
> }
>
> return ret;
> }
> +/*
> + * intel_atomic_carry_over_state - carry the current state over created states
> + * @state: atomic state
> + *
> + * The states of a commit usually come from intel_crtc_duplicate_state(),
> + * which carries the whole current state over. The upcoming
> + * DRM_MODE_ATOMIC_RESET flag of the atomic ioctl builds its commits out
> + * of states created through atomic_create_state() instead: those come
> + * pristine, with only the uapi properties userspace applied on top of
> + * the defaults.
> + *
> + * A CRTC that stays enabled across such a commit, because userspace
> + * re-applies the same configuration, takes the nomodeset path of
> + * intel_atomic_check(): that path only updates the color management
> + * part of the hw state and relies on everything else having been
> + * carried over by the duplicate. Take the current state over like a
> + * duplicate would, keeping the uapi state userspace just configured:
> + * without it, the pipe mode, the transcoder, the DPLL, the scaler
> + * bookkeeping and all the other derived state would be zeroed on a
> + * CRTC the hardware keeps driving.
> + *
> + * A created state is told apart from a duplicated one through its
> + * invalid transcoder: the state of an active CRTC always holds a valid
> + * one, a duplicate carries it over, and a created state comes reset.
> + *
> + * The planes need the same for their scaler assignment: the scaler
> + * staging frees the scaler of a plane through the new state, and
> + * assigns it one when it still needs scaling, both of which need the
> + * assignment the current state holds. A created plane state comes with
> + * none, and with the scaler still marked in use in the carried CRTC
> + * state, it could neither be freed nor replaced.
> + */
> +static int intel_atomic_carry_over_state(struct intel_atomic_state *state)
> +{
> + struct intel_crtc_state *old_crtc_state, *new_crtc_state;
> + struct intel_plane_state *old_plane_state, *new_plane_state;
> + struct intel_crtc *crtc;
> + struct intel_plane *plane;
> + int i;
> +
> + for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
> + new_crtc_state) {
> + struct intel_crtc_state *carried_state;
> +
> + if (new_crtc_state->cpu_transcoder != INVALID_TRANSCODER ||
> + !old_crtc_state->hw.active)
> + continue;
> +
> + carried_state = kmemdup(old_crtc_state, sizeof(*carried_state),
> + GFP_KERNEL);
> + if (!carried_state)
> + return -ENOMEM;
> +
> + /* Keep the uapi state userspace just configured. */
> + carried_state->uapi = new_crtc_state->uapi;
> +
> + intel_crtc_free_hw_state(new_crtc_state);
> + if (new_crtc_state->dp_tunnel_ref.tunnel)
> + drm_dp_tunnel_ref_put(&new_crtc_state->dp_tunnel_ref);
> +
> + memcpy(new_crtc_state, carried_state, sizeof(*new_crtc_state));
> + kfree(carried_state);
> +
> + /* Take the references a duplicated state would carry. */
> + if (new_crtc_state->hw.degamma_lut)
> + drm_property_blob_get(new_crtc_state->hw.degamma_lut);
> + if (new_crtc_state->hw.ctm)
> + drm_property_blob_get(new_crtc_state->hw.ctm);
> + if (new_crtc_state->hw.gamma_lut)
> + drm_property_blob_get(new_crtc_state->hw.gamma_lut);
> +
> + if (new_crtc_state->pre_csc_lut)
> + drm_property_blob_get(new_crtc_state->pre_csc_lut);
> + if (new_crtc_state->post_csc_lut)
> + drm_property_blob_get(new_crtc_state->post_csc_lut);
> +
> + if (new_crtc_state->dp_tunnel_ref.tunnel)
> + drm_dp_tunnel_ref_get(new_crtc_state->dp_tunnel_ref.tunnel,
> + &new_crtc_state->dp_tunnel_ref);
> +
> + /* Clear the transient flags, like a duplicate would. */
> + new_crtc_state->update_pipe = false;
> + new_crtc_state->update_m_n = false;
> + new_crtc_state->update_lrr = false;
> + new_crtc_state->disable_cxsr = false;
> + new_crtc_state->update_wm_pre = false;
> + new_crtc_state->update_wm_post = false;
> + new_crtc_state->fifo_changed = false;
> + new_crtc_state->preload_luts = false;
> + new_crtc_state->wm.need_postvbl_update = false;
> + new_crtc_state->do_async_flip = false;
> + new_crtc_state->fb_bits = 0;
> + new_crtc_state->update_planes = 0;
> + new_crtc_state->dsb_color = NULL;
> + new_crtc_state->dsb_commit = NULL;
> + new_crtc_state->use_dsb = false;
> + new_crtc_state->use_flipq = false;
> + }
> +
> + for_each_oldnew_intel_plane_in_state(state, plane, old_plane_state,
> + new_plane_state, i) {
> + if (new_plane_state->scaler_id < 0 &&
> + old_plane_state->scaler_id >= 0)
> + new_plane_state->scaler_id =
> + old_plane_state->scaler_id;
> + }
> +
> + return 0;
> +}
> +
> /**
> * intel_atomic_check - validate state object
> * @dev: drm device
> * @_state: state to validate
> */
> @@ -6534,10 +6644,14 @@ int intel_atomic_check(struct drm_device *dev,
> int ret;
>
> if (!intel_display_driver_check_access(display))
> return -ENODEV;
>
> + ret = intel_atomic_carry_over_state(state);
> + if (ret)
> + goto fail;
> +
> for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state) {
> /*
> * crtc's state no longer considered to be inherited
> * after the first userspace/client initiated commit.
> */
>
> --
> 2.56.1
--
Ville Syrjälä
Intel
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-11-24 13:30 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 10:59 [PATCH 0/6] drm/i915: Support DRM_MODE_ATOMIC_RESET Maxime Ripard
2026-11-24 10:59 ` [PATCH 1/6] drm/atomic-state-helper: Provide more STATE_CHECK_* variants Maxime Ripard
2026-11-24 10:59 ` [PATCH 2/6] drm/i915: Use the STATE_CHECK_* macros in the pipe config comparison Maxime Ripard
2026-11-24 11:23 ` Jani Nikula
2026-11-24 13:18 ` Maxime Ripard
2026-11-24 10:59 ` [PATCH 3/6] drm/i915: Implement CRTC atomic_create_state Maxime Ripard
2026-11-24 11:26 ` sashiko-bot
2026-11-24 10:59 ` [PATCH 4/6] drm/i915: Implement plane atomic_create_state Maxime Ripard
2026-11-24 11:19 ` sashiko-bot
2026-11-24 10:59 ` [PATCH 5/6] drm/i915: Implement connector atomic_create_state Maxime Ripard
2026-11-24 11:21 ` sashiko-bot
2026-11-24 10:59 ` [PATCH 6/6] drm/i915: Carry the current state over created states Maxime Ripard
2026-11-24 11:40 ` sashiko-bot
2026-11-24 13:29 ` Ville Syrjälä
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox