Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
7e8f0dc
drm/apple: audio: keep the DP audio domain while its DCP firmware runs
RyanTheTide Nov 23, 2026
1693055
tools/asahi: test the DP audio domain hold for a sleep
RyanTheTide Nov 23, 2026
d64d981
drm/apple: audio: hold the DP audio domain only while the DCP firmwar…
RyanTheTide Nov 23, 2026
19f90d0
tools/asahi: model the DCP's firmware-runs flag in the retained-sleep…
RyanTheTide Nov 23, 2026
002e507
drm/apple: dcp: say dcp_sleep_keeps_firmware() is for late suspend only
RyanTheTide Nov 23, 2026
3437a5a
drm/apple: dcp: keep the DP PHY of a DCP whose firmware runs through …
RyanTheTide Nov 24, 2026
c672252
tools/asahi: test the DCP sleep PHY hold
RyanTheTide Nov 24, 2026
2267280
drm/apple: dcp: keep a still-attached HDMI link through a sleep
RyanTheTide Nov 24, 2026
245f899
tools/asahi: stub the DP PHY hold in the dcpext26 suspend route test
RyanTheTide Nov 24, 2026
702e0c3
drm/apple: read the sleep PHYs under the fabric lock
RyanTheTide Nov 24, 2026
1274718
arm64: dts: apple: t8112: allow the display PHY domains to wake
RyanTheTide Nov 24, 2026
31ba92a
drm/apple: dcp: release an HDMI display unplugged during a sleep
RyanTheTide Nov 24, 2026
ca69a30
arm64: dts: apple: revert T8112 display PHY wakeup flags
RyanTheTide Nov 24, 2026
8781980
Merge integration/aurora into m2mini/dpaudio-sleep-hold
RyanTheTide Nov 24, 2026
be35165
drm/apple: serialize HDMI resume unplug with route assignment
RyanTheTide Nov 24, 2026
d2e7b95
Merge remote-tracking branch 'aurora/integration/aurora' into HEAD
RyanTheTide Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion drivers/gpu/drm/apple/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,37 @@ static __maybe_unused int dcpaud_system_suspend(struct device *dev)
return 0;
}

/*
* The DCP's firmware drives this block. A DCP that keeps its coprocessor
* running through a sleep keeps its own power domains for it (its suspend
* sets its wakeup path), and this block's domain must stay with them:
* cutting it at noirq under running DCP firmware resets the machine. A DCP
* device without a driver may still run firmware that a boot stage or an
* earlier bind left running, so its block is kept too. Every device's
* .suspend has run before this late phase, so the DCP's choice is known.
*/
static __maybe_unused int dcpaud_suspend_late(struct device *dev)
{
struct device_node *endpoint, *dcp_node = NULL;
struct platform_device *dcp_pdev = NULL;

endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0);
if (endpoint) {
dcp_node = of_graph_get_remote_port_parent(endpoint);
of_node_put(endpoint);
}
if (dcp_node && of_device_is_available(dcp_node))
dcp_pdev = of_find_device_by_node(dcp_node);
of_node_put(dcp_node);
if (dcp_pdev) {
if (!device_is_bound(&dcp_pdev->dev) || device_wakeup_path(&dcp_pdev->dev))
device_set_wakeup_path(dev);
put_device(&dcp_pdev->dev);
}

return pm_runtime_force_suspend(dev);
}

/*
* Runtime PM stops in the late phase and comes back in the early one, so it
* works through every device's .suspend and .resume. The display resumes
Expand All @@ -2083,7 +2114,7 @@ static __maybe_unused int dcpaud_system_suspend(struct device *dev)
static const struct dev_pm_ops dcpaud_pm_ops = {
.prepare = pm_sleep_ptr(dcpaud_pm_prepare),
SYSTEM_SLEEP_PM_OPS(dcpaud_system_suspend, NULL)
LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
LATE_SYSTEM_SLEEP_PM_OPS(dcpaud_suspend_late, pm_runtime_force_resume)
RUNTIME_PM_OPS(dcpaud_suspend, dcpaud_resume, NULL)
};

Expand Down
233 changes: 233 additions & 0 deletions tools/asahi/dcpaud-sleep-hold-tests.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* The actual dcp-dp-audio late sleep callback and dev_pm_ops against an OF
* graph and driver-core model that counts every node and device reference.
*/
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>

/* The harness builds with -Wno-unused-function. */
#define __maybe_unused
#define pm_sleep_ptr(fn) (fn)

/* ACTUAL_PM_MACROS */

struct device_node {
int refs;
bool available;
};

struct device {
struct device_node *of_node;
int refs;
bool bound, wakeup_path, set_wakeup_path;
};

struct platform_device {
struct device dev;
};

struct dev_pm_ops {
int (*prepare)(struct device *dev);
int (*suspend)(struct device *dev);
int (*resume)(struct device *dev);
int (*freeze)(struct device *dev);
int (*thaw)(struct device *dev);
int (*poweroff)(struct device *dev);
int (*restore)(struct device *dev);
int (*suspend_late)(struct device *dev);
int (*resume_early)(struct device *dev);
int (*freeze_late)(struct device *dev);
int (*thaw_early)(struct device *dev);
int (*poweroff_late)(struct device *dev);
int (*restore_early)(struct device *dev);
int (*runtime_suspend)(struct device *dev);
int (*runtime_resume)(struct device *dev);
int (*runtime_idle)(struct device *dev);
};

/* The model: the dpaudio node, its endpoint, the DCP node and device. */
static struct device_node audio_node, endpoint_node, dcp_node;
static struct platform_device dcp_pdev;
static struct device audio_dev = { .of_node = &audio_node };
static bool have_endpoint, have_remote, have_pdev;
static int force_suspend_ret, force_suspend_calls, find_calls;

static void get_node(struct device_node *np)
{
assert(np->refs >= 0);
np->refs++;
}

static void of_node_put(struct device_node *np)
{
if (!np)
return;
assert(np == &endpoint_node || np == &dcp_node);
assert(np->refs > 0);
np->refs--;
}

static struct device_node *of_graph_get_endpoint_by_regs(const struct device_node *parent,
int port, int reg)
{
assert(parent == &audio_node && port == 0 && reg == 0);
if (!have_endpoint)
return NULL;
get_node(&endpoint_node);
return &endpoint_node;
}

static struct device_node *of_graph_get_remote_port_parent(const struct device_node *np)
{
assert(np == &endpoint_node && endpoint_node.refs > 0);
if (!have_remote)
return NULL;
get_node(&dcp_node);
return &dcp_node;
}

static bool of_device_is_available(const struct device_node *np)
{
assert(np == &dcp_node && dcp_node.refs > 0);
return np->available;
}

static struct platform_device *of_find_device_by_node(struct device_node *np)
{
assert(np == &dcp_node && dcp_node.refs > 0);
find_calls++;
if (!have_pdev)
return NULL;
dcp_pdev.dev.refs++;
return &dcp_pdev;
}

static void put_device(struct device *dev)
{
assert(dev == &dcp_pdev.dev && dev->refs > 0);
dev->refs--;
}

static bool device_is_bound(struct device *dev)
{
assert(dev == &dcp_pdev.dev && dev->refs > 0);
return dev->bound;
}

static bool device_wakeup_path(struct device *dev)
{
assert(dev == &dcp_pdev.dev && dev->refs > 0);
return dev->wakeup_path;
}

static void device_set_wakeup_path(struct device *dev)
{
assert(dev == &audio_dev);
dev->set_wakeup_path = true;
}

static int pm_runtime_force_suspend(struct device *dev)
{
assert(dev == &audio_dev);
force_suspend_calls++;
return force_suspend_ret;
}

static int pm_runtime_force_resume(struct device *dev)
{
(void)dev;
return 0;
}

/* The rest of the driver's callbacks only have to be distinct symbols. */
static int dcpaud_pm_prepare(struct device *dev)
{
(void)dev;
return 1;
}

static int dcpaud_system_suspend(struct device *dev)
{
(void)dev;
return 2;
}

static int dcpaud_suspend(struct device *dev)
{
(void)dev;
return 3;
}

static int dcpaud_resume(struct device *dev)
{
(void)dev;
return 4;
}

/* ACTUAL_FUNCTION */

/* ACTUAL_PM_OPS */

int main(void)
{
unsigned int cases = 0, held = 0;

for (unsigned int bits = 0; bits < 128; bits++) {
bool expect;
int ret;

have_endpoint = bits & 1;
have_remote = bits & 2;
dcp_node.available = bits & 4;
have_pdev = bits & 8;
dcp_pdev.dev.bound = bits & 16;
dcp_pdev.dev.wakeup_path = bits & 32;
force_suspend_ret = bits & 64 ? -EBUSY : 0;
endpoint_node.refs = dcp_node.refs = dcp_pdev.dev.refs = 0;
audio_dev.set_wakeup_path = false;
force_suspend_calls = find_calls = 0;

/* The PM core calls the late slot for every system sleep. */
ret = dcpaud_pm_ops.suspend_late(&audio_dev);

expect = have_endpoint && have_remote && dcp_node.available && have_pdev &&
(!dcp_pdev.dev.bound || dcp_pdev.dev.wakeup_path);
if (audio_dev.set_wakeup_path != expect)
fprintf(stderr, "case %#x: wakeup path %d, expected %d\n", bits,
audio_dev.set_wakeup_path, expect);
assert(audio_dev.set_wakeup_path == expect);
/* Every reference taken is dropped, whatever the topology. */
assert(!endpoint_node.refs && !dcp_node.refs && !dcp_pdev.dev.refs);
/* An unavailable or missing DCP node is never looked up. */
if (!(have_endpoint && have_remote && dcp_node.available))
assert(!find_calls);
/* The runtime PM force-suspend always runs and its result is returned. */
assert(force_suspend_calls == 1);
assert(ret == force_suspend_ret);
held += expect;
cases++;
}

/* The wiring: late suspend and its siblings, then the rest unchanged. */
#ifdef HAVE_SUSPEND_LATE
assert(dcpaud_pm_ops.suspend_late == dcpaud_suspend_late);
assert(dcpaud_pm_ops.freeze_late == dcpaud_suspend_late);
assert(dcpaud_pm_ops.poweroff_late == dcpaud_suspend_late);
#endif
assert(dcpaud_pm_ops.resume_early == pm_runtime_force_resume);
assert(dcpaud_pm_ops.thaw_early == pm_runtime_force_resume);
assert(dcpaud_pm_ops.restore_early == pm_runtime_force_resume);
assert(dcpaud_pm_ops.prepare == dcpaud_pm_prepare);
assert(dcpaud_pm_ops.suspend == dcpaud_system_suspend);
assert(!dcpaud_pm_ops.resume);
assert(dcpaud_pm_ops.runtime_suspend == dcpaud_suspend);
assert(dcpaud_pm_ops.runtime_resume == dcpaud_resume);

printf("%u late-suspend cases passed, %u hold the dp-audio domain; pm ops wired\n",
cases, held);
return 0;
}
Loading
Loading