intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Simplify mmio_reg_cmp
@ 2017-11-03 13:10 Tvrtko Ursulin
  2017-11-03 13:18 ` Chris Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tvrtko Ursulin @ 2017-11-03 13:10 UTC (permalink / raw)
  To: Intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

If we remove one condition from the comparison mmio_reg_cmp becomes
smaller and compiler can fully inline it. This grows the text a little
bit but avoids the function call.

We depend, and verify, on the fact that addresses of mmio registers fit
in a signed integer.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/intel_uncore.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 0a6d952a2df1..a68a9960c928 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -865,12 +865,9 @@ static int mmio_reg_cmp(u32 key, const i915_reg_t *reg)
 {
 	u32 offset = i915_mmio_reg_offset(*reg);
 
-	if (key < offset)
-		return -1;
-	else if (key > offset)
-		return 1;
-	else
-		return 0;
+	GEM_BUG_ON(key > (u32)INT_MAX || offset > (u32)INT_MAX);
+
+	return (int)key - (int)offset;
 }
 
 static bool is_gen8_shadowed(u32 offset)
-- 
2.9.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915: Simplify mmio_reg_cmp
  2017-11-03 13:10 [PATCH] drm/i915: Simplify mmio_reg_cmp Tvrtko Ursulin
@ 2017-11-03 13:18 ` Chris Wilson
  2017-11-03 13:43 ` ✓ Fi.CI.BAT: success for " Patchwork
  2017-11-03 14:40 ` ✓ Fi.CI.IGT: " Patchwork
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2017-11-03 13:18 UTC (permalink / raw)
  To: Tvrtko Ursulin, Intel-gfx

Quoting Tvrtko Ursulin (2017-11-03 13:10:42)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> If we remove one condition from the comparison mmio_reg_cmp becomes
> smaller and compiler can fully inline it. This grows the text a little
> bit but avoids the function call.
> 
> We depend, and verify, on the fact that addresses of mmio registers fit
> in a signed integer.

Ok. I was thinking it would be simpler if we around the wraparound
comparison, but we don't want that here.

> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_uncore.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index 0a6d952a2df1..a68a9960c928 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -865,12 +865,9 @@ static int mmio_reg_cmp(u32 key, const i915_reg_t *reg)
static inline then?
>  {
>         u32 offset = i915_mmio_reg_offset(*reg);
>  
> -       if (key < offset)
> -               return -1;
> -       else if (key > offset)
> -               return 1;
> -       else
> -               return 0;
> +       GEM_BUG_ON(key > (u32)INT_MAX || offset > (u32)INT_MAX);

GEM_BUG_ON((key | offset) > INT_MAX); ?

Casting the INT_MAX to (u32) here is implicit.

> +
> +       return (int)key - (int)offset;
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915: Simplify mmio_reg_cmp
  2017-11-03 13:10 [PATCH] drm/i915: Simplify mmio_reg_cmp Tvrtko Ursulin
  2017-11-03 13:18 ` Chris Wilson
@ 2017-11-03 13:43 ` Patchwork
  2017-11-03 14:40 ` ✓ Fi.CI.IGT: " Patchwork
  2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2017-11-03 13:43 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Simplify mmio_reg_cmp
URL   : https://patchwork.freedesktop.org/series/33125/
State : success

== Summary ==

Series 33125v1 drm/i915: Simplify mmio_reg_cmp
https://patchwork.freedesktop.org/api/1.0/series/33125/revisions/1/mbox/

Test chamelium:
        Subgroup dp-crc-fast:
                incomplete -> PASS       (fi-kbl-7500u) fdo#102514

fdo#102514 https://bugs.freedesktop.org/show_bug.cgi?id=102514

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:443s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:455s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:379s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:541s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:275s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:504s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:507s
fi-byt-j1900     total:289  pass:253  dwarn:1   dfail:0   fail:0   skip:35  time:506s
fi-byt-n2820     total:289  pass:249  dwarn:1   dfail:0   fail:0   skip:39  time:492s
fi-cfl-s         total:289  pass:254  dwarn:3   dfail:0   fail:0   skip:32  time:562s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:417s
fi-gdg-551       total:289  pass:178  dwarn:1   dfail:0   fail:1   skip:109 time:260s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:588s
fi-glk-dsi       total:289  pass:258  dwarn:0   dfail:0   fail:1   skip:30  time:493s
fi-hsw-4770      total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:432s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:430s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:427s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:466s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:495s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:566s
fi-kbl-7567u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:482s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:583s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:559s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:453s
fi-skl-6600u     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:583s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:650s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:520s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:501s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:461s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:570s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:419s

2f945d948d05de1dd4bd1ca14eac40ff563d9d77 drm-tip: 2017y-11m-03d-09h-28m-20s UTC integration manifest
b844b8899c6e drm/i915: Simplify mmio_reg_cmp

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6938/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* ✓ Fi.CI.IGT: success for drm/i915: Simplify mmio_reg_cmp
  2017-11-03 13:10 [PATCH] drm/i915: Simplify mmio_reg_cmp Tvrtko Ursulin
  2017-11-03 13:18 ` Chris Wilson
  2017-11-03 13:43 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2017-11-03 14:40 ` Patchwork
  2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2017-11-03 14:40 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Simplify mmio_reg_cmp
URL   : https://patchwork.freedesktop.org/series/33125/
State : success

== Summary ==

Test drv_suspend:
        Subgroup fence-restore-untiled-hibernate:
                dmesg-fail -> FAIL       (shard-hsw) fdo#103375

fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375

shard-hsw        total:2539 pass:1433 dwarn:0   dfail:0   fail:9   skip:1097 time:9265s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6938/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-03 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-03 13:10 [PATCH] drm/i915: Simplify mmio_reg_cmp Tvrtko Ursulin
2017-11-03 13:18 ` Chris Wilson
2017-11-03 13:43 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-11-03 14:40 ` ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).