drm/i915: Explicitly convert some macros to boolean values
Subsystems (2)
PATCH 1/1 drm/i915: Explicitly convert some macros to boolean values
From: Tvrtko Ursulin <[email protected]>
Some IS_ and HAS_ macros can return any non-zero value for true.
One potential problem with that is that someone could assign them to integers and be surprised with the result. Therefore it is probably safer to do the conversion to 0/1 in the macros themselves.
Luckily this does not seem to have an effect on code size.
Only one call site was getting bit by this and a patch for that has been sent as "drm/i915/guc: Protect against HAS_GUC_* returning true values other than one".
--- drivers/gpu/drm/i915/i915_drv.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +10 -10
@@ -2762,14 +2762,14 @@ struct drm_i915_cmd_table {* have their own (e.g. HAS_PCH_SPLIT for ILK+ display, IS_foo for particular * chips, etc.). */ -#define IS_GEN2 (dev) (INTEL_INFO(dev)->gen_mask & BIT(1)) -#define IS_GEN3 (dev) (INTEL_INFO(dev)->gen_mask & BIT(2)) -#define IS_GEN4 (dev) (INTEL_INFO(dev)->gen_mask & BIT(3)) -#define IS_GEN5 (dev) (INTEL_INFO(dev)->gen_mask & BIT(4)) -#define IS_GEN6 (dev) (INTEL_INFO(dev)->gen_mask & BIT(5)) -#define IS_GEN7 (dev) (INTEL_INFO(dev)->gen_mask & BIT(6)) -#define IS_GEN8 (dev) (INTEL_INFO(dev)->gen_mask & BIT(7)) -#define IS_GEN9 (dev) (INTEL_INFO(dev)->gen_mask & BIT(8)) +#define IS_GEN2 (dev) !!(INTEL_INFO(dev)->gen_mask & BIT(1)) +#define IS_GEN3 (dev) !!(INTEL_INFO(dev)->gen_mask & BIT(2)) +#define IS_GEN4 (dev) !!(INTEL_INFO(dev)->gen_mask & BIT(3)) +#define IS_GEN5 (dev) !!(INTEL_INFO(dev)->gen_mask & BIT(4)) +#define IS_GEN6 (dev) !!(INTEL_INFO(dev)->gen_mask & BIT(5)) +#define IS_GEN7 (dev) !!(INTEL_INFO(dev)->gen_mask & BIT(6)) +#define IS_GEN8 (dev) !!(INTEL_INFO(dev)->gen_mask & BIT(7)) +#define IS_GEN9 (dev) !!(INTEL_INFO(dev)->gen_mask & BIT(8))#define ENGINE_MASK (id) BIT(id)#define RENDER_RING ENGINE_MASK(RCS)
@@ -2780,7 +2780,7 @@ struct drm_i915_cmd_table {#define ALL_ENGINES (~0)#define HAS_ENGINE (dev_priv, id) \ - (INTEL_INFO(dev_priv)->ring_mask & ENGINE_MASK(id)) + !!(INTEL_INFO(dev_priv)->ring_mask & ENGINE_MASK(id))#define HAS_BSD (dev_priv) HAS_ENGINE(dev_priv, VCS)#define HAS_BSD2 (dev_priv) HAS_ENGINE(dev_priv, VCS2)
@@ -2789,7 +2789,7 @@ struct drm_i915_cmd_table {#define HAS_LLC (dev) (INTEL_INFO(dev)->has_llc)#define HAS_SNOOP (dev) (INTEL_INFO(dev)->has_snoop) -#define HAS_EDRAM (dev) (__I915__(dev)->edram_cap & EDRAM_ENABLED) +#define HAS_EDRAM (dev) !!(__I915__(dev)->edram_cap & EDRAM_ENABLED)#define HAS_WT (dev) ((IS_HASWELL(dev) || IS_BROADWELL(dev)) && \ HAS_EDRAM(dev))#define I915_NEED_GFX_HWS (dev) (INTEL_INFO(dev)->need_gfx_hws)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 10 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Some
IS_andHAS_macros can return any non-zero value for true.One potential problem with that is that someone could assign them to integers and be surprised with the result. Therefore it is probably safer to do the conversion to 0/1 in the macros themselves.
Luckily this does not seem to have an effect on code size.
Indeed, gcc is quite happy to remove the !! and combine e.g. IS_GEN6() || IS_GEN7() into a single testb.
With that,
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Ro.CI.BAT: failure for drm/i915: Explicitly convert some macros to boolean values
In reply to Tvrtko Ursulin== Series Details ==
== Series Details ==
Series: drm/i915: Explicitly convert some macros to boolean values
URL : https://patchwork.freedesktop.org/series/9475/
State : failure
== Summary ==
Series 9475v1 drm/i915: Explicitly convert some macros to boolean values
http://patchwork.freedesktop.org/api/1.0/series/9475/revisions/1/mbox
Test drv_hangman:
Subgroup error-state-basic:
fail -> PASS (ro-skl3-i5-6260u)
Test drv_module_reload_basic:
dmesg-fail -> DMESG-WARN (ro-skl3-i5-6260u)
Test gem_busy:
Subgroup basic-blt:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-bsd:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-bsd1:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-bsd2:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-parallel-blt:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-parallel-bsd:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-parallel-bsd1:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-parallel-bsd2:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-parallel-render:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-parallel-vebox:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-render:
skip -> PASS (ro-skl3-i5-6260u)
Subgroup basic-vebox:
skip -> PASS (ro-skl3-i5-6260u)
Test gem_cpu_reloc:
Subgroup basic:
fail -> PASS (ro-skl3-i5-6260u)
Test gem_cs_tlb:
Subgroup basic-default:
fail -> PASS (ro-skl3-i5-6260u)
Test gem_ctx_create:
Subgroup basic-files:
fail -> PASS (ro-skl3-i5-6260u)
Test gem_ctx_exec:
Subgroup basic:
fail -> PASS (ro-skl3-i5-6260u)
Test gem_ctx_switch:
Subgroup basic-default:
skip -> PASS (ro-skl3-i5-6260u)
Test gem_exec_basic:
Subgroup basic-blt:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup basic-bsd:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup basic-bsd1:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup basic-bsd2:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup basic-default:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup basic-render:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup basic-vebox:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup gtt-blt:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup gtt-bsd:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup gtt-bsd1:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup gtt-bsd2:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup gtt-default:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup gtt-render:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup gtt-vebox:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup readonly-blt:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup readonly-bsd:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup readonly-bsd1:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup readonly-bsd2:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup readonly-default:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup readonly-render:
fail -> PASS (ro-skl3-i5-6260u)
Subgroup readonly-vebox:
fail -> PASS (ro-skl3-i5-6260u)
Test gem_exec_create:
Subgroup basic:
fail -> PASS (ro-skl3-i5-6260u)
Test gem_exec_flush:
Subgroup basic-batch-kernel-default-uc:
fail -> PASS (ro-skl3-i5-6260u)
dmesg-fail -> PASS (ro-bdw-i7-5557U)
pass -> DMESG-FAIL (fi-skl-i5-6260u)
pass -> DMESG-FAIL (fi-skl-i7-6700k)WARNING: Long output truncated
Results at /archive/results/CI_IGT_test/RO_Patchwork_1404/
54c86e3 drm-intel-nightly: 2016y-07m-04d-11h-55m-58s UTC integration manifest 3b1ccef2 drm/i915: Explicitly convert some macros to boolean values
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Tvrtko Ursulin
AppliedRe: ✗ Ro.CI.BAT: failure for drm/i915: Explicitly convert some macros to boolean values
Quoted 8 lines · Patchwork
== Series Details ==
Series: drm/i915: Explicitly convert some macros to boolean values
URL : https://patchwork.freedesktop.org/series/9475/
State : failure== Summary ==
Quoted 8 lines
Series 9475v1 drm/i915: Explicitly convert some macros to boolean values
http://patchwork.freedesktop.org/api/1.0/series/9475/revisions/1/mboxTest
drv_hangman:Subgroup error-state-basic: fail -> PASS (ro-skl3-i5-6260u) Test drv_module_reload_basic: dmesg-fail -> DMESG-WARN (ro-skl3-i5-6260u)
Raised https://bugs.freedesktop.org/show_bug.cgi?id=96805 to stop logging GuC fw fetch as an error when in fallback mode.
Quoted 84 lines
Test
gem_busy:Subgroup basic-blt: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-bsd: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-bsd1: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-bsd2: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-parallel-blt: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-parallel-bsd: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-parallel-bsd1: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-parallel-bsd2: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-parallel-render: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-parallel-vebox: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-render: skip -> PASS (ro-skl3-i5-6260u) Subgroup basic-vebox: skip -> PASS (ro-skl3-i5-6260u) Test gem_cpu_reloc: Subgroup basic: fail -> PASS (ro-skl3-i5-6260u) Test gem_cs_tlb: Subgroup basic-default: fail -> PASS (ro-skl3-i5-6260u) Test gem_ctx_create: Subgroup basic-files: fail -> PASS (ro-skl3-i5-6260u) Test gem_ctx_exec: Subgroup basic: fail -> PASS (ro-skl3-i5-6260u) Test gem_ctx_switch: Subgroup basic-default: skip -> PASS (ro-skl3-i5-6260u) Test gem_exec_basic: Subgroup basic-blt: fail -> PASS (ro-skl3-i5-6260u) Subgroup basic-bsd: fail -> PASS (ro-skl3-i5-6260u) Subgroup basic-bsd1: fail -> PASS (ro-skl3-i5-6260u) Subgroup basic-bsd2: fail -> PASS (ro-skl3-i5-6260u) Subgroup basic-default: fail -> PASS (ro-skl3-i5-6260u) Subgroup basic-render: fail -> PASS (ro-skl3-i5-6260u) Subgroup basic-vebox: fail -> PASS (ro-skl3-i5-6260u) Subgroup gtt-blt: fail -> PASS (ro-skl3-i5-6260u) Subgroup gtt-bsd: fail -> PASS (ro-skl3-i5-6260u) Subgroup gtt-bsd1: fail -> PASS (ro-skl3-i5-6260u) Subgroup gtt-bsd2: fail -> PASS (ro-skl3-i5-6260u) Subgroup gtt-default: fail -> PASS (ro-skl3-i5-6260u) Subgroup gtt-render: fail -> PASS (ro-skl3-i5-6260u) Subgroup gtt-vebox: fail -> PASS (ro-skl3-i5-6260u) Subgroup readonly-blt: fail -> PASS (ro-skl3-i5-6260u) Subgroup readonly-bsd: fail -> PASS (ro-skl3-i5-6260u) Subgroup readonly-bsd1: fail -> PASS (ro-skl3-i5-6260u) Subgroup readonly-bsd2: fail -> PASS (ro-skl3-i5-6260u) Subgroup readonly-default: fail -> PASS (ro-skl3-i5-6260u) Subgroup readonly-render: fail -> PASS (ro-skl3-i5-6260u) Subgroup readonly-vebox: fail -> PASS (ro-skl3-i5-6260u)Test
gem_exec_create:
Quoted 8 lines
Subgroup basic:
fail -> PASS (ro-skl3-i5-6260u)
Test gem_exec_flush:
Subgroup basic-batch-kernel-default-uc:
fail -> PASS (ro-skl3-i5-6260u)
dmesg-fail -> PASS (ro-bdw-i7-5557U)
pass -> DMESG-FAIL (fi-skl-i5-6260u)
pass -> DMESG-FAIL (fi-skl-i7-6700k)Filed https://bugs.freedesktop.org/show_bug.cgi?id=96806 for this one.
Quoted 8 lines
WARNING: Long output truncated
Results at /archive/results/CI_IGT_test/RO_Patchwork_1404/
54c86e3 drm-intel-nightly: 2016y-07m-04d-11h-55m-58s UTC integration manifest
3b1ccef2drm/i915: Explicitly convert some macros to boolean values
Merged to dinq, thanks for the review!
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx