From 856fd5aec438df34062508523db844aae9b54121 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sun, 29 Nov 2026 13:10:42 -0500 Subject: [PATCH 1/4] dt-bindings: power: apple: describe a PMP the boot loader hands over A board DT can leave a PMP's apple,board-id and apple,dram-vendor-id to the boot loader, which fills them in from the running machine. Without them the PMP never starts, and the PMC and the PMP report should not wait for it. Add apple,pmp-voter to the PMC, the voter agent of the PMP it names in apple,pmp, so that the PMC can leave that agent out of its static voters when the PMP was not handed over. Let a PMP report name such a PMP in apple,pmp. Signed-off-by: Erik Bourget --- .../devicetree/bindings/power/apple,pmc.yaml | 13 +++++++++++++ .../bindings/power/apple,t8140-pmp-report.yaml | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/power/apple,pmc.yaml b/Documentation/devicetree/bindings/power/apple,pmc.yaml index 9f2d9f1b3eafe..2dda852386bbb 100644 --- a/Documentation/devicetree/bindings/power/apple,pmc.yaml +++ b/Documentation/devicetree/bindings/power/apple,pmc.yaml @@ -74,6 +74,15 @@ properties: $ref: /schemas/types.yaml#/definitions/phandle description: PMP firmware owner that initializes the voter interface. + apple,pmp-voter: + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 31 + description: + Voter agent of the PMP named by apple,pmp, for a PMP whose board values + (apple,board-id and apple,dram-vendor-id) the boot loader fills in. + When it has not filled them in, the PMP never starts, so the PMC does + not wait for it and leaves this agent out of apple,static-voters. + apple,static-voters: $ref: /schemas/types.yaml#/definitions/uint32-array description: Voter agents to enable on every rail. @@ -344,6 +353,10 @@ patternProperties: - compatible - reg +dependentRequired: + apple,pmp-voter: + - apple,pmp + required: - compatible - reg diff --git a/Documentation/devicetree/bindings/power/apple,t8140-pmp-report.yaml b/Documentation/devicetree/bindings/power/apple,t8140-pmp-report.yaml index 8957dab59d3c7..9e0847cb04b0a 100644 --- a/Documentation/devicetree/bindings/power/apple,t8140-pmp-report.yaml +++ b/Documentation/devicetree/bindings/power/apple,t8140-pmp-report.yaml @@ -111,7 +111,9 @@ properties: $ref: /schemas/types.yaml#/definitions/phandle description: The PMP that publishes this report, on SoCs where the host starts the - PMP after a display handoff. + PMP after a display handoff, or where the boot loader fills in the + PMP's board values (apple,board-id and apple,dram-vendor-id). The + report does not wait for an enabled PMP without those values. apple,pmp-tables: $ref: /schemas/types.yaml#/definitions/phandle From 176c3e381376c83c4e503f9be5b65ce4ced4bafe Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sun, 29 Nov 2026 13:10:59 -0500 Subject: [PATCH 2/4] pmdomain: apple: pmc: run without a PMP the boot loader did not hand over A board DT can leave the PMP's apple,board-id and apple,dram-vendor-id to the boot loader, which fills them in from the running machine. Under a boot loader that does not, the PMP driver fails its probe for good, and a PMC that names that PMP in apple,pmp defers forever: its CLPC child, and cpufreq with it, never probes. When the PMC also gives the PMP's voter agent (apple,pmp-voter), wait for the PMP only when it is available and has both values. When it does not, say so once, skip the device link and leave that agent out of the static voters, so the PMC and CLPC run as on a board without a PMP. A PMC without apple,pmp-voter waits for its PMP as before. Signed-off-by: Erik Bourget --- drivers/pmdomain/apple/pmc.c | 23 +++++++++++++++++++++++ drivers/pmdomain/apple/pmp-handoff.h | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 drivers/pmdomain/apple/pmp-handoff.h diff --git a/drivers/pmdomain/apple/pmc.c b/drivers/pmdomain/apple/pmc.c index 7949216808a76..bf53b05f53c28 100644 --- a/drivers/pmdomain/apple/pmc.c +++ b/drivers/pmdomain/apple/pmc.c @@ -58,6 +58,8 @@ #include #include +#include "pmp-handoff.h" + #if IS_ENABLED(CONFIG_APPLE_PMC_KUNIT_TEST) #include #endif @@ -1330,8 +1332,23 @@ static int apple_pmc_probe(struct platform_device *pdev) struct device_node *pmp_node; struct platform_device *pmp; struct device_link *link; + bool pmp_voter_off = false; + u32 pmp_voter; pmp_node = of_parse_phandle(np, "apple,pmp", 0); + if (pmp_node && !of_property_read_u32(np, "apple,pmp-voter", &pmp_voter) && + !(of_device_is_available(pmp_node) && apple_pmp_has_board_values(pmp_node))) { + /* + * The boot loader did not hand this PMP over, so it never + * starts. Run without its votes rather than wait for it, so + * that the CLPC below still comes up. + */ + dev_info(dev, "%pOF was not handed over; running without its votes\n", + pmp_node); + of_node_put(pmp_node); + pmp_node = NULL; + pmp_voter_off = true; + } if (pmp_node) { pmp = of_find_device_by_node(pmp_node); of_node_put(pmp_node); @@ -1402,6 +1419,12 @@ static int apple_pmc_probe(struct platform_device *pdev) pmc->static_agents |= BIT(agents[i]); } } + if (pmp_voter_off) { + if (pmp_voter >= pmc->hw->agents) + return dev_err_probe(dev, -EINVAL, "invalid PMP voter %u\n", + pmp_voter); + pmc->static_agents &= ~BIT(pmp_voter); + } platform_set_drvdata(pdev, pmc); ret = devm_add_action_or_reset(dev, apple_pmc_release, pmc); diff --git a/drivers/pmdomain/apple/pmp-handoff.h b/drivers/pmdomain/apple/pmp-handoff.h new file mode 100644 index 0000000000000..3580bed0a07ab --- /dev/null +++ b/drivers/pmdomain/apple/pmp-handoff.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _APPLE_PMP_HANDOFF_H +#define _APPLE_PMP_HANDOFF_H + +#include +#include + +/* + * Whether @pmp has the running machine's apple,board-id and + * apple,dram-vendor-id. The PMP driver refuses to start the PMP without + * them, and a DT that leaves them to the boot loader only has them when the + * loader filled them in. + */ +static inline bool apple_pmp_has_board_values(const struct device_node *pmp) +{ + u32 val; + + return !of_property_read_u32(pmp, "apple,board-id", &val) && + !of_property_read_u32(pmp, "apple,dram-vendor-id", &val); +} + +#endif /* _APPLE_PMP_HANDOFF_H */ From 292954d133cedd6ce11c3956c06fe73429c46b46 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sun, 29 Nov 2026 13:11:41 -0500 Subject: [PATCH 3/4] pmdomain: apple: pmp-report: do not wait for a PMP that was not handed over A PMP report whose PMP is not running yet keeps the devices' requests to itself and polls until the PMP runs, every 100 ms at first and then once a second. A PMP whose board values (apple,board-id and apple,dram-vendor-id) the boot loader did not fill in never starts, so that poll never ends. When the report names an enabled PMP in apple,pmp and that PMP lacks the values, say so once and do not start the poll. The report still binds and keeps its requests, as it does while it waits. Reports that name no PMP, or a disabled one, wait as before. Signed-off-by: Erik Bourget --- drivers/pmdomain/apple/pmp-report.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/pmdomain/apple/pmp-report.c b/drivers/pmdomain/apple/pmp-report.c index 290ba7caa4231..e3fdbdbf0070d 100644 --- a/drivers/pmdomain/apple/pmp-report.c +++ b/drivers/pmdomain/apple/pmp-report.c @@ -46,6 +46,7 @@ #include "pmp-dram.h" #include "pmp-ane.h" #include "pmp-floor-gov.h" +#include "pmp-handoff.h" #define PMP_REPORT_READY 0x1 @@ -2474,6 +2475,23 @@ static int apple_pmp_report_resume(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(apple_pmp_report_pm_ops, apple_pmp_report_suspend, apple_pmp_report_resume); +/* + * Whether to wait for the PMP to run. A report that names an enabled PMP in + * apple,pmp whose board values the boot loader did not fill in keeps its + * requests to itself: that PMP never starts. Any other report waits for it. + */ +static bool apple_pmp_report_pmp_handed_over(struct apple_pmp_report *rep) +{ + struct device_node *pmp = of_parse_phandle(rep->dev->of_node, "apple,pmp", 0); + bool wait = !pmp || !of_device_is_available(pmp) || + apple_pmp_has_board_values(pmp); + + if (!wait) + dev_info(rep->dev, "%pOF was not handed over; not waiting for it\n", pmp); + of_node_put(pmp); + return wait; +} + static int apple_pmp_report_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -2565,7 +2583,7 @@ static int apple_pmp_report_probe(struct platform_device *pdev) if (ret) return dev_err_probe(dev, ret, "failed to create child devices\n"); - if (rep->defer) + if (rep->defer && apple_pmp_report_pmp_handed_over(rep)) queue_delayed_work(system_freezable_power_efficient_wq, &rep->ready_work, 0); From a377282e9c3133d516e064aedf4d884f73c6edb6 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Mon, 30 Nov 2026 17:16:49 -0500 Subject: [PATCH 4/4] tools: asahi: exercise the PMP handoff in the T6030 graph fixture The report probe now checks whether the loader supplied both PMP board properties. Extract that predicate and its board-value helper into the host fixture before the probe. Exercise missing and disabled PMP nodes, each missing property and a complete handoff. Keep historical source checks working when the probe predates this helper. Signed-off-by: DjDeveloperr --- tools/asahi/t6030-pmp-graph-tests.c | 36 ++++++++++++++++++++++++++++ tools/asahi/t6030-pmp-graph-tests.py | 16 +++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/tools/asahi/t6030-pmp-graph-tests.c b/tools/asahi/t6030-pmp-graph-tests.c index 8fa0c4124efbc..3f1f0561831f8 100644 --- a/tools/asahi/t6030-pmp-graph-tests.c +++ b/tools/asahi/t6030-pmp-graph-tests.c @@ -53,6 +53,7 @@ static void host_log(const char *format, ...) struct device_node { const char *name, *compatible; bool available, always_on, no_ack, deferred, irq_safe, uuid, soc_record, release_sleep; + bool has_board_id, has_dram_vendor_id; u32 reg; int refs; struct device_node *parent, *child, *sibling, *pmp; @@ -501,6 +502,14 @@ static bool of_property_present(const struct device_node *n, const char *p) static int of_property_read_u32(const struct device_node *n, const char *p, u32 *v) { + if (!strcmp(p, "apple,board-id") || !strcmp(p, "apple,dram-vendor-id")) { + bool present = !strcmp(p, "apple,board-id") ? n->has_board_id : n->has_dram_vendor_id; + + if (!present) + return -EINVAL; + *v = 0; + return 0; + } assert(!strcmp(p, "reg")); *v = n->reg; return 0; @@ -911,8 +920,35 @@ static int g15_vote(void) commands++; return ret; } +#if HOST_HAS_PMP_HANDOFF +static void test_pmp_handoff(void) +{ + struct device_node pmp = {}; + struct device_node report = {}; + struct device dev = { .of_node = &report }; + struct apple_pmp_report rep = { .dev = &dev }; + + assert(apple_pmp_report_pmp_handed_over(&rep)); + report.pmp = &pmp; + assert(apple_pmp_report_pmp_handed_over(&rep)); + pmp.available = true; + assert(!apple_pmp_report_pmp_handed_over(&rep)); + pmp.has_board_id = true; + assert(!apple_pmp_report_pmp_handed_over(&rep)); + pmp.has_board_id = false; + pmp.has_dram_vendor_id = true; + assert(!apple_pmp_report_pmp_handed_over(&rep)); + pmp.has_board_id = true; + assert(apple_pmp_report_pmp_handed_over(&rep)); + assert(pmp.refs == 0); +} +#endif + int main(void) { +#if HOST_HAS_PMP_HANDOFF + test_pmp_handoff(); +#endif unsigned int cases = 0; (void)apple_pmp_start_init; (void)apple_pmp_report_wait_t6030_14; diff --git a/tools/asahi/t6030-pmp-graph-tests.py b/tools/asahi/t6030-pmp-graph-tests.py index d7f2b8abe17c4..2f7b5e1467dea 100644 --- a/tools/asahi/t6030-pmp-graph-tests.py +++ b/tools/asahi/t6030-pmp-graph-tests.py @@ -27,7 +27,12 @@ def main(): p.add_argument('--mutations', action='store_true') p.add_argument('--output', required=True, type=Path) args = p.parse_args(); args.output.mkdir(parents=True, exist_ok=False) - source = subprocess.check_output(['git', '-C', str(ROOT), 'show', args.ref + ':' + extract.REPORT], text=True) if args.ref else (ROOT / extract.REPORT).read_text() + def read_source(path): + if args.ref: + return subprocess.check_output(['git', '-C', str(ROOT), 'show', args.ref + ':' + path], text=True) + return (ROOT / path).read_text() + + source = read_source(extract.REPORT) overlay = (ROOT / 'drivers/soc/apple/t6030-pmp.dtso').read_text() entries = [] for node in re.findall(r'report@[0-9a-f]+\s*\{(.*?)\n\s*\};', overlay, re.S): @@ -59,7 +64,14 @@ def main(): 'static int apple_pmp_report_entry_suspend_noirq(', 'static int apple_pmp_report_entry_resume_noirq('] offsets = re.search(r'static const struct apple_pmp_report_offsets apple_pmp_offsets_t6030 = \{.*?\n\};', source, re.S)[0] - functions = '\n'.join(extract.function(source, n) for n in names) + handoff = '' + handoff_fn = 'static bool apple_pmp_report_pmp_handed_over(' + if handoff_fn in source: + names.insert(names.index('static int apple_pmp_report_probe('), handoff_fn) + header = read_source('drivers/pmdomain/apple/pmp-handoff.h') + handoff = ('#define HOST_HAS_PMP_HANDOFF 1\n' + + extract.function(header, 'static inline bool apple_pmp_has_board_values(')) + functions = handoff + '\n'.join(extract.function(source, n) for n in names) # The T8122 14.x wait (CONFIG_APPLE_T8122_GPU_PMP_LINK=0 here) precedes the dispatch; it is # added after the mutations are placed, so they target the T6030 path only. t8122 = extract.function(source, 'static int apple_pmp_report_wait_t8122_14(') + '\n'