Commit ddb24fc5 authored by Nirmoy Das's avatar Nirmoy Das

drm/i915/ttm: Add I915_BO_PREALLOC

Add a mechanism to preserve existing data when creating
a TTM object with the I915_BO_ALLOC_USER flag. This will
be used in the subsequent patch where the I915_BO_ALLOC_USER
flag will be applied to the framebuffer object. For a pre-allocated
framebuffer without the I915_BO_PREALLOC flag.

TTM would clear the content, which is not desirable.
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: default avatarNirmoy Das <nirmoy.das@intel.com>
Reviewed-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230404143100.10452-1-nirmoy.das@intel.com
parent 4b51210f
...@@ -328,6 +328,12 @@ struct drm_i915_gem_object { ...@@ -328,6 +328,12 @@ struct drm_i915_gem_object {
*/ */
#define I915_BO_ALLOC_GPU_ONLY BIT(6) #define I915_BO_ALLOC_GPU_ONLY BIT(6)
#define I915_BO_ALLOC_CCS_AUX BIT(7) #define I915_BO_ALLOC_CCS_AUX BIT(7)
/*
* Object is allowed to retain its initial data and will not be cleared on first
* access if used along with I915_BO_ALLOC_USER. This is mainly to keep
* preallocated framebuffer data intact while transitioning it to i915drmfb.
*/
#define I915_BO_PREALLOC BIT(8)
#define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS | \ #define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS | \
I915_BO_ALLOC_VOLATILE | \ I915_BO_ALLOC_VOLATILE | \
I915_BO_ALLOC_CPU_CLEAR | \ I915_BO_ALLOC_CPU_CLEAR | \
...@@ -335,10 +341,11 @@ struct drm_i915_gem_object { ...@@ -335,10 +341,11 @@ struct drm_i915_gem_object {
I915_BO_ALLOC_PM_VOLATILE | \ I915_BO_ALLOC_PM_VOLATILE | \
I915_BO_ALLOC_PM_EARLY | \ I915_BO_ALLOC_PM_EARLY | \
I915_BO_ALLOC_GPU_ONLY | \ I915_BO_ALLOC_GPU_ONLY | \
I915_BO_ALLOC_CCS_AUX) I915_BO_ALLOC_CCS_AUX | \
#define I915_BO_READONLY BIT(8) I915_BO_PREALLOC)
#define I915_TILING_QUIRK_BIT 9 /* unknown swizzling; do not release! */ #define I915_BO_READONLY BIT(9)
#define I915_BO_PROTECTED BIT(10) #define I915_TILING_QUIRK_BIT 10 /* unknown swizzling; do not release! */
#define I915_BO_PROTECTED BIT(11)
/** /**
* @mem_flags - Mutable placement-related flags * @mem_flags - Mutable placement-related flags
* *
......
...@@ -560,7 +560,7 @@ int i915_ttm_move(struct ttm_buffer_object *bo, bool evict, ...@@ -560,7 +560,7 @@ int i915_ttm_move(struct ttm_buffer_object *bo, bool evict,
struct dma_fence *migration_fence = NULL; struct dma_fence *migration_fence = NULL;
struct ttm_tt *ttm = bo->ttm; struct ttm_tt *ttm = bo->ttm;
struct i915_refct_sgt *dst_rsgt; struct i915_refct_sgt *dst_rsgt;
bool clear; bool clear, prealloc_bo;
int ret; int ret;
if (GEM_WARN_ON(i915_ttm_is_ghost_object(bo))) { if (GEM_WARN_ON(i915_ttm_is_ghost_object(bo))) {
...@@ -590,7 +590,8 @@ int i915_ttm_move(struct ttm_buffer_object *bo, bool evict, ...@@ -590,7 +590,8 @@ int i915_ttm_move(struct ttm_buffer_object *bo, bool evict,
return PTR_ERR(dst_rsgt); return PTR_ERR(dst_rsgt);
clear = !i915_ttm_cpu_maps_iomem(bo->resource) && (!ttm || !ttm_tt_is_populated(ttm)); clear = !i915_ttm_cpu_maps_iomem(bo->resource) && (!ttm || !ttm_tt_is_populated(ttm));
if (!(clear && ttm && !(ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC))) { prealloc_bo = obj->flags & I915_BO_PREALLOC;
if (!(clear && ttm && !((ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC) && !prealloc_bo))) {
struct i915_deps deps; struct i915_deps deps;
i915_deps_init(&deps, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN); i915_deps_init(&deps, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment