Commit 4b30cb23 authored by Chris Wilson's avatar Chris Wilson

drm/i915: vfree() no longer ignores the low bits of the address

Since vfree() now likes to WARN when passed a non-page-aligned pointer,
we need to discard the low bits to comply with it.

Fixes: d31d7cb1 ("drm/i915: Support for creating write combined type vmaps")
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20160818161718.27187-3-chris@chris-wilson.co.uk
parent 3497971a
...@@ -3897,6 +3897,11 @@ static inline bool __i915_request_irq_complete(struct drm_i915_gem_request *req) ...@@ -3897,6 +3897,11 @@ static inline bool __i915_request_irq_complete(struct drm_i915_gem_request *req)
void i915_memcpy_init_early(struct drm_i915_private *dev_priv); void i915_memcpy_init_early(struct drm_i915_private *dev_priv);
bool i915_memcpy_from_wc(void *dst, const void *src, unsigned long len); bool i915_memcpy_from_wc(void *dst, const void *src, unsigned long len);
#define ptr_mask_bits(ptr) ({ \
unsigned long __v = (unsigned long)(ptr); \
(typeof(ptr))(__v & PAGE_MASK); \
})
#define ptr_unpack_bits(ptr, bits) ({ \ #define ptr_unpack_bits(ptr, bits) ({ \
unsigned long __v = (unsigned long)(ptr); \ unsigned long __v = (unsigned long)(ptr); \
(bits) = __v & ~PAGE_MASK; \ (bits) = __v & ~PAGE_MASK; \
......
...@@ -2094,11 +2094,14 @@ i915_gem_object_put_pages(struct drm_i915_gem_object *obj) ...@@ -2094,11 +2094,14 @@ i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
list_del(&obj->global_list); list_del(&obj->global_list);
if (obj->mapping) { if (obj->mapping) {
/* low bits are ignored by is_vmalloc_addr and kmap_to_page */ void *ptr;
if (is_vmalloc_addr(obj->mapping))
vunmap(obj->mapping); ptr = ptr_mask_bits(obj->mapping);
if (is_vmalloc_addr(ptr))
vunmap(ptr);
else else
kunmap(kmap_to_page(obj->mapping)); kunmap(kmap_to_page(ptr));
obj->mapping = NULL; obj->mapping = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment