<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:owen.zhang@intel.com" title="Owen Zhang <owen.zhang@intel.com>"> <span class="fn">Owen Zhang</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_CLOSED  bz_closed"
   title="CLOSED INVALID - [i915]Kernel panic occurs after ECHO 15 to /sys/kernel/debug/dri/0/i915_wedged"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=106832">bug 106832</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>owen.zhang@intel.com
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_CLOSED  bz_closed"
   title="CLOSED INVALID - [i915]Kernel panic occurs after ECHO 15 to /sys/kernel/debug/dri/0/i915_wedged"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=106832#c7">Comment # 7</a>
              on <a class="bz_bug_link 
          bz_status_CLOSED  bz_closed"
   title="CLOSED INVALID - [i915]Kernel panic occurs after ECHO 15 to /sys/kernel/debug/dri/0/i915_wedged"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=106832">bug 106832</a>
              from <span class="vcard"><a class="email" href="mailto:owen.zhang@intel.com" title="Owen Zhang <owen.zhang@intel.com>"> <span class="fn">Owen Zhang</span></a>
</span></b>
        <pre>Created <span class=""><a href="attachment.cgi?id=140479" name="attach_140479" title="draft one fix patch on kernel 4.14">attachment 140479</a> <a href="attachment.cgi?id=140479&action=edit" title="draft one fix patch on kernel 4.14">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=106832&attachment=140479'>[review]</a>
draft one fix patch on kernel 4.14

Hi Joonas and all,

Could you help to have a look this fix on 4.14 LTS?
due to we need one fix on our MSS release, so we made one fix patch based on
4.14. this changes can avoid the kernel panic.
pls kindly give your any comments and suggestions? thanks very much.

here coped the changes, Appreciate your comments.

---
 drivers/gpu/drm/i915/i915_gem.c  |  6 ++++--
 drivers/gpu/drm/i915/intel_lrc.c | 17 +++++++++++------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 877e3b6..45f8130 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3058,8 +3058,10 @@ static void engine_set_wedged(struct intel_engine_cs
*engine)
                for (n = 0; n < ARRAY_SIZE(engine->execlist_port); n++) {
                        struct drm_i915_gem_request *rq =
port_request(&port[n]);

-                       intel_engine_context_out(rq->engine);
-                       i915_gem_request_put(rq);
+                       if(rq) {
+                               intel_engine_context_out(rq->engine);
+                               i915_gem_request_put(rq);
+                       }
                }
                memset(engine->execlist_port, 0,
sizeof(engine->execlist_port));
                engine->execlist_queue = RB_ROOT;
diff --git a/drivers/gpu/drm/i915/intel_lrc.c
b/drivers/gpu/drm/i915/intel_lrc.c
index 50e9641..e620b4d 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1411,13 +1411,18 @@ static void reset_common_ring(struct intel_engine_cs
*engine,
                return;
        }

-       if (request->ctx != port_request(port)->ctx) {
-               i915_gem_request_put(port_request(port));
-               port[0] = port[1];
-               memset(&port[1], 0, sizeof(port[1]));
-       }
+       /* if the request in ELSP had been processed after GPU finished
+        * HW reset, this GPU reset occur when a forced request.
+        * */
+       if (port_request(port)) {
+               if (request->ctx != port_request(port)->ctx) {
+                       i915_gem_request_put(port_request(port));
+                       port[0] = port[1];
+                       memset(&port[1], 0, sizeof(port[1]));
+               }

-       GEM_BUG_ON(request->ctx != port_request(port)->ctx);
+               GEM_BUG_ON(request->ctx != port_request(port)->ctx);
+       }

        /* If the request was innocent, we leave the request in the ELSP
         * and will try to replay it on restarting. The context image may</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are on the CC list for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>