public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: yu.dai@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: "Michael H. Nguyen" <michael.h.nguyen@intel.com>
Subject: [PATCH v6 02/14] drm/i915: Add i915_gem_object_write() to i915_gem.c
Date: Wed, 29 Apr 2015 15:13:23 -0700	[thread overview]
Message-ID: <1430345615-5576-3-git-send-email-yu.dai@intel.com> (raw)
In-Reply-To: <1430345615-5576-1-git-send-email-yu.dai@intel.com>

From: "Michael H. Nguyen" <michael.h.nguyen@intel.com>

i915_gem_object_write() is a generic function to copy data from
user memory to gem object.

Issue: VIZ-4884
Signed-off-by: Alex Dai <yu.dai@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h |  2 ++
 drivers/gpu/drm/i915/i915_gem.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 31e13e9..f5068cb 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2646,6 +2646,8 @@ void i915_init_vm(struct drm_i915_private *dev_priv,
 		  struct i915_address_space *vm);
 void i915_gem_free_object(struct drm_gem_object *obj);
 void i915_gem_vma_destroy(struct i915_vma *vma);
+int i915_gem_object_write(struct drm_i915_gem_object *obj,
+			const void *data, const size_t size);
 
 /* Flags used by pin/bind&friends. */
 #define PIN_MAPPABLE	(1<<0)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index db59821..fabe8de 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -5238,3 +5238,31 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
 	return false;
 }
 
+/* Fill the @obj with the @size amount of @data */
+int i915_gem_object_write(struct drm_i915_gem_object *obj,
+			const void *data, const size_t size)
+{
+	struct sg_table *sg;
+	size_t bytes;
+	int ret;
+
+	ret = i915_gem_object_get_pages(obj);
+	if (ret)
+		return ret;
+
+	i915_gem_object_pin_pages(obj);
+
+	sg = obj->pages;
+
+	bytes = sg_copy_from_buffer(sg->sgl, sg->nents, (void *)data, size);
+
+	i915_gem_object_unpin_pages(obj);
+
+	if (WARN_ON(bytes != size)) {
+		DRM_ERROR("Uncompleted copy, wrote %zu of %zu", bytes, size);
+		i915_gem_object_put_pages(obj);
+		return -EIO;
+	}
+
+	return 0;
+}
-- 
1.9.1

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

  parent reply	other threads:[~2015-04-29 22:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-29 22:13 [PATCH v6 00/14] Command submission via GuC for SKL yu.dai
2015-04-29 22:13 ` [PATCH v6 01/14] drm/i915: Defer default hardware context initialisation until first open yu.dai
2015-04-29 22:13 ` yu.dai [this message]
2015-04-29 22:13 ` [PATCH v6 03/14] drm/i915: Unified firmware loading mechanism yu.dai
2015-04-29 22:13 ` [PATCH v6 04/14] drm/i915: Move execlists defines from .c to .h yu.dai
2015-04-29 22:13 ` [PATCH v6 05/14] drm/i915: Add guc firmware interface headers yu.dai
2015-04-29 22:13 ` [PATCH v6 06/14] drm/i915: GuC firmware loader yu.dai
2015-04-29 22:13 ` [PATCH v6 07/14] drm/i915: Add functions to allocate / release gem obj for GuC yu.dai
2015-05-05 18:36   ` Dave Gordon
2015-04-29 22:13 ` [PATCH v6 08/14] drm/i915: Functions to support command submission via GuC yu.dai
2015-04-29 22:13 ` [PATCH v6 09/14] drm/i915: Integration of GuC client yu.dai
2015-04-29 22:13 ` [PATCH v6 10/14] drm/i915: Interrupt routing for GuC scheduler yu.dai
2015-04-29 22:13 ` [PATCH v6 11/14] drm/i915: Enable commands submission via GuC yu.dai
2015-04-29 22:13 ` [PATCH v6 12/14] drm/i915: debugfs of GuC status yu.dai
2015-04-29 22:13 ` [PATCH v6 13/14] drm/i915: Enable GuC firmware log yu.dai
2015-05-01 17:48   ` Dave Gordon
2015-05-05 12:45   ` Dave Gordon
2015-04-29 22:13 ` [PATCH v6 14/14] Documentation/drm: kerneldoc for GuC yu.dai
2015-05-01  9:40   ` shuang.he

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=1430345615-5576-3-git-send-email-yu.dai@intel.com \
    --to=yu.dai@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=michael.h.nguyen@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