[PATCH] shudder
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Fri Aug 27 09:49:38 UTC 2021
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
drivers/gpu/drm/i915/gem/i915_gem_busy.c | 23 ++++++++++++++--------
drivers/gpu/drm/i915/gem/i915_gem_object.h | 17 ----------------
drivers/gpu/drm/i915/i915_debugfs.c | 23 +++++++++++++++++++++-
drivers/gpu/drm/i915/i915_request.c | 5 +++--
drivers/gpu/drm/i915/i915_request.h | 18 +++++++++++++++++
5 files changed, 58 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c b/drivers/gpu/drm/i915/gem/i915_gem_busy.c
index 6234e17259c1..22fc20da2eb9 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c
@@ -6,6 +6,7 @@
#include "gt/intel_engine.h"
+#include "i915_drv.h"
#include "i915_gem_ioctls.h"
#include "i915_gem_object.h"
@@ -36,7 +37,9 @@ static __always_inline u32 __busy_write_id(u16 id)
}
static __always_inline unsigned int
-__busy_set_if_active(const struct dma_fence *fence, u32 (*flag)(u16 id))
+__busy_set_if_active(const struct drm_i915_private *i915,
+ const struct dma_fence *fence,
+ u32 (*flag)(u16 id))
{
const struct i915_request *rq;
@@ -48,7 +51,7 @@ __busy_set_if_active(const struct dma_fence *fence, u32 (*flag)(u16 id))
*
* Note we only report on the status of native fences.
*/
- if (!dma_fence_is_i915(fence))
+ if (!dma_fence_is_same_i915(fence, i915))
return 0;
/* opencode to_request() in order to avoid const warnings */
@@ -62,24 +65,27 @@ __busy_set_if_active(const struct dma_fence *fence, u32 (*flag)(u16 id))
}
static __always_inline unsigned int
-busy_check_reader(const struct dma_fence *fence)
+busy_check_reader(const struct drm_i915_private *i915,
+ const struct dma_fence *fence)
{
- return __busy_set_if_active(fence, __busy_read_flag);
+ return __busy_set_if_active(i915, fence, __busy_read_flag);
}
static __always_inline unsigned int
-busy_check_writer(const struct dma_fence *fence)
+busy_check_writer(const struct drm_i915_private *i915,
+ const struct dma_fence *fence)
{
if (!fence)
return 0;
- return __busy_set_if_active(fence, __busy_write_id);
+ return __busy_set_if_active(i915, fence, __busy_write_id);
}
int
i915_gem_busy_ioctl(struct drm_device *dev, void *data,
struct drm_file *file)
{
+ struct drm_i915_private *i915 = to_i915(dev);
struct drm_i915_gem_busy *args = data;
struct drm_i915_gem_object *obj;
struct dma_resv_list *list;
@@ -113,7 +119,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
seq = raw_read_seqcount(&obj->base.resv->seq);
/* Translate the exclusive fence to the READ *and* WRITE engine */
- args->busy = busy_check_writer(dma_resv_excl_fence(obj->base.resv));
+ args->busy = busy_check_writer(i915,
+ dma_resv_excl_fence(obj->base.resv));
/* Translate shared fences to READ set of engines */
list = dma_resv_shared_list(obj->base.resv);
@@ -124,7 +131,7 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
struct dma_fence *fence =
rcu_dereference(list->shared[i]);
- args->busy |= busy_check_reader(fence);
+ args->busy |= busy_check_reader(i915, fence);
}
}
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index 48112b9d76df..3043fcbd31bd 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -503,23 +503,6 @@ i915_gem_object_finish_access(struct drm_i915_gem_object *obj)
i915_gem_object_unpin_pages(obj);
}
-static inline struct intel_engine_cs *
-i915_gem_object_last_write_engine(struct drm_i915_gem_object *obj)
-{
- struct intel_engine_cs *engine = NULL;
- struct dma_fence *fence;
-
- rcu_read_lock();
- fence = dma_resv_get_excl_unlocked(obj->base.resv);
- rcu_read_unlock();
-
- if (fence && dma_fence_is_i915(fence) && !dma_fence_is_signaled(fence))
- engine = to_request(fence)->engine;
- dma_fence_put(fence);
-
- return engine;
-}
-
void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
unsigned int cache_level);
void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj);
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 04351a851586..2f49ff0e8c21 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -135,6 +135,27 @@ static const char *stringify_vma_type(const struct i915_vma *vma)
return "ppgtt";
}
+static struct intel_engine_cs *
+last_write_engine(struct drm_i915_private *i915,
+ struct drm_i915_gem_object *obj)
+{
+ struct intel_engine_cs *engine = NULL;
+ struct dma_fence *fence;
+
+ rcu_read_lock();
+ fence = dma_resv_get_excl_unlocked(obj->base.resv);
+ rcu_read_unlock();
+
+ if (fence &&
+ !dma_fence_is_signaled(fence) &&
+ dma_fence_is_i915(fence) &&
+ to_request(fence)->i915 == i915)
+ engine = to_request(fence)->engine;
+ dma_fence_put(fence);
+
+ return engine;
+}
+
void
i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
{
@@ -230,7 +251,7 @@ i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
if (i915_gem_object_is_framebuffer(obj))
seq_printf(m, " (fb)");
- engine = i915_gem_object_last_write_engine(obj);
+ engine = last_write_engine(dev_priv, obj);
if (engine)
seq_printf(m, " (%s)", engine->name);
}
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index f564a856e66f..172131be2b24 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -914,6 +914,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)
* hold the intel_context reference. In execlist mode the request always
* eventually points to a physical engine so this isn't an issue.
*/
+ rq->i915 = tl->gt->i915;
rq->context = intel_context_get(ce);
rq->engine = ce->engine;
rq->ring = ce->ring;
@@ -1377,7 +1378,7 @@ i915_request_await_execution(struct i915_request *rq,
* want to run our callback in all cases.
*/
- if (dma_fence_is_i915(fence))
+ if (dma_fence_is_same_i915(fence, rq->i915))
ret = __i915_request_await_execution(rq,
to_request(fence));
else
@@ -1482,7 +1483,7 @@ i915_request_await_dma_fence(struct i915_request *rq, struct dma_fence *fence)
fence))
continue;
- if (dma_fence_is_i915(fence))
+ if (dma_fence_is_same_i915(fence, rq->i915))
ret = i915_request_await_request(rq, to_request(fence));
else
ret = i915_request_await_external(rq, fence);
diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h
index 1bc1349ba3c2..63e6370f0eb0 100644
--- a/drivers/gpu/drm/i915/i915_request.h
+++ b/drivers/gpu/drm/i915/i915_request.h
@@ -163,6 +163,7 @@ enum {
*/
struct i915_request {
struct dma_fence fence;
+ struct drm_i915_private *i915;
spinlock_t lock;
/**
@@ -345,6 +346,23 @@ to_request(struct dma_fence *fence)
return container_of(fence, struct i915_request, fence);
}
+static inline const struct i915_request *
+to_const_request(const struct dma_fence *fence)
+{
+ /* We assume that NULL fence/request are interoperable */
+ BUILD_BUG_ON(offsetof(struct i915_request, fence) != 0);
+ GEM_BUG_ON(fence && !dma_fence_is_i915(fence));
+ return container_of(fence, struct i915_request, fence);
+}
+
+static inline bool
+dma_fence_is_same_i915(const struct dma_fence *fence,
+ const struct drm_i915_private *i915)
+{
+ return fence->ops == &i915_fence_ops &&
+ to_const_request(fence)->i915 == i915;
+}
+
static inline struct i915_request *
i915_request_get(struct i915_request *rq)
{
--
2.30.2
More information about the Intel-gfx-trybot
mailing list