<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 10/24/2024 7:22 PM, Matthew Brost
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:ZxqCXUp+0EWLVX7u@DUT025-TGLU.fm.intel.com">
      <pre wrap="" class="moz-quote-pre">On Thu, Oct 24, 2024 at 10:14:21AM -0700, John Harrison wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">On 10/24/2024 08:18, Nirmoy Das wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="" class="moz-quote-pre">Flush xe ordered_wq in case of ufence timeout which is observed
on LNL and that points to the recent scheduling issue with E-cores.

This is similar to the recent fix:
commit e51527233804 ("drm/xe/guc/ct: Flush g2h worker in case of g2h
response timeout") and should be removed once there is E core
scheduling fix.

v2: Add platform check(Himal)
     s/__flush_workqueue/flush_workqueue(Jani)

Cc: Badal Nilawar <a class="moz-txt-link-rfc2396E" href="mailto:badal.nilawar@intel.com"><badal.nilawar@intel.com></a>
Cc: Jani Nikula <a class="moz-txt-link-rfc2396E" href="mailto:jani.nikula@intel.com"><jani.nikula@intel.com></a>
Cc: Matthew Auld <a class="moz-txt-link-rfc2396E" href="mailto:matthew.auld@intel.com"><matthew.auld@intel.com></a>
Cc: John Harrison <a class="moz-txt-link-rfc2396E" href="mailto:John.C.Harrison@Intel.com"><John.C.Harrison@Intel.com></a>
Cc: Himal Prasad Ghimiray <a class="moz-txt-link-rfc2396E" href="mailto:himal.prasad.ghimiray@intel.com"><himal.prasad.ghimiray@intel.com></a>
Cc: Lucas De Marchi <a class="moz-txt-link-rfc2396E" href="mailto:lucas.demarchi@intel.com"><lucas.demarchi@intel.com></a>
Cc: <a class="moz-txt-link-rfc2396E" href="mailto:stable@vger.kernel.org"><stable@vger.kernel.org></a> # v6.11+
Link: <a class="moz-txt-link-freetext" href="https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2754">https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2754</a>
Suggested-by: Matthew Brost <a class="moz-txt-link-rfc2396E" href="mailto:matthew.brost@intel.com"><matthew.brost@intel.com></a>
Signed-off-by: Nirmoy Das <a class="moz-txt-link-rfc2396E" href="mailto:nirmoy.das@intel.com"><nirmoy.das@intel.com></a>
Reviewed-by: Matthew Brost <a class="moz-txt-link-rfc2396E" href="mailto:matthew.brost@intel.com"><matthew.brost@intel.com></a>
---
  drivers/gpu/drm/xe/xe_wait_user_fence.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_wait_user_fence.c b/drivers/gpu/drm/xe/xe_wait_user_fence.c
index f5deb81eba01..78a0ad3c78fe 100644
--- a/drivers/gpu/drm/xe/xe_wait_user_fence.c
+++ b/drivers/gpu/drm/xe/xe_wait_user_fence.c
@@ -13,6 +13,7 @@
  #include "xe_device.h"
  #include "xe_gt.h"
  #include "xe_macros.h"
+#include "compat-i915-headers/i915_drv.h"
  #include "xe_exec_queue.h"
  static int do_compare(u64 addr, u64 value, u64 mask, u16 op)
@@ -155,6 +156,19 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, void *data,
                }
                if (!timeout) {
+                       if (IS_LUNARLAKE(xe)) {
+                               /*
+                                * This is analogous to e51527233804 ("drm/xe/guc/ct: Flush g2h
+                                * worker in case of g2h response timeout")
+                                *
+                                * TODO: Drop this change once workqueue scheduling delay issue is
+                                * fixed on LNL Hybrid CPU.
+                                */
+                               flush_workqueue(xe->ordered_wq);
</pre>
        </blockquote>
        <pre wrap="" class="moz-quote-pre">If we are having multiple instances of this workaround, can we wrap them up
in as 'LNL_FLUSH_WORKQUEUE(q)' or some such? Put the IS_LNL check inside the
macro and make it pretty obvious exactly where all the instances are by
having a single macro name to search for.

</pre>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
+1, I think Lucas is suggesting something similar to this on the chat to
make sure we don't lose track of removing these W/A when this gets
fixed.

Matt</pre>
    </blockquote>
    <p><br>
    </p>
    <p>Sounds good. I will add <span style="white-space: pre-wrap">LNL_FLUSH_WORKQUEUE() and use that for all the places we need this WA.</span></p>
    <p><span style="white-space: pre-wrap">
</span></p>
    <p><span style="white-space: pre-wrap">Regards,</span></p>
    <p><span style="white-space: pre-wrap">Nirmoy
</span></p>
    <blockquote type="cite"
      cite="mid:ZxqCXUp+0EWLVX7u@DUT025-TGLU.fm.intel.com">
      <pre wrap="" class="moz-quote-pre">

</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">John.

</pre>
        <blockquote type="cite">
          <pre wrap="" class="moz-quote-pre">+                                err = do_compare(addr, args->value, args->mask, args->op);
+                               if (err <= 0)
+                                       break;
+                       }
                        err = -ETIME;
                        break;
                }
</pre>
        </blockquote>
        <pre wrap="" class="moz-quote-pre">
</pre>
      </blockquote>
    </blockquote>
  </body>
</html>