[Intel-gfx] [PATCH] drm/i915: Use the engine name directly in the error_state file

Michel Thierry michel.thierry at intel.com
Tue Jan 9 21:37:49 UTC 2018


On 09/01/18 12:46, Chris Wilson wrote:
> Quoting Michal Wajdeczko (2018-01-09 20:39:09)
>> On Tue, 09 Jan 2018 20:33:55 +0100, Michel Thierry
>> <michel.thierry at intel.com> wrote:
>>
>>> Instead of using local string names that we will have to keep
>>> maintaining, use the engine->name directly.
>>>
>>> Suggested-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
>>> Signed-off-by: Michel Thierry <michel.thierry at intel.com>
>>> Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
> 
> I'd a patch to do this, I just had to make sure the tooling was ready
> for a name change. At the time, changing this string broke a few igt and
> intel_error_decode.
> 

I think your igt patch "lib: Fix up internal engine names (again)" 
covered it.

Not sure if there are more tools looking at the engines' registers in 
the error_state outside igt.

>>> ---
>>>   drivers/gpu/drm/i915/i915_gpu_error.c | 23 ++++++++++-------------
>>>   1 file changed, 10 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c
>>> b/drivers/gpu/drm/i915/i915_gpu_error.c
>>> index 94499c24f279..db95ecacdace 100644
>>> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
>>> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
>>> @@ -34,16 +34,12 @@
>>> #include "i915_drv.h"
>>> -static const char *engine_str(int engine)
>>> -{
>>> -     switch (engine) {
>>> -     case RCS: return "render";
>>> -     case VCS: return "bsd";
>>> -     case BCS: return "blt";
>>> -     case VECS: return "vebox";
>>> -     case VCS2: return "bsd2";
>>> -     default: return "";
>>> -     }
>>> +static const char *engine_str(struct drm_i915_private *i915, int
>>> engine_id)
>>> +{
>>> +     if (!i915->engine[engine_id])
>>> +             return "";
>>
>> While unlikely, empty string may be misleading, so maybe better we return
>> "<invalid>" or at least "?" here. Also maybe we can do as part of more
>> global helper function like
>>
>> static inline const char* intel_engine_name(struct intel_engine_cs *engine)
>> {
>>          return engine ? engine->name : "<invalid>";
>> }
>>
>> static inline struct intel_engine_cs *
>> intel_engine_lookup(struct drm_i915_private *i915, int engine_id)
>> {
>>          if (engine_id < 0 || engine_id > I915_MAX_ENGINES)
>>                  return NULL;
>>          return i915->engine[engine_id];
>> }
>>
>> and then
>>
>> static const char *engine_str(struct drm_i915_private *i915, int engine_id)
>> {
>>          return intel_engine_name(intel_engine_lookup(i915, engine_id));
>> }
> 
> No need, this is all internal, perma-allocated structs.
> -Chris
> 


More information about the Intel-gfx mailing list