All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] lib/igt_amd: improve link_settings parser for old kernel compatibility
@ 2026-09-09 20:44 Roman.Li
  2026-09-10  0:33 ` ✓ Xe.CI.BAT: success for " Patchwork
  2026-09-10  0:40 ` ✗ i915.CI.BAT: failure " Patchwork
  0 siblings, 2 replies; 3+ messages in thread
From: Roman.Li @ 2026-09-09 20:44 UTC (permalink / raw)
  To: igt-dev; +Cc: alex.hung, Roman Li, Harry Wentland

From: Roman Li <Roman.Li@amd.com>

The previous fix uses strstr() to locate each record label. However,
strstr() stops at the first NUL byte (C string semantics), which breaks
backward compatibility with old kernels that embed NUL bytes between
records. Only the Current record would parse, leaving Verified, Reported,
and Preferred unset (0), causing the same failure as the original bug.

Use memmem() instead to search the raw buffer across NUL boundaries,
combined with sscanf() for parsing. This works with both:
  - Old kernels: with embedded NUL separators
  - New kernels: with contiguous single string

Also replace hardcoded loop bound '4' with ARRAY_SIZE(labels) for
better maintainability.

Tested on eDP with both kernel variants: amd_ilr passes in both cases.

Fixes: f234bbd294f5 ("lib/igt_amd: don't rely on NUL separators parsing link_settings")
Cc: Harry Wentland <harry.wentland@amd.com>
Assisted-by: Claude Haiku 4.5
Signed-off-by: Roman Li <Roman.Li@amd.com>
---
 lib/igt_amd.c | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/lib/igt_amd.c b/lib/igt_amd.c
index 7d33ab658..ba1cfabcf 100644
--- a/lib/igt_amd.c
+++ b/lib/igt_amd.c
@@ -836,10 +836,8 @@ void igt_amd_read_link_settings(
 	static const char * const labels[] = {
 		"Current:", "Verified:", "Reported:", "Preferred:"
 	};
-	int fd, ret;
+	int fd, ret, i;
 	char buf[101];
-	char *ptr;
-	int i;
 
 	fd = igt_debugfs_connector_dir(drm_fd, connector_name, O_RDONLY);
 	if (fd < 0) {
@@ -853,22 +851,29 @@ void igt_amd_read_link_settings(
 
 	close(fd);
 
-	/* The debugfs node returns a single NUL-terminated string of the form:
+	/* The debugfs node returns a string of the form:
 	 *   "Current:  %d  0x%x  %d  Verified:  %d  0x%x  %d  "
 	 *   "Reported:  %d  0x%x  %d  Preferred:  %d  0x%x  %d\n"
-	 * Locate each label and parse the three values that follow it. Do not
-	 * rely on embedded NUL bytes (or any other delimiter) between records,
-	 * as the kernel emits a single contiguous string. */
-	ptr = buf;
-	for (i = 0; i < 4; i++) {
-		ptr = strstr(ptr, labels[i]);
-		if (ptr == NULL)
+	 * Old kernels embed NUL bytes between records; new kernels emit a
+	 * contiguous string. Use memmem() to locate each label across NUL
+	 * boundaries and sscanf() to parse values, so both layouts work.
+	 */
+	for (i = 0; i < ARRAY_SIZE(labels); i++) {
+		const char *label = labels[i];
+		char *rec = memmem(buf, ret, label, strlen(label));
+		unsigned int rate;
+		int lanes, spread;
+
+		if (!rec)
+			break;
+
+		if (sscanf(rec + strlen(label), "%d %x %d",
+			   &lanes, &rate, &spread) != 3)
 			break;
 
-		ptr += strlen(labels[i]);
-		lane_count[i] = strtol(ptr, &ptr, 10);
-		link_rate[i] = strtol(ptr, &ptr, 16);
-		link_spread[i] = strtol(ptr, &ptr, 10);
+		lane_count[i] = lanes;
+		link_rate[i] = rate;
+		link_spread[i] = spread;
 	}
 }
 
-- 
2.34.1


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

* ✓ Xe.CI.BAT: success for lib/igt_amd: improve link_settings parser for old kernel compatibility
  2026-09-09 20:44 [PATCH i-g-t] lib/igt_amd: improve link_settings parser for old kernel compatibility Roman.Li
@ 2026-09-10  0:33 ` Patchwork
  2026-09-10  0:40 ` ✗ i915.CI.BAT: failure " Patchwork
  1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2026-09-10  0:33 UTC (permalink / raw)
  To: roman.li; +Cc: igt-dev

[-- Attachment #1: Type: text/plain, Size: 6941 bytes --]

== Series Details ==

Series: lib/igt_amd: improve link_settings parser for old kernel compatibility
URL   : https://patchwork.freedesktop.org/series/173745/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_9088_BAT -> XEIGTPW_15821_BAT
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

Participating hosts (14 -> 13)
------------------------------

  Additional (1): bat-nvls-2 
  Missing    (2): bat-adlp-7 bat-nvls-1 

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

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

### IGT changes ###

#### Issues hit ####

  * igt@fbdev@eof:
    - bat-nvls-2:         NOTRUN -> [SKIP][1] ([Intel XE#8742]) +4 other tests skip
   [1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@fbdev@eof.html

  * igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
    - bat-nvls-2:         NOTRUN -> [SKIP][2] ([Intel XE#8757])
   [2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@kms_addfb_basic@addfb25-y-tiled-small-legacy.html

  * igt@kms_flip@basic-flip-vs-wf_vblank:
    - bat-nvls-2:         NOTRUN -> [SKIP][3] ([Intel XE#8756] / [Intel XE#8783]) +3 other tests skip
   [3]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@kms_flip@basic-flip-vs-wf_vblank.html

  * igt@kms_frontbuffer_tracking@basic:
    - bat-nvls-2:         NOTRUN -> [SKIP][4] ([Intel XE#8761] / [Intel XE#8773])
   [4]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@kms_frontbuffer_tracking@basic.html

  * igt@kms_pipe_crc_basic@nonblocking-crc:
    - bat-nvls-2:         NOTRUN -> [SKIP][5] ([Intel XE#8755]) +13 other tests skip
   [5]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@kms_pipe_crc_basic@nonblocking-crc.html

  * igt@kms_psr@psr-sprite-plane-onoff:
    - bat-nvls-2:         NOTRUN -> [SKIP][6] ([Intel XE#8758] / [Intel XE#8784]) +2 other tests skip
   [6]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@kms_psr@psr-sprite-plane-onoff.html

  * igt@xe_evict@evict-small-multi-vm:
    - bat-nvls-2:         NOTRUN -> [SKIP][7] ([Intel XE#8777]) +9 other tests skip
   [7]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_evict@evict-small-multi-vm.html

  * igt@xe_evict_ccs@evict-overcommit-parallel-nofree-samefd:
    - bat-nvls-2:         NOTRUN -> [SKIP][8] ([Intel XE#8744]) +1 other test skip
   [8]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_evict_ccs@evict-overcommit-parallel-nofree-samefd.html

  * igt@xe_exec_balancer@no-exec-virtual-basic:
    - bat-nvls-2:         NOTRUN -> [SKIP][9] ([Intel XE#8741]) +17 other tests skip
   [9]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_exec_balancer@no-exec-virtual-basic.html

  * igt@xe_exec_multi_queue@many-queues-basic-smem:
    - bat-nvls-2:         NOTRUN -> [SKIP][10] ([Intel XE#8377]) +13 other tests skip
   [10]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_exec_multi_queue@many-queues-basic-smem.html

  * igt@xe_huc_copy@huc_copy:
    - bat-nvls-2:         NOTRUN -> [SKIP][11] ([Intel XE#8746])
   [11]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_huc_copy@huc_copy.html

  * igt@xe_live_ktest@xe_bo:
    - bat-nvls-2:         NOTRUN -> [SKIP][12] ([Intel XE#8792])
   [12]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_live_ktest@xe_bo.html

  * igt@xe_live_ktest@xe_bo@xe_bo_evict_kunit:
    - bat-nvls-2:         NOTRUN -> [SKIP][13] ([Intel XE#8791] / [Intel XE#8792])
   [13]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_live_ktest@xe_bo@xe_bo_evict_kunit.html

  * igt@xe_live_ktest@xe_migrate@xe_validate_ccs_kunit:
    - bat-nvls-2:         NOTRUN -> [SKIP][14] ([Intel XE#8791])
   [14]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_live_ktest@xe_migrate@xe_validate_ccs_kunit.html

  * igt@xe_mmap@vram:
    - bat-nvls-2:         NOTRUN -> [SKIP][15] ([Intel XE#8747])
   [15]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_mmap@vram.html

  * igt@xe_pat@pat-index-xehpc:
    - bat-nvls-2:         NOTRUN -> [SKIP][16] ([Intel XE#8748])
   [16]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_pat@pat-index-xehpc.html

  * igt@xe_pat@pat-index-xelp:
    - bat-nvls-2:         NOTRUN -> [SKIP][17] ([Intel XE#8743])
   [17]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_pat@pat-index-xelp.html

  * igt@xe_pat@pat-index-xelpg:
    - bat-nvls-2:         NOTRUN -> [SKIP][18] ([Intel XE#8745])
   [18]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/bat-nvls-2/igt@xe_pat@pat-index-xelpg.html

  
  [Intel XE#8377]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8377
  [Intel XE#8741]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8741
  [Intel XE#8742]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8742
  [Intel XE#8743]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8743
  [Intel XE#8744]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8744
  [Intel XE#8745]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8745
  [Intel XE#8746]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8746
  [Intel XE#8747]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8747
  [Intel XE#8748]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8748
  [Intel XE#8755]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8755
  [Intel XE#8756]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8756
  [Intel XE#8757]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8757
  [Intel XE#8758]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8758
  [Intel XE#8761]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8761
  [Intel XE#8773]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8773
  [Intel XE#8777]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8777
  [Intel XE#8783]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8783
  [Intel XE#8784]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8784
  [Intel XE#8791]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8791
  [Intel XE#8792]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/8792


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

  * IGT: IGT_9088 -> IGTPW_15821
  * Linux: xe-5710-dd822035c9dcd89e47cbfa75da6f3119617fbada -> xe-5717-a3a7d02f33d6dacc90d1cc9d0e3c2fa8f3d4611d

  IGTPW_15821: 15821
  IGT_9088: 55a88d20e327d5c440cd3f3d661684fb83f29027 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  xe-5710-dd822035c9dcd89e47cbfa75da6f3119617fbada: dd822035c9dcd89e47cbfa75da6f3119617fbada
  xe-5717-a3a7d02f33d6dacc90d1cc9d0e3c2fa8f3d4611d: a3a7d02f33d6dacc90d1cc9d0e3c2fa8f3d4611d

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_15821/index.html

[-- Attachment #2: Type: text/html, Size: 8045 bytes --]

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

* ✗ i915.CI.BAT: failure for lib/igt_amd: improve link_settings parser for old kernel compatibility
  2026-09-09 20:44 [PATCH i-g-t] lib/igt_amd: improve link_settings parser for old kernel compatibility Roman.Li
  2026-09-10  0:33 ` ✓ Xe.CI.BAT: success for " Patchwork
@ 2026-09-10  0:40 ` Patchwork
  1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2026-09-10  0:40 UTC (permalink / raw)
  To: roman.li; +Cc: igt-dev

[-- Attachment #1: Type: text/plain, Size: 2782 bytes --]

== Series Details ==

Series: lib/igt_amd: improve link_settings parser for old kernel compatibility
URL   : https://patchwork.freedesktop.org/series/173745/
State : failure

== Summary ==

CI Bug Log - changes from IGT_9088 -> IGTPW_15821
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with IGTPW_15821 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_15821, please notify your bug team (I915-ci-infra@lists.freedesktop.org) to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_15821/index.html

Participating hosts (39 -> 38)
------------------------------

  Missing    (1): bat-dg2-13 

Possible new issues
-------------------

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

### IGT changes ###

#### Possible regressions ####

  * igt@kms_busy@basic:
    - fi-skl-6600u:       [PASS][1] -> [INCOMPLETE][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_9088/fi-skl-6600u/igt@kms_busy@basic.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_15821/fi-skl-6600u/igt@kms_busy@basic.html

  * igt@kms_flip@basic-flip-vs-dpms@b-dp1:
    - bat-rpls-4:         [PASS][3] -> [INCOMPLETE][4] +1 other test incomplete
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_9088/bat-rpls-4/igt@kms_flip@basic-flip-vs-dpms@b-dp1.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_15821/bat-rpls-4/igt@kms_flip@basic-flip-vs-dpms@b-dp1.html

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

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

### IGT changes ###

#### Issues hit ####

  * igt@kms_busy@basic@modeset:
    - fi-skl-6600u:       [PASS][5] -> [INCOMPLETE][6] ([i915#10056])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_9088/fi-skl-6600u/igt@kms_busy@basic@modeset.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_15821/fi-skl-6600u/igt@kms_busy@basic@modeset.html

  
  [i915#10056]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/10056


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

  * CI: CI-20190529 -> None
  * IGT: IGT_9088 -> IGTPW_15821
  * Linux: CI_DRM_19108 -> CI_DRM_19115

  CI-20190529: 20190529
  CI_DRM_19108: dd822035c9dcd89e47cbfa75da6f3119617fbada @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_19115: a3a7d02f33d6dacc90d1cc9d0e3c2fa8f3d4611d @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_15821: 15821
  IGT_9088: 55a88d20e327d5c440cd3f3d661684fb83f29027 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_15821/index.html

[-- Attachment #2: Type: text/html, Size: 3464 bytes --]

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

end of thread, other threads:[~2026-09-10  0:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 20:44 [PATCH i-g-t] lib/igt_amd: improve link_settings parser for old kernel compatibility Roman.Li
2026-09-10  0:33 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-09-10  0:40 ` ✗ i915.CI.BAT: failure " Patchwork

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.