[igt-dev] [PATCH i-g-t 6/6] tools/dpcd_reg: Add dump all functionality

Rodrigo Vivi rodrigo.vivi at intel.com
Thu Sep 6 02:05:50 UTC 2018


On Wed, Sep 05, 2018 at 05:26:26PM -0700, Dhinakaran Pandiyan wrote:
> On Fri, 2018-08-31 at 21:18 -0700, Rodrigo Vivi wrote:
> > And make it the default when no operation or device is given.
> > 
> > So, this will replace i915_dpcd for now but can be expanded
> > later.
> 
> I think we can include PSR sink status registers too and kill the
> debugfs file

good idea! I will do on the next version.

> 
> > 
> > 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
> > 
> > new tool:
> > 
> > $ sudo tools/dpcd_reg
> > 
> > Dumping DPDDC-B
> > 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
> > 
> > Dumping DPDDC-A
> > 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
> > 
> > Cc: Tarun Vyas <tarun.vyas at intel.com>
> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
> > ---
> >  tools/dpcd_reg.c | 71
> > ++++++++++++++++++++++++++++++++++++++++++++++--
> >  1 file changed, 69 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/dpcd_reg.c b/tools/dpcd_reg.c
> > index a141f1fc..0f17383e 100644
> > --- a/tools/dpcd_reg.c
> > +++ b/tools/dpcd_reg.c
> > @@ -28,6 +28,7 @@
> >  #include "igt_core.h"
> >  #include <errno.h>
> >  #include <fcntl.h>
> > +#include <dirent.h>
> >  
> >  #define INVALID	0xff
> >  
> > @@ -154,6 +155,67 @@ static int dpcd_dump(int fd)
> >  	return 0;
> >  }
> >  
> > +static int dpcd_dump_all()
> > +{
> > +	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) {
> > +		igt_warn("fail to read /dev\n");
> > +		return EXIT_FAILURE;
> > +	}
> > +
> > +	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) {
> > +				igt_warn("fail to open %s\n",
> > sysfs_path);
> > +				continue;
> > +			}
> > +
> > +			dev_fd = open(dev_path, O_RDONLY);
> > +			if (dev_fd < 0) {
> > +				igt_warn("fail to open %s\n",
> > dev_path);
> > +				continue;
> > +			}
> > +
> > +			ret = read(sysfs_fd, &dpcd_name,
> > sizeof(dpcd_name));
> > +			if (ret < 0) {
> > +				igt_warn("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) {
> > +				igt_debug("DPCD %s seems not
> > available. skipping...\n", dpcd_name);
> > +				continue;
> > +			}
> > +
> > +			igt_info("\nDumping %s", dpcd_name);
> > +			dpcd_dump(dev_fd);
> > +
> > +			close(sysfs_fd);
> > +			close(dev_fd);
> > +		}
> > +	}
> > +
> > +	closedir(dir);
> > +
> > +	return 0;
> > +}
> > +
> >  int main(int argc, char **argv)
> >  {
> >  	char dev_name[20];
> > @@ -222,8 +284,13 @@ int main(int argc, char **argv)
> >  		print_usage(argv[0], 1);
> >  
> >  	if (devid == -1) {
> > -		igt_warn("Aux device missing\n");
> > -		print_usage(argv[0], 0);
> > +		if (cmd != DUMP) {
> > +			igt_warn("Aux device missing\n");
> > +			print_usage(argv[0], 0);
> > +		}
> > +		else {
> > +			return dpcd_dump_all();
> > +		}
> >  	}
> >  
> >  	if (cmd != DUMP && offset == INVALID) {


More information about the igt-dev mailing list