From 0e997a36ecb61b161a22980ec9240ee7537f3f62 Mon Sep 17 00:00:00 2001 From: Matthew Auld Date: Thu, 29 Apr 2021 11:30:55 +0100 Subject: [PATCH] drm/i915/gem: clear userspace buffers for LMEM MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit All userspace objects must be cleared when allocating the backing store, before they are potentially visible to userspace. For now use simple CPU based clearing to do this for device local-memory objects, note that in the near future this will instead use the blitter engine. Signed-off-by: Matthew Auld Cc: Joonas Lahtinen Cc: Thomas Hellström Cc: Daniele Ceraolo Spurio Cc: Lionel Landwerlin Cc: Jon Bloomfield Cc: Jordan Justen Cc: Daniel Vetter Cc: Kenneth Graunke Cc: Jason Ekstrand Cc: Dave Airlie Cc: dri-devel@lists.freedesktop.org Cc: mesa-dev@lists.freedesktop.org Reviewed-by: Kenneth Graunke Link: https://patchwork.freedesktop.org/patch/msgid/20210429103056.407067-8-matthew.auld@intel.com --- drivers/gpu/drm/i915/gem/i915_gem_create.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_create.c b/drivers/gpu/drm/i915/gem/i915_gem_create.c index 957f790..f6729fe 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_create.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_create.c @@ -71,6 +71,7 @@ static int i915_gem_setup(struct drm_i915_gem_object *obj, u64 size) { struct intel_memory_region *mr = obj->mm.placements[0]; + unsigned int flags; int ret; size = round_up(size, object_max_page_size(obj)); @@ -83,7 +84,16 @@ i915_gem_setup(struct drm_i915_gem_object *obj, u64 size) if (i915_gem_object_size_2big(size)) return -E2BIG; - ret = mr->ops->init_object(mr, obj, size, 0); + /* + * For now resort to CPU based clearing for device local-memory, in the + * near future this will use the blitter engine for accelerated, GPU + * based clearing. + */ + flags = 0; + if (mr->type == INTEL_MEMORY_LOCAL) + flags = I915_BO_ALLOC_CPU_CLEAR; + + ret = mr->ops->init_object(mr, obj, size, flags); if (ret) return ret; -- 2.7.4