[Intel-gfx] [PATCH 2/2] tests: rc6 residency test
Daniel Vetter
daniel at ffwll.ch
Sun Mar 25 14:21:24 CEST 2012
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 at 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 at 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 at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Mail: daniel at ffwll.ch
Mobile: +41 (0)79 365 57 48
More information about the Intel-gfx
mailing list