Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 11 additions & 9 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static int dcp_secure_port_init(struct apple_dcp *dcp)
* once its secure port has gone idle. A device tree without those keeps the firmware
* running: DPMS is the backlight alone and the display stays up across a sleep. A SoC
* without a secure mailbox says so (hw.s2r_no_secure_port), and one behind
* appledrm.s2r_untested stops its firmware for DPMS off and J813 system sleep.
* appledrm.s2r_untested stops its firmware for DPMS off and system sleep.
*/
static void dcp_s2r_check_dt(struct apple_dcp *dcp)
{
Expand Down Expand Up @@ -476,13 +476,14 @@ static bool dcp_j714s_ext(struct device *dev)

/*
* The firmware stop on a SoC whose display power words were derived from its macOS device
* tree instead of measured (T8142). J813 supports DPMS off and system sleep with this
* opt-in. Off by default: such a DCP keeps its firmware running.
* tree instead of measured (T8142). DPMS off and system sleep use it with this opt-in, on
* a device tree that gives the DCP apple,display-power. Off by default: such a DCP keeps its
* firmware running.
*/
static bool s2r_untested;
module_param(s2r_untested, bool, 0444);
MODULE_PARM_DESC(s2r_untested,
"Stop the DCP firmware on DPMS off and J813 system sleep using derived T8142 power words (default 0)");
"Stop the DCP firmware on DPMS off and system sleep using derived T8142 power words (default 0)");

bool dcp_t6041_ext_enabled(void)
{
Expand Down Expand Up @@ -9397,12 +9398,13 @@ static int dcp_platform_suspend(struct device *dev)
return dcp_v27_sleep_suspend(dcp);

/*
* J813 uses the same qualified stop as DPMS off. Probe already gates
* its derived power layout on appledrm.s2r_untested; without this
* system-suspend path an active panel leaves the DCP running.
* System sleep uses the same qualified stop as DPMS off. dcp_s2r_capable()
* already holds only with the DCP's apple,display-power in the device
* tree and, for derived power words (hw.s2r_untested), with
* appledrm.s2r_untested on firmware 27.0; without this system-suspend
* path an active panel leaves the DCP running.
*/
if (pm_suspend_via_firmware() && dcp_s2r_capable(dcp) &&
(!dcp->hw.s2r_untested || of_machine_is_compatible("apple,j813"))) {
if (pm_suspend_via_firmware() && dcp_s2r_capable(dcp)) {
int ret = dcp_s2r_suspend(dcp);

/* Lit by the last resume with its CRTC off: the next resume finds it off by DPMS. */
Expand Down
11 changes: 7 additions & 4 deletions drivers/mfd/macsmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,11 @@ static int apple_smc_probe(struct platform_device *pdev)
of_device_is_compatible(dev->of_node, "apple,t6050-smc");
if (smc->saved_enabled && of_machine_is_compatible("apple,j714s"))
smc->wake_reasons = apple_smc_j714s_wake_reasons;
/* J813's late notice needs the bounded, IRQ-independent transport too. */
if (of_machine_is_compatible("apple,j813"))
/*
* A sleep controller that sends the final notice after the peer stops (T8142) needs the
* bounded, IRQ-independent transport too.
*/
if (apple_sleep_smc_defer_notice_hw())
smc->saved_enabled = true;
smc->sram_base = devm_platform_get_and_ioremap_resource(pdev, 1, &smc->sram);
if (IS_ERR(smc->sram_base))
Expand Down Expand Up @@ -1229,7 +1232,7 @@ static int apple_smc_sleep_saved_end(void *data)
}

/*
* J813's ordinary wake notice belongs in macsmc's resume_noirq, after the
* A deferred notice's ordinary wake notice belongs in macsmc's resume_noirq, after the
* device dependencies have resumed. Platform wake precedes every noirq
* device callback; an AP ON there can wake the radio before its DMA path.
* Release the bounded transport here, retaining ap_notified for the usual
Expand Down Expand Up @@ -1360,7 +1363,7 @@ static const struct apple_sleep_smc_saved_ops apple_smc_saved_ops = {
};

/*
* J813 retains its existing MBSE/AP sequence and delay floors. The transport
* The deferred notice keeps the existing MBSE/AP sequence and delay floors. The transport
* is the saved lane: no scheduler, jiffies, IRQ worker or SRAM reuse is needed
* after the peer stops. Unrelated notifications are retained until resume.
*/
Expand Down
36 changes: 34 additions & 2 deletions drivers/soc/apple/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,11 @@ struct apple_sleep_soc {
u8 display_order[SLEEP_DISPLAYS_MAX];
const struct apple_sleep_region_profile *regions;
const struct apple_sleep_smc_policy *smc_policy;
/*
* Without an smc_policy: the SMC's final MBSE/AP IDLE notice waits until ANS and the other
* peers have stopped (apple_sleep_smc_defer_notice()), as the native trace orders it.
*/
bool smc_notice_after_peers;
bool early_context;
/* The SoC's operations arm and read its wake sources: none of the common wake words */
bool own_wake;
Expand Down Expand Up @@ -1775,12 +1780,17 @@ EXPORT_SYMBOL_GPL(apple_sleep_smc_policy);
static bool sleep_j813_smc_late = true;
module_param_named(j813_smc_late, sleep_j813_smc_late, bool, 0444);
MODULE_PARM_DESC(j813_smc_late,
"TEST ONLY: J813 final SMC sleep notice after peer stops");
"TEST ONLY: final SMC sleep notice after peer stops (SoCs with smc_notice_after_peers)");

/*
* The SoC's sleep profile says whether the final SMC notice follows the peer stops: on T8142
* ANS fails its IOP IDLE handshake if the SMC is told first. A property of the SoC's sleep
* sequence, so every board with that sleep controller gets it.
*/
bool apple_sleep_smc_defer_notice(void)
{
return apple_sleep && READ_ONCE(sleep_j813_smc_late) &&
of_machine_is_compatible("apple,j813") && pm_suspend_via_firmware();
apple_sleep->soc->smc_notice_after_peers && pm_suspend_via_firmware();
}
EXPORT_SYMBOL_GPL(apple_sleep_smc_defer_notice);

Expand Down Expand Up @@ -9392,6 +9402,8 @@ static const struct apple_sleep_extra_off t8142_extra_off[] = {
static const struct apple_sleep_soc t8142_sleep_soc = {
.ops = &t8142_sleep_ops,
.untested = true,
/* J813 battery lid wake: ANS failed IOP IDLE when the SMC's notice came first. */
.smc_notice_after_peers = true,
.regs_absent = t8142_regs_absent,
.spmi_gen4 = true,
.boot_wfi_delay_ms = 3,
Expand Down Expand Up @@ -9504,6 +9516,26 @@ static const struct of_device_id apple_sleep_of_match[] = {
{ }
};

/*
* Whether this device tree's sleep controller defers the final SMC notice, read from the DT so
* macsmc can pick its bounded transport at probe, before this driver binds.
*/
bool apple_sleep_smc_defer_notice_hw(void)
{
const struct of_device_id *match;
struct device_node *np;
bool ret = false;

for_each_matching_node_and_match(np, apple_sleep_of_match, &match) {
const struct apple_sleep_soc *soc = match->data;

if (of_device_is_available(np) && soc && soc->smc_notice_after_peers)
ret = true;
}
return ret;
}
EXPORT_SYMBOL_GPL(apple_sleep_smc_defer_notice_hw);

static struct platform_driver apple_sleep_driver = {
.driver = {
.name = "apple-sleep",
Expand Down
5 changes: 4 additions & 1 deletion include/linux/soc/apple/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ struct apple_sleep_smc_saved_ops {

#if IS_ENABLED(CONFIG_APPLE_SOC_SLEEP)
const struct apple_sleep_smc_policy *apple_sleep_smc_policy(void);
/* J813 experiment: send the final SMC notice after the peer idle handshakes. */
/* Send the final SMC notice after the peer idle handshakes (the SoC's sleep profile). */
bool apple_sleep_smc_defer_notice(void);
/* The same, from the device tree alone: usable before the sleep controller binds. */
bool apple_sleep_smc_defer_notice_hw(void);
int apple_sleep_smc_register(struct device *dev,
int (*late_notice)(void *data, u64 *sent, u64 *ack), void *data);
int apple_sleep_smc_register_saved(struct device *dev,
Expand Down Expand Up @@ -244,6 +246,7 @@ int apple_sleep_engine_reset(struct device *dev);
#else
static inline const struct apple_sleep_smc_policy *apple_sleep_smc_policy(void) { return NULL; }
static inline bool apple_sleep_smc_defer_notice(void) { return false; }
static inline bool apple_sleep_smc_defer_notice_hw(void) { return false; }
static inline int apple_sleep_smc_register(struct device *dev,
int (*late_notice)(void *data, u64 *sent, u64 *ack), void *data) { return -EOPNOTSUPP; }
static inline int apple_sleep_smc_register_saved(struct device *dev,
Expand Down
Loading