Skip to contentSkip to conversation

drm/i915: Simplify mmio_reg_cmp

PATCH In review Tvrtko Ursulin 3 participants 4 messages Nov 3, 2017

Subsystems (2)
lore
Share & tools
lore

Tvrtko Ursulin

author maintainer
#0 lore raw

PATCH 1/1 drm/i915: Simplify mmio_reg_cmp

From: Tvrtko Ursulin <[email protected]>

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.

---
 drivers/gpu/drm/i915/intel_uncore.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_uncore.c +3 -6
index 0a6d952a2df1..a68a9960c928 100644
@@ -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)
Signature · 6 lines
2.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw

Quoting Tvrtko Ursulin (2017-11-03 13:10:42)

Quoted 8 lines

From: Tvrtko Ursulin <[email protected]>

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.

drivers/gpu/drm/i915/intel_uncore.c static int mmio_reg_cmp(u32 key, const i915_reg_t *reg)

Quoted 10 lines
---
 drivers/gpu/drm/i915/intel_uncore.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_uncore.c +0 -0
index 0a6d952a2df1..a68a9960c928 100644
@@ -865,12 +865,9 @@ static int mmio_reg_cmp(u32 key, const i915_reg_t *reg)

static inline then?

drivers/gpu/drm/i915/intel_uncore.c static int mmio_reg_cmp(u32 key, const i915_reg_t *reg) · line 868

Quoted 10 lines
drivers/gpu/drm/i915/intel_uncore.c +1 -6
 {
        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.

drivers/gpu/drm/i915/intel_uncore.c static int mmio_reg_cmp(u32 key, const i915_reg_t *reg) · line 870

Quoted 2 lines
drivers/gpu/drm/i915/intel_uncore.c +2 -0
+
+       return (int)key - (int)offset;

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

✓ Fi.CI.BAT: success for drm/i915: Simplify mmio_reg_cmp

In reply to Tvrtko Ursulin
== Series Details ==

== 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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✓ Fi.CI.IGT: success for drm/i915: Simplify mmio_reg_cmp

In reply to Tvrtko Ursulin
== Series Details ==

== 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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx