public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Tvrtko Ursulin <tursulin@ursulin.net>, Intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 13/13] drm/i915: Use binary search when looking for shadowed registers
Date: Fri, 30 Sep 2016 10:54:10 +0300	[thread overview]
Message-ID: <1475222050.3106.15.camel@linux.intel.com> (raw)
In-Reply-To: <1475163356-3463-14-git-send-email-tvrtko.ursulin@linux.intel.com>

On to, 2016-09-29 at 16:35 +0100, Tvrtko Ursulin wrote:
> +static int mmio_reg_cmp(const void *key, const void *elt)
+ {
<SNIP>
> 
> +	if (offset < i915_mmio_reg_offset(*reg))
> +		return -1;
> +	else if (offset > i915_mmio_reg_offset(*reg))
> +		return 1;
> +	else
> +		return 0;

I was about to suggest return a - b; but then realized it might
overflow. After a bit of searching, that is done in
regcache_default_cmp though. So not sure if it's a bug in there or did
I miss something. This is safe way at least.

>  static bool is_gen8_shadowed(u32 offset)
>  {
> > -	int i;
> > -	for (i = 0; i < ARRAY_SIZE(gen8_shadowed_regs); i++)
> > -		if (offset == gen8_shadowed_regs[i].reg)
> > -			return true;
> > +	i915_reg_t *reg;
>  
> > -	return false;
> +	reg = bsearch((void *)(unsigned long)offset,

(unsigned long) is not required, as we don't have sign bits to extend.

> +		      (const void *)gen8_shadowed_regs,
> +		      ARRAY_SIZE(gen8_shadowed_regs),
> +		      sizeof(i915_reg_t),
> +		      mmio_reg_cmp);
> +
> +	return reg ? true : false;

As I previously learnt, no need to explicitly convert bool types
anymore, so this can just be return bsearch(...);

With the last two fixed,

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-09-30  7:54 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29 15:35 [PATCH 00/13] Forcewake binary search & code shrink Tvrtko Ursulin
2016-09-29 15:35 ` [PATCH 01/13] drm/i915: Remove redundant hsw_write* mmio functions Tvrtko Ursulin
2016-09-29 15:35 ` [PATCH 02/13] drm/i915: Keep track of active forcewake domains in a bitmask Tvrtko Ursulin
2016-09-29 15:35 ` [PATCH 03/13] drm/i915: Do not inline forcewake taking in mmio accessors Tvrtko Ursulin
2016-09-29 15:35 ` [PATCH 04/13] drm/i915: Data driven register to forcewake domains lookup Tvrtko Ursulin
2016-09-29 15:35 ` [PATCH 05/13] drm/i915: Sort forcewake mapping tables Tvrtko Ursulin
2016-09-29 16:13   ` Chris Wilson
2016-09-29 15:35 ` [PATCH 06/13] drm/i915: Use binary search when looking up forcewake domains Tvrtko Ursulin
2016-09-29 16:16   ` Chris Wilson
2016-09-29 20:41     ` [PATCH] lib: Typesafe generator macro for bsearch Chris Wilson
2016-09-30 11:08     ` [PATCH 06/13] drm/i915: Use binary search when looking up forcewake domains Tvrtko Ursulin
2016-09-30 11:22       ` Chris Wilson
2016-09-29 15:35 ` [PATCH 07/13] drm/i915: Eliminate Gen9 special case Tvrtko Ursulin
2016-09-29 16:18   ` Chris Wilson
2016-09-29 15:35 ` [PATCH 08/13] drm/i915: Store the active forcewake range table pointer Tvrtko Ursulin
2016-09-29 16:21   ` Chris Wilson
2016-09-29 15:35 ` [PATCH 09/13] drm/i915: Remove identical macros Tvrtko Ursulin
2016-09-30  7:29   ` Joonas Lahtinen
2016-09-29 15:35 ` [PATCH 10/13] drm/i915: Remove identical mmio read functions Tvrtko Ursulin
2016-09-30  7:32   ` Joonas Lahtinen
2016-09-29 15:35 ` [PATCH 11/13] drm/i915: Remove identical write mmmio functions Tvrtko Ursulin
2016-09-30  8:11   ` Joonas Lahtinen
2016-09-29 15:35 ` [PATCH 12/13] drm/i915: Sort the shadow register table Tvrtko Ursulin
2016-09-29 16:23   ` Chris Wilson
2016-09-30  8:09   ` Joonas Lahtinen
2016-09-30  9:06     ` Tvrtko Ursulin
2016-09-30 11:13       ` Joonas Lahtinen
2016-09-29 15:35 ` [PATCH 13/13] drm/i915: Use binary search when looking for shadowed registers Tvrtko Ursulin
2016-09-30  7:54   ` Joonas Lahtinen [this message]
2016-09-30 10:01     ` Tvrtko Ursulin
2016-09-29 15:58 ` [PATCH 00/13] Forcewake binary search & code shrink Jani Nikula
2016-09-29 16:20 ` ✗ Fi.CI.BAT: warning for " Patchwork
2016-09-29 16:24 ` [PATCH 00/13] " Chris Wilson
2016-09-29 21:01 ` ✗ Fi.CI.BAT: failure for Forcewake binary search & code shrink (rev2) Patchwork

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=1475222050.3106.15.camel@linux.intel.com \
    --to=joonas.lahtinen@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=tursulin@ursulin.net \
    /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