Skip to contentSkip to conversation

lib/debugfs: Use a blocking read in igt_pipe_crc_get_single()

PATCH In review Ville Syrjala 3 participants 5 messages Sep 25, 2018 – Sep 27, 2018 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/debugfs: Use a blocking read in igt_pipe_crc_get_single()

From: Ville Syrjälä <[email protected]>

All users of igt_pipe_crc_get_single() want a blocking read even if the fd was opened in nonblocking mode. Make it so.

Cc Juha-Pekka Heikkila <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 lib/igt_debugfs.c           | 35 ++++++++++++-----------------------
 lib/igt_debugfs.h           |  2 +-
 tests/kms_chv_cursor_fail.c |  2 +-
 3 files changed, 14 insertions(+), 25 deletions(-)
lib/igt_debugfs.c +12 -23
index baedc2255ac9..d151d9b23ed4 100644
@@ -757,8 +757,13 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
 {
 	int ret;
 
-	while ((ret = read_crc(pipe_crc, out)) <= 0 && ret != -EINVAL)
-		usleep(1000);
+	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags & ~O_NONBLOCK);
+
+	do {
+		ret = read_crc(pipe_crc, out);
+	} while (ret == -EINTR);
+
+	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags);
 }
 
 /**
@@ -926,12 +931,8 @@ void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc)
  * @pipe_crc: pipe CRC object
  * @crc: buffer pointer for the captured CRC value
  *
- * Read a single @crc from @pipe_crc. This function does not block
- * when nonblocking CRC is requested, and will return false if no CRC
- * can be captured.
- *
- * If opened in blocking mode it will always block until a new CRC is read, like
- * igt_pipe_crc_collect_crc().
+ * Read a single @crc from @pipe_crc. This function blocks even
+ * when nonblocking CRC is requested.
  *
  * Callers must start and stop the capturing themselves by calling
  * igt_pipe_crc_start() and igt_pipe_crc_stop(). For one-shot CRC collecting
@@ -943,22 +944,11 @@ void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc)
  * Returns:
  * Whether a crc is captured, only false in non-blocking mode.
  */
-bool
-igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
+void igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
 {
-	bool found = true;
+	read_one_crc(pipe_crc, crc);
 
-	if (pipe_crc->flags & O_NONBLOCK) {
-		int ret = read_crc(pipe_crc, crc);
-
-		found = ret > 0;
-	} else
-		read_one_crc(pipe_crc, crc);
-
-	if (found)
-		crc_sanity_checks(crc);
-
-	return found;
+	crc_sanity_checks(crc);
 }
 
 /**
@@ -976,7 +966,6 @@ igt_pipe_crc_get_current(int drm_fd, igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
 {
 	unsigned vblank = kmstest_get_vblank(drm_fd, pipe_crc->pipe, 0);
 
-	igt_assert(!(pipe_crc->flags & O_NONBLOCK));
 	do {
 		read_one_crc(pipe_crc, crc);
 
lib/igt_debugfs.h +1 -1
index 9f81be0a24de..58ca07f5c15d 100644
@@ -132,7 +132,7 @@ __attribute__((warn_unused_result))
 int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
 			  igt_crc_t **out_crcs);
 void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc);
-bool igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
+void igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
 void igt_pipe_crc_get_current(int drm_fd, igt_pipe_crc_t *pipe_crc, igt_crc_t *crc);
 
 void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
tests/kms_chv_cursor_fail.c +1 -1
index 7138e549aeb7..8e50978d0be1 100644
@@ -258,7 +258,7 @@ static void prepare_crtc(data_t *data)
 
 	/* get reference crc w/o cursor */
 	igt_pipe_crc_start(data->pipe_crc);
-	igt_assert(igt_pipe_crc_get_single(data->pipe_crc, &data->ref_crc));
+	igt_pipe_crc_get_single(data->pipe_crc, &data->ref_crc);
 }
 
 static void test_crtc(data_t *data, unsigned int edges)
Signature · 6 lines
2.16.4

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for lib/debugfs: Use a blocking read in igt_pipe_crc_get_single()

== Series Details ==

== Series Details ==

Series: lib/debugfs: Use a blocking read in igt_pipe_crc_get_single()
URL : https://patchwork.freedesktop.org/series/50152/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4874 -> IGTPW_1871 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/50152/revisions/1/mbox/

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@debugfs_test@read_all_entries:
      fi-icl-u:           PASS -> DMESG-WARN (fdo#107724)

    igt@gem_exec_suspend@basic-s4-devices:
      fi-bdw-samus:       PASS -> INCOMPLETE (fdo#107773)

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a-frame-sequence:
      fi-byt-clapper:     PASS -> FAIL (fdo#103191, fdo#107362)

    igt@kms_psr@primary_page_flip:
      fi-kbl-r:           PASS -> FAIL (fdo#107336)

    igt@prime_vgem@basic-fence-flip:
      fi-skl-iommu:       PASS -> FAIL (fdo#104008)

    
    ==== Possible fixes ====

    igt@drv_module_reload@basic-reload:
      fi-blb-e6850:       INCOMPLETE (fdo#107718) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-cfl-8109u:       INCOMPLETE (fdo#106070) -> PASS

    igt@kms_psr@primary_page_flip:
      fi-cnl-u:           FAIL (fdo#107336) -> PASS

fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
fdo#106070 https://bugs.freedesktop.org/show_bug.cgi?id=106070
fdo#107336 https://bugs.freedesktop.org/show_bug.cgi?id=107336
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107718 https://bugs.freedesktop.org/show_bug.cgi?id=107718
fdo#107724 https://bugs.freedesktop.org/show_bug.cgi?id=107724
fdo#107773 https://bugs.freedesktop.org/show_bug.cgi?id=107773

== Participating hosts (48 -> 43) ==

Additional (1): fi-skl-6700hq
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-u2 fi-ctg-p8600

== Build changes ==

* IGT: IGT_4649 -> IGTPW_1871

CI_DRM_4874: 7bb42432ef1cc63b4a6a223e19455f6c4f9a1538 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1871: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1871/
IGT_4649: 19b0c74d20d9b53d4c82be14af0909a3b6846010 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1871/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for lib/debugfs: Use a blocking read in igt_pipe_crc_get_single()

In reply to Ville Syrjala
== Series Details ==

== Series Details ==

Series: lib/debugfs: Use a blocking read in igt_pipe_crc_get_single()
URL : https://patchwork.freedesktop.org/series/50152/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4649_full -> IGTPW_1871_full =

== Summary - WARNING ==

Minor unknown changes coming with IGTPW_1871_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_1871_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/50152/revisions/1/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in IGTPW_1871_full:

=== IGT changes ===

    ==== Warnings ====

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          PASS -> SKIP
      shard-snb:          SKIP -> PASS

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@kms_cursor_legacy@cursorb-vs-flipb-toggle:
      shard-glk:          PASS -> DMESG-WARN (fdo#105763, fdo#106538)

    igt@kms_frontbuffer_tracking@fbcpsr-1p-rte:
      shard-snb:          SKIP -> INCOMPLETE (fdo#105411)

    igt@kms_setmode@basic:
      shard-kbl:          PASS -> FAIL (fdo#99912)

    igt@perf@blocking:
      shard-hsw:          PASS -> FAIL (fdo#102252)

    
    ==== Possible fixes ====

    igt@kms_cursor_crc@cursor-256x256-suspend:
      shard-kbl:          INCOMPLETE (fdo#103665) -> PASS

    igt@kms_cursor_legacy@pipe-c-forked-move:
      shard-apl:          INCOMPLETE (fdo#103927) -> PASS

    igt@kms_setmode@basic:
      shard-apl:          FAIL (fdo#99912) -> PASS

    igt@kms_universal_plane@universal-plane-gen9-features-pipe-a:
      shard-kbl:          DMESG-WARN (fdo#103558, fdo#105602) -> PASS +14

fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#105763 https://bugs.freedesktop.org/show_bug.cgi?id=105763
fdo#106538 https://bugs.freedesktop.org/show_bug.cgi?id=106538
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912

== Participating hosts (5 -> 5) ==

No changes in participating hosts

== Build changes ==

* IGT: IGT_4649 -> IGTPW_1871
* Linux: CI_DRM_4859 -> CI_DRM_4874

CI_DRM_4859: 841654aee134e50b21bf8f2aab17da8d0afd14c4 @ git://anongit.freedesktop.org/gfx-ci/linux
CI_DRM_4874: 7bb42432ef1cc63b4a6a223e19455f6c4f9a1538 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1871: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1871/
IGT_4649: 19b0c74d20d9b53d4c82be14af0909a3b6846010 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1871/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by on v1 1/1
#3 lore raw
In reply to Ville Syrjala

Looks good. I suspect this will reduce those random crc errors seen in CI.

Ville Syrjala kirjoitti 25.9.2018 klo 17.53:

Quoted 102 lines

From: Ville Syrjälä <[email protected]>

All users of igt_pipe_crc_get_single() want a blocking read even if the fd was opened in nonblocking mode. Make it so.

Cc Juha-Pekka Heikkila <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
  lib/igt_debugfs.c           | 35 ++++++++++++-----------------------
  lib/igt_debugfs.h           |  2 +-
  tests/kms_chv_cursor_fail.c |  2 +-
  3 files changed, 14 insertions(+), 25 deletions(-)
lib/igt_debugfs.c +12 -23
index baedc2255ac9..d151d9b23ed4 100644
@@ -757,8 +757,13 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
  {
  	int ret;
 
-	while ((ret = read_crc(pipe_crc, out)) <= 0 && ret != -EINVAL)
-		usleep(1000);
+	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags & ~O_NONBLOCK);
+
+	do {
+		ret = read_crc(pipe_crc, out);
+	} while (ret == -EINTR);
+
+	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags);
  }
 
  /**
@@ -926,12 +931,8 @@ void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc)
   * @pipe_crc: pipe CRC object
   * @crc: buffer pointer for the captured CRC value
   *
- * Read a single @crc from @pipe_crc. This function does not block
- * when nonblocking CRC is requested, and will return false if no CRC
- * can be captured.
- *
- * If opened in blocking mode it will always block until a new CRC is read, like
- * igt_pipe_crc_collect_crc().
+ * Read a single @crc from @pipe_crc. This function blocks even
+ * when nonblocking CRC is requested.
   *
   * Callers must start and stop the capturing themselves by calling
   * igt_pipe_crc_start() and igt_pipe_crc_stop(). For one-shot CRC collecting
@@ -943,22 +944,11 @@ void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc)
   * Returns:
   * Whether a crc is captured, only false in non-blocking mode.
   */
-bool
-igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
+void igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
  {
-	bool found = true;
+	read_one_crc(pipe_crc, crc);
 
-	if (pipe_crc->flags & O_NONBLOCK) {
-		int ret = read_crc(pipe_crc, crc);
-
-		found = ret > 0;
-	} else
-		read_one_crc(pipe_crc, crc);
-
-	if (found)
-		crc_sanity_checks(crc);
-
-	return found;
+	crc_sanity_checks(crc);
  }
 
  /**
@@ -976,7 +966,6 @@ igt_pipe_crc_get_current(int drm_fd, igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
  {
  	unsigned vblank = kmstest_get_vblank(drm_fd, pipe_crc->pipe, 0);
 
-	igt_assert(!(pipe_crc->flags & O_NONBLOCK));
  	do {
  		read_one_crc(pipe_crc, crc);
 
lib/igt_debugfs.h +1 -1
index 9f81be0a24de..58ca07f5c15d 100644
@@ -132,7 +132,7 @@ __attribute__((warn_unused_result))
  int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
  			  igt_crc_t **out_crcs);
  void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc);
-bool igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
+void igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
  void igt_pipe_crc_get_current(int drm_fd, igt_pipe_crc_t *pipe_crc, igt_crc_t *crc);
 
  void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
tests/kms_chv_cursor_fail.c +0 -0
index 7138e549aeb7..8e50978d0be1 100644

tests/kms_chv_cursor_fail.c static void prepare_crtc(data_t *data) · line 264

Quoted 8 lines
tests/kms_chv_cursor_fail.c +1 -1
@@ -258,7 +258,7 @@ static void prepare_crtc(data_t *data)
 
  	/* get reference crc w/o cursor */
  	igt_pipe_crc_start(data->pipe_crc);
-	igt_assert(igt_pipe_crc_get_single(data->pipe_crc, &data->ref_crc));
+	igt_pipe_crc_get_single(data->pipe_crc, &data->ref_crc);
  }
 
  static void test_crtc(data_t *data, unsigned int edges)

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw
Quoted 49 lines · Juha-Pekka Heikkilä

Looks good. I suspect this will reduce those random crc errors seen in CI.

Ville Syrjala kirjoitti 25.9.2018 klo 17.53:

Quoted 44 lines

From: Ville Syrjälä <[email protected]>

All users of igt_pipe_crc_get_single() want a blocking read even if the fd was opened in nonblocking mode. Make it so.

Cc Juha-Pekka Heikkila <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
  lib/igt_debugfs.c           | 35 ++++++++++++-----------------------
  lib/igt_debugfs.h           |  2 +-
  tests/kms_chv_cursor_fail.c |  2 +-
  3 files changed, 14 insertions(+), 25 deletions(-)
lib/igt_debugfs.c +7 -8
index baedc2255ac9..d151d9b23ed4 100644
@@ -757,8 +757,13 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
  {
  	int ret;
 
-	while ((ret = read_crc(pipe_crc, out)) <= 0 && ret != -EINVAL)
-		usleep(1000);
+	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags & ~O_NONBLOCK);
+
+	do {
+		ret = read_crc(pipe_crc, out);
+	} while (ret == -EINTR);
+
+	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags);
  }
 
  /**
@@ -926,12 +931,8 @@ void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc)
   * @pipe_crc: pipe CRC object
   * @crc: buffer pointer for the captured CRC value
   *
- * Read a single @crc from @pipe_crc. This function does not block
- * when nonblocking CRC is requested, and will return false if no CRC
- * can be captured.
- *
- * If opened in blocking mode it will always block until a new CRC is read, like
- * igt_pipe_crc_collect_crc().
Quoted 8 lines

lib/igt_debugfs.c void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc) · line 945

Quoted 8 lines
lib/igt_debugfs.c +2 -0
+ * Read a single @crc from @pipe_crc. This function blocks even
+ * when nonblocking CRC is requested.
   *
   * Callers must start and stop the capturing themselves by calling
   * igt_pipe_crc_start() and igt_pipe_crc_stop(). For one-shot CRC collecting
@@ -943,22 +944,11 @@ void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc)
   * Returns:
   * Whether a crc is captured, only false in non-blocking mode.

I just noticed that I failed to remove this "Returns: ..." stuff here. Fixed while pushing. Thanks for the review.

Quoted 58 lines
Quoted 58 lines
lib/igt_debugfs.c +3 -15
   */
-bool
-igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
+void igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
  {
-	bool found = true;
+	read_one_crc(pipe_crc, crc);
 
-	if (pipe_crc->flags & O_NONBLOCK) {
-		int ret = read_crc(pipe_crc, crc);
-
-		found = ret > 0;
-	} else
-		read_one_crc(pipe_crc, crc);
-
-	if (found)
-		crc_sanity_checks(crc);
-
-	return found;
+	crc_sanity_checks(crc);
  }
 
  /**
@@ -976,7 +966,6 @@ igt_pipe_crc_get_current(int drm_fd, igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
  {
  	unsigned vblank = kmstest_get_vblank(drm_fd, pipe_crc->pipe, 0);
 
-	igt_assert(!(pipe_crc->flags & O_NONBLOCK));
  	do {
  		read_one_crc(pipe_crc, crc);
 
lib/igt_debugfs.h +1 -1
index 9f81be0a24de..58ca07f5c15d 100644
@@ -132,7 +132,7 @@ __attribute__((warn_unused_result))
  int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
  			  igt_crc_t **out_crcs);
  void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc);
-bool igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
+void igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
  void igt_pipe_crc_get_current(int drm_fd, igt_pipe_crc_t *pipe_crc, igt_crc_t *crc);
 
  void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
tests/kms_chv_cursor_fail.c +1 -1
index 7138e549aeb7..8e50978d0be1 100644
@@ -258,7 +258,7 @@ static void prepare_crtc(data_t *data)
 
  	/* get reference crc w/o cursor */
  	igt_pipe_crc_start(data->pipe_crc);
-	igt_assert(igt_pipe_crc_get_single(data->pipe_crc, &data->ref_crc));
+	igt_pipe_crc_get_single(data->pipe_crc, &data->ref_crc);
  }
 
  static void test_crtc(data_t *data, unsigned int edges)
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev