[igt-dev] [PATCH i-g-t] tests/kms_chamelium: add a hotplug test with active connector

Imre Deak imre.deak at intel.com
Fri Aug 16 09:23:23 UTC 2019


On Wed, Aug 14, 2019 at 06:18:49PM +0300, Simon Ser wrote:
> This test enables a connector, unplugs it, re-plugs it, and makes sure the
> Chamelium board still receives a video signal.
> 
> Legacy userspace doesn't necessarily handle hotplug uevents. This test makes
> sure we don't break it.
> 
> See [1] and [2] for more context.
> 
> [1]: https://lists.freedesktop.org/archives/igt-dev/2019-July/015071.html
> [2]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
> 
> Signed-off-by: Simon Ser <simon.ser at intel.com>
> Cc: Daniel Vetter <daniel at ffwll.ch>
> Cc: Imre Deak <imre.deak at intel.com>
> ---
> 
> We should probably skip this test on DP-MST and USB-C?

As I understand the plan is to add this test and change the existing
ones to handle hotplug events properly, that is enable/disable the
output on connect/disconnect events.

This new test case should be skipped on USB-C at least, since it would
fail expectedly (I assume also on MST). For that we would need a way to
identify these connectors, I think that could be based on the platform
and port from debugfs/i915_display_info.

Btw, note that storm detection on USB-C connectors will also work only
if the output is disabled on the connector.

> 
>  tests/kms_chamelium.c | 84 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 84 insertions(+)
> 
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index f25d13c6e7c3..5cb9a3b9b363 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -862,6 +862,80 @@ static void test_mode_timings(data_t *data, struct chamelium_port *port)
>  	drmModeFreeConnector(connector);
>  }
> 
> +#define WAIT_VIDEO_INPUT_STABLE_TIMEOUT 5 /* seconds */
> +
> +/** test_hotplug_while_active:
> + *
> + * Plug a connector, enable it, unplug it, re-plug it and check we still have a
> + * stable input signal.
> + *
> + * Legacy userspace that doesn't consume hotplug events rely on this behaviour.
> + */
> +static void
> +test_hotplug_while_active(data_t *data, struct chamelium_port *port)
> +{
> +	struct udev_monitor *mon = igt_watch_hotplug();
> +	igt_output_t *output;
> +	drmModeConnector *connector;
> +	igt_plane_t *primary;
> +	struct igt_fb fb;
> +	drmModeModeInfo *mode;
> +	unsigned int fb_id;
> +	bool ok;
> +
> +	reset_state(data, port);
> +
> +	igt_flush_hotplugs(mon);
> +
> +	chamelium_plug(data->chamelium, port);
> +	igt_assert(igt_hotplug_detected(mon, HOTPLUG_TIMEOUT));
> +	igt_assert_eq(reprobe_connector(data, port), DRM_MODE_CONNECTED);
> +
> +	output = prepare_output(data, port, TEST_EDID_BASE);
> +	connector = chamelium_port_get_connector(data->chamelium, port, false);
> +	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
> +	igt_assert(primary);
> +
> +	igt_assert(connector->count_modes > 0);
> +	mode = &connector->modes[0];
> +
> +	fb_id = igt_create_color_pattern_fb(data->drm_fd,
> +					    mode->hdisplay, mode->vdisplay,
> +					    DRM_FORMAT_XRGB8888,
> +					    LOCAL_DRM_FORMAT_MOD_NONE,
> +					    0, 0, 0, &fb);
> +	igt_assert(fb_id > 0);
> +
> +	enable_output(data, port, output, mode, &fb);
> +
> +	ok = chamelium_port_wait_video_input_stable(data->chamelium, port,
> +						    WAIT_VIDEO_INPUT_STABLE_TIMEOUT);
> +	igt_assert_f(ok, "Failed to wait for video input to become stable "
> +		     "after hotplug\n");
> +
> +	igt_flush_hotplugs(mon);
> +
> +	/* Unplug and re-plug the connector without disabling the output. */
> +	chamelium_unplug(data->chamelium, port);
> +	igt_assert_f(igt_hotplug_detected(mon, HOTPLUG_TIMEOUT),
> +		     "Expected hotplug event after unplug\n");
> +	igt_assert_eq(reprobe_connector(data, port), DRM_MODE_DISCONNECTED);
> +
> +	igt_flush_hotplugs(mon);
> +
> +	chamelium_plug(data->chamelium, port);
> +	igt_assert_f(igt_hotplug_detected(mon, HOTPLUG_TIMEOUT),
> +		     "Expected hotplug event after unplug-replug sequence\n");
> +	igt_assert_eq(reprobe_connector(data, port), DRM_MODE_CONNECTED);
> +
> +	ok = chamelium_port_wait_video_input_stable(data->chamelium, port,
> +						    WAIT_VIDEO_INPUT_STABLE_TIMEOUT);
> +	igt_assert_f(ok, "Failed to wait for video input to become stable "
> +		     "after unplug and re-plug\n");
> +
> +	igt_cleanup_hotplug(mon);
> +}
> +
> 
>  /* Playback parameters control the audio signal we synthesize and send */
>  #define PLAYBACK_CHANNELS 2
> @@ -2267,6 +2341,9 @@ igt_main
>  			test_basic_hotplug(&data, port,
>  					   HPD_TOGGLE_COUNT_FAST);
> 
> +		connector_subtest("dp-hpd-active", DisplayPort)
> +			test_hotplug_while_active(&data, port);
> +
>  		connector_subtest("dp-edid-read", DisplayPort) {
>  			test_edid_read(&data, port, TEST_EDID_BASE);
>  			test_edid_read(&data, port, TEST_EDID_ALT);
> @@ -2345,6 +2422,9 @@ igt_main
>  			test_basic_hotplug(&data, port,
>  					   HPD_TOGGLE_COUNT_FAST);
> 
> +		connector_subtest("hdmi-hpd-active", HDMIA)
> +			test_hotplug_while_active(&data, port);
> +
>  		connector_subtest("hdmi-edid-read", HDMIA) {
>  			test_edid_read(&data, port, TEST_EDID_BASE);
>  			test_edid_read(&data, port, TEST_EDID_ALT);
> @@ -2501,6 +2581,10 @@ igt_main
>  		connector_subtest("vga-hpd-fast", VGA)
>  			test_basic_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST);
> 
> +		connector_subtest("vga-hpd-active", VGA)
> +			test_hotplug_while_active(&data, port);
> +
> +
>  		connector_subtest("vga-edid-read", VGA) {
>  			test_edid_read(&data, port, TEST_EDID_BASE);
>  			test_edid_read(&data, port, TEST_EDID_ALT);
> --
> 2.22.0
> 


More information about the igt-dev mailing list