Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Functions generating SPR/GPR-based instructions lack safety checks for legacy_isa, potentially causing GCE hardware lockups on MT6572.
--
commit 4694eedf10a37d189a86ca417a39efa7d5e2b2dd
Author: Roman Vivchar [off-list ref]
mailbox: mtk-cmdq: add mt6572 support
Add legacy_isa field forwarding to the cmdq helper and a platform data
for the mt6572 GCE.
quoted hunk ↗ jump to hunk
diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index e523c84b48088..5e7bc52baaa13 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -787,6 +789,14 @@ static const struct dev_pm_ops cmdq_pm_ops = {
cmdq_runtime_resume, NULL)
};
+static const struct gce_plat gce_plat_mt6572 = {
+ .thread_nr = 14,
+ .shift = 0,
+ .control_by_sw = false,
+ .legacy_isa = true,
+ .gce_num = 1
+};
+
[Severity: High]
Does enabling legacy ISA expose missing safety checks in the cmdq helper?
Looking at drivers/soc/mediatek/mtk-cmdq-helper.c, functions like
cmdq_pkt_write_pa() and cmdq_pkt_poll_addr() appear to generate SPR and
GPR-based instructions without checking for legacy hardware capabilities:
drivers/soc/mediatek/mtk-cmdq-helper.c:cmdq_pkt_write_pa() {
...
err = cmdq_pkt_assign(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_HIGH(pa_base));
...
}
drivers/soc/mediatek/mtk-cmdq-helper.c:cmdq_pkt_poll_addr() {
...
inst.sop = CMDQ_POLL_ADDR_GPR;
...
}
If a client driver on MT6572 calls these functions, would it silently emit
structurally invalid instructions to the command buffer?
Since the legacy ISA on MT6572 does not support SPR or GPR instructions,
could this result in an unrecoverable GCE hardware lockup when flushed?
Would it make sense to check pkt->priv.legacy_isa in these functions and
return -EOPNOTSUPP to prevent hardware lockups?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907-6572-gce-v2-0-412a5b037290@protonmail.com?part=3