drm/i915: Introduce INTEL_GEN_MASK
Subsystems (3)
Joonas Lahtinen
maintainerPATCH v6 1/2 drm/i915: Introduce INTEL_GEN_MASK
Split INTEL_GEN_MASK out of IS_GEN macro, and make it usable within static declarations (unlike combound statements).
--- drivers/gpu/drm/i915/i915_drv.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +10 -12
@@ -2873,23 +2873,21 @@ intel_info(const struct drm_i915_private *dev_priv)#define INTEL_REVID (dev_priv) ((dev_priv)->drm.pdev->revision)#define GEN_FOREVER (0) + +#define INTEL_GEN_MASK (s, e) ( \ + BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \ + BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \ + GENMASK((e) != GEN_FOREVER ? (e) - 1 : BITS_PER_LONG - 1, \ + (s) != GEN_FOREVER ? (s) - 1 : 0) \ +) +/* * Returns true if Gen is in inclusive range [Start, End]. * * Use GEN_FOREVER for unbound start and or end. */ -#define IS_GEN (dev_priv, s, e) ({ \ - unsigned int __s = (s), __e = (e); \ - BUILD_BUG_ON(!__builtin_constant_p(s)); \ - BUILD_BUG_ON(!__builtin_constant_p(e)); \ - if ((__s) != GEN_FOREVER) \ - __s = (s) - 1; \ - if ((__e) == GEN_FOREVER) \ - __e = BITS_PER_LONG - 1; \ - else \ - __e = (e) - 1; \ - !!((dev_priv)->info.gen_mask & GENMASK((__e), (__s))); \ -}) +#define IS_GEN (dev_priv, s, e) \ + (!!((dev_priv)->info.gen_mask & INTEL_GEN_MASK((s), (e))))/* * Return true if revision is in range [since,until] inclusive.
Signature · 6 lines
2.13.5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerPATCH v6 2/2 drm/i915: Simplify i915_reg_read_ioctl
Convert to use the freshly available made INTEL_GEN_MASK for easier grepping and improve function readability and clarify the UABI documentation.
No functional changes.
v2:
- Lift GEM_BUG_ONs and use is_power_of_2 (Chris)
- Retain -EINVAL on bad flags behavior (Chris)
v3:
- Extract flags with 'entry->size - 1' (Chris)
v4:
- Add GEM_BUG_ON on for flags vs entry offset (Chris)
v5:
- Use 'u16' to match 'dev_priv' (Ville)
--- drivers/gpu/drm/i915/intel_uncore.c | 95 +++++++++++++++++-------------------- include/uapi/drm/i915_drm.h | 6 ++- 2 files changed, 48 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/intel_uncore.c +44 -51
@@ -1292,72 +1292,65 @@ void intel_uncore_fini(struct drm_i915_private *dev_priv)intel_uncore_forcewake_reset (dev_priv, false); } -#define GEN_RANGE (l, h) GENMASK((h) - 1, (l) - 1) - -static const struct register_whitelist { -i915_reg_t offset_ldw, offset_udw; -uint32_t size; -/* supported gens, 0x10 for 4, 0x30 for 4 and 5, etc. */ -uint32_t gen_bitmask; -} whitelist[] = { - { .offset_ldw =RING_TIMESTAMP (RENDER_RING_BASE ), - .offset_udw =RING_TIMESTAMP_UDW (RENDER_RING_BASE ), - .size =8 , .gen_bitmask =GEN_RANGE (4 ,10 ) }, -}; +static const struct reg_whitelist { +i915_reg_t offset_ldw; +i915_reg_t offset_udw; +u16 gen_mask; +u8 size; +} reg_read_whitelist[] = {{ + .offset_ldw =RING_TIMESTAMP (RENDER_RING_BASE ), + .offset_udw =RING_TIMESTAMP_UDW (RENDER_RING_BASE ), + .gen_mask =INTEL_GEN_MASK (4 ,10 ), + .size =8 +}};int i915_reg_read_ioctl (struct drm_device *dev,void *data,struct drm_file *file) {struct drm_i915_private *dev_priv =to_i915 (dev);struct drm_i915_reg_read *reg = data; -struct register_whitelist const *entry = whitelist; -unsigned size; -i915_reg_t offset_ldw, offset_udw; -int i, ret =0 ; - -for (i =0 ; i <ARRAY_SIZE (whitelist); i++, entry++) { -if (i915_mmio_reg_offset (entry->offset_ldw) == (reg->offset & -entry->size) && - (INTEL_INFO (dev_priv)->gen_mask & entry->gen_bitmask)) +struct reg_whitelist const *entry; +unsigned flags; +int remain; +int ret =0 ; + + entry = reg_read_whitelist; + remain =ARRAY_SIZE (reg_read_whitelist); +while (remain) { +u32 entry_offset =i915_mmio_reg_offset (entry->offset_ldw); + +GEM_BUG_ON (!is_power_of_2 (entry->size)); +GEM_BUG_ON (entry->size >8 ); +GEM_BUG_ON (entry_offset & (entry->size -1 )); + +if (INTEL_INFO (dev_priv)->gen_mask & entry->gen_mask && + entry_offset == (reg->offset & -entry->size))break ; + entry++; + remain--; } -if (i ==ARRAY_SIZE (whitelist)) +if (!remain)return -EINVAL ; -/* We use the low bits to encode extra flags as the register should -* be naturally aligned (and those that are not so aligned merely -* limit the available flags for that register). -*/ - offset_ldw = entry->offset_ldw; - offset_udw = entry->offset_udw; - size = entry->size; - size |= reg->offset ^i915_mmio_reg_offset (offset_ldw); + flags = reg->offset & (entry->size -1 );intel_runtime_pm_get (dev_priv); - -switch (size) { -case 8 |1 : - reg->val =I915_READ64_2x32 (offset_ldw, offset_udw); -break ; -case 8 : - reg->val =I915_READ64 (offset_ldw); -break ; -case 4 : - reg->val =I915_READ (offset_ldw); -break ; -case 2 : - reg->val =I915_READ16 (offset_ldw); -break ; -case 1 : - reg->val =I915_READ8 (offset_ldw); -break ; -default : +if (entry->size ==8 && flags ==I915_REG_READ_8B_WA ) + reg->val =I915_READ64_2x32 (entry->offset_ldw, + entry->offset_udw); +else if (entry->size ==8 && flags ==0 ) + reg->val =I915_READ64 (entry->offset_ldw); +else if (entry->size ==4 && flags ==0 ) + reg->val =I915_READ (entry->offset_ldw); +else if (entry->size ==2 && flags ==0 ) + reg->val =I915_READ16 (entry->offset_ldw); +else if (entry->size ==1 && flags ==0 ) + reg->val =I915_READ8 (entry->offset_ldw); +else ret = -EINVAL ; - goto out; - } - -out:intel_runtime_pm_put (dev_priv); +return ret; }
include/uapi/drm/i915_drm.h +4 -2
@@ -1308,14 +1308,16 @@ struct drm_i915_reg_read {* be specified */ __u64 offset; +#define I915_REG_READ_8B_WA BIT(0) +__u64 val;/* Return value */ };/* Known registers: * * Render engine timestamp - 0x2358 + 64bit - gen7+ * - Note this register returns an invalid value if using the default -* single instruction 8byte read, in order to workaround that use -* offset (0x2538 | 1) instead. +* single instruction 8byte read, in order to workaround that pass +* flag I915_REG_READ_8B_WA in offset field. * */
Signature · 6 lines
2.13.5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [v6,1/2] drm/i915: Introduce INTEL_GEN_MASK
In reply to Joonas Lahtinen== Series Details ==
== Series Details ==
Series: series starting with [v6,1/2] drm/i915: Introduce INTEL_GEN_MASK
URL : https://patchwork.freedesktop.org/series/30124/
State : success
== Summary ==
Series 30124v1 series starting with [v6,1/2] drm/i915: Introduce INTEL_GEN_MASK
https://patchwork.freedesktop.org/api/1.0/series/30124/revisions/1/mbox/
Test kms_cursor_legacy:
Subgroup basic-busy-flip-before-cursor-atomic:
pass -> FAIL (fi-snb-2600) fdo#100215 +1
Test kms_flip:
Subgroup basic-flip-vs-modeset:
pass -> SKIP (fi-skl-x1585l) fdo#101781fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:445s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:459s fi-blb-e6850 total:289 pass:224 dwarn:1 dfail:0 fail:0 skip:64 time:383s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:527s fi-bwr-2160 total:289 pass:184 dwarn:0 dfail:0 fail:0 skip:105 time:272s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:511s fi-byt-j1900 total:289 pass:254 dwarn:1 dfail:0 fail:0 skip:34 time:505s fi-cfl-s total:289 pass:250 dwarn:4 dfail:0 fail:0 skip:35 time:463s fi-elk-e7500 total:289 pass:230 dwarn:0 dfail:0 fail:0 skip:59 time:447s fi-glk-2a total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:593s fi-hsw-4770 total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:428s fi-hsw-4770r total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:408s fi-ilk-650 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:440s fi-ivb-3520m total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:483s fi-ivb-3770 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:460s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:490s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:580s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:585s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:455s 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:502s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:457s fi-skl-x1585l total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:476s fi-snb-2520m total:289 pass:251 dwarn:0 dfail:0 fail:0 skip:38 time:568s fi-snb-2600 total:289 pass:248 dwarn:0 dfail:0 fail:2 skip:39 time:423s
fi-byt-n2820 failed to connect after reboot
fi-pnv-d510 failed to connect after reboot
14ea1a9ec7378f8172037843a5e795bc9eacbd10 drm-tip: 2017y-09m-11d-12h-03m-37s UTC integration manifest 496c30e95c8d drm/i915: Simplify i915_reg_read_ioctl2878870335cf drm/i915: Introduce INTEL_GEN_MASK
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5642/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 2 lines · Joonas Lahtinen
Split
INTEL_GEN_MASKout ofIS_GENmacro, and make it usable within static declarations (unlike combound statements).
Typo -> compound to fixup when merging.
Regards,
Tvrtko
Quoted 39 lines
Signed-off-by Joonas Lahtinen <[email protected]>Cc Jani Nikula <[email protected]>Cc Chris Wilson <[email protected]>Reviewed-by Jani Nikula <[email protected]>Reviewed-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)drivers/gpu/drm/i915/i915_drv.h +8
-7@@ -2873,23 +2873,21 @@ intel_info(const struct drm_i915_private *dev_priv)#define INTEL_REVID (dev_priv) ((dev_priv)->drm.pdev->revision)#define GEN_FOREVER (0) + +#define INTEL_GEN_MASK (s, e) ( \ + BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \ + BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \ + GENMASK((e) != GEN_FOREVER ? (e) - 1 : BITS_PER_LONG - 1, \ + (s) != GEN_FOREVER ? (s) - 1 : 0) \ +) +/* * Returns true if Gen is in inclusive range [Start, End]. * * Use GEN_FOREVER for unbound start and or end. */ -#define IS_GEN (dev_priv, s, e) ({ \ - unsigned int __s = (s), __e = (e); \ - BUILD_BUG_ON(!__builtin_constant_p(s)); \ - BUILD_BUG_ON(!__builtin_constant_p(e)); \ - if ((__s) != GEN_FOREVER) \ - __s = (s) - 1; \ - if ((__e) == GEN_FOREVER) \
drivers/gpu/drm/i915/i915_drv.h intel_info(const struct drm_i915_private *dev_priv) · line 2893
Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +2
-5- __e =BITS_PER_LONG -1 ; \ - else \ - __e = (e) -1 ; \ - !!((dev_priv)->info.gen_mask &GENMASK ((__e), (__s))); \ -}) +#define IS_GEN (dev_priv, s, e) \ + (!!((dev_priv)->info.gen_mask & INTEL_GEN_MASK((s), (e))))/* * Return true if revision is in range [since,until] inclusive.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for series starting with [v6,1/2] drm/i915: Introduce INTEL_GEN_MASK
In reply to Joonas Lahtinen== Series Details ==
== Series Details ==
Series: series starting with [v6,1/2] drm/i915: Introduce INTEL_GEN_MASK
URL : https://patchwork.freedesktop.org/series/30124/
State : success
== Summary ==
Test perf:
Subgroup blocking:
fail -> PASS (shard-hsw) fdo#102252fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
shard-hsw total:2301 pass:1236 dwarn:0 dfail:0 fail:13 skip:1052 time:9402s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5642/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx