From b85358c02134f1e32b094c173d0021fb3d4633eb Mon Sep 17 00:00:00 2001 From: Dean Galvin Date: Sat, 3 Oct 2026 20:07:13 +1300 Subject: [PATCH] fix(agc): accept WRITE_DATA with ENGINE_SEL = PFP WRITE_DATA's ENGINE_SEL (control bits 31:30) picks the CP engine that performs the write: 0 the micro engine, 1 the prefetch parser, 2 the constant engine. Validate refused every engine bit, so a submission with a PFP WRITE_DATA failed as a whole. The prefetch parser handles packets in queue order ahead of the micro engine, and the driver already performs the write in queue order, so PFP is accepted like ME. The constant engine stays refused. Tests: agc_driver_pm4_tests runs a PFP WRITE_DATA and checks that a CE one is still refused. --- core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp | 2 +- core/libs/prx/libSceAgcDriver/tests/Pm4.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp b/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp index 26207b5c0..2fc1998d9 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp +++ b/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp @@ -380,7 +380,7 @@ void Validate(std::span packet, std::uint32_t queue) { break; case 0x37: { require(packet.size() >= 5, "WRITE_DATA has no data"); - require((packet[1] & ~0x00110f00u) == 0, "WRITE_DATA engine, cache or reserved fields are not implemented"); + require((packet[1] & ~0x40110f00u) == 0, "WRITE_DATA engine, cache or reserved fields are not implemented"); const auto destination = (packet[1] >> 8u) & 0xfu; require(destination == 1 || destination == 2 || (queue != 0 && destination == 5), "WRITE_DATA register or GDS destination is not implemented"); require((packet[2] & 3u) == 0, "misaligned WRITE_DATA destination"); diff --git a/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp b/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp index 8a8ac97ba..8d32b2f5f 100644 --- a/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp @@ -265,6 +265,9 @@ void testMemory() { check(data[0] == 11 && data[1] == 12, "WRITE_DATA increment failed"); execute(state, makePacket(0x37, {0x10100, low(data.data()), high(data.data()), 21, 22})); check(data[0] == 22 && data[1] == 12, "WRITE_DATA fixed destination failed"); + execute(state, makePacket(0x37, {0x40000100, low(data.data()), high(data.data()), 41, 42})); + check(data[0] == 41 && data[1] == 42, "WRITE_DATA from the PFP failed"); + expectFailure([&] { AgcDriver::Pm4::Validate(makePacket(0x37, {0x80000100, low(data.data()), high(data.data()), 51}), 0); }, "engine"); execute(state, makePacket(0x81, {4, 31, 32})); execute(state, makePacket(0x83, {4, 2, low(data.data()), high(data.data())})); check(data[0] == 31 && data[1] == 32, "constant RAM round trip failed");