|
|
@@ -132,13 +132,12 @@ class QtCleanService:
|
|
|
return observer.snapshot(live=live, include_steps=True), live
|
|
|
|
|
|
@staticmethod
|
|
|
- def _training_outcomes(firmware, started):
|
|
|
- """DDR Training SUCCEEDED is stage health, not an AMT/MT verdict."""
|
|
|
+ def _task_outcomes(firmware, started, detail_id, name):
|
|
|
latest = {}
|
|
|
if not started:
|
|
|
return latest
|
|
|
for row in firmware.get("stage_progress", {}).get("steps", []):
|
|
|
- if (row.get("detail_id") != "ddr_training" or row.get("name") != "DDR Training"
|
|
|
+ if (row.get("detail_id") != detail_id or row.get("name") != name
|
|
|
or not isinstance(row.get("cpu"), int)
|
|
|
or (row.get("ended_unix_ms") or 0) < started):
|
|
|
continue
|
|
|
@@ -148,6 +147,11 @@ class QtCleanService:
|
|
|
latest[cpu] = (stamp, row.get("state", ""))
|
|
|
return {cpu: state for cpu, (_, state) in latest.items()}
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def _training_outcomes(cls, firmware, started):
|
|
|
+ """DDR Training SUCCEEDED is stage health, not an AMT/MT verdict."""
|
|
|
+ return cls._task_outcomes(firmware, started, "ddr_training", "DDR Training")
|
|
|
+
|
|
|
def _input(self, rt, firmware, live):
|
|
|
p = firmware.get("console_prompt", {})
|
|
|
kind = p.get("kind", "")
|
|
|
@@ -215,6 +219,10 @@ class QtCleanService:
|
|
|
try:
|
|
|
key = (int(details["cpu"]), canonical_channel(details["channel"], self._runtime(sid).cfg["channels_per_cpu"]))
|
|
|
record.setdefault("failed_channels", set()).add(key)
|
|
|
+ stage_name = {"bios_training": "training", "amemdiag": "amt"}.get(event.get("phase", ""), event.get("phase", ""))
|
|
|
+ if stage_name not in ("training", "rmt", "amt", "mt"):
|
|
|
+ stage_name = "training"
|
|
|
+ record.setdefault("failed_channel_stages", {}).setdefault(key, stage_name)
|
|
|
except (TypeError, ValueError, BenchError):
|
|
|
pass
|
|
|
cursor = page["next_after_sequence"]
|
|
|
@@ -222,6 +230,155 @@ class QtCleanService:
|
|
|
if not page["has_more"]:
|
|
|
break
|
|
|
|
|
|
+ def _channels(self, rt, fw, observer, record, started, temperatures):
|
|
|
+ cpu_count = rt.cfg["cpu_count"]
|
|
|
+ ch_count = rt.cfg["channels_per_cpu"]
|
|
|
+ boot_matches = (fw.get("boot_id") == record["boot_id"]
|
|
|
+ if record.get("boot_id") else not record and bool(fw.get("boot_id")))
|
|
|
+ if record.get("state") == "starting" or fw.get("boot_pending") or not boot_matches:
|
|
|
+ return [{"cpu": cpu, "channel": str(ch), "name": f"CPU{cpu}_CH{chr(65 + ch)}",
|
|
|
+ "present": False,
|
|
|
+ "stages": {"detected": False, "training": "idle", "rmt": "idle", "amt": "idle", "mt": "idle"},
|
|
|
+ "failed_stage": "", "state": "idle", "temperature_c": None}
|
|
|
+ for cpu in range(cpu_count) for ch in range(ch_count)]
|
|
|
+
|
|
|
+ stage_started = started or (fw.get("boot_started_unix_ms", 0) if not record else 0)
|
|
|
+
|
|
|
+ def norm_key(c, ch_val):
|
|
|
+ try:
|
|
|
+ if isinstance(c, bool) or c is None or ch_val is None:
|
|
|
+ return None
|
|
|
+ return int(c), canonical_channel(ch_val, ch_count)
|
|
|
+ except (TypeError, ValueError, BenchError):
|
|
|
+ return None
|
|
|
+
|
|
|
+ failed_channel_stages = dict(record.get("failed_channel_stages", {}))
|
|
|
+ default_err_stage = record.get("failure_scope") if record.get("failure_scope") in ("training", "rmt", "amt", "mt") else "training"
|
|
|
+ for key in record.get("failed_channels", set()):
|
|
|
+ failed_channel_stages.setdefault(key, default_err_stage)
|
|
|
+ if not record:
|
|
|
+ for (c, ch_val), st in getattr(observer, "channel_errors", {}).items():
|
|
|
+ nk = norm_key(c, ch_val)
|
|
|
+ if nk:
|
|
|
+ failed_channel_stages.setdefault(nk, st if st in ("training", "rmt", "amt", "mt") else "training")
|
|
|
+
|
|
|
+ dimms_by_ch = {}
|
|
|
+ for d in fw.get("training_dimms", []):
|
|
|
+ nk = norm_key(d.get("cpu"), d.get("channel"))
|
|
|
+ if nk:
|
|
|
+ dimms_by_ch.setdefault(nk, []).append(d)
|
|
|
+
|
|
|
+ chans_by_ch = {}
|
|
|
+ for c_row in fw.get("training_channels", []):
|
|
|
+ nk = norm_key(c_row.get("cpu"), c_row.get("channel"))
|
|
|
+ if nk:
|
|
|
+ chans_by_ch[nk] = c_row
|
|
|
+
|
|
|
+ rmt_measured_chs = set()
|
|
|
+ for m in fw.get("rmt_measurements", []):
|
|
|
+ if (m.get("observed_unix_ms") or 0) >= stage_started:
|
|
|
+ nk = norm_key(m.get("cpu"), m.get("channel"))
|
|
|
+ if nk:
|
|
|
+ rmt_measured_chs.add(nk)
|
|
|
+
|
|
|
+ sensor_chs = set()
|
|
|
+ for c, ch_val in getattr(observer, "detected_sensor_channels", set()):
|
|
|
+ nk = norm_key(c, ch_val)
|
|
|
+ if nk:
|
|
|
+ sensor_chs.add(nk)
|
|
|
+
|
|
|
+ present_map = {}
|
|
|
+ disabled_map = {}
|
|
|
+ for cpu in range(cpu_count):
|
|
|
+ for ch in range(ch_count):
|
|
|
+ key = (cpu, str(ch))
|
|
|
+ d_rows = dimms_by_ch.get(key, [])
|
|
|
+ c_row = chans_by_ch.get(key, {})
|
|
|
+ has_pos_dimm = any(
|
|
|
+ d.get("presence") == "present" or bool(d.get("sn")) or bool(d.get("serial"))
|
|
|
+ or bool(d.get("reported_dimm_code")) or d.get("training_state") in ("enabled", "disabled")
|
|
|
+ for d in d_rows
|
|
|
+ )
|
|
|
+ explicitly_absent = bool(d_rows) and all(d.get("presence") == "absent" for d in d_rows) and not has_pos_dimm
|
|
|
+ present_map[key] = (not explicitly_absent) and (
|
|
|
+ has_pos_dimm or c_row.get("state") in ("enabled", "disabled")
|
|
|
+ or key in rmt_measured_chs or key in sensor_chs or key in failed_channel_stages
|
|
|
+ )
|
|
|
+ disabled_map[key] = (
|
|
|
+ any(d.get("training_state") == "disabled" for d in d_rows)
|
|
|
+ or c_row.get("state") == "disabled"
|
|
|
+ )
|
|
|
+
|
|
|
+ training = self._task_outcomes(fw, stage_started, "ddr_training", "DDR Training")
|
|
|
+ rmt_tasks = self._task_outcomes(fw, stage_started, "rmt_task", "Rank Margin Tool")
|
|
|
+ rmt_rows = {r["cpu"]: r for r in fw.get("rmt_results", [])
|
|
|
+ if isinstance(r.get("cpu"), int) and (r.get("observed_unix_ms") or 0) >= stage_started}
|
|
|
+ amt_rows = {a["cpu"]: a for a in fw.get("amt_results", [])
|
|
|
+ if isinstance(a.get("cpu"), int) and (a.get("observed_unix_ms") or 0) >= stage_started}
|
|
|
+ mt = fw.get("mt_result", {}) if (fw.get("mt_result", {}).get("observed_unix_ms") or 0) >= stage_started else {}
|
|
|
+
|
|
|
+ any_present_cpu = {cpu: any(present_map[(cpu, str(c))] for c in range(ch_count)) for cpu in range(cpu_count)}
|
|
|
+ any_rmt_cpu = {cpu: any((cpu, str(c)) in rmt_measured_chs for c in range(ch_count)) for cpu in range(cpu_count)}
|
|
|
+ any_present_station = any(present_map.values())
|
|
|
+ any_ch_err_stage = {st: any(v == st for v in failed_channel_stages.values()) for st in ("training", "rmt", "amt", "mt")}
|
|
|
+ any_ch_err_cpu = {(cpu, st): any(k[0] == cpu and v == st for k, v in failed_channel_stages.items())
|
|
|
+ for cpu in range(cpu_count) for st in ("training", "rmt", "amt", "mt")}
|
|
|
+
|
|
|
+ channels = []
|
|
|
+ for cpu in range(cpu_count):
|
|
|
+ for ch in range(ch_count):
|
|
|
+ key = (cpu, str(ch))
|
|
|
+ present = present_map[key]
|
|
|
+ disabled = disabled_map[key]
|
|
|
+ ch_err = failed_channel_stages.get(key, "")
|
|
|
+ cpu_fail_target = present or not any_present_cpu[cpu]
|
|
|
+ station_fail_target = present or not any_present_station
|
|
|
+
|
|
|
+ if ch_err == "training" or (training.get(cpu) == "failed" and not any_ch_err_cpu[(cpu, "training")] and cpu_fail_target):
|
|
|
+ st_training = "fail"
|
|
|
+ elif training.get(cpu) == "completed" and present and not disabled:
|
|
|
+ st_training = "pass"
|
|
|
+ else:
|
|
|
+ st_training = "idle"
|
|
|
+
|
|
|
+ rmt_failed = rmt_tasks.get(cpu) == "failed" or rmt_rows.get(cpu, {}).get("state") == "failed"
|
|
|
+ rmt_passed = (rmt_tasks.get(cpu) == "completed" or rmt_rows.get(cpu, {}).get("state") == "completed") and not rmt_failed
|
|
|
+ if ch_err == "rmt" or (rmt_failed and not any_ch_err_cpu[(cpu, "rmt")] and cpu_fail_target):
|
|
|
+ st_rmt = "fail"
|
|
|
+ elif rmt_passed and present and not disabled and (key in rmt_measured_chs or not any_rmt_cpu[cpu]):
|
|
|
+ st_rmt = "pass"
|
|
|
+ else:
|
|
|
+ st_rmt = "idle"
|
|
|
+
|
|
|
+ amt_row = amt_rows.get(cpu, {})
|
|
|
+ amt_failed = amt_row.get("status") in ("fail", "block", "blocked")
|
|
|
+ amt_passed = amt_row.get("status") == "pass" and bool(amt_row.get("verdict_supported")) and (amt_row.get("algorithm_count") or 0) > 0
|
|
|
+ if ch_err == "amt" or (amt_failed and not any_ch_err_cpu[(cpu, "amt")] and cpu_fail_target):
|
|
|
+ st_amt = "fail"
|
|
|
+ elif amt_passed and present and not disabled:
|
|
|
+ st_amt = "pass"
|
|
|
+ else:
|
|
|
+ st_amt = "idle"
|
|
|
+
|
|
|
+ mt_failed = mt.get("status") == "fail"
|
|
|
+ mt_passed = mt.get("status") == "pass" and mt.get("complete") is True
|
|
|
+ if ch_err == "mt" or (mt_failed and not any_ch_err_stage["mt"] and station_fail_target):
|
|
|
+ st_mt = "fail"
|
|
|
+ elif mt_passed and present and not disabled:
|
|
|
+ st_mt = "pass"
|
|
|
+ else:
|
|
|
+ st_mt = "idle"
|
|
|
+
|
|
|
+ stages = {"detected": bool(present), "training": st_training, "rmt": st_rmt, "amt": st_amt, "mt": st_mt}
|
|
|
+ failed_stage = next((s for s in ("training", "rmt", "amt", "mt") if stages[s] == "fail"), ch_err)
|
|
|
+ ch_state = ("fail" if failed_stage else
|
|
|
+ "pass" if (present and not disabled and any(stages[s] == "pass" for s in ("training", "rmt", "amt", "mt"))) else
|
|
|
+ "idle")
|
|
|
+ channels.append({"cpu": cpu, "channel": str(ch), "name": f"CPU{cpu}_CH{chr(65 + ch)}",
|
|
|
+ "present": bool(present), "stages": stages, "failed_stage": failed_stage,
|
|
|
+ "state": ch_state, "temperature_c": temperatures.get(key)})
|
|
|
+ return channels
|
|
|
+
|
|
|
async def state(self):
|
|
|
stations = []
|
|
|
for sid, rt in self.bench.runtimes.items():
|
|
|
@@ -234,14 +391,6 @@ class QtCleanService:
|
|
|
await self._observe_errors(sid, record)
|
|
|
started = record.get("started_unix_ms", 0)
|
|
|
verdict, completed_mt, verdict_scope = self._outcome(fw, started, rt.cfg["cpu_count"]) if started else ("unknown", False, "")
|
|
|
- # Passive multi-station monitoring must also show proven Training
|
|
|
- # health on a BIOS boot that Qt did not initiate. With an active
|
|
|
- # Qt StartTest, however, never mix another boot into that run.
|
|
|
- training_started = started or (fw.get("boot_started_unix_ms", 0) if not record else 0)
|
|
|
- training_boot_matches = (fw.get("boot_id") == record["boot_id"]
|
|
|
- if record.get("boot_id") else not record and bool(fw.get("boot_id")))
|
|
|
- training = (self._training_outcomes(fw, training_started)
|
|
|
- if training_boot_matches else {})
|
|
|
if record.get("test_failed"):
|
|
|
verdict = "fail"
|
|
|
verdict_scope = record.get("failure_scope", "")
|
|
|
@@ -272,15 +421,8 @@ class QtCleanService:
|
|
|
except (KeyError, TypeError, ValueError, BenchError):
|
|
|
continue
|
|
|
temperatures[key] = max(value, temperatures.get(key, value))
|
|
|
- # Green means this CPU's DDR Training explicitly completed, never
|
|
|
- # that the later AMT/MT memory algorithms passed. A training failure
|
|
|
- # affects that CPU; a located memory error affects its channel.
|
|
|
- channels = [{"cpu": cpu, "channel": str(channel),
|
|
|
- "state": "fail" if (cpu, str(channel)) in record.get("failed_channels", set())
|
|
|
- or training.get(cpu) == "failed" else
|
|
|
- "pass" if training.get(cpu) == "completed" else "unknown",
|
|
|
- "name": f"CPU{cpu}_CH{chr(65 + channel)}", "temperature_c": temperatures.get((cpu, str(channel)))}
|
|
|
- for cpu in range(rt.cfg["cpu_count"]) for channel in range(rt.cfg["channels_per_cpu"])]
|
|
|
+ channels = self._channels(rt, fw, rt.firmware if rt.run else rt.diagnostic.firmware,
|
|
|
+ record, started, temperatures)
|
|
|
connection = rt.snapshot["sol_state"] if rt.run else rt.diagnostic.state["state"]
|
|
|
if connection == "closed":
|
|
|
connection = "offline"
|