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 2/5] drm/i915: Support for creating Stolen memory backed objects
Date: Wed, 29 Apr 2015 15:01:56 +0530 [thread overview]
Message-ID: <1430299919-9865-3-git-send-email-ankitprasad.r.sharma@intel.com> (raw)
In-Reply-To: <1430299919-9865-1-git-send-email-ankitprasad.r.sharma@intel.com>
From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
Extend the drm_i915_gem_create structure to add support for
creating Stolen memory backed objects. Added a new flag through
which user can specify the preference to allocate the object from
stolen memory, which if set, an attempt will be made to allocate
the object from stolen memory subject to the availability of
free space in the stolen region.
testcase: igt/gem_create_stolen
Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
---
drivers/gpu/drm/i915/i915_dma.c | 3 +++
drivers/gpu/drm/i915/i915_gem.c | 31 +++++++++++++++++++++++++++----
include/uapi/drm/i915_drm.h | 15 +++++++++++++++
3 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index d49ed68..491c91f 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -163,6 +163,9 @@ static int i915_getparam(struct drm_device *dev, void *data,
if (!value)
return -ENODEV;
break;
+ case I915_PARAM_CREATE_VERSION:
+ value = 1;
+ break;
default:
DRM_DEBUG("Unknown parameter %d\n", param->param);
return -EINVAL;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 84e2a23..81c5381 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -391,7 +391,8 @@ static int
i915_gem_create(struct drm_file *file,
struct drm_device *dev,
uint64_t size,
- uint32_t *handle_p)
+ uint32_t *handle_p,
+ uint32_t flags)
{
struct drm_i915_gem_object *obj;
int ret;
@@ -401,8 +402,29 @@ i915_gem_create(struct drm_file *file,
if (size == 0)
return -EINVAL;
+ if (flags & ~(I915_CREATE_PLACEMENT_STOLEN))
+ return -EINVAL;
+
/* Allocate the new object */
- obj = i915_gem_alloc_object(dev, size);
+ if (flags & I915_CREATE_PLACEMENT_STOLEN) {
+ mutex_lock(&dev->struct_mutex);
+ obj = i915_gem_object_create_stolen(dev, size);
+ if (!obj) {
+ mutex_unlock(&dev->struct_mutex);
+ return -ENOMEM;
+ }
+
+ ret = i915_gem_exec_clear_object(obj, file->driver_priv);
+ if (ret) {
+ i915_gem_object_free(obj);
+ mutex_unlock(&dev->struct_mutex);
+ return ret;
+ }
+
+ mutex_unlock(&dev->struct_mutex);
+ } else
+ obj = i915_gem_alloc_object(dev, size);
+
if (obj == NULL)
return -ENOMEM;
@@ -425,7 +447,7 @@ i915_gem_dumb_create(struct drm_file *file,
args->pitch = ALIGN(args->width * DIV_ROUND_UP(args->bpp, 8), 64);
args->size = args->pitch * args->height;
return i915_gem_create(file, dev,
- args->size, &args->handle);
+ args->size, &args->handle, 0);
}
/**
@@ -438,7 +460,8 @@ i915_gem_create_ioctl(struct drm_device *dev, void *data,
struct drm_i915_gem_create *args = data;
return i915_gem_create(file, dev,
- args->size, &args->handle);
+ args->size, &args->handle,
+ args->flags);
}
static inline int
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 8d1be90..ab4f3a9 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -350,6 +350,7 @@ typedef struct drm_i915_irq_wait {
#define I915_PARAM_REVISION 32
#define I915_PARAM_SUBSLICE_TOTAL 33
#define I915_PARAM_EU_TOTAL 34
+#define I915_PARAM_CREATE_VERSION 35
typedef struct drm_i915_getparam {
int param;
@@ -445,6 +446,20 @@ struct drm_i915_gem_create {
*/
__u32 handle;
__u32 pad;
+ /**
+ * Requested flags (currently used for placement
+ * (which memory domain))
+ *
+ * You can request that the object be created from special memory
+ * rather than regular system pages using this parameter. Such
+ * irregular objects may have certain restrictions (such as CPU
+ * access to a stolen object is verboten).
+ *
+ * This can be used in the future for other purposes too
+ * e.g. specifying tiling/caching/madvise
+ */
+ __u32 flags;
+#define I915_CREATE_PLACEMENT_STOLEN (1<<0) /* Cannot use CPU mmaps or pread/pwrite */
};
struct drm_i915_gem_pread {
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-04-29 9:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 9:31 [PATCH v2 0/5] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2015-04-29 9:31 ` [PATCH 1/5] drm/i915: Clearing buffer objects via blitter engine ankitprasad.r.sharma
2015-04-29 9:31 ` ankitprasad.r.sharma [this message]
2015-04-29 9:31 ` [PATCH 3/5] drm/i915: Add support for stealing purgable stolen pages ankitprasad.r.sharma
2015-04-29 9:31 ` [PATCH 4/5] drm/i915: Support for pread/pwrite from/to non shmem backed objects ankitprasad.r.sharma
2015-04-29 10:19 ` Chris Wilson
2015-04-29 10:57 ` Chris Wilson
2015-04-29 9:31 ` [PATCH 5/5] drm/i915: Add support for getting size of the stolen region ankitprasad.r.sharma
2015-04-29 10:27 ` Chris Wilson
2015-05-05 11:42 ` Ankitprasad Sharma
2015-05-05 12:54 ` Chris Wilson
-- strict thread matches above, loose matches on Subject: below --
2015-09-23 10:51 [PATCH v7 0/5] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2015-09-23 10:51 ` [PATCH 2/5] drm/i915: Support for creating " ankitprasad.r.sharma
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=1430299919-9865-3-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