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

This patch provides a support for the User to immediately flush
out the cachelines for the pre-populated pages of an object, at the
time of its creation. This will not lead to any redundancy and would
further reduce the time for which the 'struct_mutex' is kept locked in
execbuffer path, as cache flush of the newly allocated pages is anyways
done when the object is submitted to GPU.

v2: flush_cpu_write_domain expects the struct mutex to be locked which
was triggerring WARN_ONs, hence doing the required changes in an inline
manner (Ankit)

Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sha...@intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c | 2 +-
 drivers/gpu/drm/i915/i915_gem.c | 7 +++++++
 include/uapi/drm/i915_drm.h     | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 955aa16..eb0b31d 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -171,7 +171,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
                value = HAS_RESOURCE_STREAMER(dev);
                break;
        case I915_PARAM_CREATE_VERSION:
-               value = 3;
+               value = 4;
                break;
        default:
                DRM_DEBUG("Unknown parameter %d\n", param->param);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4430128..fa4cfb0 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -426,6 +426,13 @@ i915_gem_create(struct drm_file *file,
                        return ret;
                }
 
+               if (flags & I915_CREATE_FLUSH) {
+                       if (i915_gem_clflush_object(obj, false))
+                               i915_gem_chipset_flush(obj->base.dev);
+
+                       obj->base.write_domain = 0;
+               }
+
                mutex_lock(&dev->struct_mutex);
                __i915_gem_object_get_pages__tail_locked(obj);
                mutex_unlock(&dev->struct_mutex);
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 26ea715..547305a 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -469,7 +469,8 @@ struct drm_i915_gem_create {
        __u32 flags;
 #define I915_CREATE_PLACEMENT_STOLEN   (1<<0) /* Cannot use CPU mmaps */
 #define I915_CREATE_POPULATE           (1<<1) /* Pre-populate object pages */
-#define __I915_CREATE_UNKNOWN_FLAGS    -(I915_CREATE_POPULATE << 1)
+#define I915_CREATE_FLUSH              (1<<2) /* Clflush prepopulated pages */
+#define __I915_CREATE_UNKNOWN_FLAGS    -(I915_CREATE_FLUSH << 1)
 };
 
 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

Reply via email to