public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: vfree() no longer ignores the low bits of the address
Date: Thu, 18 Aug 2016 10:45:10 +0100	[thread overview]
Message-ID: <57B583A6.7060106@linux.intel.com> (raw)
In-Reply-To: <20160818090117.12690-1-chris@chris-wilson.co.uk>


On 18/08/16 10:01, Chris Wilson wrote:
> Since vfree() now likes to WARN when passed a none page-aligned pointer,
> we need to discard the low bits to comply with it.
>
> Fixes: d31d7cb1460c ("drm/i915: Support for creating write combined type vmaps")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_drv.h |  5 +++++
>   drivers/gpu/drm/i915/i915_gem.c | 11 +++++++----
>   2 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 35caa9b2f36a..cc1e72dbf18e 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3896,6 +3896,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);
>   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) ({					\
>   	unsigned long __v = (unsigned long)(ptr);			\
>   	(bits) = __v & ~PAGE_MASK;					\
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index a8d0f70c22f9..cffa57b14246 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2094,11 +2094,14 @@ i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
>   	list_del(&obj->global_list);
>
>   	if (obj->mapping) {
> -		/* low bits are ignored by is_vmalloc_addr and kmap_to_page */
> -		if (is_vmalloc_addr(obj->mapping))
> -			vunmap(obj->mapping);
> +		void *ptr;
> +
> +		ptr = ptr_mask_bits(obj->mapping);
> +		if (is_vmalloc_addr(ptr))
> +			vunmap(ptr);
>   		else
> -			kunmap(kmap_to_page(obj->mapping));
> +			kunmap(kmap_to_page(ptr));
> +
>   		obj->mapping = NULL;
>   	}
>
>

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-08-18  9:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18  9:01 [PATCH] drm/i915: vfree() no longer ignores the low bits of the address Chris Wilson
2016-08-18  9:44 ` ✗ Ro.CI.BAT: failure for " Patchwork
2016-08-18  9:45 ` Tvrtko Ursulin [this message]
2016-08-18 10:36 ` [PATCH] " Joonas Lahtinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57B583A6.7060106@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox