Commit cf9cb028 authored by Tvrtko Ursulin's avatar Tvrtko Ursulin

drm/i915: Use internal class when counting engine resets

Commit 50357944 ("drm/i915/gsc: Mark internal GSC engine with reserved uabi class")
made the GSC0 engine not have a valid uabi class and so broke the engine
reset counting, which in turn was made class based in cb823ed9 ("drm/i915/gt: Use intel_gt as the primary object for handling resets").

Despite the title and commit text of the latter is not mentioning it (and
has left the storage array incorrectly sized), tracking by class, despite
it adding aliasing in hypthotetical multi-tile systems, is handy for
virtual engines which for instance do not have a valid engine->id.

Therefore we keep that but just change it to use the internal class which
is always valid. We also add a helper to increment the count, which
aligns with the existing getter.

What was broken without this fix were out of bounds reads every time a
reset would happen on the GSC0 engine, or during selftests when storing
and cross-checking the counts in igt_live_test_begin and
igt_live_test_end.
Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Fixes: dfed6b58 ("drm/i915/gsc: Mark internal GSC engine with reserved uabi class")
[tursulin: fixed Fixes tag]
Reported-by: default avatarAlan Previn Teres Alexis <alan.previn.teres.alexis@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231201122109.729006-2-tvrtko.ursulin@linux.intel.com
parent 0647ece3
...@@ -1293,7 +1293,7 @@ int __intel_engine_reset_bh(struct intel_engine_cs *engine, const char *msg) ...@@ -1293,7 +1293,7 @@ int __intel_engine_reset_bh(struct intel_engine_cs *engine, const char *msg)
if (msg) if (msg)
drm_notice(&engine->i915->drm, drm_notice(&engine->i915->drm,
"Resetting %s for %s\n", engine->name, msg); "Resetting %s for %s\n", engine->name, msg);
atomic_inc(&engine->i915->gpu_error.reset_engine_count[engine->uabi_class]); i915_increase_reset_engine_count(&engine->i915->gpu_error, engine);
ret = intel_gt_reset_engine(engine); ret = intel_gt_reset_engine(engine);
if (ret) { if (ret) {
......
...@@ -5003,7 +5003,8 @@ static void capture_error_state(struct intel_guc *guc, ...@@ -5003,7 +5003,8 @@ static void capture_error_state(struct intel_guc *guc,
if (match) { if (match) {
intel_engine_set_hung_context(e, ce); intel_engine_set_hung_context(e, ce);
engine_mask |= e->mask; engine_mask |= e->mask;
atomic_inc(&i915->gpu_error.reset_engine_count[e->uabi_class]); i915_increase_reset_engine_count(&i915->gpu_error,
e);
} }
} }
...@@ -5015,7 +5016,7 @@ static void capture_error_state(struct intel_guc *guc, ...@@ -5015,7 +5016,7 @@ static void capture_error_state(struct intel_guc *guc,
} else { } else {
intel_engine_set_hung_context(ce->engine, ce); intel_engine_set_hung_context(ce->engine, ce);
engine_mask = ce->engine->mask; engine_mask = ce->engine->mask;
atomic_inc(&i915->gpu_error.reset_engine_count[ce->engine->uabi_class]); i915_increase_reset_engine_count(&i915->gpu_error, ce->engine);
} }
with_intel_runtime_pm(&i915->runtime_pm, wakeref) with_intel_runtime_pm(&i915->runtime_pm, wakeref)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "display/intel_display_device.h" #include "display/intel_display_device.h"
#include "gt/intel_engine.h" #include "gt/intel_engine.h"
#include "gt/intel_engine_types.h"
#include "gt/intel_gt_types.h" #include "gt/intel_gt_types.h"
#include "gt/uc/intel_uc_fw.h" #include "gt/uc/intel_uc_fw.h"
...@@ -232,7 +233,7 @@ struct i915_gpu_error { ...@@ -232,7 +233,7 @@ struct i915_gpu_error {
atomic_t reset_count; atomic_t reset_count;
/** Number of times an engine has been reset */ /** Number of times an engine has been reset */
atomic_t reset_engine_count[I915_NUM_ENGINES]; atomic_t reset_engine_count[MAX_ENGINE_CLASS];
}; };
struct drm_i915_error_state_buf { struct drm_i915_error_state_buf {
...@@ -255,7 +256,14 @@ static inline u32 i915_reset_count(struct i915_gpu_error *error) ...@@ -255,7 +256,14 @@ static inline u32 i915_reset_count(struct i915_gpu_error *error)
static inline u32 i915_reset_engine_count(struct i915_gpu_error *error, static inline u32 i915_reset_engine_count(struct i915_gpu_error *error,
const struct intel_engine_cs *engine) const struct intel_engine_cs *engine)
{ {
return atomic_read(&error->reset_engine_count[engine->uabi_class]); return atomic_read(&error->reset_engine_count[engine->class]);
}
static inline void
i915_increase_reset_engine_count(struct i915_gpu_error *error,
const struct intel_engine_cs *engine)
{
atomic_inc(&error->reset_engine_count[engine->class]);
} }
#define CORE_DUMP_FLAG_NONE 0x0 #define CORE_DUMP_FLAG_NONE 0x0
......
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