Skip to contentSkip to conversation

drm/i915: Special case kernel_context switch request

PATCH In review Mika Kuoppala 4 participants 5 messages May 22, 2018 – May 27, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Special case kernel_context switch request

From: Mika Kuoppala <[email protected]>

When checking if engine is idling on a kernel context, the last request emitted to it could have been the exact request to switch into kernel context.

Do not bail out early even if engine has requests, if the last request was for kernel context.

Fixes a89d1f921c15 ("drm/i915: Split i915_gem_timeline into individual timelines")
Cc Chris Wilson <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_context.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_context.c +4 -1
index b69b18ef8120..3fe1212b0f7e 100644
@@ -595,7 +595,10 @@ static bool engine_has_idle_kernel_context(struct intel_engine_cs *engine)
 	lockdep_assert_held(&engine->i915->drm.struct_mutex);
 
 	list_for_each_entry(ring, active_rings, active_link) {
-		if (last_request_on_engine(ring->timeline, engine))
+		struct i915_request *rq =
+			last_request_on_engine(ring->timeline, engine);
+
+		if (rq && rq->gem_context != engine->i915->kernel_context)
 			return false;
 	}
 
Signature · 6 lines
2.17.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw

Quoting Mika Kuoppala (2018-05-22 13:49:24)

Quoted 6 lines

From: Mika Kuoppala <[email protected]>

When checking if engine is idling on a kernel context, the last request emitted to it could have been the exact request to switch into kernel context.

Quoted 6 lines

Do not bail out early even if engine has requests, if the last request was for kernel context.

Fixes a89d1f921c15 ("drm/i915: Split i915_gem_timeline into individual timelines")
Cc Chris Wilson <[email protected]>

I feel there's some redundancy here (in the checks at different levels), but that's my fault.

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

✗ Fi.CI.BAT: failure for drm/i915: Special case kernel_context switch request

In reply to Mika Kuoppala
== Series Details ==

== Series Details ==

Series: drm/i915: Special case kernel_context switch request
URL : https://patchwork.freedesktop.org/series/43572/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4221 -> Patchwork_9082 =

== Summary - FAILURE ==

Serious unknown changes coming with Patchwork_9082 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_9082, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/43572/revisions/1/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9082:

=== IGT changes ===

    ==== Possible regressions ====

    igt@drv_module_reload@basic-reload:
      fi-ilk-650:         PASS -> DMESG-WARN

== Known issues ==

Here are the changes found in Patchwork_9082 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@kms_flip@basic-flip-vs-wf_vblank:
      fi-skl-6770hq:      PASS -> FAIL (fdo#100368, fdo#103928)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
      fi-skl-6700k2:      PASS -> FAIL (fdo#104724, fdo#103191)

    
    ==== Possible fixes ====

    igt@kms_flip@basic-flip-vs-dpms:
      fi-bxt-dsi:         INCOMPLETE (fdo#103927) -> PASS

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-c-frame-sequence:
      fi-cfl-s3:          FAIL (fdo#103481) -> PASS

fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#103481 https://bugs.freedesktop.org/show_bug.cgi?id=103481
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#103928 https://bugs.freedesktop.org/show_bug.cgi?id=103928
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724

== Participating hosts (44 -> 39) ==

Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-skl-6700hq

== Build changes ==

* Linux: CI_DRM_4221 -> Patchwork_9082

CI_DRM_4221: d83aef98e4f2e35440222c69ef80a68daf1abb4e @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4490: 0b381c7d1067a4fe520b72d4d391d4920834cbe0 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9082: 39378c31a4723a75c807c46f5812cf94964daffb @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4490: 6ab75f7eb5e1dccbb773e1739beeb2d7cbd6ad0d @ git://anongit.freedesktop.org/piglit

== Kernel 32bit build ==

Warning: Kernel 32bit buildtest failed:
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9082/build_32bit.log

  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     scripts/mod/devicetable-offsets.h
  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  CC [M]  drivers/gpu/drm/i915/i915_query.o
In file included from ./include/asm-generic/barrier.h:20:0,
                 from ./arch/x86/include/asm/barrier.h:86,
                 from ./include/linux/nospec.h:8,
                 from drivers/gpu/drm/i915/i915_query.c:7:
drivers/gpu/drm/i915/i915_query.c: In function ‘i915_query_ioctl’:
./include/linux/compiler.h:339:38: error: call to ‘__compiletime_assert_119’ declared with attribute error: BUILD_BUG_ON failed: sizeof(_s) > sizeof(long)
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
./include/linux/compiler.h:319:4: note: in definition of macro ‘__compiletime_assert’
    prefix ## suffix();    \
    ^~~~~~

./include/linux/compiler.h:339:2: note: in expansion of macro ‘_compiletime_assert’
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:45:37: note: in expansion of macro ‘compiletime_assert’

 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^~~~~~~~~~~~~~~~~~

./include/linux/build_bug.h:69:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) ^~~~~~~~~~~~~~~~
./include/linux/nospec.h:53:2: note: in expansion of macro ‘BUILD_BUG_ON’
BUILD_BUG_ON(sizeof(_i) > sizeof(long)); \
^~~~~~~~~~~~
drivers/gpu/drm/i915/i915_query.c:118:15: note: in expansion of macro ‘array_index_nospec’
func_idx = array_index_nospec(func_idx,
^~~~~~~~~~~~~~~~~~
scripts/Makefile.build:312: recipe for target 'drivers/gpu/drm/i915/i915_query.o' failed make[4]: *** [drivers/gpu/drm/i915/i915_query.o] Error 1 scripts/Makefile.build:559: recipe for target 'drivers/gpu/drm/i915' failed make[3]: *** [drivers/gpu/drm/i915] Error 2
scripts/Makefile.build:559: recipe for target 'drivers/gpu/drm' failed make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:559: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1060: recipe for target 'drivers' failed
make: *** [drivers] Error 2

== Linux commits ==

39378c31a472 drm/i915: Special case kernel_context switch request

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9082/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
In reply to Mika Kuoppala

Quoting Mika Kuoppala (2018-05-22 13:49:24)

Quoted 21 lines

From: Mika Kuoppala <[email protected]>

When checking if engine is idling on a kernel context, the last request emitted to it could have been the exact request to switch into kernel context.

Do not bail out early even if engine has requests, if the last request was for kernel context.

Fixes a89d1f921c15 ("drm/i915: Split i915_gem_timeline into individual timelines")
Cc Chris Wilson <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_context.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
index b69b18ef8120..3fe1212b0f7e 100644

drivers/gpu/drm/i915/i915_gem_context.c static bool engine_has_idle_kernel_context(struct intel_engine_cs *engine) · line 602

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +4 -1
@@ -595,7 +595,10 @@ static bool engine_has_idle_kernel_context(struct intel_engine_cs *engine)
        lockdep_assert_held(&engine->i915->drm.struct_mutex);
 
        list_for_each_entry(ring, active_rings, active_link) {
-               if (last_request_on_engine(ring->timeline, engine))
+               struct i915_request *rq =
+                       last_request_on_engine(ring->timeline, engine);
+
+               if (rq && rq->gem_context != engine->i915->kernel_context)
                        return false;

Ah, this isn't enough yet. The challenge is that we don't want to report false when there is an active batch followed by the kernel context.

I think we can rely on the kernel request priority being the lowest here...
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
In reply to Mika Kuoppala
Thank you for the patch! Yet something to improve:

Hi Mika,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20180517]
[cannot apply to drm-intel/for-linux-next v4.17-rc6 v4.17-rc5 v4.17-rc4 v4.17-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Mika-Kuoppala/drm-i915-Special-case-kernel_context-switch-request/20180524-233610
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

drivers/gpu/drm/i915/i915_gem_context.c: In function 'engine_has_idle_kernel_context':

>> drivers/gpu/drm/i915/i915_gem_context.c:608:15: error: 'struct i915_request' has no member named 'gem_context'
      if (rq && rq->gem_context != engine->i915->kernel_context)
                  ^~

vim +608 drivers/gpu/drm/i915/i915_gem_context.c

596
597 static bool engine_has_idle_kernel_context(struct intel_engine_cs *engine)
598 {
599 struct list_head * const active_rings = &engine->i915->gt.active_rings;
600 struct intel_ring *ring;
601
602 lockdep_assert_held(&engine->i915->drm.struct_mutex);
603
604 list_for_each_entry(ring, active_rings, active_link) {
605 struct i915_request *rq =
606 last_request_on_engine(ring->timeline, engine);
607

 > 608			if (rq && rq->gem_context != engine->i915->kernel_context)

609 return false;
610 }
611
612 return intel_engine_has_kernel_context(engine);
613 }
614

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx