diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2016-12-13 14:37:27 +0000 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2016-12-15 13:31:26 +0000 |
commit | 2bf0d26706f899e124a2b340dc0529386bb2b235 (patch) | |
tree | 825d46bd0cee90097a0ed29964ebc99c624aeedf /drivers/gpu/drm/i915/i915_vma.h | |
parent | 2ee7dc497e348eecbb82adbb1ea9e9a7e29fe921 (diff) | |
download | talos-obmc-linux-2bf0d26706f899e124a2b340dc0529386bb2b235.tar.gz talos-obmc-linux-2bf0d26706f899e124a2b340dc0529386bb2b235.zip |
drm/i915: Optimise VMA lookup slightly
Cast VM pointers before substraction to save the compiler
doing a smart one which includes multiplication.
v2: Only keep the first optimisation and prettify it. (Chris Wilson)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1481639847-9214-1-git-send-email-tvrtko.ursulin@linux.intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/i915_vma.h')
-rw-r--r-- | drivers/gpu/drm/i915/i915_vma.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h index 21be74c61065..e3b2b3b1e056 100644 --- a/drivers/gpu/drm/i915/i915_vma.h +++ b/drivers/gpu/drm/i915/i915_vma.h @@ -178,15 +178,23 @@ static inline void i915_vma_put(struct i915_vma *vma) i915_gem_object_put(vma->obj); } +static __always_inline ptrdiff_t ptrdiff(const void *a, const void *b) +{ + return a - b; +} + static inline long i915_vma_compare(struct i915_vma *vma, struct i915_address_space *vm, const struct i915_ggtt_view *view) { + ptrdiff_t cmp; + GEM_BUG_ON(view && !i915_is_ggtt(vm)); - if (vma->vm != vm) - return vma->vm - vm; + cmp = ptrdiff(vma->vm, vm); + if (cmp) + return cmp; if (!view) return vma->ggtt_view.type; |