]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915: Compact memcmp in i915_vma_compare()
authorChris Wilson <chris@chris-wilson.co.uk>
Sat, 14 Jan 2017 00:28:23 +0000 (00:28 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Sat, 14 Jan 2017 16:17:44 +0000 (16:17 +0000)
commit7e0ff553e06c5978ac3955bacadc0f0581a13c63
tree88dee7a13b233ad2c29784d9dfc88fcc4e7a5059
parent53133d7df7e017057ef8a7e035ad9a96ee1fd1e9
drm/i915: Compact memcmp in i915_vma_compare()

In preparation for the next patch to convert to using an anonymous union
and leaving the excess bytes in the union uninitialised, we first need
to make sure we do not compare using those uninitialised bytes. We also
want to preserve the compactness of the code, avoiding a second call to
memcmp or introducing a switch, so we take advantage of using the type
as an encoded size (as well as a unique identifier for each type of view).

v2: Add the rationale for why we encode size into ggtt_view.type as a
comment before the memcmp()
v3: Use a switch to also assert that no two i915_ggtt_view_type have the same
value.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170114002827.31315-3-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem_gtt.h
drivers/gpu/drm/i915/i915_vma.h