drm/i915/gsc: Mark internal GSC engine with reserved uabi class
Subsystems (2)
PATCH 1/1 drm/i915/gsc: Mark internal GSC engine with reserved uabi class
From: Tvrtko Ursulin <[email protected]>
The GSC CS is not exposed to the user, so we skipped assigning a uabi class number for it. However, the trace logs use the uabi class and instance to identify the engine, so leaving uabi class unset makes the GSC CS show up as the RCS in those logs.
Given that the engine is not exposed to the user, we can't add a new case in the uabi enum, so we insted internally define a kernel internal class as -1.
At the same time remove special handling for the name and complete the uabi_classes array so internal class is automatically correctly assigned.
Engine will show as 65535:0 other0 in the logs/traces which should be unique enough.
---
Daniele I borrowed most of your commit text as is, hope you don't mind but I was lazy. See if you like this solution. It is also untested so lets see.
--- drivers/gpu/drm/i915/gt/intel_engine_user.c | 37 ++++++++++++--------- 1 file changed, 21 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_user.c +21 -16
@@ -41,12 +41,15 @@ void intel_engine_add_user(struct intel_engine_cs *engine)llist_add (&engine->uabi_llist, &engine->i915->uabi_engines_llist); } +#define I915_NO_UABI_CLASS (-1) +static const u8 uabi_classes[] = { [RENDER_CLASS ] =I915_ENGINE_CLASS_RENDER , [COPY_ENGINE_CLASS ] =I915_ENGINE_CLASS_COPY , [VIDEO_DECODE_CLASS ] =I915_ENGINE_CLASS_VIDEO , [VIDEO_ENHANCEMENT_CLASS ] =I915_ENGINE_CLASS_VIDEO_ENHANCE , [COMPUTE_CLASS ] =I915_ENGINE_CLASS_COMPUTE , + [OTHER_CLASS ] =I915_NO_UABI_CLASS ,/* Not exposed to users, no uabi class. */ }; static int engine_cmp(void *priv, const struct list_head *A,
@@ -200,6 +203,7 @@ static void engine_rename(struct intel_engine_cs *engine, const char *name, u16void intel_engines_driver_register (struct drm_i915_private *i915) { +u16 name_instance, other_instance =0 ;struct legacy_ring ring = {};struct list_head *it, *next;struct rb_node **p, *prev;
@@ -216,27 +220,28 @@ void intel_engines_driver_register(struct drm_i915_private *i915)if (intel_gt_has_unrecoverable_error (engine->gt))continue ;/* ignore incomplete engines */ -/* -* We don't want to expose the GSC engine to the users, but we -* still rename it so it is easier to identify in the debug logs -*/ -if (engine->id ==GSC0 ) { -engine_rename (engine,"gsc" ,0 ); -continue ; - } -GEM_BUG_ON (engine->class >=ARRAY_SIZE (uabi_classes)); engine->uabi_class = uabi_classes[engine->class]; +if (engine->uabi_class ==I915_NO_UABI_CLASS ) { + name_instance = other_instance++; + }else { +GEM_BUG_ON (engine->uabi_class >= +ARRAY_SIZE (i915->engine_uabi_class_count)); + name_instance = + i915->engine_uabi_class_count[engine->uabi_class]++; + } + engine->uabi_instance = name_instance; -GEM_BUG_ON (engine->uabi_class >= -ARRAY_SIZE (i915->engine_uabi_class_count)); - engine->uabi_instance = - i915->engine_uabi_class_count[engine->uabi_class]++; - -/* Replace the internal name with the final user facing name */ +/* +* Replace the internal name with the final user and log facing +* name. +*/ engine_rename (engine,intel_engine_class_repr (engine->class), - engine->uabi_instance); + name_instance); + +if (engine->uabi_class ==I915_NO_UABI_CLASS ) +continue ;rb_link_node (&engine->uabi_node, prev, p);rb_insert_color (&engine->uabi_node, &i915->uabi_engines);
Signature · 1 line
2.40.1
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Tvrtko,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-intel/for-linux-next-fixes]
[also build test WARNING on drm-tip/drm-tip drm/drm-next drm-exynos/exynos-drm-next drm-misc/drm-misc-next linus/master v6.7-rc1 next-20231115] [cannot apply to drm-intel/for-linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Tvrtko-Ursulin/drm-i915-gsc-Mark-internal-GSC-engine-with-reserved-uabi-class/20231115-190507 base: git://anongit.freedesktop.org/drm-intel for-linux-next-fixes patch link: https://lore.kernel.org/r/20231115110216.267138-1-tvrtko.ursulin%40linux.intel.com patch subject: [PATCH] drm/i915/gsc: Mark internal GSC engine with reserved uabi class config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20231116/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/gpu/drm/i915/gt/intel_engine_user.c:225:26: warning: result of comparison of constant -1 with expression of type 'u16' (aka 'unsigned short') is always false [-Wtautological-constant-out-of-range-compare]
if (engine->uabi_class == I915_NO_UABI_CLASS) {
~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/gt/intel_engine_user.c:243:26: warning: result of comparison of constant -1 with expression of type 'u16' (aka 'unsigned short') is always false [-Wtautological-constant-out-of-range-compare]
if (engine->uabi_class == I915_NO_UABI_CLASS)
~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~2 warnings generated.
vim +225 drivers/gpu/drm/i915/gt/intel_engine_user.c
203
204 void intel_engines_driver_register(struct drm_i915_private *i915)
205 {
206 u16 name_instance, other_instance = 0;
207 struct legacy_ring ring = {};
208 struct list_head *it, *next;
209 struct rb_node **p, *prev;
210 LIST_HEAD(engines);
211
212 sort_engines(i915, &engines);
213
214 prev = NULL;
215 p = &i915->uabi_engines.rb_node;
216 list_for_each_safe(it, next, &engines) {
217 struct intel_engine_cs *engine =
218 container_of(it, typeof(*engine), uabi_list);
219
220 if (intel_gt_has_unrecoverable_error(engine->gt))
221 continue; /* ignore incomplete engines */
222
223 GEM_BUG_ON(engine->class >= ARRAY_SIZE(uabi_classes));
224 engine->uabi_class = uabi_classes[engine->class];
> 225 if (engine->uabi_class == I915_NO_UABI_CLASS) {
226 name_instance = other_instance++;
227 } else {
228 GEM_BUG_ON(engine->uabi_class >=
229 ARRAY_SIZE(i915->engine_uabi_class_count));
230 name_instance =
231 i915->engine_uabi_class_count[engine->uabi_class]++;
232 }
233 engine->uabi_instance = name_instance;
234
235 /*
236 * Replace the internal name with the final user and log facing
237 * name.
238 */
239 engine_rename(engine,
240 intel_engine_class_repr(engine->class),
241 name_instance);
242
243 if (engine->uabi_class == I915_NO_UABI_CLASS)
244 continue;
245
246 rb_link_node(&engine->uabi_node, prev, p);
247 rb_insert_color(&engine->uabi_node, &i915->uabi_engines);
248
249 GEM_BUG_ON(intel_engine_lookup_user(i915,
250 engine->uabi_class,
251 engine->uabi_instance) != engine);
252
253 /* Fix up the mapping to match default execbuf::user_map[] */
254 add_legacy_ring(&ring, engine);
255
256 prev = &engine->uabi_node;
257 p = &prev->rb_right;
258 }
259
260 if (IS_ENABLED(CONFIG_DRM_I915_SELFTESTS) &&
261 IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)) {
262 struct intel_engine_cs *engine;
263 unsigned int isolation;
264 int class, inst;
265 int errors = 0;
266
267 for (class = 0; class < ARRAY_SIZE(i915->engine_uabi_class_count); class++) {
268 for (inst = 0; inst < i915->engine_uabi_class_count[class]; inst++) {
269 engine = intel_engine_lookup_user(i915,
270 class, inst);
271 if (!engine) {
272 pr_err("UABI engine not found for { class:%d, instance:%d }\n",
273 class, inst);
274 errors++;
275 continue;
276 }
277
278 if (engine->uabi_class != class ||
279 engine->uabi_instance != inst) {
280 pr_err("Wrong UABI engine:%s { class:%d, instance:%d } found for { class:%d, instance:%d }\n",
281 engine->name,
282 engine->uabi_class,
283 engine->uabi_instance,
284 class, inst); 285 errors++;
286 continue;
287 }
288 }
289 }
290
291 /*
292 * Make sure that classes with multiple engine instances all
293 * share the same basic configuration.
294 */
295 isolation = intel_engines_has_context_isolation(i915);
296 for_each_uabi_engine(engine, i915) {
297 unsigned int bit = BIT(engine->uabi_class);
298 unsigned int expected = engine->default_state ? bit : 0;
299
300 if ((isolation & bit) != expected) {
301 pr_err("mismatching default context state for class %d on engine %s\n",
302 engine->uabi_class, engine->name);
303 errors++;
304 }
305 }
306
307 if (drm_WARN(&i915->drm, errors,
308 "Invalid UABI engine mapping found"))
309 i915->uabi_engines = RB_ROOT;
310 }
311
312 set_scheduler_caps(i915);
313 }
314
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 18 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
The GSC CS is not exposed to the user, so we skipped assigning a uabi class number for it. However, the trace logs use the uabi class and instance to identify the engine, so leaving uabi class unset makes the GSC CS show up as the RCS in those logs.
Given that the engine is not exposed to the user, we can't add a new case in the uabi enum, so we insted internally define a kernel internal class as -1.
At the same time remove special handling for the name and complete the
uabi_classesarray so internal class is automatically correctly assigned.Engine will show as 65535:0 other0 in the logs/traces which should be unique enough.
Quoted 8 lines
Signed-off-by Tvrtko Ursulin <[email protected]>Fixes 194babe26bdc ("drm/i915/mtl: don't expose GSC command streamer to the user")Cc Daniele Ceraolo Spurio <[email protected]>Cc Alan Previn <[email protected]>Cc Matt Roper <[email protected]>---
Daniele I borrowed most of your commit text as is, hope you don't mind but I was lazy. See if you like this solution. It is also untested so lets see.
I'm ok with this approach. As you said the naming is unique so we can easily identify the engine. I've tested this locally with a small change (see below) and I see the expected values in the logs.
drivers/gpu/drm/i915/gt/intel_engine_user.c void intel_engine_add_user(struct intel_engine_cs *engine) · line 44
Quoted 13 lines
--- drivers/gpu/drm/i915/gt/intel_engine_user.c | 37 ++++++++++++--------- 1 file changed, 21 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/gt/intel_engine_user.c +1
-0@@ -41,12 +41,15 @@ void intel_engine_add_user(struct intel_engine_cs *engine)llist_add (&engine->uabi_llist, &engine->i915->uabi_engines_llist); } +#define I915_NO_UABI_CLASS (-1)
I see the lkp is complaining about using this for comparison against a u16. When I locally tried to reduce this to u16 my compiler also complained that we're assigning it to a u8 in the uabi_classes array, so I've just set I915_NO_UABI_CLASS directly to 255 and it all worked as expected. With that fix, or an alternative change to work with all the involved types:
Daniele
Quoted 64 lines
drivers/gpu/drm/i915/gt/intel_engine_user.c +20
-16+static const u8 uabi_classes[] = { [RENDER_CLASS ] =I915_ENGINE_CLASS_RENDER , [COPY_ENGINE_CLASS ] =I915_ENGINE_CLASS_COPY , [VIDEO_DECODE_CLASS ] =I915_ENGINE_CLASS_VIDEO , [VIDEO_ENHANCEMENT_CLASS ] =I915_ENGINE_CLASS_VIDEO_ENHANCE , [COMPUTE_CLASS ] =I915_ENGINE_CLASS_COMPUTE , + [OTHER_CLASS ] =I915_NO_UABI_CLASS ,/* Not exposed to users, no uabi class. */ }; static int engine_cmp(void *priv, const struct list_head *A,@@ -200,6 +203,7 @@ static void engine_rename(struct intel_engine_cs *engine, const char *name, u16void intel_engines_driver_register (struct drm_i915_private *i915) { +u16 name_instance, other_instance =0 ;struct legacy_ring ring = {};struct list_head *it, *next;struct rb_node **p, *prev;@@ -216,27 +220,28 @@ void intel_engines_driver_register(struct drm_i915_private *i915)if (intel_gt_has_unrecoverable_error (engine->gt))continue ;/* ignore incomplete engines */ -/* -* We don't want to expose the GSC engine to the users, but we -* still rename it so it is easier to identify in the debug logs -*/ -if (engine->id ==GSC0 ) { -engine_rename (engine,"gsc" ,0 ); -continue ; - } -GEM_BUG_ON (engine->class >=ARRAY_SIZE (uabi_classes)); engine->uabi_class = uabi_classes[engine->class]; +if (engine->uabi_class ==I915_NO_UABI_CLASS ) { + name_instance = other_instance++; + }else { +GEM_BUG_ON (engine->uabi_class >= +ARRAY_SIZE (i915->engine_uabi_class_count)); + name_instance = + i915->engine_uabi_class_count[engine->uabi_class]++; + } + engine->uabi_instance = name_instance; -GEM_BUG_ON (engine->uabi_class >= -ARRAY_SIZE (i915->engine_uabi_class_count)); - engine->uabi_instance = - i915->engine_uabi_class_count[engine->uabi_class]++; - -/* Replace the internal name with the final user facing name */ +/* +* Replace the internal name with the final user and log facing +* name. +*/ engine_rename (engine,intel_engine_class_repr (engine->class), - engine->uabi_instance); + name_instance); + +if (engine->uabi_class ==I915_NO_UABI_CLASS ) +continue ;rb_link_node (&engine->uabi_node, prev, p);rb_insert_color (&engine->uabi_node, &i915->uabi_engines);
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gsc: Mark internal GSC engine with reserved uabi class
In reply to Tvrtko Ursulin== Series Details ==
== Series Details ==
Series: drm/i915/gsc: Mark internal GSC engine with reserved uabi class
URL : https://patchwork.freedesktop.org/series/126455/
State : warning
== Summary ==
Error: dim checkpatch failed58cf74c214fb drm/i915/gsc: Mark internal GSC engine with reserved uabi class
-:76: WARNING:AVOID_BUG: Do not crash the kernel unless it is absolutely unavoidable--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants #76: FILE: drivers/gpu/drm/i915/gt/intel_engine_user.c:228:
+ GEM_BUG_ON(engine->uabi_class >=
total: 0 errors, 1 warnings, 0 checks, 66 lines checked
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/gsc: Mark internal GSC engine with reserved uabi class
In reply to Tvrtko Ursulin== Series Details ==
== Series Details ==
Series: drm/i915/gsc: Mark internal GSC engine with reserved uabi class
URL : https://patchwork.freedesktop.org/series/126455/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_13881 -> Patchwork_126455v1
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_126455v1 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes
introduced in Patchwork_126455v1, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126455v1/index.html
Participating hosts (40 -> 35)
------------------------------
Missing (5): bat-kbl-2 bat-dg2-9 fi-snb-2520m fi-hsw-4770 bat-rpls-1
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_126455v1:
### IGT changes ###
#### Possible regressions ####
* igt@i915_module_load@load:
- bat-mtlp-6: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13881/bat-mtlp-6/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126455v1/bat-mtlp-6/igt@[email protected]
- bat-mtlp-8: [PASS][3] -> [ABORT][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13881/bat-mtlp-8/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126455v1/bat-mtlp-8/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_126455v1 that come from known issues:
### CI changes ###
#### Issues hit ####
* boot:
- bat-jsl-1: [PASS][5] -> [FAIL][6] ([i915#8293])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13881/bat-jsl-1/boot.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126455v1/bat-jsl-1/boot.html
#### Possible fixes ####
* boot:
- fi-bsw-n3050: [FAIL][7] ([i915#8293]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13881/fi-bsw-n3050/boot.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126455v1/fi-bsw-n3050/boot.html
### IGT changes ###
#### Issues hit ####
* igt@gem_lmem_swapping@random-engines:
- fi-bsw-n3050: NOTRUN -> [SKIP][9] ([fdo#109271]) +14 other tests skip
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126455v1/fi-bsw-n3050/igt@[email protected]
* igt@kms_hdmi_inject@inject-audio:
- fi-kbl-guc: [PASS][10] -> [FAIL][11] ([IGT#3])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13881/fi-kbl-guc/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126455v1/fi-kbl-guc/igt@[email protected]
- fi-bsw-n3050: NOTRUN -> [FAIL][12] ([IGT#3])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126455v1/fi-bsw-n3050/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[IGT#3]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/3
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#8293]: https://gitlab.freedesktop.org/drm/intel/issues/8293
Build changes
-------------
* Linux: CI_DRM_13881 -> Patchwork_126455v1
CI-20190529: 20190529
CI_DRM_13881: 36732395a74634a9ff9db10c79c4c52719cdab40 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7590: c484e1422184a3183d11f1595e53a6715574520f @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_126455v1: 36732395a74634a9ff9db10c79c4c52719cdab40 @ git://anongit.freedesktop.org/gfx-ci/linux
### Linux commits
94e76a597733 drm/i915/gsc: Mark internal GSC engine with reserved uabi class
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126455v1/index.html