<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi Michal,<br>
    </p>
    <div class="moz-cite-prefix">On 6/3/2024 4:19 PM, Michal Wajdeczko
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:452de901-f35e-49df-8e5f-c4ce676ece0b@intel.com">
      <pre class="moz-quote-pre" wrap="">

On 03.06.2024 10:17, Nirmoy Das wrote:
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">Add missing lock that is protecting relay->incoming_actions.
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
good catch!

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">
Cc: Michal Wajdeczko <a class="moz-txt-link-rfc2396E" href="mailto:michal.wajdeczko@intel.com"><michal.wajdeczko@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>
---
 drivers/gpu/drm/xe/xe_guc_relay.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_relay.c b/drivers/gpu/drm/xe/xe_guc_relay.c
index c3bbaf474f9a..ade6162dc259 100644
--- a/drivers/gpu/drm/xe/xe_guc_relay.c
+++ b/drivers/gpu/drm/xe/xe_guc_relay.c
@@ -761,7 +761,14 @@ static void relay_process_incoming_action(struct xe_guc_relay *relay)
 
 static bool relay_needs_worker(struct xe_guc_relay *relay)
 {
-       return !list_empty(&relay->incoming_actions);
+       bool is_empty;
+
+       spin_lock(&relay->lock);
+       is_empty = list_empty(&relay->incoming_actions);
+       spin_unlock(&relay->lock);
+
+       return !is_empty;
+
 }
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
alternate solution could be to just rely on the new return value from
relay_process_incoming_action() that could tell us if there was nothing
to dequeue so then we wont start new worker (at potential cost of one
extra worker cycle to see that), but this LGTM too, so

Reviewed-by: Michal Wajdeczko <a class="moz-txt-link-rfc2396E" href="mailto:michal.wajdeczko@intel.com"><michal.wajdeczko@intel.com></a></pre>
    </blockquote>
    <p>I did spent some time modifying <span
      style="white-space: pre-wrap">relay_process_incoming_action</span>()
      to return a bool but I am not sure which one is better.</p>
    <p>I will for now pick this one :) <br>
    </p>
    <p><br>
    </p>
    <p>Thanks,</p>
    <p>Nirmoy<br>
    </p>
    <blockquote type="cite"
      cite="mid:452de901-f35e-49df-8e5f-c4ce676ece0b@intel.com">
      <pre class="moz-quote-pre" wrap="">
</pre>
    </blockquote>
  </body>
</html>