From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH 2/2] tests: rc6 residency test Date: Sun, 25 Mar 2012 14:21:24 +0200 Message-ID: <20120325122124.GC5909@phenom.ffwll.local> References: <1332641388-7688-1-git-send-email-ben@bwidawsk.net> <1332641388-7688-5-git-send-email-ben@bwidawsk.net> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by gabe.freedesktop.org (Postfix) with ESMTP id CBA309E75A for ; Sun, 25 Mar 2012 05:20:39 -0700 (PDT) Received: by wgbds1 with SMTP id ds1so1874514wgb.0 for ; Sun, 25 Mar 2012 05:20:39 -0700 (PDT) In-Reply-To: <1332641388-7688-5-git-send-email-ben@bwidawsk.net> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Ben Widawsky Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org 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 > --- > 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 =3D \ > 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 =A9 2012 Intel Corporation > + * > + * Permission is hereby granted, free of charge, to any person obtaining= a > + * copy of this software and associated documentation files (the "Softwa= re"), > + * to deal in the Software without restriction, including without limita= tion > + * the rights to use, copy, modify, merge, publish, distribute, sublicen= se, > + * 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, EXPRE= SS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SH= ALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER D= EALINGS > + * IN THE SOFTWARE. > + * > + * Authors: > + * Ben Widawsky > + * > + */ > + > +#include > +#define _GNU_SOURCE > +#include > +#include > +#include > +#include "drmtest.h" > + > +static unsigned int readit(const char *path) > +{ > + unsigned int ret; > + > + FILE *file; > + file =3D fopen(path, "r"); > + if (file =3D=3D 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 =3D 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 =3D drm_open_any(); > + close(fd); I think we want a gem_quiescent_gpu here to ensure things are _really_ idle. > + > + ret =3D asprintf(&path, "/sys/class/drm/card%d/power/rc6", device); > + if (ret =3D=3D -1 || ret < strlen("/sys/class/drm/card0/power/rc6")) > + abort(); > + > + value =3D readit(path); > + > + // Sleep for 3 seconds and compare > + sleep(3); > + value2 =3D 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