All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: [Intel-gfx] [PATCH] drm/i915/gem: Poison stolen pages before use
Date: Thu, 08 Oct 2020 16:04:42 +0300	[thread overview]
Message-ID: <87d01sg979.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20201008105059.3656-1-chris@chris-wilson.co.uk>

Chris Wilson <chris@chris-wilson.co.uk> writes:

> When allocating objects from stolen, memset() the backing store to
> POISON_INUSE (0x5a) to help identify any uninitialised use of a stolen
> object.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 33 ++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
> index 0be5e8683337..4c2869c0a802 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
> @@ -572,6 +572,38 @@ static const struct drm_i915_gem_object_ops i915_gem_object_stolen_ops = {
>  	.release = i915_gem_object_release_stolen,
>  };
>  
> +static void dbg_poison(struct drm_i915_gem_object *obj)
> +{
> +#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
> +	struct drm_i915_private *i915 = to_i915(obj->base.dev);
> +	struct i915_ggtt *ggtt = &i915->ggtt;
> +	struct sgt_iter iter;
> +	dma_addr_t addr;
> +
> +	if (!drm_mm_node_allocated(&ggtt->error_capture))
> +		return;
> +
> +	mutex_lock(&ggtt->error_mutex);
> +	for_each_sgt_daddr(addr, iter, obj->mm.pages) {
> +		void __iomem *s;
> +
> +		ggtt->vm.insert_page(&ggtt->vm, addr,
> +				     ggtt->error_capture.start,
> +				     I915_CACHE_NONE, 0);
> +		mb();
> +
> +		s = io_mapping_map_wc(&ggtt->iomap,
> +				      ggtt->error_capture.start,
> +				      PAGE_SIZE);
> +		memset(s, POISON_INUSE, PAGE_SIZE);
> +		io_mapping_unmap(s);
> +	}
> +	mb();
> +	ggtt->vm.clear_range(&ggtt->vm, ggtt->error_capture.start, PAGE_SIZE);
> +	mutex_unlock(&ggtt->error_mutex);
> +#endif
> +}
> +
>  static struct drm_i915_gem_object *
>  __i915_gem_object_create_stolen(struct intel_memory_region *mem,
>  				struct drm_mm_node *stolen)
> @@ -598,6 +630,7 @@ __i915_gem_object_create_stolen(struct intel_memory_region *mem,
>  		goto cleanup;
>  
>  	i915_gem_object_init_memory_region(obj, mem, 0);
> +	dbg_poison(obj);
>  
>  	return obj;
>  
> -- 
> 2.20.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2020-10-08 13:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08 10:50 [Intel-gfx] [PATCH] drm/i915/gem: Poison stolen pages before use Chris Wilson
2020-10-08 13:04 ` Mika Kuoppala [this message]
2020-10-08 15:18 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2020-10-08 15:18 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2020-10-08 15:40 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-10-08 18:17 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

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=87d01sg979.fsf@gaia.fi.intel.com \
    --to=mika.kuoppala@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.