* [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT.
@ 2018-08-21 0:12 Rodrigo Vivi
2018-08-21 1:33 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Rodrigo Vivi @ 2018-08-21 0:12 UTC (permalink / raw)
To: igt-dev; +Cc: Rafael Antognolli, Jani Nikula, Dhinakaran Pandiyan, Rodrigo Vivi
The idea is to remove the dump from i915's debugfs, but
before we need to be able to keep the current debug dpcd list
and IGT seems a good place to have some flexibility.
FIXME: fffff trash...
Current debugfs:
$ sudo cat /sys/kernel/debug/dri/0/DP-1/i915_dpcd
0000: 12 14 c4 01 01 00 01 00 02 02 06 00 00 00 02
0070: 00 00
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0100: 14 84 00 06 06 06 06 00 01 04 00
0200: 41 00 77 77 01 03 22 22
0600: 01
0700: 01
0701: 00 00 00 00
0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01
0732: 00 00
$ sudo cat /sys/kernel/debug/dri/0/eDP-1/i915_dpcd
0000: 12 14 84 40 00 00 01 01 02 00 00 00 00 0b 00
0070: 01 00
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0100: 14 04 00 00 00 00 00 00 00 00 00
0200: 41 00 00 00 80 00 66 66
0600: 01
0700: 02
0701: 9f 40 00 00
0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00
0732: 00 00
---------------------------------------------------------
Current dpcd_dump proposed here:
$ sudo ./build/tools/dpcd_dump
Dumping DPDDC-B
:
0000: 12 14 ffffffc4 01 01 00 01 00 02 02 06 00 00 00 02
0070: 00 00
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0100: 14 ffffff84 00 06 06 06 06 00 01 04 00
0200: 41 00 77 77 01 03 22 22
0600: 01
0700: 01
0701: 00 00 00 00
0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01
0732: 00 00
DPCD DPDDC-C
seems not available. skipping...
Dumping DPDDC-A
:
0000: 12 14 ffffff84 40 00 00 01 01 02 00 00 00 00 0b 00
0070: 01 00
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0100: 14 04 00 00 00 00 00 00 00 00 00
0200: 41 00 00 00 ffffff80 00 66 66
0600: 01
0700: 02
0701: ffffff9f 40 00 00
0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00
0732: 00 00
Cc: Rafael Antognolli <rafael.antognolli@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
tools/Makefile.sources | 1 +
tools/dpcd_dump.c | 152 +++++++++++++++++++++++++++++++++++++++++
tools/meson.build | 1 +
3 files changed, 154 insertions(+)
create mode 100644 tools/dpcd_dump.c
diff --git a/tools/Makefile.sources b/tools/Makefile.sources
index abd23a0f..f4921f83 100644
--- a/tools/Makefile.sources
+++ b/tools/Makefile.sources
@@ -6,6 +6,7 @@ noinst_PROGRAMS = \
$(NULL)
tools_prog_lists = \
+ dpcd_dump \
igt_stats \
intel_audio_dump \
intel_reg \
diff --git a/tools/dpcd_dump.c b/tools/dpcd_dump.c
new file mode 100644
index 00000000..1b989e53
--- /dev/null
+++ b/tools/dpcd_dump.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <string.h>
+
+struct dpcd_block {
+ /* DPCD dump start address. */
+ unsigned int offset;
+ /* DPCD dump size. If unset, defaults to 1. */
+ size_t size;
+};
+
+static const struct dpcd_block dpcd_dump[] = {
+ /* DP_DPCD_REV */
+ { .offset = 0, .size = 15 },
+ /* DP_PSR_SUPPORT to DP_PSR_CAPS*/
+ { .offset = 0x70, .size = 2 },
+ /* DP_DOWNSTREAM_PORT_0 */
+ { .offset = 0x80, .size = 16 },
+ /* DP_LINK_BW_SET to DP_EDP_CONFIGURATION_SET */
+ { .offset = 0x100, .size = 11 },
+ /* DP_SINK_COUNT to DP_ADJUST_REQUEST_LANE2_3 */
+ { .offset = 0x200, .size = 8 },
+ /* DP_SET_POWER */
+ { .offset = 0x600 },
+ /* DP_EDP_DPCD_REV */
+ { .offset = 0x700 },
+ /* DP_EDP_GENERAL_CAP_1 to DP_EDP_GENERAL_CAP_3 */
+ { .offset = 0x701, .size = 4 },
+ /* DP_EDP_DISPLAY_CONTROL_REGISTER to DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB */
+ { .offset = 0x720, .size = 16},
+ /* DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET to DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET */
+ { .offset = 0x732, .size = 2 },
+};
+
+void dump_all(int fd)
+{
+ int ret, i, j, size;
+ char buf[32];
+
+ for (i = 0; i < sizeof(dpcd_dump) / sizeof(dpcd_dump[0]); i++) {
+ ret = lseek(fd, dpcd_dump[i].offset, SEEK_SET);
+ if (ret < 0) {
+ fprintf(stderr, "lseek to %04x failed!\n", dpcd_dump[i].offset);
+ return;
+ }
+
+ size = dpcd_dump[i].size ? dpcd_dump[i].size: 1;
+ printf("%04x: ", dpcd_dump[i].offset);
+ ret = read(fd, &buf, size);
+ if (ret < 0) {
+ fprintf(stderr, "read of %d bytes to %04x failed!\n", size, dpcd_dump[i].offset);
+ return;
+ }
+
+ for (j = 0; j < size; j++)
+ printf(" %02x", buf[j]);
+ printf("\n");
+ }
+}
+
+int main(int argc, char **argv)
+{
+ struct dirent *dirent;
+ DIR *dir;
+ char dev_path[PATH_MAX];
+ char sysfs_path[PATH_MAX];
+ int dev_fd, sysfs_fd, ret = 0;
+ char dpcd_name[8];
+ char discard;
+
+ dir = opendir("/sys/class/drm_dp_aux_dev/");
+ if (!dir) {
+ fprintf(stderr, "fail to read /dev\n");
+ return -1;
+ }
+
+ while ((dirent = readdir(dir))) {
+ if (strncmp(dirent->d_name, "drm_dp_aux", 10) == 0) {
+ sprintf(dev_path, "/dev/%s", dirent->d_name);
+ sprintf(sysfs_path, "/sys/class/drm_dp_aux_dev/%s/name",
+ dirent->d_name);
+
+ sysfs_fd = open(sysfs_path, O_RDONLY);
+ if (sysfs_fd < 0) {
+ fprintf(stderr,"fail to open %s\n", sysfs_path);
+ continue;
+ }
+
+ dev_fd = open(dev_path, O_RDONLY);
+ if (dev_fd < 0) {
+ fprintf(stderr,"fail to open %s\n", dev_path);
+ continue;
+ }
+
+ ret = read(sysfs_fd, &dpcd_name, sizeof(dpcd_name));
+ if (ret < 0) {
+ fprintf(stderr, "fail to read dpcd name from %s\n\n", sysfs_path);
+ continue;
+ }
+ dpcd_name[ret] = '\0';
+
+ /* Dummy read to check if dpcd is available */
+ ret = read(dev_fd, &discard, 1);
+ if (ret != 1) {
+ fprintf(stderr, "DPCD %s seems not available. skipping...\n", dpcd_name);
+ continue;
+ }
+
+ printf("Dumping %s:\n", dpcd_name);
+ dump_all(dev_fd);
+ printf("\n");
+
+
+
+ close(sysfs_fd);
+ close(dev_fd);
+ }
+ }
+
+ closedir(dir);
+
+ return 0;
+}
diff --git a/tools/meson.build b/tools/meson.build
index e4517d66..3326a5a7 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -14,6 +14,7 @@ endforeach
tools_progs = [
# FIXME we already have a libtestcase with this name as target
#'igt_stats',
+ 'dpcd_dump',
'intel_audio_dump',
'intel_backlight',
'intel_bios_dumper',
--
2.17.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 9+ messages in thread* [igt-dev] ✓ Fi.CI.BAT: success for tools/dpcd_dump: Introduce DPCD dump on IGT. 2018-08-21 0:12 [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT Rodrigo Vivi @ 2018-08-21 1:33 ` Patchwork 2018-08-21 4:12 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork 2018-08-21 7:42 ` [igt-dev] [RFC] " Jani Nikula 2 siblings, 0 replies; 9+ messages in thread From: Patchwork @ 2018-08-21 1:33 UTC (permalink / raw) To: Rodrigo Vivi; +Cc: igt-dev == Series Details == Series: tools/dpcd_dump: Introduce DPCD dump on IGT. URL : https://patchwork.freedesktop.org/series/48470/ State : success == Summary == = CI Bug Log - changes from CI_DRM_4690 -> IGTPW_1732 = == Summary - SUCCESS == No regressions found. External URL: https://patchwork.freedesktop.org/api/1.0/series/48470/revisions/1/mbox/ == Known issues == Here are the changes found in IGTPW_1732 that come from known issues: === IGT changes === ==== Issues hit ==== igt@drv_selftest@live_hangcheck: fi-kbl-7560u: PASS -> DMESG-FAIL (fdo#106560, fdo#106947) igt@kms_pipe_crc_basic@read-crc-pipe-b: {fi-byt-clapper}: PASS -> FAIL (fdo#107362) {igt@pm_rpm@module-reload}: fi-cnl-psr: PASS -> WARN (fdo#107602) ==== Possible fixes ==== igt@kms_flip@basic-flip-vs-modeset: fi-skl-6700hq: DMESG-WARN (fdo#105998) -> PASS +1 igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a: {fi-byt-clapper}: FAIL (fdo#107362) -> PASS {name}: This element is suppressed. This means it is ignored when computing the status of the difference (SUCCESS, WARNING, or FAILURE). fdo#105998 https://bugs.freedesktop.org/show_bug.cgi?id=105998 fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560 fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947 fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362 fdo#107602 https://bugs.freedesktop.org/show_bug.cgi?id=107602 == Participating hosts (52 -> 48) == Missing (4): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u == Build changes == * IGT: IGT_4606 -> IGTPW_1732 CI_DRM_4690: 5b8042159e2b05425c098868ed6fac9518ee638d @ git://anongit.freedesktop.org/gfx-ci/linux IGTPW_1732: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1732/ IGT_4606: 38a44003774e35c587c67c8766b35e75dbb993b8 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools == Logs == For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1732/issues.html _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 9+ messages in thread
* [igt-dev] ✓ Fi.CI.IGT: success for tools/dpcd_dump: Introduce DPCD dump on IGT. 2018-08-21 0:12 [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT Rodrigo Vivi 2018-08-21 1:33 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork @ 2018-08-21 4:12 ` Patchwork 2018-08-21 7:42 ` [igt-dev] [RFC] " Jani Nikula 2 siblings, 0 replies; 9+ messages in thread From: Patchwork @ 2018-08-21 4:12 UTC (permalink / raw) To: Rodrigo Vivi; +Cc: igt-dev == Series Details == Series: tools/dpcd_dump: Introduce DPCD dump on IGT. URL : https://patchwork.freedesktop.org/series/48470/ State : success == Summary == = CI Bug Log - changes from IGT_4606_full -> IGTPW_1732_full = == Summary - WARNING == Minor unknown changes coming with IGTPW_1732_full need to be verified manually. If you think the reported changes have nothing to do with the changes introduced in IGTPW_1732_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/48470/revisions/1/mbox/ == Possible new issues == Here are the unknown changes that may have been introduced in IGTPW_1732_full: === IGT changes === ==== Warnings ==== igt@pm_rc6_residency@rc6-accuracy: shard-kbl: SKIP -> PASS shard-snb: PASS -> SKIP == Known issues == Here are the changes found in IGTPW_1732_full that come from known issues: === IGT changes === ==== Issues hit ==== igt@gem_ctx_isolation@rcs0-s3: shard-kbl: PASS -> INCOMPLETE (fdo#103665, fdo#107556) igt@gem_exec_schedule@pi-ringfull-bsd: shard-glk: NOTRUN -> FAIL (fdo#103158) igt@gem_fenced_exec_thrash@no-spare-fences: shard-snb: PASS -> INCOMPLETE (fdo#105411) igt@gem_render_copy_redux@normal: shard-kbl: PASS -> INCOMPLETE (fdo#103665, fdo#106650) igt@kms_available_modes_crc@available_mode_test_crc: shard-glk: NOTRUN -> FAIL (fdo#106641) igt@perf_pmu@rc6-runtime-pm-long: shard-apl: PASS -> FAIL (fdo#105010) igt@testdisplay: shard-glk: PASS -> INCOMPLETE (fdo#107093, fdo#103359, k.org#198133) ==== Possible fixes ==== igt@gem_ctx_isolation@rcs0-s3: shard-glk: FAIL (fdo#103375) -> PASS +1 igt@gem_reg_read@timestamp-monotonic: shard-snb: INCOMPLETE (fdo#105411) -> PASS igt@kms_rotation_crc@primary-rotation-180: shard-snb: FAIL (fdo#103925) -> PASS igt@kms_setmode@basic: shard-kbl: FAIL (fdo#99912) -> PASS igt@perf_pmu@rc6-runtime-pm-long: shard-kbl: FAIL (fdo#105010) -> PASS fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158 fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359 fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375 fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665 fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925 fdo#105010 https://bugs.freedesktop.org/show_bug.cgi?id=105010 fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411 fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641 fdo#106650 https://bugs.freedesktop.org/show_bug.cgi?id=106650 fdo#107093 https://bugs.freedesktop.org/show_bug.cgi?id=107093 fdo#107556 https://bugs.freedesktop.org/show_bug.cgi?id=107556 fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912 k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133 == Participating hosts (5 -> 5) == No changes in participating hosts == Build changes == * IGT: IGT_4606 -> IGTPW_1732 * Linux: CI_DRM_4684 -> CI_DRM_4690 CI_DRM_4684: bb1a6d0044581c5d8867afde39111ea4605c644d @ git://anongit.freedesktop.org/gfx-ci/linux CI_DRM_4690: 5b8042159e2b05425c098868ed6fac9518ee638d @ git://anongit.freedesktop.org/gfx-ci/linux IGTPW_1732: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1732/ IGT_4606: 38a44003774e35c587c67c8766b35e75dbb993b8 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools == Logs == For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1732/shards.html _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT. 2018-08-21 0:12 [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT Rodrigo Vivi 2018-08-21 1:33 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork 2018-08-21 4:12 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork @ 2018-08-21 7:42 ` Jani Nikula 2018-08-21 14:58 ` Rodrigo Vivi 2 siblings, 1 reply; 9+ messages in thread From: Jani Nikula @ 2018-08-21 7:42 UTC (permalink / raw) To: Rodrigo Vivi, igt-dev Cc: Rafael Antognolli, Dhinakaran Pandiyan, Rodrigo Vivi On Mon, 20 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: > The idea is to remove the dump from i915's debugfs, but > before we need to be able to keep the current debug dpcd list > and IGT seems a good place to have some flexibility. See also [1]. I'm not sure what the status is now. Tarun? I don't think we should have both as separate binaries. BR, Jani. [1] http://patchwork.freedesktop.org/patch/msgid/20180614071141.144275-1-tarun.vyas@intel.com > > FIXME: fffff trash... > > Current debugfs: > > $ sudo cat /sys/kernel/debug/dri/0/DP-1/i915_dpcd > 0000: 12 14 c4 01 01 00 01 00 02 02 06 00 00 00 02 > 0070: 00 00 > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 0100: 14 84 00 06 06 06 06 00 01 04 00 > 0200: 41 00 77 77 01 03 22 22 > 0600: 01 > 0700: 01 > 0701: 00 00 00 00 > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > 0732: 00 00 > > $ sudo cat /sys/kernel/debug/dri/0/eDP-1/i915_dpcd > 0000: 12 14 84 40 00 00 01 01 02 00 00 00 00 0b 00 > 0070: 01 00 > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 0100: 14 04 00 00 00 00 00 00 00 00 00 > 0200: 41 00 00 00 80 00 66 66 > 0600: 01 > 0700: 02 > 0701: 9f 40 00 00 > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > 0732: 00 00 > > --------------------------------------------------------- > > Current dpcd_dump proposed here: > $ sudo ./build/tools/dpcd_dump > > Dumping DPDDC-B > : > 0000: 12 14 ffffffc4 01 01 00 01 00 02 02 06 00 00 00 02 > 0070: 00 00 > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 0100: 14 ffffff84 00 06 06 06 06 00 01 04 00 > 0200: 41 00 77 77 01 03 22 22 > 0600: 01 > 0700: 01 > 0701: 00 00 00 00 > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > 0732: 00 00 > > DPCD DPDDC-C > seems not available. skipping... > Dumping DPDDC-A > : > 0000: 12 14 ffffff84 40 00 00 01 01 02 00 00 00 00 0b 00 > 0070: 01 00 > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 0100: 14 04 00 00 00 00 00 00 00 00 00 > 0200: 41 00 00 00 ffffff80 00 66 66 > 0600: 01 > 0700: 02 > 0701: ffffff9f 40 00 00 > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > 0732: 00 00 > > Cc: Rafael Antognolli <rafael.antognolli@intel.com> > Cc: Jani Nikula <jani.nikula@intel.com> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> > --- > tools/Makefile.sources | 1 + > tools/dpcd_dump.c | 152 +++++++++++++++++++++++++++++++++++++++++ > tools/meson.build | 1 + > 3 files changed, 154 insertions(+) > create mode 100644 tools/dpcd_dump.c > > diff --git a/tools/Makefile.sources b/tools/Makefile.sources > index abd23a0f..f4921f83 100644 > --- a/tools/Makefile.sources > +++ b/tools/Makefile.sources > @@ -6,6 +6,7 @@ noinst_PROGRAMS = \ > $(NULL) > > tools_prog_lists = \ > + dpcd_dump \ > igt_stats \ > intel_audio_dump \ > intel_reg \ > diff --git a/tools/dpcd_dump.c b/tools/dpcd_dump.c > new file mode 100644 > index 00000000..1b989e53 > --- /dev/null > +++ b/tools/dpcd_dump.c > @@ -0,0 +1,152 @@ > +/* > + * Copyright © 2018 Intel Corporation > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice (including the next > + * paragraph) shall be included in all copies or substantial portions of the > + * Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS > + * IN THE SOFTWARE. > + * > + */ > + > +#include <stdio.h> > +#include <stdlib.h> > +#include <unistd.h> > +#include <sys/types.h> > +#include <sys/stat.h> > +#include <fcntl.h> > +#include <dirent.h> > +#include <string.h> > + > +struct dpcd_block { > + /* DPCD dump start address. */ > + unsigned int offset; > + /* DPCD dump size. If unset, defaults to 1. */ > + size_t size; > +}; > + > +static const struct dpcd_block dpcd_dump[] = { > + /* DP_DPCD_REV */ > + { .offset = 0, .size = 15 }, > + /* DP_PSR_SUPPORT to DP_PSR_CAPS*/ > + { .offset = 0x70, .size = 2 }, > + /* DP_DOWNSTREAM_PORT_0 */ > + { .offset = 0x80, .size = 16 }, > + /* DP_LINK_BW_SET to DP_EDP_CONFIGURATION_SET */ > + { .offset = 0x100, .size = 11 }, > + /* DP_SINK_COUNT to DP_ADJUST_REQUEST_LANE2_3 */ > + { .offset = 0x200, .size = 8 }, > + /* DP_SET_POWER */ > + { .offset = 0x600 }, > + /* DP_EDP_DPCD_REV */ > + { .offset = 0x700 }, > + /* DP_EDP_GENERAL_CAP_1 to DP_EDP_GENERAL_CAP_3 */ > + { .offset = 0x701, .size = 4 }, > + /* DP_EDP_DISPLAY_CONTROL_REGISTER to DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB */ > + { .offset = 0x720, .size = 16}, > + /* DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET to DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET */ > + { .offset = 0x732, .size = 2 }, > +}; > + > +void dump_all(int fd) > +{ > + int ret, i, j, size; > + char buf[32]; > + > + for (i = 0; i < sizeof(dpcd_dump) / sizeof(dpcd_dump[0]); i++) { > + ret = lseek(fd, dpcd_dump[i].offset, SEEK_SET); > + if (ret < 0) { > + fprintf(stderr, "lseek to %04x failed!\n", dpcd_dump[i].offset); > + return; > + } > + > + size = dpcd_dump[i].size ? dpcd_dump[i].size: 1; > + printf("%04x: ", dpcd_dump[i].offset); > + ret = read(fd, &buf, size); > + if (ret < 0) { > + fprintf(stderr, "read of %d bytes to %04x failed!\n", size, dpcd_dump[i].offset); > + return; > + } > + > + for (j = 0; j < size; j++) > + printf(" %02x", buf[j]); > + printf("\n"); > + } > +} > + > +int main(int argc, char **argv) > +{ > + struct dirent *dirent; > + DIR *dir; > + char dev_path[PATH_MAX]; > + char sysfs_path[PATH_MAX]; > + int dev_fd, sysfs_fd, ret = 0; > + char dpcd_name[8]; > + char discard; > + > + dir = opendir("/sys/class/drm_dp_aux_dev/"); > + if (!dir) { > + fprintf(stderr, "fail to read /dev\n"); > + return -1; > + } > + > + while ((dirent = readdir(dir))) { > + if (strncmp(dirent->d_name, "drm_dp_aux", 10) == 0) { > + sprintf(dev_path, "/dev/%s", dirent->d_name); > + sprintf(sysfs_path, "/sys/class/drm_dp_aux_dev/%s/name", > + dirent->d_name); > + > + sysfs_fd = open(sysfs_path, O_RDONLY); > + if (sysfs_fd < 0) { > + fprintf(stderr,"fail to open %s\n", sysfs_path); > + continue; > + } > + > + dev_fd = open(dev_path, O_RDONLY); > + if (dev_fd < 0) { > + fprintf(stderr,"fail to open %s\n", dev_path); > + continue; > + } > + > + ret = read(sysfs_fd, &dpcd_name, sizeof(dpcd_name)); > + if (ret < 0) { > + fprintf(stderr, "fail to read dpcd name from %s\n\n", sysfs_path); > + continue; > + } > + dpcd_name[ret] = '\0'; > + > + /* Dummy read to check if dpcd is available */ > + ret = read(dev_fd, &discard, 1); > + if (ret != 1) { > + fprintf(stderr, "DPCD %s seems not available. skipping...\n", dpcd_name); > + continue; > + } > + > + printf("Dumping %s:\n", dpcd_name); > + dump_all(dev_fd); > + printf("\n"); > + > + > + > + close(sysfs_fd); > + close(dev_fd); > + } > + } > + > + closedir(dir); > + > + return 0; > +} > diff --git a/tools/meson.build b/tools/meson.build > index e4517d66..3326a5a7 100644 > --- a/tools/meson.build > +++ b/tools/meson.build > @@ -14,6 +14,7 @@ endforeach > tools_progs = [ > # FIXME we already have a libtestcase with this name as target > #'igt_stats', > + 'dpcd_dump', > 'intel_audio_dump', > 'intel_backlight', > 'intel_bios_dumper', -- Jani Nikula, Intel Open Source Graphics Center _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT. 2018-08-21 7:42 ` [igt-dev] [RFC] " Jani Nikula @ 2018-08-21 14:58 ` Rodrigo Vivi 2018-08-22 10:35 ` Jani Nikula 0 siblings, 1 reply; 9+ messages in thread From: Rodrigo Vivi @ 2018-08-21 14:58 UTC (permalink / raw) To: Jani Nikula; +Cc: igt-dev, Rafael Antognolli, Dhinakaran Pandiyan On Tue, Aug 21, 2018 at 10:42:35AM +0300, Jani Nikula wrote: > On Mon, 20 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: > > The idea is to remove the dump from i915's debugfs, but > > before we need to be able to keep the current debug dpcd list > > and IGT seems a good place to have some flexibility. > > See also [1]. I'm not sure what the status is now. Tarun? oh, I had missed that, sorry. I now remember Tarun and DK talking about that but I had forgotten... > > I don't think we should have both as separate binaries. I agree! Tarun, feel free to get my dump functions and merge to your work. maybe my one could be default behaviour of yours when no condition is giving. My idea is to start with the current dump that we have in debugfs and later to expand that to be more generic like in a txt list like we have for intel_reg. Thanks, Rodrigo. > > BR, > Jani. > > > [1] http://patchwork.freedesktop.org/patch/msgid/20180614071141.144275-1-tarun.vyas@intel.com > > > > > > FIXME: fffff trash... > > > > Current debugfs: > > > > $ sudo cat /sys/kernel/debug/dri/0/DP-1/i915_dpcd > > 0000: 12 14 c4 01 01 00 01 00 02 02 06 00 00 00 02 > > 0070: 00 00 > > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > 0100: 14 84 00 06 06 06 06 00 01 04 00 > > 0200: 41 00 77 77 01 03 22 22 > > 0600: 01 > > 0700: 01 > > 0701: 00 00 00 00 > > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > > 0732: 00 00 > > > > $ sudo cat /sys/kernel/debug/dri/0/eDP-1/i915_dpcd > > 0000: 12 14 84 40 00 00 01 01 02 00 00 00 00 0b 00 > > 0070: 01 00 > > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > 0100: 14 04 00 00 00 00 00 00 00 00 00 > > 0200: 41 00 00 00 80 00 66 66 > > 0600: 01 > > 0700: 02 > > 0701: 9f 40 00 00 > > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > > 0732: 00 00 > > > > --------------------------------------------------------- > > > > Current dpcd_dump proposed here: > > $ sudo ./build/tools/dpcd_dump > > > > Dumping DPDDC-B > > : > > 0000: 12 14 ffffffc4 01 01 00 01 00 02 02 06 00 00 00 02 > > 0070: 00 00 > > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > 0100: 14 ffffff84 00 06 06 06 06 00 01 04 00 > > 0200: 41 00 77 77 01 03 22 22 > > 0600: 01 > > 0700: 01 > > 0701: 00 00 00 00 > > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > > 0732: 00 00 > > > > DPCD DPDDC-C > > seems not available. skipping... > > Dumping DPDDC-A > > : > > 0000: 12 14 ffffff84 40 00 00 01 01 02 00 00 00 00 0b 00 > > 0070: 01 00 > > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > 0100: 14 04 00 00 00 00 00 00 00 00 00 > > 0200: 41 00 00 00 ffffff80 00 66 66 > > 0600: 01 > > 0700: 02 > > 0701: ffffff9f 40 00 00 > > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > > 0732: 00 00 > > > > Cc: Rafael Antognolli <rafael.antognolli@intel.com> > > Cc: Jani Nikula <jani.nikula@intel.com> > > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> > > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> > > --- > > tools/Makefile.sources | 1 + > > tools/dpcd_dump.c | 152 +++++++++++++++++++++++++++++++++++++++++ > > tools/meson.build | 1 + > > 3 files changed, 154 insertions(+) > > create mode 100644 tools/dpcd_dump.c > > > > diff --git a/tools/Makefile.sources b/tools/Makefile.sources > > index abd23a0f..f4921f83 100644 > > --- a/tools/Makefile.sources > > +++ b/tools/Makefile.sources > > @@ -6,6 +6,7 @@ noinst_PROGRAMS = \ > > $(NULL) > > > > tools_prog_lists = \ > > + dpcd_dump \ > > igt_stats \ > > intel_audio_dump \ > > intel_reg \ > > diff --git a/tools/dpcd_dump.c b/tools/dpcd_dump.c > > new file mode 100644 > > index 00000000..1b989e53 > > --- /dev/null > > +++ b/tools/dpcd_dump.c > > @@ -0,0 +1,152 @@ > > +/* > > + * Copyright © 2018 Intel Corporation > > + * > > + * Permission is hereby granted, free of charge, to any person obtaining a > > + * copy of this software and associated documentation files (the "Software"), > > + * to deal in the Software without restriction, including without limitation > > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > > + * and/or sell copies of the Software, and to permit persons to whom the > > + * Software is furnished to do so, subject to the following conditions: > > + * > > + * The above copyright notice and this permission notice (including the next > > + * paragraph) shall be included in all copies or substantial portions of the > > + * Software. > > + * > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS > > + * IN THE SOFTWARE. > > + * > > + */ > > + > > +#include <stdio.h> > > +#include <stdlib.h> > > +#include <unistd.h> > > +#include <sys/types.h> > > +#include <sys/stat.h> > > +#include <fcntl.h> > > +#include <dirent.h> > > +#include <string.h> > > + > > +struct dpcd_block { > > + /* DPCD dump start address. */ > > + unsigned int offset; > > + /* DPCD dump size. If unset, defaults to 1. */ > > + size_t size; > > +}; > > + > > +static const struct dpcd_block dpcd_dump[] = { > > + /* DP_DPCD_REV */ > > + { .offset = 0, .size = 15 }, > > + /* DP_PSR_SUPPORT to DP_PSR_CAPS*/ > > + { .offset = 0x70, .size = 2 }, > > + /* DP_DOWNSTREAM_PORT_0 */ > > + { .offset = 0x80, .size = 16 }, > > + /* DP_LINK_BW_SET to DP_EDP_CONFIGURATION_SET */ > > + { .offset = 0x100, .size = 11 }, > > + /* DP_SINK_COUNT to DP_ADJUST_REQUEST_LANE2_3 */ > > + { .offset = 0x200, .size = 8 }, > > + /* DP_SET_POWER */ > > + { .offset = 0x600 }, > > + /* DP_EDP_DPCD_REV */ > > + { .offset = 0x700 }, > > + /* DP_EDP_GENERAL_CAP_1 to DP_EDP_GENERAL_CAP_3 */ > > + { .offset = 0x701, .size = 4 }, > > + /* DP_EDP_DISPLAY_CONTROL_REGISTER to DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB */ > > + { .offset = 0x720, .size = 16}, > > + /* DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET to DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET */ > > + { .offset = 0x732, .size = 2 }, > > +}; > > + > > +void dump_all(int fd) > > +{ > > + int ret, i, j, size; > > + char buf[32]; > > + > > + for (i = 0; i < sizeof(dpcd_dump) / sizeof(dpcd_dump[0]); i++) { > > + ret = lseek(fd, dpcd_dump[i].offset, SEEK_SET); > > + if (ret < 0) { > > + fprintf(stderr, "lseek to %04x failed!\n", dpcd_dump[i].offset); > > + return; > > + } > > + > > + size = dpcd_dump[i].size ? dpcd_dump[i].size: 1; > > + printf("%04x: ", dpcd_dump[i].offset); > > + ret = read(fd, &buf, size); > > + if (ret < 0) { > > + fprintf(stderr, "read of %d bytes to %04x failed!\n", size, dpcd_dump[i].offset); > > + return; > > + } > > + > > + for (j = 0; j < size; j++) > > + printf(" %02x", buf[j]); > > + printf("\n"); > > + } > > +} > > + > > +int main(int argc, char **argv) > > +{ > > + struct dirent *dirent; > > + DIR *dir; > > + char dev_path[PATH_MAX]; > > + char sysfs_path[PATH_MAX]; > > + int dev_fd, sysfs_fd, ret = 0; > > + char dpcd_name[8]; > > + char discard; > > + > > + dir = opendir("/sys/class/drm_dp_aux_dev/"); > > + if (!dir) { > > + fprintf(stderr, "fail to read /dev\n"); > > + return -1; > > + } > > + > > + while ((dirent = readdir(dir))) { > > + if (strncmp(dirent->d_name, "drm_dp_aux", 10) == 0) { > > + sprintf(dev_path, "/dev/%s", dirent->d_name); > > + sprintf(sysfs_path, "/sys/class/drm_dp_aux_dev/%s/name", > > + dirent->d_name); > > + > > + sysfs_fd = open(sysfs_path, O_RDONLY); > > + if (sysfs_fd < 0) { > > + fprintf(stderr,"fail to open %s\n", sysfs_path); > > + continue; > > + } > > + > > + dev_fd = open(dev_path, O_RDONLY); > > + if (dev_fd < 0) { > > + fprintf(stderr,"fail to open %s\n", dev_path); > > + continue; > > + } > > + > > + ret = read(sysfs_fd, &dpcd_name, sizeof(dpcd_name)); > > + if (ret < 0) { > > + fprintf(stderr, "fail to read dpcd name from %s\n\n", sysfs_path); > > + continue; > > + } > > + dpcd_name[ret] = '\0'; > > + > > + /* Dummy read to check if dpcd is available */ > > + ret = read(dev_fd, &discard, 1); > > + if (ret != 1) { > > + fprintf(stderr, "DPCD %s seems not available. skipping...\n", dpcd_name); > > + continue; > > + } > > + > > + printf("Dumping %s:\n", dpcd_name); > > + dump_all(dev_fd); > > + printf("\n"); > > + > > + > > + > > + close(sysfs_fd); > > + close(dev_fd); > > + } > > + } > > + > > + closedir(dir); > > + > > + return 0; > > +} > > diff --git a/tools/meson.build b/tools/meson.build > > index e4517d66..3326a5a7 100644 > > --- a/tools/meson.build > > +++ b/tools/meson.build > > @@ -14,6 +14,7 @@ endforeach > > tools_progs = [ > > # FIXME we already have a libtestcase with this name as target > > #'igt_stats', > > + 'dpcd_dump', > > 'intel_audio_dump', > > 'intel_backlight', > > 'intel_bios_dumper', > > -- > Jani Nikula, Intel Open Source Graphics Center _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT. 2018-08-21 14:58 ` Rodrigo Vivi @ 2018-08-22 10:35 ` Jani Nikula 2018-08-22 16:16 ` Rodrigo Vivi 0 siblings, 1 reply; 9+ messages in thread From: Jani Nikula @ 2018-08-22 10:35 UTC (permalink / raw) To: Rodrigo Vivi; +Cc: igt-dev, Rafael Antognolli, Dhinakaran Pandiyan On Tue, 21 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: > On Tue, Aug 21, 2018 at 10:42:35AM +0300, Jani Nikula wrote: >> On Mon, 20 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: >> > The idea is to remove the dump from i915's debugfs, but >> > before we need to be able to keep the current debug dpcd list >> > and IGT seems a good place to have some flexibility. >> >> See also [1]. I'm not sure what the status is now. Tarun? > > oh, I had missed that, sorry. > I now remember Tarun and DK talking about that but I had forgotten... > >> >> I don't think we should have both as separate binaries. > > I agree! Tarun, feel free to get my dump functions and merge to your > work. > > maybe my one could be default behaviour of yours when no condition > is giving. > > My idea is to start with the current dump that we have in debugfs > and later to expand that to be more generic like in a txt list like > we have for intel_reg. And now we're going full circle wrt the discussion in [1]. If we bolted dpcd access to intel_reg directly, we'd get all of that for free... BR, Jani. > > Thanks, > Rodrigo. > >> >> BR, >> Jani. >> >> >> [1] http://patchwork.freedesktop.org/patch/msgid/20180614071141.144275-1-tarun.vyas@intel.com >> >> >> > >> > FIXME: fffff trash... >> > >> > Current debugfs: >> > >> > $ sudo cat /sys/kernel/debug/dri/0/DP-1/i915_dpcd >> > 0000: 12 14 c4 01 01 00 01 00 02 02 06 00 00 00 02 >> > 0070: 00 00 >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> > 0100: 14 84 00 06 06 06 06 00 01 04 00 >> > 0200: 41 00 77 77 01 03 22 22 >> > 0600: 01 >> > 0700: 01 >> > 0701: 00 00 00 00 >> > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 >> > 0732: 00 00 >> > >> > $ sudo cat /sys/kernel/debug/dri/0/eDP-1/i915_dpcd >> > 0000: 12 14 84 40 00 00 01 01 02 00 00 00 00 0b 00 >> > 0070: 01 00 >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> > 0100: 14 04 00 00 00 00 00 00 00 00 00 >> > 0200: 41 00 00 00 80 00 66 66 >> > 0600: 01 >> > 0700: 02 >> > 0701: 9f 40 00 00 >> > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 >> > 0732: 00 00 >> > >> > --------------------------------------------------------- >> > >> > Current dpcd_dump proposed here: >> > $ sudo ./build/tools/dpcd_dump >> > >> > Dumping DPDDC-B >> > : >> > 0000: 12 14 ffffffc4 01 01 00 01 00 02 02 06 00 00 00 02 >> > 0070: 00 00 >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> > 0100: 14 ffffff84 00 06 06 06 06 00 01 04 00 >> > 0200: 41 00 77 77 01 03 22 22 >> > 0600: 01 >> > 0700: 01 >> > 0701: 00 00 00 00 >> > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 >> > 0732: 00 00 >> > >> > DPCD DPDDC-C >> > seems not available. skipping... >> > Dumping DPDDC-A >> > : >> > 0000: 12 14 ffffff84 40 00 00 01 01 02 00 00 00 00 0b 00 >> > 0070: 01 00 >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> > 0100: 14 04 00 00 00 00 00 00 00 00 00 >> > 0200: 41 00 00 00 ffffff80 00 66 66 >> > 0600: 01 >> > 0700: 02 >> > 0701: ffffff9f 40 00 00 >> > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 >> > 0732: 00 00 >> > >> > Cc: Rafael Antognolli <rafael.antognolli@intel.com> >> > Cc: Jani Nikula <jani.nikula@intel.com> >> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> >> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> >> > --- >> > tools/Makefile.sources | 1 + >> > tools/dpcd_dump.c | 152 +++++++++++++++++++++++++++++++++++++++++ >> > tools/meson.build | 1 + >> > 3 files changed, 154 insertions(+) >> > create mode 100644 tools/dpcd_dump.c >> > >> > diff --git a/tools/Makefile.sources b/tools/Makefile.sources >> > index abd23a0f..f4921f83 100644 >> > --- a/tools/Makefile.sources >> > +++ b/tools/Makefile.sources >> > @@ -6,6 +6,7 @@ noinst_PROGRAMS = \ >> > $(NULL) >> > >> > tools_prog_lists = \ >> > + dpcd_dump \ >> > igt_stats \ >> > intel_audio_dump \ >> > intel_reg \ >> > diff --git a/tools/dpcd_dump.c b/tools/dpcd_dump.c >> > new file mode 100644 >> > index 00000000..1b989e53 >> > --- /dev/null >> > +++ b/tools/dpcd_dump.c >> > @@ -0,0 +1,152 @@ >> > +/* >> > + * Copyright © 2018 Intel Corporation >> > + * >> > + * Permission is hereby granted, free of charge, to any person obtaining a >> > + * copy of this software and associated documentation files (the "Software"), >> > + * to deal in the Software without restriction, including without limitation >> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, >> > + * and/or sell copies of the Software, and to permit persons to whom the >> > + * Software is furnished to do so, subject to the following conditions: >> > + * >> > + * The above copyright notice and this permission notice (including the next >> > + * paragraph) shall be included in all copies or substantial portions of the >> > + * Software. >> > + * >> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL >> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER >> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS >> > + * IN THE SOFTWARE. >> > + * >> > + */ >> > + >> > +#include <stdio.h> >> > +#include <stdlib.h> >> > +#include <unistd.h> >> > +#include <sys/types.h> >> > +#include <sys/stat.h> >> > +#include <fcntl.h> >> > +#include <dirent.h> >> > +#include <string.h> >> > + >> > +struct dpcd_block { >> > + /* DPCD dump start address. */ >> > + unsigned int offset; >> > + /* DPCD dump size. If unset, defaults to 1. */ >> > + size_t size; >> > +}; >> > + >> > +static const struct dpcd_block dpcd_dump[] = { >> > + /* DP_DPCD_REV */ >> > + { .offset = 0, .size = 15 }, >> > + /* DP_PSR_SUPPORT to DP_PSR_CAPS*/ >> > + { .offset = 0x70, .size = 2 }, >> > + /* DP_DOWNSTREAM_PORT_0 */ >> > + { .offset = 0x80, .size = 16 }, >> > + /* DP_LINK_BW_SET to DP_EDP_CONFIGURATION_SET */ >> > + { .offset = 0x100, .size = 11 }, >> > + /* DP_SINK_COUNT to DP_ADJUST_REQUEST_LANE2_3 */ >> > + { .offset = 0x200, .size = 8 }, >> > + /* DP_SET_POWER */ >> > + { .offset = 0x600 }, >> > + /* DP_EDP_DPCD_REV */ >> > + { .offset = 0x700 }, >> > + /* DP_EDP_GENERAL_CAP_1 to DP_EDP_GENERAL_CAP_3 */ >> > + { .offset = 0x701, .size = 4 }, >> > + /* DP_EDP_DISPLAY_CONTROL_REGISTER to DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB */ >> > + { .offset = 0x720, .size = 16}, >> > + /* DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET to DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET */ >> > + { .offset = 0x732, .size = 2 }, >> > +}; >> > + >> > +void dump_all(int fd) >> > +{ >> > + int ret, i, j, size; >> > + char buf[32]; >> > + >> > + for (i = 0; i < sizeof(dpcd_dump) / sizeof(dpcd_dump[0]); i++) { >> > + ret = lseek(fd, dpcd_dump[i].offset, SEEK_SET); >> > + if (ret < 0) { >> > + fprintf(stderr, "lseek to %04x failed!\n", dpcd_dump[i].offset); >> > + return; >> > + } >> > + >> > + size = dpcd_dump[i].size ? dpcd_dump[i].size: 1; >> > + printf("%04x: ", dpcd_dump[i].offset); >> > + ret = read(fd, &buf, size); >> > + if (ret < 0) { >> > + fprintf(stderr, "read of %d bytes to %04x failed!\n", size, dpcd_dump[i].offset); >> > + return; >> > + } >> > + >> > + for (j = 0; j < size; j++) >> > + printf(" %02x", buf[j]); >> > + printf("\n"); >> > + } >> > +} >> > + >> > +int main(int argc, char **argv) >> > +{ >> > + struct dirent *dirent; >> > + DIR *dir; >> > + char dev_path[PATH_MAX]; >> > + char sysfs_path[PATH_MAX]; >> > + int dev_fd, sysfs_fd, ret = 0; >> > + char dpcd_name[8]; >> > + char discard; >> > + >> > + dir = opendir("/sys/class/drm_dp_aux_dev/"); >> > + if (!dir) { >> > + fprintf(stderr, "fail to read /dev\n"); >> > + return -1; >> > + } >> > + >> > + while ((dirent = readdir(dir))) { >> > + if (strncmp(dirent->d_name, "drm_dp_aux", 10) == 0) { >> > + sprintf(dev_path, "/dev/%s", dirent->d_name); >> > + sprintf(sysfs_path, "/sys/class/drm_dp_aux_dev/%s/name", >> > + dirent->d_name); >> > + >> > + sysfs_fd = open(sysfs_path, O_RDONLY); >> > + if (sysfs_fd < 0) { >> > + fprintf(stderr,"fail to open %s\n", sysfs_path); >> > + continue; >> > + } >> > + >> > + dev_fd = open(dev_path, O_RDONLY); >> > + if (dev_fd < 0) { >> > + fprintf(stderr,"fail to open %s\n", dev_path); >> > + continue; >> > + } >> > + >> > + ret = read(sysfs_fd, &dpcd_name, sizeof(dpcd_name)); >> > + if (ret < 0) { >> > + fprintf(stderr, "fail to read dpcd name from %s\n\n", sysfs_path); >> > + continue; >> > + } >> > + dpcd_name[ret] = '\0'; >> > + >> > + /* Dummy read to check if dpcd is available */ >> > + ret = read(dev_fd, &discard, 1); >> > + if (ret != 1) { >> > + fprintf(stderr, "DPCD %s seems not available. skipping...\n", dpcd_name); >> > + continue; >> > + } >> > + >> > + printf("Dumping %s:\n", dpcd_name); >> > + dump_all(dev_fd); >> > + printf("\n"); >> > + >> > + >> > + >> > + close(sysfs_fd); >> > + close(dev_fd); >> > + } >> > + } >> > + >> > + closedir(dir); >> > + >> > + return 0; >> > +} >> > diff --git a/tools/meson.build b/tools/meson.build >> > index e4517d66..3326a5a7 100644 >> > --- a/tools/meson.build >> > +++ b/tools/meson.build >> > @@ -14,6 +14,7 @@ endforeach >> > tools_progs = [ >> > # FIXME we already have a libtestcase with this name as target >> > #'igt_stats', >> > + 'dpcd_dump', >> > 'intel_audio_dump', >> > 'intel_backlight', >> > 'intel_bios_dumper', >> >> -- >> Jani Nikula, Intel Open Source Graphics Center -- Jani Nikula, Intel Open Source Graphics Center _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT. 2018-08-22 10:35 ` Jani Nikula @ 2018-08-22 16:16 ` Rodrigo Vivi 2018-08-22 17:11 ` Pandiyan, Dhinakaran 0 siblings, 1 reply; 9+ messages in thread From: Rodrigo Vivi @ 2018-08-22 16:16 UTC (permalink / raw) To: Jani Nikula; +Cc: igt-dev, Rafael Antognolli, Dhinakaran Pandiyan On Wed, Aug 22, 2018 at 01:35:09PM +0300, Jani Nikula wrote: > On Tue, 21 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: > > On Tue, Aug 21, 2018 at 10:42:35AM +0300, Jani Nikula wrote: > >> On Mon, 20 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: > >> > The idea is to remove the dump from i915's debugfs, but > >> > before we need to be able to keep the current debug dpcd list > >> > and IGT seems a good place to have some flexibility. > >> > >> See also [1]. I'm not sure what the status is now. Tarun? > > > > oh, I had missed that, sorry. > > I now remember Tarun and DK talking about that but I had forgotten... > > > >> > >> I don't think we should have both as separate binaries. > > > > I agree! Tarun, feel free to get my dump functions and merge to your > > work. > > > > maybe my one could be default behaviour of yours when no condition > > is giving. > > > > My idea is to start with the current dump that we have in debugfs > > and later to expand that to be more generic like in a txt list like > > we have for intel_reg. > > And now we're going full circle wrt the discussion in [1]. If we bolted > dpcd access to intel_reg directly, we'd get all of that for free... nah! my bad for missing that discussion... sorry yeah, this is a good point... but on the other hand I'm not sure if I like *intel*_reg to read dpcd, specially with IGT nowadays standing for IGT is GPU Tools ;) so, what about moving core of intel_reg to some common library and intel_reg gets used only for intel regs and dpcd_reg for dpcd generically? > > BR, > Jani. > > > > > > > > Thanks, > > Rodrigo. > > > >> > >> BR, > >> Jani. > >> > >> > >> [1] http://patchwork.freedesktop.org/patch/msgid/20180614071141.144275-1-tarun.vyas@intel.com > >> > >> > >> > > >> > FIXME: fffff trash... > >> > > >> > Current debugfs: > >> > > >> > $ sudo cat /sys/kernel/debug/dri/0/DP-1/i915_dpcd > >> > 0000: 12 14 c4 01 01 00 01 00 02 02 06 00 00 00 02 > >> > 0070: 00 00 > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >> > 0100: 14 84 00 06 06 06 06 00 01 04 00 > >> > 0200: 41 00 77 77 01 03 22 22 > >> > 0600: 01 > >> > 0700: 01 > >> > 0701: 00 00 00 00 > >> > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > >> > 0732: 00 00 > >> > > >> > $ sudo cat /sys/kernel/debug/dri/0/eDP-1/i915_dpcd > >> > 0000: 12 14 84 40 00 00 01 01 02 00 00 00 00 0b 00 > >> > 0070: 01 00 > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >> > 0100: 14 04 00 00 00 00 00 00 00 00 00 > >> > 0200: 41 00 00 00 80 00 66 66 > >> > 0600: 01 > >> > 0700: 02 > >> > 0701: 9f 40 00 00 > >> > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > >> > 0732: 00 00 > >> > > >> > --------------------------------------------------------- > >> > > >> > Current dpcd_dump proposed here: > >> > $ sudo ./build/tools/dpcd_dump > >> > > >> > Dumping DPDDC-B > >> > : > >> > 0000: 12 14 ffffffc4 01 01 00 01 00 02 02 06 00 00 00 02 > >> > 0070: 00 00 > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >> > 0100: 14 ffffff84 00 06 06 06 06 00 01 04 00 > >> > 0200: 41 00 77 77 01 03 22 22 > >> > 0600: 01 > >> > 0700: 01 > >> > 0701: 00 00 00 00 > >> > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > >> > 0732: 00 00 > >> > > >> > DPCD DPDDC-C > >> > seems not available. skipping... > >> > Dumping DPDDC-A > >> > : > >> > 0000: 12 14 ffffff84 40 00 00 01 01 02 00 00 00 00 0b 00 > >> > 0070: 01 00 > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >> > 0100: 14 04 00 00 00 00 00 00 00 00 00 > >> > 0200: 41 00 00 00 ffffff80 00 66 66 > >> > 0600: 01 > >> > 0700: 02 > >> > 0701: ffffff9f 40 00 00 > >> > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > >> > 0732: 00 00 > >> > > >> > Cc: Rafael Antognolli <rafael.antognolli@intel.com> > >> > Cc: Jani Nikula <jani.nikula@intel.com> > >> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> > >> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> > >> > --- > >> > tools/Makefile.sources | 1 + > >> > tools/dpcd_dump.c | 152 +++++++++++++++++++++++++++++++++++++++++ > >> > tools/meson.build | 1 + > >> > 3 files changed, 154 insertions(+) > >> > create mode 100644 tools/dpcd_dump.c > >> > > >> > diff --git a/tools/Makefile.sources b/tools/Makefile.sources > >> > index abd23a0f..f4921f83 100644 > >> > --- a/tools/Makefile.sources > >> > +++ b/tools/Makefile.sources > >> > @@ -6,6 +6,7 @@ noinst_PROGRAMS = \ > >> > $(NULL) > >> > > >> > tools_prog_lists = \ > >> > + dpcd_dump \ > >> > igt_stats \ > >> > intel_audio_dump \ > >> > intel_reg \ > >> > diff --git a/tools/dpcd_dump.c b/tools/dpcd_dump.c > >> > new file mode 100644 > >> > index 00000000..1b989e53 > >> > --- /dev/null > >> > +++ b/tools/dpcd_dump.c > >> > @@ -0,0 +1,152 @@ > >> > +/* > >> > + * Copyright © 2018 Intel Corporation > >> > + * > >> > + * Permission is hereby granted, free of charge, to any person obtaining a > >> > + * copy of this software and associated documentation files (the "Software"), > >> > + * to deal in the Software without restriction, including without limitation > >> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > >> > + * and/or sell copies of the Software, and to permit persons to whom the > >> > + * Software is furnished to do so, subject to the following conditions: > >> > + * > >> > + * The above copyright notice and this permission notice (including the next > >> > + * paragraph) shall be included in all copies or substantial portions of the > >> > + * Software. > >> > + * > >> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > >> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > >> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > >> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > >> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > >> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS > >> > + * IN THE SOFTWARE. > >> > + * > >> > + */ > >> > + > >> > +#include <stdio.h> > >> > +#include <stdlib.h> > >> > +#include <unistd.h> > >> > +#include <sys/types.h> > >> > +#include <sys/stat.h> > >> > +#include <fcntl.h> > >> > +#include <dirent.h> > >> > +#include <string.h> > >> > + > >> > +struct dpcd_block { > >> > + /* DPCD dump start address. */ > >> > + unsigned int offset; > >> > + /* DPCD dump size. If unset, defaults to 1. */ > >> > + size_t size; > >> > +}; > >> > + > >> > +static const struct dpcd_block dpcd_dump[] = { > >> > + /* DP_DPCD_REV */ > >> > + { .offset = 0, .size = 15 }, > >> > + /* DP_PSR_SUPPORT to DP_PSR_CAPS*/ > >> > + { .offset = 0x70, .size = 2 }, > >> > + /* DP_DOWNSTREAM_PORT_0 */ > >> > + { .offset = 0x80, .size = 16 }, > >> > + /* DP_LINK_BW_SET to DP_EDP_CONFIGURATION_SET */ > >> > + { .offset = 0x100, .size = 11 }, > >> > + /* DP_SINK_COUNT to DP_ADJUST_REQUEST_LANE2_3 */ > >> > + { .offset = 0x200, .size = 8 }, > >> > + /* DP_SET_POWER */ > >> > + { .offset = 0x600 }, > >> > + /* DP_EDP_DPCD_REV */ > >> > + { .offset = 0x700 }, > >> > + /* DP_EDP_GENERAL_CAP_1 to DP_EDP_GENERAL_CAP_3 */ > >> > + { .offset = 0x701, .size = 4 }, > >> > + /* DP_EDP_DISPLAY_CONTROL_REGISTER to DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB */ > >> > + { .offset = 0x720, .size = 16}, > >> > + /* DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET to DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET */ > >> > + { .offset = 0x732, .size = 2 }, > >> > +}; > >> > + > >> > +void dump_all(int fd) > >> > +{ > >> > + int ret, i, j, size; > >> > + char buf[32]; > >> > + > >> > + for (i = 0; i < sizeof(dpcd_dump) / sizeof(dpcd_dump[0]); i++) { > >> > + ret = lseek(fd, dpcd_dump[i].offset, SEEK_SET); > >> > + if (ret < 0) { > >> > + fprintf(stderr, "lseek to %04x failed!\n", dpcd_dump[i].offset); > >> > + return; > >> > + } > >> > + > >> > + size = dpcd_dump[i].size ? dpcd_dump[i].size: 1; > >> > + printf("%04x: ", dpcd_dump[i].offset); > >> > + ret = read(fd, &buf, size); > >> > + if (ret < 0) { > >> > + fprintf(stderr, "read of %d bytes to %04x failed!\n", size, dpcd_dump[i].offset); > >> > + return; > >> > + } > >> > + > >> > + for (j = 0; j < size; j++) > >> > + printf(" %02x", buf[j]); > >> > + printf("\n"); > >> > + } > >> > +} > >> > + > >> > +int main(int argc, char **argv) > >> > +{ > >> > + struct dirent *dirent; > >> > + DIR *dir; > >> > + char dev_path[PATH_MAX]; > >> > + char sysfs_path[PATH_MAX]; > >> > + int dev_fd, sysfs_fd, ret = 0; > >> > + char dpcd_name[8]; > >> > + char discard; > >> > + > >> > + dir = opendir("/sys/class/drm_dp_aux_dev/"); > >> > + if (!dir) { > >> > + fprintf(stderr, "fail to read /dev\n"); > >> > + return -1; > >> > + } > >> > + > >> > + while ((dirent = readdir(dir))) { > >> > + if (strncmp(dirent->d_name, "drm_dp_aux", 10) == 0) { > >> > + sprintf(dev_path, "/dev/%s", dirent->d_name); > >> > + sprintf(sysfs_path, "/sys/class/drm_dp_aux_dev/%s/name", > >> > + dirent->d_name); > >> > + > >> > + sysfs_fd = open(sysfs_path, O_RDONLY); > >> > + if (sysfs_fd < 0) { > >> > + fprintf(stderr,"fail to open %s\n", sysfs_path); > >> > + continue; > >> > + } > >> > + > >> > + dev_fd = open(dev_path, O_RDONLY); > >> > + if (dev_fd < 0) { > >> > + fprintf(stderr,"fail to open %s\n", dev_path); > >> > + continue; > >> > + } > >> > + > >> > + ret = read(sysfs_fd, &dpcd_name, sizeof(dpcd_name)); > >> > + if (ret < 0) { > >> > + fprintf(stderr, "fail to read dpcd name from %s\n\n", sysfs_path); > >> > + continue; > >> > + } > >> > + dpcd_name[ret] = '\0'; > >> > + > >> > + /* Dummy read to check if dpcd is available */ > >> > + ret = read(dev_fd, &discard, 1); > >> > + if (ret != 1) { > >> > + fprintf(stderr, "DPCD %s seems not available. skipping...\n", dpcd_name); > >> > + continue; > >> > + } > >> > + > >> > + printf("Dumping %s:\n", dpcd_name); > >> > + dump_all(dev_fd); > >> > + printf("\n"); > >> > + > >> > + > >> > + > >> > + close(sysfs_fd); > >> > + close(dev_fd); > >> > + } > >> > + } > >> > + > >> > + closedir(dir); > >> > + > >> > + return 0; > >> > +} > >> > diff --git a/tools/meson.build b/tools/meson.build > >> > index e4517d66..3326a5a7 100644 > >> > --- a/tools/meson.build > >> > +++ b/tools/meson.build > >> > @@ -14,6 +14,7 @@ endforeach > >> > tools_progs = [ > >> > # FIXME we already have a libtestcase with this name as target > >> > #'igt_stats', > >> > + 'dpcd_dump', > >> > 'intel_audio_dump', > >> > 'intel_backlight', > >> > 'intel_bios_dumper', > >> > >> -- > >> Jani Nikula, Intel Open Source Graphics Center > > -- > Jani Nikula, Intel Open Source Graphics Center > _______________________________________________ > igt-dev mailing list > igt-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/igt-dev _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT. 2018-08-22 16:16 ` Rodrigo Vivi @ 2018-08-22 17:11 ` Pandiyan, Dhinakaran 2018-08-27 22:26 ` Tarun Vyas 0 siblings, 1 reply; 9+ messages in thread From: Pandiyan, Dhinakaran @ 2018-08-22 17:11 UTC (permalink / raw) To: Vivi, Rodrigo, Nikula, Jani Cc: igt-dev@lists.freedesktop.org, Antognolli, Rafael > -----Original Message----- > From: Vivi, Rodrigo > Sent: Wednesday, August 22, 2018 9:17 AM > To: Nikula, Jani <jani.nikula@intel.com> > Cc: igt-dev@lists.freedesktop.org; Antognolli, Rafael > <rafael.antognolli@intel.com>; Pandiyan, Dhinakaran > <dhinakaran.pandiyan@intel.com> > Subject: Re: [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT. > > On Wed, Aug 22, 2018 at 01:35:09PM +0300, Jani Nikula wrote: > > On Tue, 21 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: > > > On Tue, Aug 21, 2018 at 10:42:35AM +0300, Jani Nikula wrote: > > >> On Mon, 20 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: > > >> > The idea is to remove the dump from i915's debugfs, but before we > > >> > need to be able to keep the current debug dpcd list and IGT seems > > >> > a good place to have some flexibility. > > >> > > >> See also [1]. I'm not sure what the status is now. Tarun? > > > > > > oh, I had missed that, sorry. > > > I now remember Tarun and DK talking about that but I had forgotten... > > > > > >> > > >> I don't think we should have both as separate binaries. > > > > > > I agree! Tarun, feel free to get my dump functions and merge to your > > > work. > > > > > > maybe my one could be default behaviour of yours when no condition > > > is giving. > > > > > > My idea is to start with the current dump that we have in debugfs > > > and later to expand that to be more generic like in a txt list like > > > we have for intel_reg. > > > > And now we're going full circle wrt the discussion in [1]. If we > > bolted dpcd access to intel_reg directly, we'd get all of that for free... > > nah! my bad for missing that discussion... sorry > > yeah, this is a good point... > > but on the other hand I'm not sure if I like *intel*_reg to read dpcd, specially with > IGT nowadays standing for IGT is GPU Tools ;) > > so, what about moving core of intel_reg to some common library and intel_reg > gets used only for intel regs and dpcd_reg for dpcd generically? > Yeah, that was the plan we'd discussed. The idea was to get dpcd_reg --read, --write merged first and then later implement --decode. -DK > > > > BR, > > Jani. > > > > > > > > > > > > > > Thanks, > > > Rodrigo. > > > > > >> > > >> BR, > > >> Jani. > > >> > > >> > > >> [1] > > >> http://patchwork.freedesktop.org/patch/msgid/20180614071141.144275- > > >> 1-tarun.vyas@intel.com > > >> > > >> > > >> > > > >> > FIXME: fffff trash... > > >> > > > >> > Current debugfs: > > >> > > > >> > $ sudo cat /sys/kernel/debug/dri/0/DP-1/i915_dpcd > > >> > 0000: 12 14 c4 01 01 00 01 00 02 02 06 00 00 00 02 > > >> > 0070: 00 00 > > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > >> > 0100: 14 84 00 06 06 06 06 00 01 04 00 > > >> > 0200: 41 00 77 77 01 03 22 22 > > >> > 0600: 01 > > >> > 0700: 01 > > >> > 0701: 00 00 00 00 > > >> > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > > >> > 0732: 00 00 > > >> > > > >> > $ sudo cat /sys/kernel/debug/dri/0/eDP-1/i915_dpcd > > >> > 0000: 12 14 84 40 00 00 01 01 02 00 00 00 00 0b 00 > > >> > 0070: 01 00 > > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > >> > 0100: 14 04 00 00 00 00 00 00 00 00 00 > > >> > 0200: 41 00 00 00 80 00 66 66 > > >> > 0600: 01 > > >> > 0700: 02 > > >> > 0701: 9f 40 00 00 > > >> > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > > >> > 0732: 00 00 > > >> > > > >> > --------------------------------------------------------- > > >> > > > >> > Current dpcd_dump proposed here: > > >> > $ sudo ./build/tools/dpcd_dump > > >> > > > >> > Dumping DPDDC-B > > >> > : > > >> > 0000: 12 14 ffffffc4 01 01 00 01 00 02 02 06 00 00 00 02 > > >> > 0070: 00 00 > > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > >> > 0100: 14 ffffff84 00 06 06 06 06 00 01 04 00 > > >> > 0200: 41 00 77 77 01 03 22 22 > > >> > 0600: 01 > > >> > 0700: 01 > > >> > 0701: 00 00 00 00 > > >> > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > > >> > 0732: 00 00 > > >> > > > >> > DPCD DPDDC-C > > >> > seems not available. skipping... > > >> > Dumping DPDDC-A > > >> > : > > >> > 0000: 12 14 ffffff84 40 00 00 01 01 02 00 00 00 00 0b 00 > > >> > 0070: 01 00 > > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > >> > 0100: 14 04 00 00 00 00 00 00 00 00 00 > > >> > 0200: 41 00 00 00 ffffff80 00 66 66 > > >> > 0600: 01 > > >> > 0700: 02 > > >> > 0701: ffffff9f 40 00 00 > > >> > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > > >> > 0732: 00 00 > > >> > > > >> > Cc: Rafael Antognolli <rafael.antognolli@intel.com> > > >> > Cc: Jani Nikula <jani.nikula@intel.com> > > >> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> > > >> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> > > >> > --- > > >> > tools/Makefile.sources | 1 + > > >> > tools/dpcd_dump.c | 152 > +++++++++++++++++++++++++++++++++++++++++ > > >> > tools/meson.build | 1 + > > >> > 3 files changed, 154 insertions(+) create mode 100644 > > >> > tools/dpcd_dump.c > > >> > > > >> > diff --git a/tools/Makefile.sources b/tools/Makefile.sources > > >> > index abd23a0f..f4921f83 100644 > > >> > --- a/tools/Makefile.sources > > >> > +++ b/tools/Makefile.sources > > >> > @@ -6,6 +6,7 @@ noinst_PROGRAMS = \ > > >> > $(NULL) > > >> > > > >> > tools_prog_lists = \ > > >> > + dpcd_dump \ > > >> > igt_stats \ > > >> > intel_audio_dump \ > > >> > intel_reg \ > > >> > diff --git a/tools/dpcd_dump.c b/tools/dpcd_dump.c new file mode > > >> > 100644 index 00000000..1b989e53 > > >> > --- /dev/null > > >> > +++ b/tools/dpcd_dump.c > > >> > @@ -0,0 +1,152 @@ > > >> > +/* > > >> > + * Copyright (c) 2018 Intel Corporation > > >> > + * > > >> > + * Permission is hereby granted, free of charge, to any person > > >> > +obtaining a > > >> > + * copy of this software and associated documentation files (the > > >> > +"Software"), > > >> > + * to deal in the Software without restriction, including > > >> > +without limitation > > >> > + * the rights to use, copy, modify, merge, publish, distribute, > > >> > +sublicense, > > >> > + * and/or sell copies of the Software, and to permit persons to > > >> > +whom the > > >> > + * Software is furnished to do so, subject to the following conditions: > > >> > + * > > >> > + * The above copyright notice and this permission notice > > >> > +(including the next > > >> > + * paragraph) shall be included in all copies or substantial > > >> > +portions of the > > >> > + * Software. > > >> > + * > > >> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY > > >> > +KIND, EXPRESS OR > > >> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > > >> > +MERCHANTABILITY, > > >> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN > NO > > >> > +EVENT SHALL > > >> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, > > >> > +DAMAGES OR OTHER > > >> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR > > >> > +OTHERWISE, ARISING > > >> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE > OR > > >> > +OTHER DEALINGS > > >> > + * IN THE SOFTWARE. > > >> > + * > > >> > + */ > > >> > + > > >> > +#include <stdio.h> > > >> > +#include <stdlib.h> > > >> > +#include <unistd.h> > > >> > +#include <sys/types.h> > > >> > +#include <sys/stat.h> > > >> > +#include <fcntl.h> > > >> > +#include <dirent.h> > > >> > +#include <string.h> > > >> > + > > >> > +struct dpcd_block { > > >> > + /* DPCD dump start address. */ > > >> > + unsigned int offset; > > >> > + /* DPCD dump size. If unset, defaults to 1. */ > > >> > + size_t size; > > >> > +}; > > >> > + > > >> > +static const struct dpcd_block dpcd_dump[] = { > > >> > + /* DP_DPCD_REV */ > > >> > + { .offset = 0, .size = 15 }, > > >> > + /* DP_PSR_SUPPORT to DP_PSR_CAPS*/ > > >> > + { .offset = 0x70, .size = 2 }, > > >> > + /* DP_DOWNSTREAM_PORT_0 */ > > >> > + { .offset = 0x80, .size = 16 }, > > >> > + /* DP_LINK_BW_SET to DP_EDP_CONFIGURATION_SET */ > > >> > + { .offset = 0x100, .size = 11 }, > > >> > + /* DP_SINK_COUNT to DP_ADJUST_REQUEST_LANE2_3 */ > > >> > + { .offset = 0x200, .size = 8 }, > > >> > + /* DP_SET_POWER */ > > >> > + { .offset = 0x600 }, > > >> > + /* DP_EDP_DPCD_REV */ > > >> > + { .offset = 0x700 }, > > >> > + /* DP_EDP_GENERAL_CAP_1 to DP_EDP_GENERAL_CAP_3 */ > > >> > + { .offset = 0x701, .size = 4 }, > > >> > + /* DP_EDP_DISPLAY_CONTROL_REGISTER to > DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB */ > > >> > + { .offset = 0x720, .size = 16}, > > >> > + /* DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET to > DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET */ > > >> > + { .offset = 0x732, .size = 2 }, }; > > >> > + > > >> > +void dump_all(int fd) > > >> > +{ > > >> > + int ret, i, j, size; > > >> > + char buf[32]; > > >> > + > > >> > + for (i = 0; i < sizeof(dpcd_dump) / sizeof(dpcd_dump[0]); i++) { > > >> > + ret = lseek(fd, dpcd_dump[i].offset, SEEK_SET); > > >> > + if (ret < 0) { > > >> > + fprintf(stderr, "lseek to %04x failed!\n", > dpcd_dump[i].offset); > > >> > + return; > > >> > + } > > >> > + > > >> > + size = dpcd_dump[i].size ? dpcd_dump[i].size: 1; > > >> > + printf("%04x: ", dpcd_dump[i].offset); > > >> > + ret = read(fd, &buf, size); > > >> > + if (ret < 0) { > > >> > + fprintf(stderr, "read of %d bytes to %04x failed!\n", size, > dpcd_dump[i].offset); > > >> > + return; > > >> > + } > > >> > + > > >> > + for (j = 0; j < size; j++) > > >> > + printf(" %02x", buf[j]); > > >> > + printf("\n"); > > >> > + } > > >> > +} > > >> > + > > >> > +int main(int argc, char **argv) > > >> > +{ > > >> > + struct dirent *dirent; > > >> > + DIR *dir; > > >> > + char dev_path[PATH_MAX]; > > >> > + char sysfs_path[PATH_MAX]; > > >> > + int dev_fd, sysfs_fd, ret = 0; > > >> > + char dpcd_name[8]; > > >> > + char discard; > > >> > + > > >> > + dir = opendir("/sys/class/drm_dp_aux_dev/"); > > >> > + if (!dir) { > > >> > + fprintf(stderr, "fail to read /dev\n"); > > >> > + return -1; > > >> > + } > > >> > + > > >> > + while ((dirent = readdir(dir))) { > > >> > + if (strncmp(dirent->d_name, "drm_dp_aux", 10) == 0) { > > >> > + sprintf(dev_path, "/dev/%s", dirent->d_name); > > >> > + sprintf(sysfs_path, > "/sys/class/drm_dp_aux_dev/%s/name", > > >> > + dirent->d_name); > > >> > + > > >> > + sysfs_fd = open(sysfs_path, O_RDONLY); > > >> > + if (sysfs_fd < 0) { > > >> > + fprintf(stderr,"fail to open %s\n", sysfs_path); > > >> > + continue; > > >> > + } > > >> > + > > >> > + dev_fd = open(dev_path, O_RDONLY); > > >> > + if (dev_fd < 0) { > > >> > + fprintf(stderr,"fail to open %s\n", dev_path); > > >> > + continue; > > >> > + } > > >> > + > > >> > + ret = read(sysfs_fd, &dpcd_name, sizeof(dpcd_name)); > > >> > + if (ret < 0) { > > >> > + fprintf(stderr, "fail to read dpcd name from > %s\n\n", sysfs_path); > > >> > + continue; > > >> > + } > > >> > + dpcd_name[ret] = '\0'; > > >> > + > > >> > + /* Dummy read to check if dpcd is available */ > > >> > + ret = read(dev_fd, &discard, 1); > > >> > + if (ret != 1) { > > >> > + fprintf(stderr, "DPCD %s seems not available. > skipping...\n", dpcd_name); > > >> > + continue; > > >> > + } > > >> > + > > >> > + printf("Dumping %s:\n", dpcd_name); > > >> > + dump_all(dev_fd); > > >> > + printf("\n"); > > >> > + > > >> > + > > >> > + > > >> > + close(sysfs_fd); > > >> > + close(dev_fd); > > >> > + } > > >> > + } > > >> > + > > >> > + closedir(dir); > > >> > + > > >> > + return 0; > > >> > +} > > >> > diff --git a/tools/meson.build b/tools/meson.build index > > >> > e4517d66..3326a5a7 100644 > > >> > --- a/tools/meson.build > > >> > +++ b/tools/meson.build > > >> > @@ -14,6 +14,7 @@ endforeach > > >> > tools_progs = [ > > >> > # FIXME we already have a libtestcase with this name as target > > >> > #'igt_stats', > > >> > + 'dpcd_dump', > > >> > 'intel_audio_dump', > > >> > 'intel_backlight', > > >> > 'intel_bios_dumper', > > >> > > >> -- > > >> Jani Nikula, Intel Open Source Graphics Center > > > > -- > > Jani Nikula, Intel Open Source Graphics Center > > _______________________________________________ > > igt-dev mailing list > > igt-dev@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/igt-dev _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT. 2018-08-22 17:11 ` Pandiyan, Dhinakaran @ 2018-08-27 22:26 ` Tarun Vyas 0 siblings, 0 replies; 9+ messages in thread From: Tarun Vyas @ 2018-08-27 22:26 UTC (permalink / raw) To: Pandiyan, Dhinakaran Cc: Nikula, Jani, igt-dev@lists.freedesktop.org, Antognolli, Rafael, Vivi, Rodrigo On Wed, Aug 22, 2018 at 10:11:54AM -0700, Pandiyan, Dhinakaran wrote: Hi Guys, > > > > -----Original Message----- > > From: Vivi, Rodrigo > > Sent: Wednesday, August 22, 2018 9:17 AM > > To: Nikula, Jani <jani.nikula@intel.com> > > Cc: igt-dev@lists.freedesktop.org; Antognolli, Rafael > > <rafael.antognolli@intel.com>; Pandiyan, Dhinakaran > > <dhinakaran.pandiyan@intel.com> > > Subject: Re: [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT. > > > > On Wed, Aug 22, 2018 at 01:35:09PM +0300, Jani Nikula wrote: > > > On Tue, 21 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: > > > > On Tue, Aug 21, 2018 at 10:42:35AM +0300, Jani Nikula wrote: > > > >> On Mon, 20 Aug 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote: > > > >> > The idea is to remove the dump from i915's debugfs, but before we > > > >> > need to be able to keep the current debug dpcd list and IGT seems > > > >> > a good place to have some flexibility. > > > >> > > > >> See also [1]. I'm not sure what the status is now. Tarun? I addressed Ville's comments in the v2: https://patchwork.freedesktop.org/patch/229684/. This one dumps [n] bytes at a time, as specified by the user and can do byte writes. > > > > > > > > oh, I had missed that, sorry. > > > > I now remember Tarun and DK talking about that but I had forgotten... > > > > > > > >> > > > >> I don't think we should have both as separate binaries. > > > > > > > > I agree! Tarun, feel free to get my dump functions and merge to your > > > > work. As DK mentioned below, we planned to merge just the Read/Write first and then improve on that as we move on. So maybe we can make the dump as the default behavior in the follow up patches ? > > > > > > > > maybe my one could be default behaviour of yours when no condition > > > > is giving. > > > > > > > > My idea is to start with the current dump that we have in debugfs > > > > and later to expand that to be more generic like in a txt list like > > > > we have for intel_reg. > > > > > > And now we're going full circle wrt the discussion in [1]. If we > > > bolted dpcd access to intel_reg directly, we'd get all of that for free... > > > > nah! my bad for missing that discussion... sorry > > > > yeah, this is a good point... > > > > but on the other hand I'm not sure if I like *intel*_reg to read dpcd, specially with > > IGT nowadays standing for IGT is GPU Tools ;) > > > > so, what about moving core of intel_reg to some common library and intel_reg > > gets used only for intel regs and dpcd_reg for dpcd generically? > > > Yeah, that was the plan we'd discussed. The idea was to get dpcd_reg --read, --write > merged first and then later implement --decode. So if you guys are OK with Read [n] bytes/ Write, to start with then we can have https://patchwork.freedesktop.org/patch/229684/ reviewed and follow up with improvements. Please let me know how we want to move forward here. Thanks, Tarun > > -DK > > > > > > > BR, > > > Jani. > > > > > > > > > > > > > > > > > > > > Thanks, > > > > Rodrigo. > > > > > > > >> > > > >> BR, > > > >> Jani. > > > >> > > > >> > > > >> [1] > > > >> http://patchwork.freedesktop.org/patch/msgid/20180614071141.144275- > > > >> 1-tarun.vyas@intel.com > > > >> > > > >> > > > >> > > > > >> > FIXME: fffff trash... > > > >> > > > > >> > Current debugfs: > > > >> > > > > >> > $ sudo cat /sys/kernel/debug/dri/0/DP-1/i915_dpcd > > > >> > 0000: 12 14 c4 01 01 00 01 00 02 02 06 00 00 00 02 > > > >> > 0070: 00 00 > > > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > > >> > 0100: 14 84 00 06 06 06 06 00 01 04 00 > > > >> > 0200: 41 00 77 77 01 03 22 22 > > > >> > 0600: 01 > > > >> > 0700: 01 > > > >> > 0701: 00 00 00 00 > > > >> > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > > > >> > 0732: 00 00 > > > >> > > > > >> > $ sudo cat /sys/kernel/debug/dri/0/eDP-1/i915_dpcd > > > >> > 0000: 12 14 84 40 00 00 01 01 02 00 00 00 00 0b 00 > > > >> > 0070: 01 00 > > > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > > >> > 0100: 14 04 00 00 00 00 00 00 00 00 00 > > > >> > 0200: 41 00 00 00 80 00 66 66 > > > >> > 0600: 01 > > > >> > 0700: 02 > > > >> > 0701: 9f 40 00 00 > > > >> > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > > > >> > 0732: 00 00 > > > >> > > > > >> > --------------------------------------------------------- > > > >> > > > > >> > Current dpcd_dump proposed here: > > > >> > $ sudo ./build/tools/dpcd_dump > > > >> > > > > >> > Dumping DPDDC-B > > > >> > : > > > >> > 0000: 12 14 ffffffc4 01 01 00 01 00 02 02 06 00 00 00 02 > > > >> > 0070: 00 00 > > > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > > >> > 0100: 14 ffffff84 00 06 06 06 06 00 01 04 00 > > > >> > 0200: 41 00 77 77 01 03 22 22 > > > >> > 0600: 01 > > > >> > 0700: 01 > > > >> > 0701: 00 00 00 00 > > > >> > 0720: 00 01 00 00 00 01 01 00 00 00 00 00 01 00 00 01 > > > >> > 0732: 00 00 > > > >> > > > > >> > DPCD DPDDC-C > > > >> > seems not available. skipping... > > > >> > Dumping DPDDC-A > > > >> > : > > > >> > 0000: 12 14 ffffff84 40 00 00 01 01 02 00 00 00 00 0b 00 > > > >> > 0070: 01 00 > > > >> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > > >> > 0100: 14 04 00 00 00 00 00 00 00 00 00 > > > >> > 0200: 41 00 00 00 ffffff80 00 66 66 > > > >> > 0600: 01 > > > >> > 0700: 02 > > > >> > 0701: ffffff9f 40 00 00 > > > >> > 0720: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 > > > >> > 0732: 00 00 > > > >> > > > > >> > Cc: Rafael Antognolli <rafael.antognolli@intel.com> > > > >> > Cc: Jani Nikula <jani.nikula@intel.com> > > > >> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> > > > >> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> > > > >> > --- > > > >> > tools/Makefile.sources | 1 + > > > >> > tools/dpcd_dump.c | 152 > > +++++++++++++++++++++++++++++++++++++++++ > > > >> > tools/meson.build | 1 + > > > >> > 3 files changed, 154 insertions(+) create mode 100644 > > > >> > tools/dpcd_dump.c > > > >> > > > > >> > diff --git a/tools/Makefile.sources b/tools/Makefile.sources > > > >> > index abd23a0f..f4921f83 100644 > > > >> > --- a/tools/Makefile.sources > > > >> > +++ b/tools/Makefile.sources > > > >> > @@ -6,6 +6,7 @@ noinst_PROGRAMS = \ > > > >> > $(NULL) > > > >> > > > > >> > tools_prog_lists = \ > > > >> > + dpcd_dump \ > > > >> > igt_stats \ > > > >> > intel_audio_dump \ > > > >> > intel_reg \ > > > >> > diff --git a/tools/dpcd_dump.c b/tools/dpcd_dump.c new file mode > > > >> > 100644 index 00000000..1b989e53 > > > >> > --- /dev/null > > > >> > +++ b/tools/dpcd_dump.c > > > >> > @@ -0,0 +1,152 @@ > > > >> > +/* > > > >> > + * Copyright (c) 2018 Intel Corporation > > > >> > + * > > > >> > + * Permission is hereby granted, free of charge, to any person > > > >> > +obtaining a > > > >> > + * copy of this software and associated documentation files (the > > > >> > +"Software"), > > > >> > + * to deal in the Software without restriction, including > > > >> > +without limitation > > > >> > + * the rights to use, copy, modify, merge, publish, distribute, > > > >> > +sublicense, > > > >> > + * and/or sell copies of the Software, and to permit persons to > > > >> > +whom the > > > >> > + * Software is furnished to do so, subject to the following conditions: > > > >> > + * > > > >> > + * The above copyright notice and this permission notice > > > >> > +(including the next > > > >> > + * paragraph) shall be included in all copies or substantial > > > >> > +portions of the > > > >> > + * Software. > > > >> > + * > > > >> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY > > > >> > +KIND, EXPRESS OR > > > >> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > > > >> > +MERCHANTABILITY, > > > >> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN > > NO > > > >> > +EVENT SHALL > > > >> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, > > > >> > +DAMAGES OR OTHER > > > >> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR > > > >> > +OTHERWISE, ARISING > > > >> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE > > OR > > > >> > +OTHER DEALINGS > > > >> > + * IN THE SOFTWARE. > > > >> > + * > > > >> > + */ > > > >> > + > > > >> > +#include <stdio.h> > > > >> > +#include <stdlib.h> > > > >> > +#include <unistd.h> > > > >> > +#include <sys/types.h> > > > >> > +#include <sys/stat.h> > > > >> > +#include <fcntl.h> > > > >> > +#include <dirent.h> > > > >> > +#include <string.h> > > > >> > + > > > >> > +struct dpcd_block { > > > >> > + /* DPCD dump start address. */ > > > >> > + unsigned int offset; > > > >> > + /* DPCD dump size. If unset, defaults to 1. */ > > > >> > + size_t size; > > > >> > +}; > > > >> > + > > > >> > +static const struct dpcd_block dpcd_dump[] = { > > > >> > + /* DP_DPCD_REV */ > > > >> > + { .offset = 0, .size = 15 }, > > > >> > + /* DP_PSR_SUPPORT to DP_PSR_CAPS*/ > > > >> > + { .offset = 0x70, .size = 2 }, > > > >> > + /* DP_DOWNSTREAM_PORT_0 */ > > > >> > + { .offset = 0x80, .size = 16 }, > > > >> > + /* DP_LINK_BW_SET to DP_EDP_CONFIGURATION_SET */ > > > >> > + { .offset = 0x100, .size = 11 }, > > > >> > + /* DP_SINK_COUNT to DP_ADJUST_REQUEST_LANE2_3 */ > > > >> > + { .offset = 0x200, .size = 8 }, > > > >> > + /* DP_SET_POWER */ > > > >> > + { .offset = 0x600 }, > > > >> > + /* DP_EDP_DPCD_REV */ > > > >> > + { .offset = 0x700 }, > > > >> > + /* DP_EDP_GENERAL_CAP_1 to DP_EDP_GENERAL_CAP_3 */ > > > >> > + { .offset = 0x701, .size = 4 }, > > > >> > + /* DP_EDP_DISPLAY_CONTROL_REGISTER to > > DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB */ > > > >> > + { .offset = 0x720, .size = 16}, > > > >> > + /* DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET to > > DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET */ > > > >> > + { .offset = 0x732, .size = 2 }, }; > > > >> > + > > > >> > +void dump_all(int fd) > > > >> > +{ > > > >> > + int ret, i, j, size; > > > >> > + char buf[32]; > > > >> > + > > > >> > + for (i = 0; i < sizeof(dpcd_dump) / sizeof(dpcd_dump[0]); i++) { > > > >> > + ret = lseek(fd, dpcd_dump[i].offset, SEEK_SET); > > > >> > + if (ret < 0) { > > > >> > + fprintf(stderr, "lseek to %04x failed!\n", > > dpcd_dump[i].offset); > > > >> > + return; > > > >> > + } > > > >> > + > > > >> > + size = dpcd_dump[i].size ? dpcd_dump[i].size: 1; > > > >> > + printf("%04x: ", dpcd_dump[i].offset); > > > >> > + ret = read(fd, &buf, size); > > > >> > + if (ret < 0) { > > > >> > + fprintf(stderr, "read of %d bytes to %04x failed!\n", size, > > dpcd_dump[i].offset); > > > >> > + return; > > > >> > + } > > > >> > + > > > >> > + for (j = 0; j < size; j++) > > > >> > + printf(" %02x", buf[j]); > > > >> > + printf("\n"); > > > >> > + } > > > >> > +} > > > >> > + > > > >> > +int main(int argc, char **argv) > > > >> > +{ > > > >> > + struct dirent *dirent; > > > >> > + DIR *dir; > > > >> > + char dev_path[PATH_MAX]; > > > >> > + char sysfs_path[PATH_MAX]; > > > >> > + int dev_fd, sysfs_fd, ret = 0; > > > >> > + char dpcd_name[8]; > > > >> > + char discard; > > > >> > + > > > >> > + dir = opendir("/sys/class/drm_dp_aux_dev/"); > > > >> > + if (!dir) { > > > >> > + fprintf(stderr, "fail to read /dev\n"); > > > >> > + return -1; > > > >> > + } > > > >> > + > > > >> > + while ((dirent = readdir(dir))) { > > > >> > + if (strncmp(dirent->d_name, "drm_dp_aux", 10) == 0) { > > > >> > + sprintf(dev_path, "/dev/%s", dirent->d_name); > > > >> > + sprintf(sysfs_path, > > "/sys/class/drm_dp_aux_dev/%s/name", > > > >> > + dirent->d_name); > > > >> > + > > > >> > + sysfs_fd = open(sysfs_path, O_RDONLY); > > > >> > + if (sysfs_fd < 0) { > > > >> > + fprintf(stderr,"fail to open %s\n", sysfs_path); > > > >> > + continue; > > > >> > + } > > > >> > + > > > >> > + dev_fd = open(dev_path, O_RDONLY); > > > >> > + if (dev_fd < 0) { > > > >> > + fprintf(stderr,"fail to open %s\n", dev_path); > > > >> > + continue; > > > >> > + } > > > >> > + > > > >> > + ret = read(sysfs_fd, &dpcd_name, sizeof(dpcd_name)); > > > >> > + if (ret < 0) { > > > >> > + fprintf(stderr, "fail to read dpcd name from > > %s\n\n", sysfs_path); > > > >> > + continue; > > > >> > + } > > > >> > + dpcd_name[ret] = '\0'; > > > >> > + > > > >> > + /* Dummy read to check if dpcd is available */ > > > >> > + ret = read(dev_fd, &discard, 1); > > > >> > + if (ret != 1) { > > > >> > + fprintf(stderr, "DPCD %s seems not available. > > skipping...\n", dpcd_name); > > > >> > + continue; > > > >> > + } > > > >> > + > > > >> > + printf("Dumping %s:\n", dpcd_name); > > > >> > + dump_all(dev_fd); > > > >> > + printf("\n"); > > > >> > + > > > >> > + > > > >> > + > > > >> > + close(sysfs_fd); > > > >> > + close(dev_fd); > > > >> > + } > > > >> > + } > > > >> > + > > > >> > + closedir(dir); > > > >> > + > > > >> > + return 0; > > > >> > +} > > > >> > diff --git a/tools/meson.build b/tools/meson.build index > > > >> > e4517d66..3326a5a7 100644 > > > >> > --- a/tools/meson.build > > > >> > +++ b/tools/meson.build > > > >> > @@ -14,6 +14,7 @@ endforeach > > > >> > tools_progs = [ > > > >> > # FIXME we already have a libtestcase with this name as target > > > >> > #'igt_stats', > > > >> > + 'dpcd_dump', > > > >> > 'intel_audio_dump', > > > >> > 'intel_backlight', > > > >> > 'intel_bios_dumper', > > > >> > > > >> -- > > > >> Jani Nikula, Intel Open Source Graphics Center > > > > > > -- > > > Jani Nikula, Intel Open Source Graphics Center > > > _______________________________________________ > > > igt-dev mailing list > > > igt-dev@lists.freedesktop.org > > > https://lists.freedesktop.org/mailman/listinfo/igt-dev _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-08-27 22:26 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-08-21 0:12 [igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT Rodrigo Vivi 2018-08-21 1:33 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork 2018-08-21 4:12 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork 2018-08-21 7:42 ` [igt-dev] [RFC] " Jani Nikula 2018-08-21 14:58 ` Rodrigo Vivi 2018-08-22 10:35 ` Jani Nikula 2018-08-22 16:16 ` Rodrigo Vivi 2018-08-22 17:11 ` Pandiyan, Dhinakaran 2018-08-27 22:26 ` Tarun Vyas
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).