On Sat, Jul 04, 2026 at 12:50:25PM +0200, Michał Grzelak wrote: > On Wed, 1 Jul 2026, Imre Deak wrote: > > Initialize a reusable test context for DP link KUnit tests. Sets up > > minimal device, connector, encoder, and DP structures, and seeds the > > pseudo-random generator for deterministic test runs. > > > > Signed-off-by: Imre Deak <[email protected]> > > --- > > .../i915/display/tests/intel_dp_link_test.c | 50 +++++++++++++++++++ > > 1 file changed, 50 insertions(+) > > > > diff --git a/drivers/gpu/drm/i915/display/tests/intel_dp_link_test.c > > b/drivers/gpu/drm/i915/display/tests/intel_dp_link_test.c > > index 62e1844605ac5..aa5358c94839f 100644 > > --- a/drivers/gpu/drm/i915/display/tests/intel_dp_link_test.c > > +++ b/drivers/gpu/drm/i915/display/tests/intel_dp_link_test.c > > @@ -5,7 +5,32 @@ > > > > #include <kunit/test.h> > > > > +#include <linux/compiler.h> > > +#include <linux/device.h> > > +#include <linux/prandom.h> > > +#include <linux/random.h> > > + > > +#include <drm/display/drm_dp_helper.h> > > + > > +#include <drm/intel/display_member.h> > > + > > +#include "intel_connector.h" > > +#include "intel_display_core.h" > > +#include "intel_display_types.h" > > + > > struct test_ctx { > > + struct { > > + struct intel_display display; > > + struct device device; > > + struct __intel_generic_device generic_device; > > + > > + struct intel_connector connector; > > + struct intel_digital_port dig_port; > > + > > + struct intel_crtc_state crtc_state; > > crtc_state is not used in this patch; if it is used implicitly in next > patch, I'm thinking about moving this hunk to it.
Nothing is used in this patch from the above context besides being initialized. I kept this as a separate patch since the same context is used by all the tests added later. > Whether it applies or not: > > Reviewed-by: Michał Grzelak <[email protected]> > > BR, > Michał > > > + } dev; > > + > > + struct rnd_state rnd; > > }; > > > > static struct kunit_case intel_dp_link_test_cases[] = { > > @@ -16,6 +41,29 @@ static struct test_ctx test_ctx; > > > > static int intel_dp_link_test_init(struct kunit *test) > > { > > + struct intel_digital_port *dig_port; > > + struct intel_encoder *encoder; > > + struct intel_dp *intel_dp; > > + > > + /* Reset the dev state for each test. */ > > + memset(&test_ctx.dev, 0, sizeof(test_ctx.dev)); > > + > > + test_ctx.dev.generic_device.drm.dev = &test_ctx.dev.device; > > + > > + test_ctx.dev.display.drm = &test_ctx.dev.generic_device.drm; > > + test_ctx.dev.generic_device.display = &test_ctx.dev.display; > > + > > + encoder = &test_ctx.dev.dig_port.base; > > + encoder->base.dev = &test_ctx.dev.generic_device.drm; > > + > > + dig_port = &test_ctx.dev.dig_port; > > + dig_port->base.type = INTEL_OUTPUT_DP; > > + > > + test_ctx.dev.connector.encoder = encoder; > > + > > + intel_dp = &dig_port->dp; > > + intel_dp->attached_connector = &test_ctx.dev.connector; > > + > > test->priv = &test_ctx; > > > > return 0; > > @@ -27,6 +75,8 @@ static void intel_dp_link_test_exit(struct kunit *test) > > > > static int intel_dp_link_test_suite_init(struct kunit_suite *test_suite) > > { > > + prandom_seed_state(&test_ctx.rnd, 0); > > + > > return 0; > > } > > > > -- > > 2.49.1 > > > >
