summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-16 09:59:24 -0500
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-16 09:59:24 -0500
commit630f5a0df40f5262f1c4e071450af65391aaad0f (patch)
treeb226cf17a6629ed793649b5eae45b670aa96bb1f
parented8a9c6b8e061fe772fc0050ab83c2dec2db8d1e (diff)
downloadopen-iov-630f5a0df40f5262f1c4e071450af65391aaad0f.tar.gz
open-iov-630f5a0df40f5262f1c4e071450af65391aaad0f.zip
vgsp: eng89b - persist the colour-target bind across pushes
Most beef draw pushes carry no colour-target bind of their own (the client binds the target once per context/target switch in an earlier state push), so the per-window admission refused the real frame pushes on most boots ('beef draw-synth: no valid last colour-target bind', the shallow-boot lottery). Track the last complete, plausible bind seen on a trusted push (same surface-class validity as the first-bind check; an invalid later write never overwrites a valid state) and admit a beef draw window on it: RT-PERSIST + '3D mark admitted (persisted colour-target bind)' receipts. Knob sema_gl_win_rt_persist, default 1.
-rw-r--r--kernel/gsp_sema_service.c122
-rwxr-xr-xtools/guest-diag/run_cycles_long.sh5
2 files changed, 125 insertions, 2 deletions
diff --git a/kernel/gsp_sema_service.c b/kernel/gsp_sema_service.c
index 69b7341..f0f6632 100644
--- a/kernel/gsp_sema_service.c
+++ b/kernel/gsp_sema_service.c
@@ -12190,6 +12190,108 @@ static bool svc_gl_window_rt_first_valid(const u8 *buf, u32 len, u32 start_off,
return false;
}
+/*
+ * eng89: persisted colour-target bind.
+ *
+ * The client binds its colour target once per context/target switch (an INC
+ * run over methods 0x800/0x804/0x808/0x80c), in a state push that is often
+ * NOT the push that carries the frame's draw window. The per-window
+ * admission checks below therefore refuse the real draw pushes on most
+ * boots ("beef draw-synth: no valid last colour-target bind"), which is the
+ * shallow-boot lottery. Track the last complete, plausible bind seen on a
+ * trusted push of this channel and admit a beef draw window on that
+ * persisted state. Only a bind that passes the same surface-class validity
+ * as svc_gl_window_rt_first_valid is stored, so a data blob cannot poison
+ * it (an invalid later write leaves the previous valid state in place).
+ */
+static u32 svc_gl_rtp_a[4], svc_gl_rtp_b[4], svc_gl_rtp_w[4], svc_gl_rtp_h[4];
+static u32 svc_gl_rtp_mask;
+static u64 svc_gl_rtp_push;
+static bool svc_gl_rtp = true;
+module_param_named(sema_gl_win_rt_persist, svc_gl_rtp, bool, 0644);
+MODULE_PARM_DESC(sema_gl_win_rt_persist,
+ "Remember the last valid colour-target bind from any trusted push and admit beef draw windows on that persisted state (default 1)");
+
+static bool svc_gl_rtp_valid(void)
+{
+ return READ_ONCE(svc_gl_rtp_mask) != 0u;
+}
+
+static void svc_gl_rt_note(const u8 *buf, u32 len, u64 h, u64 push)
+{
+ u32 A[4] = { 0 }, B[4] = { 0 }, W[4] = { 0 }, H[4] = { 0 };
+ bool sa[4] = { false }, sb[4] = { false };
+ bool sw[4] = { false }, sh[4] = { false };
+ u32 o = 0, j, nval = 0;
+
+ if (!buf || len < 4u)
+ return;
+ while (o + 4u <= len) {
+ u32 hh, op, cnt, m, span = 1u, k;
+
+ memcpy(&hh, buf + o, 4);
+ op = (hh >> 29) & 7u;
+ cnt = (hh >> 16) & 0xfffu;
+ m = (hh & 0x1fffu) << 2;
+ if ((op == 1u || op == 3u || op == 5u) && cnt &&
+ o + 4u + cnt * 4u <= len)
+ span = 1u + cnt;
+ for (k = 0; k < span; k++) {
+ u32 mm = m + 4u * k, v = 0;
+
+ if (k && op != 1u && op != 3u)
+ break;
+ if (k)
+ memcpy(&v, buf + o + 4u + k * 4u, 4);
+ else if (op == 4u)
+ v = (hh >> 16) & 0x1fffu;
+ else
+ continue;
+ for (j = 0; j < 4u; j++) {
+ u32 base = 0x800u + j * 0x40u;
+
+ if (mm == base) { A[j] = v; sa[j] = true; }
+ else if (mm == base + 4u) { B[j] = v; sb[j] = true; }
+ else if (mm == base + 8u) { W[j] = v; sw[j] = true; }
+ else if (mm == base + 0xcu) { H[j] = v; sh[j] = true; }
+ }
+ }
+ o += span * 4u;
+ }
+ for (j = 0; j < 4u; j++) {
+ if (sa[j] && sb[j] && sw[j] && sh[j] &&
+ (A[j] & ~0xffu) == 0 && (A[j] & 0xffu) <= 1u &&
+ B[j] >= 0x08000000u && B[j] < 0x40000000u &&
+ (B[j] & 3u) == 0 && W[j] > 0 && W[j] <= 0x4000u &&
+ H[j] > 0 && H[j] <= 0x4000u) {
+ svc_gl_rtp_a[j] = A[j];
+ svc_gl_rtp_b[j] = B[j];
+ svc_gl_rtp_w[j] = W[j];
+ svc_gl_rtp_h[j] = H[j];
+ nval++;
+ }
+ }
+ if (nval) {
+ WRITE_ONCE(svc_gl_rtp_push, push);
+ smp_wmb();
+ WRITE_ONCE(svc_gl_rtp_mask, READ_ONCE(svc_gl_rtp_mask) | 1u);
+ if (gsp_sema_dbg) {
+ static u32 rtp_log;
+
+ if (rtp_log < 16u) {
+ rtp_log++;
+ pr_info("sema-gl: RT-PERSIST h=0x%llx push=0x%llx groups=%u A=%08x,%08x,%08x,%08x B=%08x,%08x,%08x,%08x W=%08x,%08x,%08x,%08x H=%08x,%08x,%08x,%08x\n",
+ (unsigned long long)h,
+ (unsigned long long)push, nval,
+ A[0], A[1], A[2], A[3],
+ B[0], B[1], B[2], B[3],
+ W[0], W[1], W[2], W[3],
+ H[0], H[1], H[2], H[3]);
+ }
+ }
+ }
+}
+
static bool svc_gl_window_drawwin_ok(const u8 *buf, u32 len, u32 start_off,
u32 at_off)
{
@@ -12209,6 +12311,24 @@ static bool svc_gl_window_drawwin_ok(const u8 *buf, u32 len, u32 start_off,
}
return true;
}
+ /*
+ * eng89: the draw window usually carries no bind of its own (the
+ * target was bound by an earlier state push). Admit on the
+ * persisted bind when one is known; the replay context's RT state
+ * comes from the channel shadow, not from this window.
+ */
+ if (READ_ONCE(svc_gl_rtp) && svc_gl_rtp_valid()) {
+ static u32 rtp_adm_log;
+
+ if (rtp_adm_log < 16u) {
+ rtp_adm_log++;
+ pr_info("sema-gl: 3D mark admitted (persisted colour-target bind) start=0x%x at=0x%x win=%u words\n",
+ start_off, at_off,
+ at_off > start_off ?
+ (at_off - start_off) / 4u : 0u);
+ }
+ return true;
+ }
return false;
}
@@ -12251,6 +12371,8 @@ static void svc_gl_flush(struct nv_vgpu_device *vgpu,
svc_gl_arrival_note(push_va, buf, len);
/* CONT.411: state at every flush entry for the kick channel. */
svc_gl_watch_note(ch, "entry", push_va, len, at_off, trusted);
+ if (trusted && READ_ONCE(svc_gl_rtp))
+ svc_gl_rt_note(buf, len, ch->h_object, push_va);
svc_gl_prog_apply_param();
if (!svc_gl.seen || !trusted) {
svc_gl_watch_note(ch, !svc_gl.seen ? "early-noseen" :
diff --git a/tools/guest-diag/run_cycles_long.sh b/tools/guest-diag/run_cycles_long.sh
index bf14ca2..fa8dd77 100755
--- a/tools/guest-diag/run_cycles_long.sh
+++ b/tools/guest-diag/run_cycles_long.sh
@@ -78,7 +78,7 @@ analyze_tag() { # analyze_tag <tag> <dmesg-file> <gl-log> <gz-log>
RC=0
for TAG in "$@"; do
say "=== $TAG start (GZ_SECS=$GZ_SECS GLF_FRAMES=$GLF_FRAMES params=$(basename "$INSMOD_PARAMS")) ==="
- DM_START=$(sudo dmesg 2>/dev/null | wc -l)
+ DM_SINCE=$(date "+%Y-%m-%d %H:%M:%S")
if ! INSMOD_PARAMS="$INSMOD_PARAMS" bash "$HERE/cycle-r1780.sh" "$TAG" "$MODULE" \
> "$BACKUP/$TAG-cycle.log" 2>&1; then
say "$TAG CYCLE FAILED (see $BACKUP/$TAG-cycle.log)"
@@ -109,7 +109,8 @@ for TAG in "$@"; do
say "$TAG mission: $DONE"
fi
- sudo dmesg 2>/dev/null | tail -n +$((DM_START + 1)) > "$BACKUP/$TAG-dmesg.log"
+ sudo dmesg -T --since "$DM_SINCE" 2>/dev/null > "$BACKUP/$TAG-dmesg.log" || \
+ sudo dmesg 2>/dev/null | tail -n 4000 > "$BACKUP/$TAG-dmesg.log"
gexec 30 'cat /tmp/mission-gl.log 2>/dev/null' > "$BACKUP/$TAG-gl.log"
gexec 30 'cat /tmp/mission-gz.log 2>/dev/null' > "$BACKUP/$TAG-gz.log"
gexec 30 'tail -c 3000 /tmp/mission-run.log 2>/dev/null' > "$BACKUP/$TAG-run.log"