From 4eded98ed9b4e191e5c94e2424349d48d86f26c6 Mon Sep 17 00:00:00 2001 From: Fredrik Silfver <1684291+freber@users.noreply.github.com> Date: Sun, 15 Nov 2026 11:51:44 +0100 Subject: [PATCH] pmdomain: apple: admit the J615 legacy tree to the J613 PACC0 floor The 15-inch M3 MacBook Air (J615) has the J613's SoC, DRAM, PMP tables and PACC0 request layout. Both boards take their PMP, PMP report, PMGR, GPU and CPU nodes from t8122.dtsi and t8122-j613-j615.dtsi. Without the floor its memory reads 19.8 GB/s, close to the 21 GB/s the J613 measured. The board check alone would never admit a J615 as it boots today. The device tree that m1n1 embeds is a legacy handoff tree. Its report binds the generic "apple,t8122-pmp-v2-report", whose driver starts the halted 14.x PMP (firmware 3B18C886-4C70-349B-B1C4-70F35DE2C5CD) and names it with apple,pmp. That PMP is still disabled when the report probes. apple_pmp_start_init() takes it over right after j613_floor_probe() and enables it once the display asks for it. The J613 path needs the native report's match data, a PMP that names the report (apple,pmp-report), an available PMP and the 26.6.2 firmware. On machines compatible with "apple,j615" the floor becomes eligible only on that generic T8122 report, behind the same pmp_report.j613_floor veto. It is also off by default. A J615 owner opts in with pmp_report.j615_floor=1 until the floor is qualified on that board the way the J613 was (disable and re-enable, boot veto, suspend, policy teardown, sustained power). It takes the PMP that the report names with apple,pmp. It may take that PMP while it is still disabled, because this report's driver starts it (offsets->starts_pmp). It accepts only the 14.x firmware UUID. A refused identity warns and leaves the floor off. The report keeps probing then, because on a legacy tree it starts the PMP that the display and GPU depend on. The experimental t8122-j615-25g83 tree is deliberately not covered. It binds the native J613 report, whose match data turns the floor on by default. The floor has not run on that path. A J615 is never admitted on the native report or with the J613 firmware UUID. Nothing is written early. The floor's start work already waits for the report to read READY and then for j613_floor_start_delay_ms. The J613 path is unchanged. Its gate, PMP link, availability check, UUID and fatal identity refusal behave as before. Every J615 branch needs the J615 board check. The parameter, sysfs group and messages keep their j613 names. Tested on a J615 with the 14.x PMP firmware, running this change on a 7.2.11 kernel that carries the J613 floor and T8122 PPT patches, where the J615 floor was still on by default. The floor was admitted 11 s into boot. The PMP confirmed each raise to DCS4 SOC2 and each release in about 31 ms. membw2 with 4 threads read 68.2 GB/s with the floor against 19.8 GB/s without it. CPU 0 stayed at 69.2 ms with pms_c1ppt powered (302.7 ms on the stock kernel). No GPU errors were logged. The host test gains truth tables for J615 admission and firmware identity, the DVFS-STATE words read back on the J615 and static checks for the J615 branches. Six new mutants are registered in run-host-tests.py. They make J613 accept the 14.x firmware, J615 accept any firmware or the J613 firmware, J615 pass on the native report, the parameter fail to veto J615 and J615 run without its opt-in. A static check keeps pmp_report.j615_floor off by default. Assisted-by: LLM Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TqFXgsntBCgau1RkXP1KRQ Signed-off-by: Fredrik Silfver <1684291+freber@users.noreply.github.com> --- drivers/pmdomain/apple/pmp-j613-floor-gov.h | 29 +++++++++ drivers/pmdomain/apple/pmp-report.c | 70 ++++++++++++++++++--- tools/asahi/pmp-j613-floor-tests.py | 61 ++++++++++++++++++ tools/asahi/run-host-tests.py | 4 +- 4 files changed, 154 insertions(+), 10 deletions(-) diff --git a/drivers/pmdomain/apple/pmp-j613-floor-gov.h b/drivers/pmdomain/apple/pmp-j613-floor-gov.h index 71f211c099025..abcc19bf10ba4 100644 --- a/drivers/pmdomain/apple/pmp-j613-floor-gov.h +++ b/drivers/pmdomain/apple/pmp-j613-floor-gov.h @@ -223,6 +223,35 @@ static inline bool pmp_floor_drop_confirmed(unsigned long long resp, unsigned lo */ /* Firmware identity qualified by the J613 hypervisor and Linux trials. */ #define PMP_FLOOR_J613_UUID "EFD60284-7C58-33A9-8522-CB3366AF6040" +/* + * J615 (15-inch M3 MacBook Air, same SoC, DRAM and PMP tables): the 14.x PMP + * image that Linux starts from a legacy handoff tree. On owner hardware a + * PACC0 DCS 4/SOC 2 store read back from DVFS-STATE as 0x24 within 5.1 ms, + * and the valid floor 0 as 0x0. + */ +#define PMP_FLOOR_J615_UUID "3B18C886-4C70-349B-B1C4-70F35DE2C5CD" + +/* + * J615 is admitted only on the path tested on owner hardware, the generic + * T8122 report of a legacy handoff tree whose driver starts the 14.x PMP. + * The native J613 report of the experimental J615 25G83 tree is not covered. + * The parameter may veto the J615 like the J613. A J615 also needs its own + * opt-in until the floor is qualified on that board. + */ +static inline bool pmp_floor_j615_enabled(bool j615, bool native_default, + bool legacy_report, bool allowed, + bool opted_in) +{ + return j615 && !native_default && legacy_report && allowed && opted_in; +} + +/* J613 runs only on its qualified firmware, J615 only on its 14.x image. */ +static inline bool pmp_floor_uuid_ok(const char *uuid, bool j615) +{ + if (j615) + return !strcmp(uuid, PMP_FLOOR_J615_UUID); + return !strcmp(uuid, PMP_FLOOR_J613_UUID); +} #define PMP_FLOOR_REC_SIZE 0x7c /* soc-device record */ #define PMP_FLOOR_REC_NAME 0x74 /* its 8-byte, NUL-padded name */ #define PMP_FLOOR_RANGE_SIZE 32 /* ptd-range record: id, base, count, name at 16 */ diff --git a/drivers/pmdomain/apple/pmp-report.c b/drivers/pmdomain/apple/pmp-report.c index 7ce01a88bb069..635f6518af8ec 100644 --- a/drivers/pmdomain/apple/pmp-report.c +++ b/drivers/pmdomain/apple/pmp-report.c @@ -1510,6 +1510,14 @@ EXPORT_SYMBOL_GPL(apple_pmp_report_wait_ready); static bool j613_floor = true; module_param(j613_floor, bool, 0444); MODULE_PARM_DESC(j613_floor, "J613: own the CPU memory-floor request and run its governor (default: on for the native J613 report; 0 disables)"); +/* + * J615 legacy handoff trees: off until the floor is qualified on that board + * (disable and re-enable, boot veto, suspend, policy teardown, sustained + * power). j613_floor=0 still vetoes it. + */ +static bool j615_floor; +module_param(j615_floor, bool, 0444); +MODULE_PARM_DESC(j615_floor, "J615: run the memory floor on a legacy handoff tree (default: off; j613_floor=0 still vetoes it)"); static unsigned int j613_floor_dcs = 4; module_param(j613_floor_dcs, uint, 0444); /* Fabric 2: 4-thread CPU copy 67 -> 92 GB/s, GPU copy 62 -> 76 GB/s over fabric 0. */ @@ -2143,29 +2151,68 @@ static void j613_floor_put_pmp(void *pmp) of_node_put(pmp); } +/* + * J615: the J613's SoC, DRAM, PMP tables and PACC0 layout. It is admitted + * only on the generic T8122 report of a legacy handoff tree, whose driver + * starts the 14.x PMP and names it with apple,pmp. The native J613 report of + * the experimental J615 25G83 tree is not covered. A refused J615 identity + * leaves the floor off and the report probing. + */ +static bool j615_floor_eligible(const struct apple_pmp_report *rep) +{ + return pmp_floor_j615_enabled(of_machine_is_compatible("apple,j615"), + rep->offsets->j613_floor_default, + of_device_is_compatible(rep->dev->of_node, + "apple,t8122-pmp-v2-report"), + j613_floor, j615_floor); +} + +/* The PMP names this report; a J615 legacy report names its PMP instead. */ +static bool j613_floor_linked(struct device_node *pmp, struct device_node *report, + bool j615) +{ + struct device_node *link; + bool linked; + + if (j615) { + link = of_parse_phandle(report, "apple,pmp", 0); + linked = link == pmp; + } else { + link = of_parse_phandle(pmp, "apple,pmp-report", 0); + linked = link == report; + } + of_node_put(link); + return linked; +} + static int j613_floor_probe(struct apple_pmp_report *rep) { struct device *dev = rep->dev; struct j613_floor *f; - struct device_node *pmp, *link; + struct device_node *pmp; const char *uuid; unsigned long flags; + bool j615 = j615_floor_eligible(rep); int ret; if (!pmp_floor_enabled(of_machine_is_compatible("apple,j613"), - rep->offsets->j613_floor_default, j613_floor)) + rep->offsets->j613_floor_default, j613_floor) && !j615) return 0; f = devm_kzalloc(dev, sizeof(*f), GFP_KERNEL); if (!f) return -ENOMEM; - /* Native PMP startup remains owned by its existing supplier driver. */ + /* + * Native PMP startup remains owned by its existing supplier driver; on a + * J615 legacy tree this report's driver starts the PMP. That PMP is still + * disabled here: apple_pmp_start_init() takes it over after this probe and + * enables it once the display asks, and the floor's start work waits for + * the report to read READY before it writes anything. + */ for_each_compatible_node(pmp, NULL, "apple,t8122-pmp-v2") { - link = of_parse_phandle(pmp, "apple,pmp-report", 0); - if (link != dev->of_node || !of_device_is_available(pmp)) { - of_node_put(link); + if (!j613_floor_linked(pmp, dev->of_node, j615)) + continue; + if (!of_device_is_available(pmp) && !(j615 && rep->offsets->starts_pmp)) continue; - } - of_node_put(link); if (f->pmp) { of_node_put(pmp); return -EINVAL; @@ -2178,8 +2225,13 @@ static int j613_floor_probe(struct apple_pmp_report *rep) } } if (!f->pmp || of_property_read_string(f->pmp, "apple,tunable-uuid", &uuid) || - strcmp(uuid, PMP_FLOOR_J613_UUID)) + !pmp_floor_uuid_ok(uuid, j615)) { + if (j615) { + dev_warn(dev, "J615 floor PMP identity refused; floor off\n"); + return 0; + } return dev_err_probe(dev, -EINVAL, "J613 floor PMP identity refused\n"); + } f->cpu_idle = devm_kcalloc(dev, nr_cpu_ids, sizeof(u64), GFP_KERNEL); f->cpu_wall = devm_kcalloc(dev, nr_cpu_ids, sizeof(u64), GFP_KERNEL); f->cluster_sum = devm_kcalloc(dev, nr_cpu_ids, sizeof(unsigned int), GFP_KERNEL); diff --git a/tools/asahi/pmp-j613-floor-tests.py b/tools/asahi/pmp-j613-floor-tests.py index fe319a1ea37e2..9ce1de8eea541 100755 --- a/tools/asahi/pmp-j613-floor-tests.py +++ b/tools/asahi/pmp-j613-floor-tests.py @@ -38,6 +38,23 @@ 'no-sum': ('(c->cpu_sum_pct && cluster_sum_pct >= c->cpu_sum_pct)', '(cluster_sum_pct && 0)'), # Skip the CPU-client name check. 'no-names': ('return "CPU clients EACC0/PACC0 not named once";', '(void)0;'), + # J613 would accept the J615 14.x firmware. + 'j613-takes-j615-uuid': ('return !strcmp(uuid, PMP_FLOOR_J613_UUID);', + 'return !strcmp(uuid, PMP_FLOOR_J613_UUID) || !strcmp(uuid, PMP_FLOOR_J615_UUID);'), + # J615 would accept any firmware. + 'j615-any-uuid': ('return !strcmp(uuid, PMP_FLOOR_J615_UUID);', 'return (void)uuid, true;'), + # J615 would accept the J613 firmware. + 'j615-takes-j613-uuid': ('return !strcmp(uuid, PMP_FLOOR_J615_UUID);', + 'return !strcmp(uuid, PMP_FLOOR_J615_UUID) || !strcmp(uuid, PMP_FLOOR_J613_UUID);'), + # J615 would be admitted on the native J613 report (the untested 25G83 tree). + 'j615-native': ('return j615 && !native_default && legacy_report && allowed && opted_in;', + 'return j615 && (native_default || legacy_report) && allowed && opted_in;'), + # The parameter would not veto the J615. + 'j615-no-disable': ('return j615 && !native_default && legacy_report && allowed && opted_in;', + 'return (void)allowed, j615 && !native_default && legacy_report && opted_in;'), + # The J615 would run the floor without its opt-in. + 'j615-no-optin': ('return j615 && !native_default && legacy_report && allowed && opted_in;', + 'return (void)opted_in, j615 && !native_default && legacy_report && allowed;'), } HARNESS = r''' @@ -79,6 +96,21 @@ CHECK(pmp_floor_raise_confirmed(0x3204, 4, 0) && !pmp_floor_raise_confirmed(0x3200, 4, 0)); CHECK(!pmp_floor_raise_confirmed(0x3204, 4, 1) && pmp_floor_raise_confirmed(0x3224, 4, 2)); CHECK(pmp_floor_drop_confirmed(0x3200, 0x3204) && !pmp_floor_drop_confirmed(0x3204, 0x3204)); + /* J615 only on the generic report of a legacy tree, never the native one. */ + for (unsigned int j615 = 0; j615 <= 1; j615++) + for (unsigned int native = 0; native <= 1; native++) + for (unsigned int legacy = 0; legacy <= 1; legacy++) + for (unsigned int allowed = 0; allowed <= 1; allowed++) + for (unsigned int opt = 0; opt <= 1; opt++) + CHECK(pmp_floor_j615_enabled(j615, native, legacy, allowed, opt) == + (bool)(j615 && !native && legacy && allowed && opt)); + /* J613 runs only on its qualified firmware, J615 only on its 14.x image. */ + CHECK(pmp_floor_uuid_ok(PMP_FLOOR_J613_UUID, false) && !pmp_floor_uuid_ok(PMP_FLOOR_J613_UUID, true)); + CHECK(!pmp_floor_uuid_ok(PMP_FLOOR_J615_UUID, false) && pmp_floor_uuid_ok(PMP_FLOOR_J615_UUID, true)); + CHECK(!pmp_floor_uuid_ok("3b18c886-4c70-349b-b1c4-70f35de2c5cd", true)); + CHECK(!pmp_floor_uuid_ok("", false) && !pmp_floor_uuid_ok("", true)); + /* Measured on J615 with the 14.x image: 0x24 held (DCS4 SOC2), 0x0 released. */ + CHECK(pmp_floor_raise_confirmed(0x24, 4, 2) && pmp_floor_drop_confirmed(0x0, 0x24)); return 0; } @@ -377,6 +409,35 @@ def static_checks(): assert 'pmp_floor_enabled(of_machine_is_compatible("apple,j613"),' in probe assert 'rep->offsets->j613_floor_default, j613_floor)' in probe assert 'module_param(j613_floor, bool, 0444);' in floor + # J615: its own board check behind the same parameter veto, admitted only + # on the generic T8122 report of a legacy tree and never on the native + # J613 report of the experimental J615 25G83 tree. J613's gate, link and + # fatal identity refusal are unchanged. + assert '&& !j615)' in probe + j615 = ' '.join(block(floor, 'static bool j615_floor_eligible(').split()) + assert ('return pmp_floor_j615_enabled(of_machine_is_compatible("apple,j615"), ' + 'rep->offsets->j613_floor_default, of_device_is_compatible(rep->dev->of_node, ' + '"apple,t8122-pmp-v2-report"), j613_floor, j615_floor);') in j615 + # J615 stays opt-in: its parameter defaults to off. + assert re.search(r'^static bool j615_floor;$', floor, re.M) + assert 'module_param(j615_floor, bool, 0444);' in floor + assert floor.count('of_machine_is_compatible("apple,j615")') == 1 + assert src.count('pmp_floor_j615_enabled(') == 1 + # J613 takes the PMP that names its report, J615 only the PMP its report names. + link = block(floor, 'static bool j613_floor_linked(') + j615_link, j613_link = link[link.index('if (j615) {'):].split('} else {') + assert 'of_parse_phandle(report, "apple,pmp", 0);' in j615_link and 'linked = link == pmp;' in j615_link + assert 'apple,pmp-report' not in j615_link + assert 'of_parse_phandle(pmp, "apple,pmp-report", 0);' in j613_link and 'linked = link == report;' in j613_link + assert 'j613_floor_linked(pmp, dev->of_node, j615)' in probe + # Only a J615 report that starts its own PMP may take it while it is still + # disabled at probe (the legacy tree); every other PMP must be available. + assert 'if (!of_device_is_available(pmp) && !(j615 && rep->offsets->starts_pmp))' in probe + assert probe.count('of_device_is_available(pmp)') == 1 + assert '!pmp_floor_uuid_ok(uuid, j615)) {' in probe + refusal = probe[probe.index('!pmp_floor_uuid_ok(uuid, j615)) {'):] + assert refusal.index('if (j615) {') < refusal.index('return 0;') < \ + refusal.index('return dev_err_probe(dev, -EINVAL, "J613 floor PMP identity refused\\n");') print('pmp-j613-floor: static source checks passed') diff --git a/tools/asahi/run-host-tests.py b/tools/asahi/run-host-tests.py index c55301bd6fa74..dd5d9a6626958 100755 --- a/tools/asahi/run-host-tests.py +++ b/tools/asahi/run-host-tests.py @@ -198,7 +198,9 @@ def mutations(flag, names, base, expect=KILL): 'finish-without-physical', 'poll-after-callback', 'poll-unsupported', 'stale-observation', 'drain-two', 'post-send-wake-refusal'), out()), 'pmp-agx-vote-tests.py': [(out('--output'), PASS), (out('--output') + ['--mutations'], PASS)], - 'pmp-j613-floor-tests.py': [([], PASS)] + mutations('--mutant', ['no-hold', 'no-rate', 'no-streak', 'bad-word', 'foreign-ok', 'no-names', 'no-sum', 'no-board', 'no-default', 'no-disable'], []), + 'pmp-j613-floor-tests.py': [([], PASS)] + mutations('--mutant', ['no-hold', 'no-rate', 'no-streak', 'bad-word', 'foreign-ok', 'no-names', 'no-sum', 'no-board', 'no-default', 'no-disable', + 'j613-takes-j615-uuid', 'j615-any-uuid', 'j615-takes-j613-uuid', 'j615-native', + 'j615-no-disable', 'j615-no-optin'], []), 'pmp-j613-hwmon-tests.py': [([], PASS)], 'pmu-rtc-tests.py': [(out(), PASS)] + mutations('--mutation', ('ack-clobber', 'arm-ack', 'offset-seconds',