[igt-dev] [RFC] tools/dpcd_dump: Introduce DPCD dump on IGT.

Jani Nikula jani.nikula at intel.com
Tue Aug 21 07:42:35 UTC 2018


On Mon, 20 Aug 2018, Rodrigo Vivi <rodrigo.vivi at 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 at intel.com>
> Cc: Jani Nikula <jani.nikula at intel.com>
> Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi at 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


More information about the igt-dev mailing list