diff options
| author | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-11-15 18:53:00 -0500 |
|---|---|---|
| committer | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-11-15 18:53:00 -0500 |
| commit | cb786b9bdb188b49614ebba77d8359f74af5e416 (patch) | |
| tree | dd52ac81f61ba63e28360545fa60b5d1925a0192 /kernel | |
| parent | 01c22a8d96d9de45a02d7556178445b3eed89f2b (diff) | |
| download | open-iov-cb786b9bdb188b49614ebba77d8359f74af5e416.tar.gz open-iov-cb786b9bdb188b49614ebba77d8359f74af5e416.zip | |
vgsp: eng71 - scan the tracked data pages for the vertex payload and bind VS0
c812/c813: the 151-word DRAW-window release has VS0=VS1=VS3=0 and
SZ0=SZ1=SZ3=0; the DRAW_IAB emits its 8x3-vertex draws (VA=0xd74=0x15)
against no vertex stream, so nothing rasterizes. The client's vertex
payload is a 24-vertex, 20-byte-stride float2 buffer (FORMAT 0x1014,
ATTR(0) float2 offset 0) written into the launch's tracked data pages.
sema_gl_vs_autobind (0=off, 1=scan+log, 2=bind; params=2): scan the
0x120400000..0x120800000 data pages for a 512-byte block of 24
plausible float2 vertices (score>=8 nice values), then prepend to the
saved release window: VS0 location [fmt=0x1014, upper, lower=reloc_va
+off], and the Turing stream SIZE pair (0x600<-0, 0x604<-0x100000).
VS-SCAN/MME-VS-BIND/MME-VS-SIZE receipts; the starts 0..21 x stride
20 resolve inside the 1 MB bound.
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/gsp_phys_booter.c | 177 |
1 files changed, 155 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; |
