<!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/25/2024 9:55 PM, Michal Wajdeczko
wrote:<br>
</div>
<blockquote type="cite" cite="mid:7c2a77ab-64ab-4244-b533-cdbe0a51bcc7@intel.com">
<pre class="moz-quote-pre" wrap="">On 25.06.2024 10:49, Nirmoy Das wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">GuC TLB invalidation depends on GuC to process the request from the CT
queue and then the real time to invalidate TLB. Add a function to return
overestimated possible time a TLB inval H2G might take which can be used
as timeout value for TLB invalidation wait time.
Closes: <a class="moz-txt-link-freetext" href="https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1622">https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1622</a>
Cc: Matthew Brost <a class="moz-txt-link-rfc2396E" href="mailto:matthew.brost@intel.com"><matthew.brost@intel.com></a>
Suggested-by: Daniele Ceraolo Spurio <a class="moz-txt-link-rfc2396E" href="mailto:daniele.ceraolospurio@intel.com"><daniele.ceraolospurio@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_gt_tlb_invalidation.c | 2 +-
drivers/gpu/drm/xe/xe_guc_ct.c | 12 ++++++++++++
drivers/gpu/drm/xe/xe_guc_ct.h | 2 ++
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c b/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
index e1f1ccb01143..fa61070d6201 100644
--- a/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
+++ b/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
@@ -17,7 +17,7 @@
#include "xe_trace.h"
#include "regs/xe_guc_regs.h"
-#define TLB_TIMEOUT (HZ / 4)
+#define TLB_TIMEOUT xe_guc_tlb_timeout_jiffies()
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">if this is no longer a macro then maybe better get rid of it and use
function call directly ?</pre>
</blockquote>
Wanted to keep the diff to minimal.<br>
<blockquote type="cite" cite="mid:7c2a77ab-64ab-4244-b533-cdbe0a51bcc7@intel.com">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">
static void xe_gt_tlb_fence_timeout(struct work_struct *work)
{
diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
index b4137fe195a4..e30c0da86acc 100644
--- a/drivers/gpu/drm/xe/xe_guc_ct.c
+++ b/drivers/gpu/drm/xe/xe_guc_ct.c
@@ -112,6 +112,18 @@ ct_to_xe(struct xe_guc_ct *ct)
#define CTB_G2H_BUFFER_SIZE (4 * CTB_H2G_BUFFER_SIZE)
#define G2H_ROOM_BUFFER_SIZE (CTB_G2H_BUFFER_SIZE / 4)
+/**
+ * xe_guc_tlb_timeout_jiffies - Calculate the maximum time to process a tlb inval command
+ *
+ * This function computes the maximum time to process a tlb inval H2G commands
+ * in jiffies. A 4KB buffer full of commands takes a little over a second to process,
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">these numbers looks like from experiment - what commands did you use?
do we have SLA from the GuC for max processing time of any command?</pre>
</blockquote>
<p>This is from i915 which was added with
<a class="moz-txt-link-freetext" href="https://patchwork.freedesktop.org/patch/563102/">https://patchwork.freedesktop.org/patch/563102/</a></p>
<blockquote type="cite" cite="mid:7c2a77ab-64ab-4244-b533-cdbe0a51bcc7@intel.com">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">+ * so this time is set to 2 seconds to be safe.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">nit: missing "Return:" tag
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">+ */
+long xe_guc_tlb_timeout_jiffies(void)
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">this function doesn't fit into xe_guc_ct component at all
if you need to reflect CTB size in TLB timeout calculation then:
a) from xe_guc_ct export function that will tell you max number of
commands it can queue (or are already in the CTB queue)
b) in xe_guc_tlb import above function and apply additional timeout per
each H2G action in flight</pre>
</blockquote>
<p>Currently only information we have which is also validated
/r-b-ed by GuC team is the above calculation.</p>
<p>I can export xe_guc_ct_max_queue_time_jiffies and use that in <span style="white-space: pre-wrap">xe_guc_tlb so the function fits their component.</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:7c2a77ab-64ab-4244-b533-cdbe0a51bcc7@intel.com">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">+{
+ return (CTB_H2G_BUFFER_SIZE * HZ) / SZ_2K;
+}
+
static size_t guc_ct_size(void)
{
return 2 * CTB_DESC_SIZE + CTB_H2G_BUFFER_SIZE +
diff --git a/drivers/gpu/drm/xe/xe_guc_ct.h b/drivers/gpu/drm/xe/xe_guc_ct.h
index 105bb8e99a8d..a9755574d6c9 100644
--- a/drivers/gpu/drm/xe/xe_guc_ct.h
+++ b/drivers/gpu/drm/xe/xe_guc_ct.h
@@ -64,4 +64,6 @@ xe_guc_ct_send_block_no_fail(struct xe_guc_ct *ct, const u32 *action, u32 len)
return xe_guc_ct_send_recv_no_fail(ct, action, len, NULL);
}
+long xe_guc_tlb_timeout_jiffies(void);
+
#endif
</pre>
</blockquote>
</blockquote>
</body>
</html>