Skip to content

Commit 3499b75

Browse files
author
Jocelyn Falempe
committed
drm/i915: allow control over the flags when migrating
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041690 Upstream Status: git://anongit.freedesktop.org/drm/drm commit 999f456 Author: Matthew Auld <matthew.auld@intel.com> AuthorDate: Tue Oct 4 14:19:14 2022 +0100 Commit: Matthew Auld <matthew.auld@intel.com> CommitDate: Wed Oct 5 09:02:45 2022 +0100 In the next patch we want to move the object (if the current resource is not compatible), to the mappable part of lmem for some display buffers. Currently that requires being able to unset the I915_BO_ALLOC_GPU_ONLY hint. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Jianshui Yu <jianshui.yu@intel.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Nirmoy Das <nirmoy.das@intel.com> Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20221004131916.233474-3-matthew.auld@intel.com Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
1 parent 860afd8 commit 3499b75

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

drivers/gpu/drm/i915/gem/i915_gem_object.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,41 @@ bool i915_gem_object_can_migrate(struct drm_i915_gem_object *obj,
652652
int i915_gem_object_migrate(struct drm_i915_gem_object *obj,
653653
struct i915_gem_ww_ctx *ww,
654654
enum intel_region_id id)
655+
{
656+
return __i915_gem_object_migrate(obj, ww, id, obj->flags);
657+
}
658+
659+
/**
660+
* __i915_gem_object_migrate - Migrate an object to the desired region id, with
661+
* control of the extra flags
662+
* @obj: The object to migrate.
663+
* @ww: An optional struct i915_gem_ww_ctx. If NULL, the backend may
664+
* not be successful in evicting other objects to make room for this object.
665+
* @id: The region id to migrate to.
666+
* @flags: The object flags. Normally just obj->flags.
667+
*
668+
* Attempt to migrate the object to the desired memory region. The
669+
* object backend must support migration and the object may not be
670+
* pinned, (explicitly pinned pages or pinned vmas). The object must
671+
* be locked.
672+
* On successful completion, the object will have pages pointing to
673+
* memory in the new region, but an async migration task may not have
674+
* completed yet, and to accomplish that, i915_gem_object_wait_migration()
675+
* must be called.
676+
*
677+
* Note: the @ww parameter is not used yet, but included to make sure
678+
* callers put some effort into obtaining a valid ww ctx if one is
679+
* available.
680+
*
681+
* Return: 0 on success. Negative error code on failure. In particular may
682+
* return -ENXIO on lack of region space, -EDEADLK for deadlock avoidance
683+
* if @ww is set, -EINTR or -ERESTARTSYS if signal pending, and
684+
* -EBUSY if the object is pinned.
685+
*/
686+
int __i915_gem_object_migrate(struct drm_i915_gem_object *obj,
687+
struct i915_gem_ww_ctx *ww,
688+
enum intel_region_id id,
689+
unsigned int flags)
655690
{
656691
struct drm_i915_private *i915 = to_i915(obj->base.dev);
657692
struct intel_memory_region *mr;
@@ -672,7 +707,7 @@ int i915_gem_object_migrate(struct drm_i915_gem_object *obj,
672707
return 0;
673708
}
674709

675-
return obj->ops->migrate(obj, mr);
710+
return obj->ops->migrate(obj, mr, flags);
676711
}
677712

678713
/**

drivers/gpu/drm/i915/gem/i915_gem_object.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ bool i915_gem_object_migratable(struct drm_i915_gem_object *obj);
608608
int i915_gem_object_migrate(struct drm_i915_gem_object *obj,
609609
struct i915_gem_ww_ctx *ww,
610610
enum intel_region_id id);
611+
int __i915_gem_object_migrate(struct drm_i915_gem_object *obj,
612+
struct i915_gem_ww_ctx *ww,
613+
enum intel_region_id id,
614+
unsigned int flags);
611615

612616
bool i915_gem_object_can_migrate(struct drm_i915_gem_object *obj,
613617
enum intel_region_id id);

drivers/gpu/drm/i915/gem/i915_gem_object_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ struct drm_i915_gem_object_ops {
107107
* pinning or for as long as the object lock is held.
108108
*/
109109
int (*migrate)(struct drm_i915_gem_object *obj,
110-
struct intel_memory_region *mr);
110+
struct intel_memory_region *mr,
111+
unsigned int flags);
111112

112113
void (*release)(struct drm_i915_gem_object *obj);
113114

drivers/gpu/drm/i915/gem/i915_gem_ttm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,10 @@ static int __i915_ttm_migrate(struct drm_i915_gem_object *obj,
878878
}
879879

880880
static int i915_ttm_migrate(struct drm_i915_gem_object *obj,
881-
struct intel_memory_region *mr)
881+
struct intel_memory_region *mr,
882+
unsigned int flags)
882883
{
883-
return __i915_ttm_migrate(obj, mr, obj->flags);
884+
return __i915_ttm_migrate(obj, mr, flags);
884885
}
885886

886887
static void i915_ttm_put_pages(struct drm_i915_gem_object *obj,

0 commit comments

Comments
 (0)