From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Widawsky Subject: Re: [PATCH 3/5] lib: Add a drm_open_any_render() that will try to use render nodes Date: Thu, 24 Oct 2013 13:43:22 -0700 Message-ID: <20131024204322.GB28973@bwidawsk.net> References: <1382625656-3199-1-git-send-email-damien.lespiau@intel.com> <1382625656-3199-4-git-send-email-damien.lespiau@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail.bwidawsk.net (bwidawsk.net [166.78.191.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 17C0AE642F for ; Thu, 24 Oct 2013 13:43:35 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1382625656-3199-4-git-send-email-damien.lespiau@intel.com> 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: Damien Lespiau Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Thu, Oct 24, 2013 at 03:40:54PM +0100, Damien Lespiau wrote: > I was fedup with having to run my tests as root and not being able to > use my usual setup for tests that only exercise the GT part of the GPU. > > Render nodes to the rescue! I think usually this is a bad idea except for pretty isolated proof of concept kind of things. Mostly intel-gpu-tools is testing our kernel driver, and therefore running without a reboot anyway is sort of unusual. What do you think about providing some sort of option (maybe via env var) instead of what you did in patch 5? > > Signed-off-by: Damien Lespiau > --- > lib/drmtest.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > lib/drmtest.h | 1 + > 2 files changed, 59 insertions(+) > > diff --git a/lib/drmtest.c b/lib/drmtest.c > index 3b80920..8164ef9 100644 > --- a/lib/drmtest.c > +++ b/lib/drmtest.c > @@ -222,6 +222,35 @@ static int __drm_open_any(void) > return fd; > } > > +static int __drm_open_any_render(void) > +{ > + char *name; > + int i, fd; > + > + for (i = 128; i < (128 + 16); i++) { > + int ret; > + > + ret = asprintf(&name, "/dev/dri/renderD%u", i); > + igt_assert(ret != -1); > + > + fd = open(name, O_RDWR); > + free(name); > + > + if (fd == -1) > + continue; > + > + if (!is_intel(fd)) { > + close(fd); > + fd = -1; > + continue; > + } > + > + return fd; > + } > + > + return fd; > +} > + > static void quiescent_gpu_at_exit(int sig) > { > int fd; > @@ -233,6 +262,17 @@ static void quiescent_gpu_at_exit(int sig) > } > } > > +static void quiescent_gpu_at_exit_render(int sig) > +{ > + int fd; > + > + fd = __drm_open_any_render(); > + if (fd >= 0) { > + gem_quiescent_gpu(fd); > + close(fd); > + } > +} > + > int drm_open_any(void) > { > static int open_count; > @@ -249,6 +289,24 @@ int drm_open_any(void) > return fd; > } > > +int drm_open_any_render(void) > +{ > + static int open_count; > + int fd = __drm_open_any_render(); > + > + /* no render nodes, fallback to drm_open_any() */ > + if (fd == -1) > + return drm_open_any(); > + > + if (__sync_fetch_and_add(&open_count, 1)) > + return fd; > + > + gem_quiescent_gpu(fd); > + igt_install_exit_handler(quiescent_gpu_at_exit_render); > + > + return fd; > +} > + > int __gem_set_tiling(int fd, uint32_t handle, int tiling, int stride) > { > struct drm_i915_gem_set_tiling st; > diff --git a/lib/drmtest.h b/lib/drmtest.h > index 609e7d8..f5e2708 100644 > --- a/lib/drmtest.h > +++ b/lib/drmtest.h > @@ -50,6 +50,7 @@ drm_intel_bo * gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd, > > int drm_get_card(void); > int drm_open_any(void); > +int drm_open_any_render(void); > > void gem_quiescent_gpu(int fd); > > -- > 1.8.3.1 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Ben Widawsky, Intel Open Source Technology Center