diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/gsp_phys_booter.c | 85 | ||||
| -rw-r--r-- | kernel/gsp_sema_service.c | 54 | ||||
| -rw-r--r-- | kernel/gsp_sema_service.h | 1 |
3 files changed, 133 insertions, 7 deletions
diff --git a/kernel/gsp_phys_booter.c b/kernel/gsp_phys_booter.c index a98a588..8da7478 100644 --- a/kernel/gsp_phys_booter.c +++ b/kernel/gsp_phys_booter.c @@ -19119,6 +19119,40 @@ static bool gsp_phys_gr_mme_window_has_draw_ia(const u32 *win, u32 n) return false; } +/* + * eng69: vertex-stream location persistence. The client's per-frame DRAW + * window carries only SET_VERTEX_STREAM_A_FORMAT (0x1c00/0x1c30, one data + * word = the format); the [fmt, UPPER, LOWER] location pair lives in its + * setup push. Return the window's format word for stream j and set + * *has_pair when the window already carries the count>=3 pair run. + */ +static u32 gsp_phys_gr_mme_window_vs_fmt(const u32 *win, u32 n, u32 j, + bool *has_pair) +{ + u32 r = 0, fmt = 0, want = 0x1c00u + j * 0x10u; + + *has_pair = false; + while (r < n) { + u32 h = win[r]; + u32 op = (h >> 29) & 7u; + u32 cnt = (h >> 16) & 0x1fffu; + u32 span = 1u; + u32 m0 = (h & 0xfffu) << 2; + + if ((op == 1u || op == 3u || op == 5u) && cnt && + r + 1u + cnt <= n) + span = 1u + cnt; + if (m0 == want) { + if (span >= 2u && !fmt) + fmt = win[r + 1u]; + if (span >= 4u) + *has_pair = true; + } + r += span; + } + return fmt; +} + static u32 gsp_phys_gr_mme_release_due_ms(void) { u32 ms = READ_ONCE(gsp_phys_rmcall_gr_mme_pack_release_ms); @@ -19227,6 +19261,8 @@ static void gsp_phys_gr_mme_release_save(const struct gsp_phys_gr_submit *req, bool draw_ia, keep = false; const char *prefer = NULL; u32 old_h = 0, old_win = 0; + u32 vs_pre[12]; + u32 vs_n = 0; static u32 prefer_log; if (!READ_ONCE(gsp_phys_rmcall_gr_mme_pack_release) || !req) @@ -19279,6 +19315,44 @@ static void gsp_phys_gr_mme_release_save(const struct gsp_phys_gr_submit *req, prefer = "draw-win"; } if (!keep) { + /* + * eng69: prepend the client's last vertex-stream location + * pairs (streams 0 and 3) when this window carries only the + * FORMAT run. The pair is a normal INC run + * [fmt, UPPER, LOWER] at 0x1c00/0x1c30; the normal window + * patch relocates it to a shadow VA using the launch page + * set (the service re-adds the sticky VB pages to every GL + * candidate). Without it the release draw fetches vertices + * from an unbound stream (c807 DRAW-STATE VS0=0, wrote=0). + */ + u32 vj; + + 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 (req->stream_n + vs_n > GSP_PHYS_GR_MME_RELEASE_WIN_MAX) + vs_n = 0; s->valid = false; s->armed = false; s->fired = false; @@ -19313,8 +19387,11 @@ static void gsp_phys_gr_mme_release_save(const struct gsp_phys_gr_submit *req, s->qmd_hpa = req->qmd_hpa; s->push_len = req->push_len; s->stream_rel = req->stream_rel; - s->stream_n = req->stream_n; - memcpy(s->win, req->stream, (size_t)req->stream_n * 4u); + s->stream_n = req->stream_n + vs_n; + if (vs_n) + memcpy(s->win, vs_pre, (size_t)vs_n * 4u); + memcpy(s->win + vs_n, req->stream, + (size_t)req->stream_n * 4u); s->prog_va = req->prog_va; s->n_prog_binds = req->n_prog_binds; memcpy(s->prog_bind_va, req->prog_bind_va, @@ -19340,9 +19417,9 @@ static void gsp_phys_gr_mme_release_save(const struct gsp_phys_gr_submit *req, req->h_object, win_n); } pr_info("vgsp-gr: MME-CARRY-SAVE h=0x%x win=%u held=%u draw_ia=%u " - "raw=%u push=0x%llx\n", + "raw=%u vs_pre=%u push=0x%llx\n", req->h_object, win_n, held, draw_ia, req->stream_n, - (unsigned long long)req->push_va); + vs_n / 4u, (unsigned long long)req->push_va); } /* diff --git a/kernel/gsp_sema_service.c b/kernel/gsp_sema_service.c index 4a7180e..cafb0dc 100644 --- a/kernel/gsp_sema_service.c +++ b/kernel/gsp_sema_service.c @@ -9788,6 +9788,24 @@ static u8 svc_gl_shader_type[32] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* + * eng69: sticky SET_VERTEX_STREAM_A_LOCATION pair bases. The client's + * per-frame DRAW window carries only SET_VERTEX_STREAM_A_FORMAT + * (0x1c00 <- tid, no location run); the [fmt, BASE_UPPER, BASE_LOWER] + * pair is written by its setup push and must be replayed with the DRAW + * window or the engine fetches vertices from an unbound VA (c807: + * DRAW-STATE VS0=0, no stores). Record the last pair base per stream j + * from any decoded client push; the section capture re-adds these pages + * to the candidate page set and the booter prepends the relocated pair + * to the saved release window. + */ +static u64 svc_gl_vs_base[8]; +static u32 svc_gl_vs_log; + +u64 gsp_sema_gl_vs_base(u32 j) +{ + return j < 8u ? READ_ONCE(svc_gl_vs_base[j]) : 0; +} +/* * SESSION 153-CONTINUED-10 (task 1): the C597 class ATTACHMENT. * * A SET_OBJECT bind is sticky on real hardware: the class stays bound to @@ -11078,9 +11096,22 @@ static void svc_gl_field(u32 addr, u32 count, const u8 *data, u32 dlen) * 153-CONTINUED-10 draw-push decode). */ case 0x1c10: - if (count >= 3) - svc_gl_add_ptr(((u64)(v[1] & 0xff) << 32) | - (u64)(v[2] & 0xfffffffc)); + if (count >= 3) { + u64 vb = ((u64)(v[1] & 0xff) << 32) | + (u64)(v[2] & 0xfffffffc); + u32 vj = (addr - 0x1c00u) >> 4; + + if (vj < 8u && vb) { + if (READ_ONCE(svc_gl_vs_base[vj]) != vb && + svc_gl_vs_log < 16u) { + svc_gl_vs_log++; + pr_info("sema-gl: VS-BIND j=%u base=0x%llx\n", + vj, (unsigned long long)vb); + } + WRITE_ONCE(svc_gl_vs_base[vj], vb); + } + svc_gl_add_ptr(vb); + } return; case 0x2380: /* SET_CONSTANT_BUFFER_SELECTOR_A/B: [size, upper, * lower]. Observed [00010000 00000001 2150a500]. @@ -22957,6 +22988,23 @@ static void svc_decode_stream(struct nv_vgpu_device *vgpu, const u8 *buf, svc_gl.start_off = off; svc_gl.rel_va = keep_rel; svc_gl.rel_payload = keep_pay; + /* + * eng69: keep the client's vertex-stream + * location pages in every draw section's page + * set (the per-frame window only carries the + * FORMAT; the booter prepends the saved + * location pair to the release window). + */ + { + u32 vk; + + for (vk = 0; vk < 8u; vk++) + if (READ_ONCE( + svc_gl_vs_base[vk])) + svc_gl_add_ptr( + READ_ONCE( + svc_gl_vs_base[vk])); + } /* SESSION 153-CONTINUED-10: the bind is sticky - * remember it so the class-space recognizer * (BEGIN 0x1618, below) accepts this channel's diff --git a/kernel/gsp_sema_service.h b/kernel/gsp_sema_service.h index 5a1c491..926f81e 100644 --- a/kernel/gsp_sema_service.h +++ b/kernel/gsp_sema_service.h @@ -628,6 +628,7 @@ bool gsp_sema_gr_surf_recs(u64 *va, u32 *n); * emission trapped the lane). */ u64 gsp_sema_mme_sa_get(u32 *entries, u32 n); +u64 gsp_sema_gl_vs_base(u32 j); /* * Golden SA completion (sema_gl_mme_sa_golden_fill): set the host-side |
