All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround
@ 2019-03-18 23:44 José Roberto de Souza
  2019-03-19  1:02 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/chamelium: Add test for hotplug workaround (rev2) Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: José Roberto de Souza @ 2019-03-18 23:44 UTC (permalink / raw)
  To: igt-dev

It is know that some unpowered type-c dongles can take some time to
boot and be responsible in the DDC/aux transaction lines so a
workaround was implemented in kernel(drm/i915: Enable hotplug retry)
to fix it but is possible that this could happen to other DP sinks.

So this test will try to simulate the sceneario described above, it
will disable the DDC lines and plug the connector, the hotplug should
fail and then enabling the DDC lines kernel should report the
connector as connected.

The workaround will reprobe connector after 1 second after kernel
gives up on the first try to probe the connector, so that is why a
smaller timeout to detect hotplug was needed.

v2:
- Removing igt_assert() from the igt_hotplug_detected() when checking
if device can act on hotplug fast enough
- Checking time spend between hotplug and the enabling of DDC lines
(Imre)

Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 tests/kms_chamelium.c | 110 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)

diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index c2090037..c79516ef 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -45,6 +45,8 @@ typedef struct {
 
 #define HOTPLUG_TIMEOUT 20 /* seconds */
 
+#define FAST_HOTPLUG_TIMEOUT (1) /* second */
+
 #define HPD_STORM_PULSE_INTERVAL_DP 100 /* ms */
 #define HPD_STORM_PULSE_INTERVAL_HDMI 200 /* ms */
 
@@ -107,6 +109,21 @@ reprobe_connector(data_t *data, struct chamelium_port *port)
 	return status;
 }
 
+static drmModeConnection
+connector_status_get(data_t *data, struct chamelium_port *port)
+{
+	drmModeConnector *connector;
+	drmModeConnection status;
+
+	igt_debug("Getting connector state %s...\n", chamelium_port_get_name(port));
+	connector = chamelium_port_get_connector(data->chamelium, port, false);
+	igt_assert(connector);
+	status = connector->connection;
+
+	drmModeFreeConnector(connector);
+	return status;
+}
+
 static void
 wait_for_connector(data_t *data, struct chamelium_port *port,
 		   drmModeConnection status)
@@ -253,6 +270,96 @@ test_basic_hotplug(data_t *data, struct chamelium_port *port, int toggle_count)
 	igt_hpd_storm_reset(data->drm_fd);
 }
 
+static void
+test_fast_hotplug_handling(data_t *data, struct chamelium_port *port,
+			   struct udev_monitor *mon)
+{
+	drmModeConnection status;
+
+	igt_flush_hotplugs(mon);
+	chamelium_plug(data->chamelium, port);
+	igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
+	status = connector_status_get(data, port);
+	igt_require(status == DRM_MODE_CONNECTED);
+
+	igt_flush_hotplugs(mon);
+	chamelium_unplug(data->chamelium, port);
+	igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
+	status = connector_status_get(data, port);
+	igt_require(status == DRM_MODE_DISCONNECTED);
+}
+
+/*
+ * Test kernel workaround for sinks that takes some time to have the DDC/aux
+ * channel responsive after the hotplug
+ */
+static void
+test_late_aux_wa(data_t *data, struct chamelium_port *port)
+{
+	struct udev_monitor *mon = igt_watch_hotplug();
+	drmModeConnection status;
+	struct timespec begin;
+	uint64_t delta_nsec;
+	uint8_t retries = 0;
+
+	/* Reset will unplug all connectors */
+	reset_state(data, NULL);
+
+	/* Check if it device can act on hotplugs fast enough for this test */
+	test_fast_hotplug_handling(data, port, mon);
+
+retry:
+	/* It is fast enough, lets disable the DDC lines and plug again */
+	igt_flush_hotplugs(mon);
+	chamelium_port_set_ddc_state(data->chamelium, port, false);
+	chamelium_plug(data->chamelium, port);
+	igt_gettime(&begin);
+	igt_assert(!chamelium_port_get_ddc_state(data->chamelium, port));
+
+	/*
+	 * Give some time to kernel try to process hotplug but it should fail
+	 */
+	igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
+	status = connector_status_get(data, port);
+	igt_assert(status == DRM_MODE_DISCONNECTED);
+
+	/*
+	 * Enable the DDC line and the kernel workaround should reprobe and
+	 * report as connected
+	 */
+	chamelium_port_set_ddc_state(data->chamelium, port, true);
+
+	/*
+	 * i915 uses the maximum timeout that each platform support to do aux
+	 * transactions, this timeout can vary from 1.6msec to 4msec and i915
+	 * driver tries the same aux transaction up to 5 times before return a
+	 * error and additionally drm helpers will ask driver to do the same aux
+	 * transaction up to 32 times, so it will take at least 256msec~640msec
+	 * to kernel give up on a sink detection.
+	 *
+	 * The workaround will be schedule to run 1 second after the driver
+	 * failed to probe the connector that signaled a hotplug, so if this
+	 * test is preempt it could fail because the workaround is already
+	 * running with the DDC lines still off, so lets try again until the
+	 * time requirement is meet.
+	 */
+	delta_nsec = igt_nsec_elapsed(&begin);
+	if (delta_nsec > (NSEC_PER_SEC * 1.3f)) {
+		igt_assert_f(retries != 5, "Test preempted too many times");
+		retries++;
+
+		/* Wait for 1 more sec to make sure the workaround finished */
+		chamelium_unplug(data->chamelium, port);
+		igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
+		goto retry;
+	}
+
+	igt_assert(chamelium_port_get_ddc_state(data->chamelium, port));
+	igt_assert(igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT));
+	status = connector_status_get(data, port);
+	igt_assert(status == DRM_MODE_CONNECTED);
+}
+
 static void
 test_edid_read(data_t *data, struct chamelium_port *port,
 	       int edid_id, const unsigned char *edid)
@@ -1308,6 +1415,9 @@ igt_main
 
 		connector_subtest("dp-frame-dump", DisplayPort)
 			test_display_frame_dump(&data, port);
+
+		connector_subtest("dp-late-aux-wa", DisplayPort)
+			test_late_aux_wa(&data, port);
 	}
 
 	igt_subtest_group {
-- 
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for tests/chamelium: Add test for hotplug workaround (rev2)
  2019-03-18 23:44 [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround José Roberto de Souza
@ 2019-03-19  1:02 ` Patchwork
  2019-03-19 14:12 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  2019-03-22 22:32 ` [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround Imre Deak
  2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2019-03-19  1:02 UTC (permalink / raw)
  To: José Roberto de Souza; +Cc: igt-dev

== Series Details ==

Series: tests/chamelium: Add test for hotplug workaround (rev2)
URL   : https://patchwork.freedesktop.org/series/57913/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5770 -> IGTPW_2657
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/57913/revisions/2/mbox/

Known issues
------------

  Here are the changes found in IGTPW_2657 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@amdgpu/amd_basic@query-info:
    - fi-bsw-kefka:       NOTRUN -> SKIP [fdo#109271] +55

  * igt@kms_busy@basic-flip-c:
    - fi-bsw-kefka:       NOTRUN -> SKIP [fdo#109271] / [fdo#109278]

  
#### Possible fixes ####

  * igt@kms_busy@basic-flip-a:
    - fi-gdg-551:         FAIL [fdo#103182] -> PASS

  * igt@kms_frontbuffer_tracking@basic:
    - fi-icl-u3:          FAIL [fdo#103167] -> PASS

  * igt@kms_pipe_crc_basic@read-crc-pipe-a-frame-sequence:
    - fi-byt-clapper:     FAIL [fdo#103191] / [fdo#107362] -> PASS

  * igt@prime_vgem@basic-fence-flip:
    - fi-gdg-551:         DMESG-FAIL [fdo#103182] -> PASS

  
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
  [fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
  [fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278


Participating hosts (44 -> 40)
------------------------------

  Additional (1): fi-bsw-kefka 
  Missing    (5): fi-kbl-soraka fi-hsw-4200u fi-bsw-cyan fi-pnv-d510 fi-bdw-samus 


Build changes
-------------

    * IGT: IGT_4888 -> IGTPW_2657

  CI_DRM_5770: 7f60fa0ec6f20661a49a3eeed6e4b0a175783cf6 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2657: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2657/
  IGT_4888: 71ad19eb8fe4f0eecae3bf063e107293b90b9abc @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@kms_chamelium@dp-late-aux-wa

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2657/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for tests/chamelium: Add test for hotplug workaround (rev2)
  2019-03-18 23:44 [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround José Roberto de Souza
  2019-03-19  1:02 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/chamelium: Add test for hotplug workaround (rev2) Patchwork
@ 2019-03-19 14:12 ` Patchwork
  2019-03-22 22:32 ` [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround Imre Deak
  2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2019-03-19 14:12 UTC (permalink / raw)
  To: José Roberto de Souza; +Cc: igt-dev

== Series Details ==

Series: tests/chamelium: Add test for hotplug workaround (rev2)
URL   : https://patchwork.freedesktop.org/series/57913/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5770_full -> IGTPW_2657_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/57913/revisions/2/mbox/

New tests
---------

  New tests have been introduced between CI_DRM_5770_full and IGTPW_2657_full:

### New IGT tests (1) ###

  * igt@kms_chamelium@dp-late-aux-wa:
    - Statuses : 5 skip(s)
    - Exec time: [0.0] s

  

Known issues
------------

  Here are the changes found in IGTPW_2657_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@kms_atomic_transition@4x-modeset-transitions-nonblocking-fencing:
    - shard-glk:          NOTRUN -> SKIP [fdo#109271] / [fdo#109278]

  * igt@kms_busy@extended-modeset-hang-newfb-render-f:
    - shard-kbl:          NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +1

  * igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
    - shard-snb:          PASS -> DMESG-WARN [fdo#107956]

  * igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-c:
    - shard-hsw:          PASS -> DMESG-WARN [fdo#107956] +1

  * igt@kms_busy@extended-pageflip-hang-newfb-render-b:
    - shard-glk:          PASS -> DMESG-WARN [fdo#107956]

  * {igt@kms_chamelium@dp-late-aux-wa} (NEW):
    - shard-hsw:          NOTRUN -> SKIP [fdo#109271]
    - shard-snb:          NOTRUN -> SKIP [fdo#109271]

  * igt@kms_color@pipe-b-ctm-max:
    - shard-apl:          PASS -> FAIL [fdo#108147] +1

  * igt@kms_color@pipe-b-degamma:
    - shard-apl:          PASS -> FAIL [fdo#104782]

  * igt@kms_color@pipe-c-ctm-max:
    - shard-kbl:          PASS -> FAIL [fdo#108147]

  * igt@kms_cursor_crc@cursor-128x42-sliding:
    - shard-apl:          PASS -> FAIL [fdo#103232] +3

  * igt@kms_cursor_crc@cursor-256x85-sliding:
    - shard-kbl:          PASS -> FAIL [fdo#103232] +1

  * igt@kms_cursor_legacy@pipe-c-forked-bo:
    - shard-apl:          PASS -> INCOMPLETE [fdo#103927]

  * igt@kms_flip@flip-vs-expired-vblank-interruptible:
    - shard-glk:          PASS -> FAIL [fdo#105363]

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-render:
    - shard-apl:          PASS -> FAIL [fdo#103167] +2
    - shard-kbl:          PASS -> FAIL [fdo#103167]

  * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-blt:
    - shard-glk:          PASS -> FAIL [fdo#103167] +6

  * igt@kms_pipe_b_c_ivb@enable-pipe-c-while-b-has-3-lanes:
    - shard-kbl:          NOTRUN -> SKIP [fdo#109271] +25

  * igt@kms_psr@sprite_plane_onoff:
    - shard-glk:          NOTRUN -> SKIP [fdo#109271] +12

  * igt@kms_rotation_crc@multiplane-rotation-cropping-top:
    - shard-kbl:          PASS -> FAIL [fdo#109016]

  * igt@kms_setmode@basic:
    - shard-hsw:          PASS -> FAIL [fdo#99912]

  * igt@kms_vblank@pipe-c-ts-continuation-dpms-suspend:
    - shard-apl:          PASS -> FAIL [fdo#104894] +1
    - shard-kbl:          PASS -> FAIL [fdo#104894] +1

  * igt@prime_nv_api@i915_nv_reimport_twice_check_flink_name:
    - shard-apl:          NOTRUN -> SKIP [fdo#109271] +7

  * igt@tools_test@tools_test:
    - shard-kbl:          PASS -> SKIP [fdo#109271]

  
#### Possible fixes ####

  * igt@kms_busy@extended-modeset-hang-newfb-render-a:
    - shard-hsw:          DMESG-WARN [fdo#107956] -> PASS +1
    - shard-snb:          DMESG-WARN [fdo#107956] -> PASS

  * igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
    - shard-kbl:          DMESG-WARN [fdo#107956] -> PASS +1

  * igt@kms_cursor_crc@cursor-64x64-suspend:
    - shard-apl:          FAIL [fdo#103191] / [fdo#103232] -> PASS
    - shard-kbl:          FAIL [fdo#103191] / [fdo#103232] -> PASS

  * igt@kms_cursor_crc@cursor-size-change:
    - shard-apl:          FAIL [fdo#103232] -> PASS +1

  * igt@kms_draw_crc@draw-method-xrgb8888-render-untiled:
    - shard-snb:          SKIP [fdo#109271] -> PASS +1

  * igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
    - shard-glk:          FAIL [fdo#105363] -> PASS +1

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-cpu:
    - shard-kbl:          FAIL [fdo#103167] -> PASS

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt:
    - shard-apl:          FAIL [fdo#103167] -> PASS +1

  * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-mmap-cpu:
    - shard-glk:          FAIL [fdo#103167] -> PASS +5

  * {igt@kms_plane@pixel-format-pipe-a-planes-source-clamping}:
    - shard-apl:          FAIL [fdo#110033] -> PASS
    - shard-kbl:          FAIL [fdo#110127] -> PASS

  * {igt@kms_plane@pixel-format-pipe-c-planes}:
    - shard-glk:          SKIP [fdo#109271] -> PASS +1

  * {igt@kms_plane_multiple@atomic-pipe-b-tiling-none}:
    - shard-glk:          FAIL [fdo#110037] -> PASS +1

  * {igt@kms_plane_multiple@atomic-pipe-c-tiling-yf}:
    - shard-apl:          FAIL [fdo#110037] -> PASS +2

  * igt@kms_plane_scaling@pipe-a-scaler-with-clipping-clamping:
    - shard-glk:          SKIP [fdo#109271] / [fdo#109278] -> PASS +1

  * igt@kms_vblank@pipe-c-ts-continuation-modeset:
    - shard-kbl:          FAIL [fdo#104894] -> PASS
    - shard-apl:          FAIL [fdo#104894] -> PASS

  
#### Warnings ####

  * igt@kms_plane_scaling@pipe-a-scaler-with-rotation:
    - shard-glk:          FAIL [fdo#110098] -> SKIP [fdo#109271] / [fdo#109278]

  * igt@kms_plane_scaling@pipe-b-scaler-with-rotation:
    - shard-glk:          SKIP [fdo#109271] / [fdo#109278] -> FAIL [fdo#110098] +2

  * igt@runner@aborted:
    - shard-glk:          FAIL [fdo#109373] / [k.org#202321] -> ( 2 FAIL ) [fdo#109373] / [k.org#202321]

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
  [fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#104782]: https://bugs.freedesktop.org/show_bug.cgi?id=104782
  [fdo#104894]: https://bugs.freedesktop.org/show_bug.cgi?id=104894
  [fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
  [fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
  [fdo#108147]: https://bugs.freedesktop.org/show_bug.cgi?id=108147
  [fdo#109016]: https://bugs.freedesktop.org/show_bug.cgi?id=109016
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
  [fdo#109373]: https://bugs.freedesktop.org/show_bug.cgi?id=109373
  [fdo#110033]: https://bugs.freedesktop.org/show_bug.cgi?id=110033
  [fdo#110037]: https://bugs.freedesktop.org/show_bug.cgi?id=110037
  [fdo#110038]: https://bugs.freedesktop.org/show_bug.cgi?id=110038
  [fdo#110098]: https://bugs.freedesktop.org/show_bug.cgi?id=110098
  [fdo#110127]: https://bugs.freedesktop.org/show_bug.cgi?id=110127
  [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
  [k.org#202321]: https://bugzilla.kernel.org/show_bug.cgi?id=202321


Participating hosts (10 -> 5)
------------------------------

  Missing    (5): shard-skl pig-hsw-4770r pig-glk-j5005 shard-iclb pig-skl-6260u 


Build changes
-------------

    * IGT: IGT_4888 -> IGTPW_2657
    * Piglit: piglit_4509 -> None

  CI_DRM_5770: 7f60fa0ec6f20661a49a3eeed6e4b0a175783cf6 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2657: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2657/
  IGT_4888: 71ad19eb8fe4f0eecae3bf063e107293b90b9abc @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2657/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround
  2019-03-18 23:44 [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround José Roberto de Souza
  2019-03-19  1:02 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/chamelium: Add test for hotplug workaround (rev2) Patchwork
  2019-03-19 14:12 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
@ 2019-03-22 22:32 ` Imre Deak
  2019-03-22 23:23   ` Souza, Jose
  2 siblings, 1 reply; 5+ messages in thread
From: Imre Deak @ 2019-03-22 22:32 UTC (permalink / raw)
  To: José Roberto de Souza; +Cc: igt-dev

On Mon, Mar 18, 2019 at 04:44:24PM -0700, José Roberto de Souza wrote:
> It is know that some unpowered type-c dongles can take some time to
> boot and be responsible in the DDC/aux transaction lines so a
> workaround was implemented in kernel(drm/i915: Enable hotplug retry)
> to fix it but is possible that this could happen to other DP sinks.
> 
> So this test will try to simulate the sceneario described above, it
> will disable the DDC lines and plug the connector, the hotplug should
> fail and then enabling the DDC lines kernel should report the
> connector as connected.
> 
> The workaround will reprobe connector after 1 second after kernel
> gives up on the first try to probe the connector, so that is why a
> smaller timeout to detect hotplug was needed.
> 
> v2:
> - Removing igt_assert() from the igt_hotplug_detected() when checking
> if device can act on hotplug fast enough
> - Checking time spend between hotplug and the enabling of DDC lines
> (Imre)
> 
> Cc: Imre Deak <imre.deak@intel.com>
> Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> ---
>  tests/kms_chamelium.c | 110 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 110 insertions(+)
> 
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index c2090037..c79516ef 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -45,6 +45,8 @@ typedef struct {
>  
>  #define HOTPLUG_TIMEOUT 20 /* seconds */
>  
> +#define FAST_HOTPLUG_TIMEOUT (1) /* second */
> +
>  #define HPD_STORM_PULSE_INTERVAL_DP 100 /* ms */
>  #define HPD_STORM_PULSE_INTERVAL_HDMI 200 /* ms */
>  
> @@ -107,6 +109,21 @@ reprobe_connector(data_t *data, struct chamelium_port *port)
>  	return status;
>  }
>  
> +static drmModeConnection
> +connector_status_get(data_t *data, struct chamelium_port *port)
> +{
> +	drmModeConnector *connector;
> +	drmModeConnection status;
> +
> +	igt_debug("Getting connector state %s...\n", chamelium_port_get_name(port));
> +	connector = chamelium_port_get_connector(data->chamelium, port, false);
> +	igt_assert(connector);
> +	status = connector->connection;
> +
> +	drmModeFreeConnector(connector);
> +	return status;
> +}
> +
>  static void
>  wait_for_connector(data_t *data, struct chamelium_port *port,
>  		   drmModeConnection status)
> @@ -253,6 +270,96 @@ test_basic_hotplug(data_t *data, struct chamelium_port *port, int toggle_count)
>  	igt_hpd_storm_reset(data->drm_fd);
>  }
>  
> +static void
> +test_fast_hotplug_handling(data_t *data, struct chamelium_port *port,
> +			   struct udev_monitor *mon)
> +{
> +	drmModeConnection status;
> +
> +	igt_flush_hotplugs(mon);
> +	chamelium_plug(data->chamelium, port);
> +	igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
> +	status = connector_status_get(data, port);
> +	igt_require(status == DRM_MODE_CONNECTED);
> +
> +	igt_flush_hotplugs(mon);
> +	chamelium_unplug(data->chamelium, port);
> +	igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
> +	status = connector_status_get(data, port);
> +	igt_require(status == DRM_MODE_DISCONNECTED);
> +}
> +
> +/*
> + * Test kernel workaround for sinks that takes some time to have the DDC/aux
> + * channel responsive after the hotplug
> + */
> +static void
> +test_late_aux_wa(data_t *data, struct chamelium_port *port)
> +{
> +	struct udev_monitor *mon = igt_watch_hotplug();
> +	drmModeConnection status;
> +	struct timespec begin;
> +	uint64_t delta_nsec;
> +	uint8_t retries = 0;
> +
> +	/* Reset will unplug all connectors */
> +	reset_state(data, NULL);
> +
> +	/* Check if it device can act on hotplugs fast enough for this test */
> +	test_fast_hotplug_handling(data, port, mon);
> +
> +retry:
> +	/* It is fast enough, lets disable the DDC lines and plug again */
> +	igt_flush_hotplugs(mon);
> +	chamelium_port_set_ddc_state(data->chamelium, port, false);
> +	chamelium_plug(data->chamelium, port);
> +	igt_gettime(&begin);

Should start measuring already before chamelium_plug(), otherwise we
could miss time that elapsed since the beginning of HPD
interrupt->hotplug processing in the kernel.

> +	igt_assert(!chamelium_port_get_ddc_state(data->chamelium, port));
> +
> +	/*
> +	 * Give some time to kernel try to process hotplug but it should fail
> +	 */
> +	igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
> +	status = connector_status_get(data, port);
> +	igt_assert(status == DRM_MODE_DISCONNECTED);
> +
> +	/*
> +	 * Enable the DDC line and the kernel workaround should reprobe and
> +	 * report as connected
> +	 */
> +	chamelium_port_set_ddc_state(data->chamelium, port, true);
> +
> +	/*
> +	 * i915 uses the maximum timeout that each platform support to do aux
> +	 * transactions, this timeout can vary from 1.6msec to 4msec and i915
> +	 * driver tries the same aux transaction up to 5 times before return a
> +	 * error and additionally drm helpers will ask driver to do the same aux
> +	 * transaction up to 32 times, so it will take at least 256msec~640msec
> +	 * to kernel give up on a sink detection.
> +	 *
> +	 * The workaround will be schedule to run 1 second after the driver
> +	 * failed to probe the connector that signaled a hotplug, so if this
> +	 * test is preempt it could fail because the workaround is already
> +	 * running with the DDC lines still off, so lets try again until the
> +	 * time requirement is meet.
> +	 */
> +	delta_nsec = igt_nsec_elapsed(&begin);
> +	if (delta_nsec > (NSEC_PER_SEC * 1.3f)) {

1.3 sec is too late for the 256msec+1sec scenario.. Should be 1.2.

I guess you're still working on the HDMI test? Please also add it to the
meson and automake sources. I guess we can merge it before the kernel patches
letting it fail until that.

> +		igt_assert_f(retries != 5, "Test preempted too many times");
> +		retries++;
> +
> +		/* Wait for 1 more sec to make sure the workaround finished */
> +		chamelium_unplug(data->chamelium, port);
> +		igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
> +		goto retry;
> +	}
> +
> +	igt_assert(chamelium_port_get_ddc_state(data->chamelium, port));
> +	igt_assert(igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT));
> +	status = connector_status_get(data, port);
> +	igt_assert(status == DRM_MODE_CONNECTED);
> +}
> +
>  static void
>  test_edid_read(data_t *data, struct chamelium_port *port,
>  	       int edid_id, const unsigned char *edid)
> @@ -1308,6 +1415,9 @@ igt_main
>  
>  		connector_subtest("dp-frame-dump", DisplayPort)
>  			test_display_frame_dump(&data, port);
> +
> +		connector_subtest("dp-late-aux-wa", DisplayPort)
> +			test_late_aux_wa(&data, port);
>  	}
>  
>  	igt_subtest_group {
> -- 
> 2.21.0
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround
  2019-03-22 22:32 ` [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround Imre Deak
@ 2019-03-22 23:23   ` Souza, Jose
  0 siblings, 0 replies; 5+ messages in thread
From: Souza, Jose @ 2019-03-22 23:23 UTC (permalink / raw)
  To: Deak, Imre; +Cc: igt-dev


[-- Attachment #1.1: Type: text/plain, Size: 7800 bytes --]

On Sat, 2019-03-23 at 00:32 +0200, Imre Deak wrote:
> On Mon, Mar 18, 2019 at 04:44:24PM -0700, José Roberto de Souza
> wrote:
> > It is know that some unpowered type-c dongles can take some time to
> > boot and be responsible in the DDC/aux transaction lines so a
> > workaround was implemented in kernel(drm/i915: Enable hotplug
> > retry)
> > to fix it but is possible that this could happen to other DP sinks.
> > 
> > So this test will try to simulate the sceneario described above, it
> > will disable the DDC lines and plug the connector, the hotplug
> > should
> > fail and then enabling the DDC lines kernel should report the
> > connector as connected.
> > 
> > The workaround will reprobe connector after 1 second after kernel
> > gives up on the first try to probe the connector, so that is why a
> > smaller timeout to detect hotplug was needed.
> > 
> > v2:
> > - Removing igt_assert() from the igt_hotplug_detected() when
> > checking
> > if device can act on hotplug fast enough
> > - Checking time spend between hotplug and the enabling of DDC lines
> > (Imre)
> > 
> > Cc: Imre Deak <imre.deak@intel.com>
> > Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> > ---
> >  tests/kms_chamelium.c | 110
> > ++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 110 insertions(+)
> > 
> > diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> > index c2090037..c79516ef 100644
> > --- a/tests/kms_chamelium.c
> > +++ b/tests/kms_chamelium.c
> > @@ -45,6 +45,8 @@ typedef struct {
> >  
> >  #define HOTPLUG_TIMEOUT 20 /* seconds */
> >  
> > +#define FAST_HOTPLUG_TIMEOUT (1) /* second */
> > +
> >  #define HPD_STORM_PULSE_INTERVAL_DP 100 /* ms */
> >  #define HPD_STORM_PULSE_INTERVAL_HDMI 200 /* ms */
> >  
> > @@ -107,6 +109,21 @@ reprobe_connector(data_t *data, struct
> > chamelium_port *port)
> >  	return status;
> >  }
> >  
> > +static drmModeConnection
> > +connector_status_get(data_t *data, struct chamelium_port *port)
> > +{
> > +	drmModeConnector *connector;
> > +	drmModeConnection status;
> > +
> > +	igt_debug("Getting connector state %s...\n",
> > chamelium_port_get_name(port));
> > +	connector = chamelium_port_get_connector(data->chamelium, port,
> > false);
> > +	igt_assert(connector);
> > +	status = connector->connection;
> > +
> > +	drmModeFreeConnector(connector);
> > +	return status;
> > +}
> > +
> >  static void
> >  wait_for_connector(data_t *data, struct chamelium_port *port,
> >  		   drmModeConnection status)
> > @@ -253,6 +270,96 @@ test_basic_hotplug(data_t *data, struct
> > chamelium_port *port, int toggle_count)
> >  	igt_hpd_storm_reset(data->drm_fd);
> >  }
> >  
> > +static void
> > +test_fast_hotplug_handling(data_t *data, struct chamelium_port
> > *port,
> > +			   struct udev_monitor *mon)
> > +{
> > +	drmModeConnection status;
> > +
> > +	igt_flush_hotplugs(mon);
> > +	chamelium_plug(data->chamelium, port);
> > +	igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
> > +	status = connector_status_get(data, port);
> > +	igt_require(status == DRM_MODE_CONNECTED);
> > +
> > +	igt_flush_hotplugs(mon);
> > +	chamelium_unplug(data->chamelium, port);
> > +	igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
> > +	status = connector_status_get(data, port);
> > +	igt_require(status == DRM_MODE_DISCONNECTED);
> > +}
> > +
> > +/*
> > + * Test kernel workaround for sinks that takes some time to have
> > the DDC/aux
> > + * channel responsive after the hotplug
> > + */
> > +static void
> > +test_late_aux_wa(data_t *data, struct chamelium_port *port)
> > +{
> > +	struct udev_monitor *mon = igt_watch_hotplug();
> > +	drmModeConnection status;
> > +	struct timespec begin;
> > +	uint64_t delta_nsec;
> > +	uint8_t retries = 0;
> > +
> > +	/* Reset will unplug all connectors */
> > +	reset_state(data, NULL);
> > +
> > +	/* Check if it device can act on hotplugs fast enough for this
> > test */
> > +	test_fast_hotplug_handling(data, port, mon);
> > +
> > +retry:
> > +	/* It is fast enough, lets disable the DDC lines and plug again
> > */
> > +	igt_flush_hotplugs(mon);
> > +	chamelium_port_set_ddc_state(data->chamelium, port, false);
> > +	chamelium_plug(data->chamelium, port);
> > +	igt_gettime(&begin);
> 
> Should start measuring already before chamelium_plug(), otherwise we
> could miss time that elapsed since the beginning of HPD
> interrupt->hotplug processing in the kernel.

Okay

> 
> > +	igt_assert(!chamelium_port_get_ddc_state(data->chamelium,
> > port));
> > +
> > +	/*
> > +	 * Give some time to kernel try to process hotplug but it
> > should fail
> > +	 */
> > +	igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
> > +	status = connector_status_get(data, port);
> > +	igt_assert(status == DRM_MODE_DISCONNECTED);
> > +
> > +	/*
> > +	 * Enable the DDC line and the kernel workaround should reprobe
> > and
> > +	 * report as connected
> > +	 */
> > +	chamelium_port_set_ddc_state(data->chamelium, port, true);
> > +
> > +	/*
> > +	 * i915 uses the maximum timeout that each platform support to
> > do aux
> > +	 * transactions, this timeout can vary from 1.6msec to 4msec
> > and i915
> > +	 * driver tries the same aux transaction up to 5 times before
> > return a
> > +	 * error and additionally drm helpers will ask driver to do the
> > same aux
> > +	 * transaction up to 32 times, so it will take at least
> > 256msec~640msec
> > +	 * to kernel give up on a sink detection.
> > +	 *
> > +	 * The workaround will be schedule to run 1 second after the
> > driver
> > +	 * failed to probe the connector that signaled a hotplug, so if
> > this
> > +	 * test is preempt it could fail because the workaround is
> > already
> > +	 * running with the DDC lines still off, so lets try again
> > until the
> > +	 * time requirement is meet.
> > +	 */
> > +	delta_nsec = igt_nsec_elapsed(&begin);
> > +	if (delta_nsec > (NSEC_PER_SEC * 1.3f)) {
> 
> 1.3 sec is too late for the 256msec+1sec scenario.. Should be 1.2.

Okay

> 
> I guess you're still working on the HDMI test? Please also add it to
> the
> meson and automake sources. I guess we can merge it before the kernel
> patches
> letting it fail until that.

The HDMI test is ready but it requires a change in chameleon side, got
the changed merged upstream[1] this week but it will take some time to
chromiumos to release a over-the-air chameleond update, it is okay send
the test but it will skip while the new method is not
available(checking the return of the chameleond server)?

[1] 
https://chromium.googlesource.com/chromiumos/platform/chameleon/+/231016d02369d33ba1c3b3322e4bc88d881bf520

> 
> > +		igt_assert_f(retries != 5, "Test preempted too many
> > times");
> > +		retries++;
> > +
> > +		/* Wait for 1 more sec to make sure the workaround
> > finished */
> > +		chamelium_unplug(data->chamelium, port);
> > +		igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
> > +		goto retry;
> > +	}
> > +
> > +	igt_assert(chamelium_port_get_ddc_state(data->chamelium,
> > port));
> > +	igt_assert(igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT));
> > +	status = connector_status_get(data, port);
> > +	igt_assert(status == DRM_MODE_CONNECTED);
> > +}
> > +
> >  static void
> >  test_edid_read(data_t *data, struct chamelium_port *port,
> >  	       int edid_id, const unsigned char *edid)
> > @@ -1308,6 +1415,9 @@ igt_main
> >  
> >  		connector_subtest("dp-frame-dump", DisplayPort)
> >  			test_display_frame_dump(&data, port);
> > +
> > +		connector_subtest("dp-late-aux-wa", DisplayPort)
> > +			test_late_aux_wa(&data, port);
> >  	}
> >  
> >  	igt_subtest_group {
> > -- 
> > 2.21.0
> > 

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-22 23:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 23:44 [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround José Roberto de Souza
2019-03-19  1:02 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/chamelium: Add test for hotplug workaround (rev2) Patchwork
2019-03-19 14:12 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-03-22 22:32 ` [igt-dev] [PATCH v2 i-g-t] tests/chamelium: Add test for hotplug workaround Imre Deak
2019-03-22 23:23   ` Souza, Jose

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.