Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	Daniel Vetter <daniel@ffwll.ch>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH i-g-t] lib/chipset: Cache devid
Date: Wed, 11 Feb 2015 09:49:04 +0100	[thread overview]
Message-ID: <20150211084904.GK24485@phenom.ffwll.local> (raw)
In-Reply-To: <20150210225033.GH18032@nuc-i3427.alporthouse.com>

On Tue, Feb 10, 2015 at 10:50:33PM +0000, Chris Wilson wrote:
> On Tue, Feb 10, 2015 at 11:45:12PM +0100, Daniel Vetter wrote:
> > On Tue, Feb 10, 2015 at 11:39:45PM +0100, Daniel Vetter wrote:
> > > On Tue, Feb 10, 2015 at 11:37:42PM +0100, Daniel Vetter wrote:
> > > > On Tue, Feb 10, 2015 at 10:28:22PM +0000, Chris Wilson wrote:
> > > > > On Tue, Feb 10, 2015 at 10:59:16PM +0100, Daniel Vetter wrote:
> > > > > > Chris Wilson complained that this adds a lot of noise to the test
> > > > > > startup when full debugging is enabled, so let's cache it. We can do
> > > > > > that since there's only ever one intel gpu in a given system.
> > > > > > 
> > > > > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > > 
> > > > > Couldn't we move the devid cache to lib/drmtest.c::is_intel() ?
> > > > 
> > > > Sounds like just another place where we should use the helper from
> > > > intel_chipset.c. Next patch in-flight ...
> > > 
> > > Ok I'm blind, is_intel can fail. So I guess I should extract a new
> > > __get_drm_devid which can fail, put the caching in there (plus override)
> > > and use that in in intel_chipset.c ...
> > 
> > Doesn't really work since doing the ioctl is part of the dance we do to
> > figure out whether the fd is really an intel or not :(
> 
> Something like:

Yeah, lgtm.
-Daniel

> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 7cdef36..4090a4a 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -72,6 +72,8 @@
>   * and [batchbuffer](intel-gpu-tools-intel-batchbuffer.html) libraries as dependencies.
>   */
>  
> +uint16_t __drm_device_id;
> +
>  static int is_i915_device(int fd)
>  {
>         drm_version_t version;
> @@ -100,7 +102,11 @@ is_intel(int fd)
>         if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
>                 return 0;
>  
> -       return IS_INTEL(devid);
> +       if (!IS_INTEL(devid))
> +               return 0;
> +
> +       __drm_device_id = devid;
> +       return 1;
>  }
>  
>  static void check_stop_rings(void)
> diff --git a/lib/drmtest.h b/lib/drmtest.h
> index 508cc83..fabf43e 100644
> --- a/lib/drmtest.h
> +++ b/lib/drmtest.h
> @@ -70,6 +70,8 @@ static inline void *igt_mmap64(void *addr, size_t length, int prot, int flags,
>   */
>  #define ALIGN(v, a) (((v) + (a)-1) & ~((a)-1))
>  
> +extern uint16_t __drm_device_id;
> +
>  int drm_get_card(void);
>  int __drm_open_any(void);
>  int drm_open_any(void);
> diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
> index fafd232..33177c6 100644
> --- a/lib/intel_chipset.c
> +++ b/lib/intel_chipset.c
> @@ -125,26 +125,15 @@ intel_get_pci_device(void)
>  uint32_t
>  intel_get_drm_devid(int fd)
>  {
> -       uint32_t devid = 0;
>         const char *override;
>  
> -       override = getenv("INTEL_DEVID_OVERRIDE");
> -       if (override) {
> -               devid = strtod(override, NULL);
> -       } else {
> -               struct drm_i915_getparam gp;
> -               int ret;
> -
> -               memset(&gp, 0, sizeof(gp));
> -               gp.param = I915_PARAM_CHIPSET_ID;
> -               gp.value = (int *)&devid;
> -
> -               ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
> -               igt_assert(ret == 0);
> -               errno = 0;
> -       }
> +       igt_assert(__drm_device_id);
>  
> -       return devid;
> +       override = getenv("INTEL_DEVID_OVERRIDE");
> +       if (override)
> +               return strtod(override, NULL);
> +       else
> +               return __drm_device_id;
>  }
>  
>  /**
> 
> -- 
> Chris Wilson, Intel Open Source Technology Centre

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2015-02-11  8:48 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 02/17] lib/ioctl: api polish for gem_context_has_param Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc Daniel Vetter
2015-02-10 21:58   ` Chris Wilson
2015-02-11  8:37     ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 04/17] igt/ioctls: doc for gem_mmap Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible Daniel Vetter
2015-02-10 21:54   ` Chris Wilson
2015-02-11  8:42     ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 06/17] lib/ioctl: Add gem_context_destroy helpers Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 07/17] tests/gem_ctx_*: Use helpers Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 08/17] tests/gem_reset_stat: Use new ctx helpers Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 09/17] lib/ioctl: Document ctx param functions Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 10/17] tests: Add gem_ctx_param_basic Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 11/17] tests: Add invalid pad tests for ctx create/destroy Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 12/17] tests/gem_ppgtt: Start rcs before bcs for context tests Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 13/17] tests: Align subtest with naming convention Daniel Vetter
2015-02-10 21:53   ` Chris Wilson
2015-02-11  8:44     ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 14/17] lib/igt_aux: s/swap/igt_swap/ Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 15/17] tests/gem_wait: Adjust makefile Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 16/17] doc: Consolidate naming conventions into docbook Daniel Vetter
2015-02-10 18:06 ` [PATCH i-g-t 17/17] lib/igt_gt: Document and consolidate Daniel Vetter
2015-02-10 21:36 ` [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Chris Wilson
2015-02-10 21:56   ` Daniel Vetter
2015-02-10 21:59   ` [PATCH i-g-t] lib/chipset: Cache devid Daniel Vetter
2015-02-10 22:28     ` Chris Wilson
2015-02-10 22:37       ` Daniel Vetter
2015-02-10 22:39         ` Daniel Vetter
2015-02-10 22:45           ` Daniel Vetter
2015-02-10 22:50             ` Chris Wilson
2015-02-11  8:49               ` Daniel Vetter [this message]

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=20150211084904.GK24485@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@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