public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: Damien Lespiau <damien.lespiau@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/8] lib: Add a small helper to open debugfs files
Date: Wed, 16 Oct 2013 08:28:14 -0700	[thread overview]
Message-ID: <20131016152813.GA640@bwidawsk.net> (raw)
In-Reply-To: <1381862674-17763-2-git-send-email-damien.lespiau@intel.com>

On Tue, Oct 15, 2013 at 07:44:27PM +0100, Damien Lespiau wrote:
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  lib/Makefile.am   |  2 ++
>  lib/igt_debugfs.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/igt_debugfs.h | 36 ++++++++++++++++++++++++++
>  3 files changed, 113 insertions(+)
>  create mode 100644 lib/igt_debugfs.c
>  create mode 100644 lib/igt_debugfs.h
> 
> diff --git a/lib/Makefile.am b/lib/Makefile.am
> index 387141b..5710802 100644
> --- a/lib/Makefile.am
> +++ b/lib/Makefile.am
> @@ -11,6 +11,8 @@ libintel_tools_la_SOURCES = 	\
>  	i830_reg.h		\
>  	i915_3d.h		\
>  	i915_reg.h		\
> +	igt_debugfs.c		\
> +	igt_debugfs.h		\
>  	instdone.c		\
>  	instdone.h		\
>  	intel_batchbuffer.c	\
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> new file mode 100644
> index 0000000..33c4fc1
> --- /dev/null
> +++ b/lib/igt_debugfs.c
> @@ -0,0 +1,75 @@
> +/*
> + * Copyright © 2013 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 <sys/stat.h>
> +#include <sys/mount.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <fcntl.h>
> +
> +#include "igt_debugfs.h"
> +
> +int igt_debugfs_init(igt_debugfs_t *debugfs)
> +{
> +	const char *path = "/sys/kernel/debug";
> +	struct stat st;
> +	int n;
> +
> +	if (stat("/debug/dri", &st) == 0) {
> +		path = "/debug/dri";
> +		goto find_minor;
> +	}
> +
> +	if (stat("/sys/kernel/debug/dri", &st) == 0)
> +		goto find_minor;
> +
> +	if (stat("/sys/kernel/debug", &st))
> +		return errno;
> +
> +	if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0))
> +		return errno;
> +
> +find_minor:
> +	strcpy(debugfs->root, path);
> +	for (n = 0; n < 16; n++) {
> +		int len = sprintf(debugfs->dri_path, "%s/dri/%d", path, n);
> +		sprintf(debugfs->dri_path + len, "/i915_error_state");
> +		if (stat(debugfs->dri_path, &st) == 0) {
> +			debugfs->dri_path[len] = '\0';
> +			return 0;
> +		}
> +	}
> +
> +	debugfs->dri_path[0] = '\0';
> +	return ENOENT;
> +}
> +
> +int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename)
> +{
> +	char buf[1024];
> +
> +	sprintf(buf, "%s/%s", debugfs->dri_path, filename);
> +	return open(buf, O_RDONLY);
> +}
> diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
> new file mode 100644
> index 0000000..aa9449a
> --- /dev/null
> +++ b/lib/igt_debugfs.h
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright © 2013 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.
> + *
> + */
> +
> +#ifndef __IGT_DEBUGFS_H__
> +#define __IGT_DEBUGFS_H__
> +
> +typedef struct {
> +	char root[128];
> +	char dri_path[128];
> +} igt_debugfs_t;
> +
> +int igt_debugfs_init(igt_debugfs_t *debugfs);
> +int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename);
> +
> +#endif /* __IGT_DEBUGFS_H__ */

Can you please consolidate this with the stuff in lib/intel_mmio.c?

(I didn't look at the later patches yet).

-- 
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2013-10-16 15:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
2013-10-15 18:44 ` [PATCH 1/8] lib: Add a small helper to open debugfs files Damien Lespiau
2013-10-16 15:28   ` Ben Widawsky [this message]
2013-10-15 18:44 ` [PATCH 2/8] lib: Add igt_debugfs_fopen() Damien Lespiau
2013-10-15 18:44 ` [PATCH 3/8] lib: Add a igt_assert_cmpint() Damien Lespiau
2013-10-15 18:44 ` [PATCH 4/8] lib: Add kmstest_paint_color() Damien Lespiau
2013-10-15 18:44 ` [PATCH 5/8] lib: Add a igt_display.h with a few enums and defines from the kernel Damien Lespiau
2013-10-15 18:44 ` [PATCH 6/8] lib: Make igt_debugfs_open() take the mode as argument Damien Lespiau
2013-10-15 18:44 ` [PATCH 7/8] lib: Add igt_wait_for_vblank() helper Damien Lespiau
2013-10-15 18:44 ` [PATCH 8/8] debugfs_pipe_crc: Let's check CRCs! Damien Lespiau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131016152813.GA640@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=damien.lespiau@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox