summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/gsp_phys_booter.c177
-rw-r--r--tools/guest-diag/params-r1624.txt1
2 files changed, 156 insertions, 22 deletions
diff --git a/kernel/gsp_phys_booter.c b/kernel/gsp_phys_booter.c
index ad55aab..40606c9 100644
--- a/kernel/gsp_phys_booter.c
+++ b/kernel/gsp_phys_booter.c
@@ -19165,6 +19165,105 @@ static u32 gsp_phys_gr_mme_window_vs_fmt(const u32 *win, u32 n, u32 j,
return fmt;
}
+/*
+ * eng71 VB autobind: the direct-GL DRAW window carries no vertex-stream
+ * state, so the DRAW_IAB's 8x3-vertex draws fetch from an unbound/stale
+ * stream (c812/c813 VS0=SZ0=0). The client's vertex payload is a 24-vertex,
+ * 20-byte-stride buffer (FORMAT 0x1014: stride 20; ATTR(0): float2 at
+ * offset 0) written into the launch's tracked data pages. Scan those pages
+ * for a vertex-like block and (autobind>=2) bind stream 0 to it with a
+ * large size. 0=off, 1=scan+log, 2=scan+bind.
+ */
+static u32 gsp_phys_rmcall_gr_vs_autobind;
+module_param_named(sema_gl_vs_autobind, gsp_phys_rmcall_gr_vs_autobind,
+ uint, 0644);
+MODULE_PARM_DESC(sema_gl_vs_autobind,
+ "Scan the release launch's tracked data pages for the 24x20 B float2 vertex payload and bind VS0 to it (0=off, 1=scan+log, 2=bind; default 0)");
+
+#define GSP_PHYS_VS_STRIDE 20u
+#define GSP_PHYS_VS_COUNT 24u
+#define GSP_PHYS_VS_BYTES (GSP_PHYS_VS_STRIDE * GSP_PHYS_VS_COUNT)
+
+static bool gsp_phys_vs_f32_ok(u32 w)
+{
+ u32 e = (w >> 23) & 0xffu;
+
+ return e != 0xffu && (e <= 133u || w == 0u || w == 0x80000000u);
+}
+
+static bool gsp_phys_vs_nice(u32 w)
+{
+ return w == 0u || w == 0x80000000u || w == 0x3f800000u ||
+ w == 0xbf800000u || w == 0x3f000000u || w == 0xbf000000u ||
+ w == 0x40000000u || w == 0xc0000000u || w == 0x3f400000u ||
+ w == 0xbf400000u;
+}
+
+static u32 gsp_phys_gr_vs_score(const u8 *p)
+{
+ u32 k, score = 0;
+
+ for (k = 0; k < GSP_PHYS_VS_COUNT; k++) {
+ u32 x, y;
+
+ memcpy(&x, p + k * GSP_PHYS_VS_STRIDE, 4);
+ memcpy(&y, p + k * GSP_PHYS_VS_STRIDE + 4, 4);
+ if (!gsp_phys_vs_f32_ok(x) || !gsp_phys_vs_f32_ok(y))
+ return 0;
+ if (gsp_phys_vs_nice(x) && gsp_phys_vs_nice(y) &&
+ (x != 0u || y != 0u))
+ score++;
+ }
+ return score;
+}
+
+/*
+ * Scan the launch's data pages for the vertex block. Returns 1 and fills
+ * base_va/off on success. The candidate must be inside a tracked page
+ * whose reloc_va is engine-visible; score>=8 nice float2 vertices.
+ */
+static u32 gsp_phys_gr_vs_scan(const struct gsp_phys_gr_submit *req,
+ u64 *base_va, u32 *off_out)
+{
+ u32 i, off, best = 0;
+
+ if (!req || !req->n_data || !req->data)
+ return 0;
+ for (i = 0; i < req->n_data && i < 1025u; i++) {
+ u64 va = req->data[i].va;
+ u64 rva = req->data[i].reloc_va;
+ const u8 *p;
+
+ if (!rva || va < 0x120400000ULL || va >= 0x120800000ULL)
+ continue;
+ p = (const u8 *)__va(req->data[i].hpa);
+ if (!p)
+ continue;
+ for (off = 0; off + GSP_PHYS_VS_BYTES <= 4096u; off += 4u) {
+ u32 x, y, sc;
+
+ memcpy(&x, p + off, 4);
+ memcpy(&y, p + off + 4, 4);
+ if (!gsp_phys_vs_f32_ok(x) || !gsp_phys_vs_f32_ok(y) ||
+ (!x && !y))
+ continue;
+ sc = gsp_phys_gr_vs_score(p + off);
+ if (sc > best) {
+ best = sc;
+ *base_va = rva + off;
+ *off_out = off;
+ }
+ }
+ }
+ if (best >= 8u) {
+ pr_info("vgsp-gr: VS-SCAN base=0x%llx off=0x%x score=%u (24x20 B float2)\n",
+ (unsigned long long)*base_va, *off_out, best);
+ return 1;
+ }
+ pr_info("vgsp-gr: VS-SCAN no candidate (best=%u)\n", best);
+ return 0;
+}
+
static u32 gsp_phys_gr_mme_release_due_ms(void)
{
u32 ms = READ_ONCE(gsp_phys_rmcall_gr_mme_pack_release_ms);
@@ -19339,29 +19438,63 @@ static void gsp_phys_gr_mme_release_save(const struct gsp_phys_gr_submit *req,
*/
u32 vj;
- for (vj = 0; vj < 8u; vj++) {
- u64 vva = gsp_sema_gl_vs_base(vj);
- bool has = false;
- u32 vfmt;
+ {
+ static u32 vs_scan_n;
+ u64 scan_va = 0;
+ u32 scan_off = 0;
+ bool scan_ok = false;
+
+ if (READ_ONCE(gsp_phys_rmcall_gr_vs_autobind) &&
+ vs_scan_n < 4u) {
+ vs_scan_n++;
+ scan_ok = gsp_phys_gr_vs_scan(req, &scan_va,
+ &scan_off);
+ }
+ for (vj = 0; vj < 8u; vj++) {
+ u64 vva = gsp_sema_gl_vs_base(vj);
+ bool has = false;
+ u32 vfmt;
- if (vj != 0u && vj != 3u)
- continue;
- vfmt = gsp_phys_gr_mme_window_vs_fmt(req->stream,
- req->stream_n, vj,
- &has);
- if (!vva || has || vs_n + 4u > ARRAY_SIZE(vs_pre))
- continue;
- if (!vfmt)
- vfmt = 0x1014u;
- vs_pre[vs_n++] = (1u << 29) | (3u << 16) |
- (((0x1c00u + vj * 0x10u) >> 2) &
- 0xfffu);
- vs_pre[vs_n++] = vfmt;
- vs_pre[vs_n++] = (u32)(vva >> 32) & 0xffu;
- vs_pre[vs_n++] = (u32)vva & 0xfffffffcULL;
- pr_info("vgsp-gr: MME-VS-BIND synth j=%u base=0x%llx fmt=0x%x h=0x%x push=0x%llx\n",
- vj, (unsigned long long)vva, vfmt,
- req->h_object, req->push_va);
+ if (vj != 0u && vj != 3u)
+ continue;
+ vfmt = gsp_phys_gr_mme_window_vs_fmt(
+ req->stream, req->stream_n, vj, &has);
+ if (!vva && vj == 0u && scan_ok &&
+ READ_ONCE(gsp_phys_rmcall_gr_vs_autobind) >=
+ 2u)
+ vva = scan_va;
+ if (!vva || has ||
+ vs_n + 7u > ARRAY_SIZE(vs_pre))
+ continue;
+ if (!vfmt)
+ vfmt = 0x1014u;
+ vs_pre[vs_n++] = (1u << 29) | (3u << 16) |
+ (((0x1c00u + vj * 0x10u) >> 2) &
+ 0xfffu);
+ vs_pre[vs_n++] = vfmt;
+ vs_pre[vs_n++] = (u32)(vva >> 32) & 0xffu;
+ vs_pre[vs_n++] = (u32)vva & 0xfffffffcULL;
+ pr_info("vgsp-gr: MME-VS-BIND synth j=%u base=0x%llx fmt=0x%x h=0x%x push=0x%llx\n",
+ vj, (unsigned long long)vva, vfmt,
+ req->h_object, req->push_va);
+ /*
+ * Stream size (Turing binds SIZE_A/B; the
+ * replay has none). 1 MB covers the 24x20 B
+ * payload with margin.
+ */
+ if (vj == 0u &&
+ READ_ONCE(gsp_phys_rmcall_gr_vs_autobind) >=
+ 2u && vs_n + 3u <= ARRAY_SIZE(vs_pre)) {
+ vs_pre[vs_n++] = (1u << 29) |
+ (2u << 16) |
+ ((0x600u >> 2) &
+ 0xfffu);
+ vs_pre[vs_n++] = 0u;
+ vs_pre[vs_n++] = 0x00100000u;
+ pr_info("vgsp-gr: MME-VS-SIZE synth j=0 size=0x100000 h=0x%x push=0x%llx\n",
+ req->h_object, req->push_va);
+ }
+ }
}
if (req->stream_n + vs_n > GSP_PHYS_GR_MME_RELEASE_WIN_MAX)
vs_n = 0;
diff --git a/tools/guest-diag/params-r1624.txt b/tools/guest-diag/params-r1624.txt
index 351fb00..accec65 100644
--- a/tools/guest-diag/params-r1624.txt
+++ b/tools/guest-diag/params-r1624.txt
@@ -8,3 +8,4 @@ sema_gl_mme_pack_carry=1 sema_gl_mme_pack_carry_ms=100 sema_gl_mme_pack_release=
sema_gl_sph_bind_pair_safe=1 sema_gl_mme_sa_golden_fill=1 sema_gl_mme_release_sa_arm=1
sema_gl_sph_stage_disable=0x04
sema_gl_viewport=1
+ sema_gl_vs_autobind=2