intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: ankitprasad.r.sharma@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>,
	akash.goel@intel.com, shashidhar.hiremath@intel.com
Subject: [PATCH 1/4] drm/i915: Clearing buffer objects via CPU/GTT
Date: Wed, 22 Jul 2015 19:21:46 +0530	[thread overview]
Message-ID: <1437573109-19211-2-git-send-email-ankitprasad.r.sharma@intel.com> (raw)
In-Reply-To: <1437573109-19211-1-git-send-email-ankitprasad.r.sharma@intel.com>

From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>

This patch adds support for clearing buffer objects via CPU/GTT. This
is particularly useful for clearing out the non shmem backed objects.
Currently intend to use this only for buffers allocated from stolen
region.

Testcase: igt/gem_stolen

Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h |  1 +
 drivers/gpu/drm/i915/i915_gem.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ea9caf2..f6af9c0 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2764,6 +2764,7 @@ int i915_gem_obj_prepare_shmem_read(struct drm_i915_gem_object *obj,
 				    int *needs_clflush);
 
 int __must_check i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
+int i915_gem_clear_object(struct drm_i915_gem_object *obj);
 
 static inline int __sg_page_count(struct scatterlist *sg)
 {
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index a2a4a27..fc434ae 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -5469,3 +5469,37 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
 	return false;
 }
 
+int i915_gem_clear_object(struct drm_i915_gem_object *obj)
+{
+	int ret = 0;
+	char __iomem *base;
+	int size = obj->base.size;
+	struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
+	unsigned alignment = 0;
+
+	ret = i915_gem_obj_ggtt_pin(obj, alignment, PIN_MAPPABLE);
+	if (ret) {
+		DRM_ERROR("Mapping of gem object to GTT failed\n");
+		return ret;
+	}
+
+	ret = i915_gem_object_put_fence(obj);
+	if (ret)
+		goto unpin;
+
+	/* Get the CPU virtual address of the buffer */
+	base = ioremap_wc(dev_priv->gtt.mappable_base +
+			  i915_gem_obj_ggtt_offset(obj), size);
+	if (base == NULL) {
+		DRM_ERROR("Mapping of gem object to CPU failed\n");
+		ret = -ENOSPC;
+		goto unpin;
+	}
+
+	memset_io(base, 0, size);
+
+	iounmap(base);
+unpin:
+	i915_gem_object_ggtt_unpin(obj);
+	return ret;
+}
-- 
1.9.1

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

  reply	other threads:[~2015-07-22 14:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 13:51 [PATCH v5 0/4] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2015-07-22 13:51 ` ankitprasad.r.sharma [this message]
2015-07-22 15:01   ` [PATCH 1/4] drm/i915: Clearing buffer objects via CPU/GTT Tvrtko Ursulin
2015-07-22 15:05     ` Chris Wilson
2015-07-22 15:06     ` Chris Wilson
2015-07-22 15:16       ` Tvrtko Ursulin
2015-07-22 15:23         ` Chris Wilson
2015-07-22 13:51 ` [PATCH 2/4] drm/i915: Support for creating Stolen memory backed objects ankitprasad.r.sharma
2015-07-22 15:14   ` Tvrtko Ursulin
2015-07-22 15:27     ` Chris Wilson
2015-07-22 13:51 ` [PATCH 3/4] drm/i915: Add support for stealing purgable stolen pages ankitprasad.r.sharma
2015-07-22 15:10   ` Chris Wilson
2015-07-27  9:38   ` Daniel Vetter
2015-07-29 12:04     ` Chris Wilson
2015-07-31 14:42       ` Goel, Akash
2015-07-31 15:06         ` Chris Wilson
2015-07-31 16:34           ` Goel, Akash
2015-07-31 14:24     ` Goel, Akash
2015-07-22 13:51 ` [PATCH 4/4] drm/i915: Support for pread/pwrite from/to non shmem backed objects ankitprasad.r.sharma
2015-07-22 14:39   ` Chris Wilson
2015-07-31 13:16     ` Goel, Akash
2015-09-10 17:50       ` Ankitprasad Sharma
2015-09-15  9:58       ` Chris Wilson
2015-07-22 15:46   ` Tvrtko Ursulin
2015-07-22 16:05     ` Daniel Vetter
2015-07-22 16:17       ` Tvrtko Ursulin
  -- strict thread matches above, loose matches on Subject: below --
2015-09-15  8:33 [PATCH v6 0/4] Support for creating/using Stolen memory " ankitprasad.r.sharma
2015-09-15  8:33 ` [PATCH 1/4] drm/i915: Clearing buffer objects via CPU/GTT ankitprasad.r.sharma
2015-09-15 14:00   ` Tvrtko Ursulin

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=1437573109-19211-2-git-send-email-ankitprasad.r.sharma@intel.com \
    --to=ankitprasad.r.sharma@intel.com \
    --cc=akash.goel@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=shashidhar.hiremath@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).