Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Ben Widawsky <ben@bwidawsk.net>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/2] tests: rc6 residency test
Date: Sun, 25 Mar 2012 14:21:24 +0200	[thread overview]
Message-ID: <20120325122124.GC5909@phenom.ffwll.local> (raw)
In-Reply-To: <1332641388-7688-5-git-send-email-ben@bwidawsk.net>

On Sat, Mar 24, 2012 at 07:09:48PM -0700, Ben Widawsky wrote:
> This is meant to test the sysfs entry for showing rc6 residency in
> milliseconds. Remember, sysfs is a permanent interface.
> 
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> ---
>  tests/Makefile.am     |    1 +
>  tests/rc6_residency.c |   80 +++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 81 insertions(+)
>  create mode 100644 tests/rc6_residency.c
> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 6544ec7..a8eed88 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -56,6 +56,7 @@ TESTS_progs = \
>  	drm_vma_limiter_cpu \
>  	drm_vma_limiter_gtt \
>  	drm_vma_limiter_cached \
> +	rc6_residency \
>  	$(NULL)
>  
>  # IMPORTANT: The ZZ_ tests need to be run last!
> diff --git a/tests/rc6_residency.c b/tests/rc6_residency.c
> new file mode 100644
> index 0000000..8ae6aa4
> --- /dev/null
> +++ b/tests/rc6_residency.c
> @@ -0,0 +1,80 @@
> +/*
> + * Copyright © 2012 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.
> + *
> + * Authors:
> + *    Ben Widawsky <ben@bwidawsk.net>
> + *
> + */
> +
> +#include <stdlib.h>
> +#define _GNU_SOURCE
> +#include <stdio.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include "drmtest.h"
> +
> +static unsigned int readit(const char *path)
> +{
> +	unsigned int ret;
> +
> +	FILE *file;
> +	file = fopen(path, "r");
> +	if (file == NULL) {
> +		fprintf(stderr, "Couldn't open %s (%d)\n", path, errno);
> +		abort();
> +	}
> +	fscanf(file, "%u", &ret);
> +	fclose(file);
> +
> +	return ret;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> +	/* TODO: don't always assume 0 */
> +	const int device = 0;

Yeah, I'd like to have this, because I have machines with other gpus
besides the intel one ;-)

> +	char *path;
> +	int fd, ret;
> +	unsigned int value, value2;
> +
> +	/* Use drm_open_any to verify device existence */
> +	fd = drm_open_any();
> +	close(fd);

I think we want a gem_quiescent_gpu here to ensure things are _really_
idle.

> +
> +	ret = asprintf(&path, "/sys/class/drm/card%d/power/rc6", device);
> +	if (ret == -1 || ret < strlen("/sys/class/drm/card0/power/rc6"))
> +		abort();
> +
> +	value = readit(path);
> +
> +	// Sleep for 3 seconds and compare
> +	sleep(3);
> +	value2 = readit(path);
> +	free(path);
> +
> +	/* Plenty of fudge */
> +	if (((value2 - value) > 3900) ||
> +	    ((value2 - value) < 2100))
> +		exit(EXIT_FAILURE);

Does that mean that rc6 residency is inclusive of lower-level
rc6-resdidency? I.e. on ivb where we enable rc6p, does that include rc6p
residency? Othwerwise I think we need to add rc6p and rc6pp in, too.

Cheers, Daniel

> +
> +	exit(EXIT_SUCCESS);
> +}
> -- 
> 1.7.9.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

  reply	other threads:[~2012-03-25 12:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-25  2:09 [PATCH 1/3] drm/i915: add rc6 residency times to debugfs Ben Widawsky
2012-03-25  2:09 ` [PATCH 2/3] drm/i915: extract intel_enable_rc6() Ben Widawsky
2012-03-25 12:10   ` Daniel Vetter
2012-03-29  0:30     ` Ben Widawsky
2012-03-25  2:09 ` [PATCH 3/3] drm/i915: rc6 in sysfs Ben Widawsky
2012-03-25  2:14   ` Ben Widawsky
2012-03-25 12:15   ` Daniel Vetter
2012-03-29  0:31     ` Ben Widawsky
2012-03-25  2:09 ` [PATCH 1/2] build: make sure we have asprintf Ben Widawsky
2012-03-25  2:09 ` [PATCH 2/2] tests: rc6 residency test Ben Widawsky
2012-03-25 12:21   ` Daniel Vetter [this message]
2012-03-25  2:22 ` [PATCH 1/3] drm/i915: add rc6 residency times to debugfs Ben Widawsky

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=20120325122124.GC5909@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=ben@bwidawsk.net \
    --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