Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: Fix gtt_view asserts

gcc is too smart for us and doesn't evaluate BUILD_BUG_ON()s in
unused static inlines. Collect them up in one static inline and
actually call it to make sure gcc sees it.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180828133723.18505-1-ville.syrjala@linux.intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

+6 -11
+4 -11
drivers/gpu/drm/i915/i915_gem_gtt.h
··· 167 167 } plane[2]; 168 168 } __packed; 169 169 170 - static inline void assert_intel_rotation_info_is_packed(void) 171 - { 172 - BUILD_BUG_ON(sizeof(struct intel_rotation_info) != 8*sizeof(unsigned int)); 173 - } 174 - 175 170 struct intel_partial_info { 176 171 u64 offset; 177 172 unsigned int size; 178 173 } __packed; 179 - 180 - static inline void assert_intel_partial_info_is_packed(void) 181 - { 182 - BUILD_BUG_ON(sizeof(struct intel_partial_info) != sizeof(u64) + sizeof(unsigned int)); 183 - } 184 174 185 175 enum i915_ggtt_view_type { 186 176 I915_GGTT_VIEW_NORMAL = 0, ··· 178 188 I915_GGTT_VIEW_PARTIAL = sizeof(struct intel_partial_info), 179 189 }; 180 190 181 - static inline void assert_i915_ggtt_view_type_is_unique(void) 191 + static inline void assert_i915_gem_gtt_types(void) 182 192 { 193 + BUILD_BUG_ON(sizeof(struct intel_rotation_info) != 8*sizeof(unsigned int)); 194 + BUILD_BUG_ON(sizeof(struct intel_partial_info) != sizeof(u64) + sizeof(unsigned int)); 195 + 183 196 /* As we encode the size of each branch inside the union into its type, 184 197 * we have to be careful that each branch has a unique size. 185 198 */
+2
drivers/gpu/drm/i915/i915_vma.h
··· 251 251 if (cmp) 252 252 return cmp; 253 253 254 + assert_i915_gem_gtt_types(); 255 + 254 256 /* ggtt_view.type also encodes its size so that we both distinguish 255 257 * different views using it as a "type" and also use a compact (no 256 258 * accessing of uninitialised padding bytes) memcmp without storing