[PATCH 7/7] drm/i915: fix stolen mem detection
Robert Beckett
bob.beckett at collabora.com
Thu Apr 7 12:02:06 UTC 2022
Signed-off-by: Robert Beckett <bob.beckett at collabora.com>
---
drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 13 ++++++++++---
drivers/gpu/drm/i915/gem/i915_gem_stolen.h | 2 +-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
index 7706e46d1f46..19ca374faa45 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
@@ -712,8 +712,15 @@ u64 i915_gem_object_stolen_offset(struct drm_i915_gem_object *obj)
return PFN_PHYS(ttm_obj->resource->start);
}
-bool i915_gem_object_is_stolen(const struct drm_i915_gem_object *obj)
+bool i915_gem_object_is_stolen(struct drm_i915_gem_object *obj)
{
- return obj->mm.region->type == INTEL_MEMORY_STOLEN_SYSTEM ||
- obj->mm.region->type == INTEL_MEMORY_STOLEN_LOCAL;
+ struct intel_memory_region *mr = READ_ONCE(obj->mm.region);
+
+#ifdef CONFIG_LOCKDEP
+ if (i915_gem_object_migratable(obj) &&
+ i915_gem_object_evictable(obj))
+ assert_object_held(obj);
+#endif
+ return mr && (mr->type == INTEL_MEMORY_STOLEN_SYSTEM ||
+ mr->type == INTEL_MEMORY_STOLEN_LOCAL);
}
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.h b/drivers/gpu/drm/i915/gem/i915_gem_stolen.h
index 4b7a2b3c42b8..b39cb6e6c768 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.h
@@ -25,7 +25,7 @@ i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
resource_size_t size);
u64 i915_gem_object_stolen_offset(struct drm_i915_gem_object *obj);
-bool i915_gem_object_is_stolen(const struct drm_i915_gem_object *obj);
+bool i915_gem_object_is_stolen(struct drm_i915_gem_object *obj);
struct ttm_resource *
i915_gem_stolen_reserve_range(struct drm_i915_private *i915,
resource_size_t size,
--
2.25.1
More information about the Intel-gfx-trybot
mailing list