diff --git a/drivers/mfd/macsmc.c b/drivers/mfd/macsmc.c index 1a4f9c2da8cfc..acd46a48e2c8a 100644 --- a/drivers/mfd/macsmc.c +++ b/drivers/mfd/macsmc.c @@ -646,9 +646,11 @@ static int apple_smc_probe(struct platform_device *pdev) mutex_init(&smc->mutex); spin_lock_init(&smc->lock); smc->dev = &pdev->dev; - smc->saved_enabled = of_machine_is_compatible("apple,j714s") && + smc->saved_enabled = of_machine_is_compatible("apple,t6050") && + (of_machine_is_compatible("apple,j714s") || + of_machine_is_compatible("apple,j716c")) && of_device_is_compatible(dev->of_node, "apple,t6050-smc"); - if (smc->saved_enabled) + if (smc->saved_enabled && of_machine_is_compatible("apple,j714s")) smc->wake_reasons = apple_smc_j714s_wake_reasons; smc->sram_base = devm_platform_get_and_ioremap_resource(pdev, 1, &smc->sram); if (IS_ERR(smc->sram_base)) @@ -1537,6 +1539,21 @@ static int apple_smc_suspend_noirq(struct device *dev) static int apple_smc_resume_noirq(struct device *dev) { struct apple_smc *smc = dev_get_drvdata(dev); + unsigned int i; + + /* + * A wake by something the SMC reports (a port's plug or unplug) brings a notification + * right behind it, and its handler's ordinary command can be in flight here: posted, its + * reply waiting in the mailbox with the interrupt still off. That is no unresolved saved + * command. Take the reply in by polling before judging the lane; refusing here left the + * SMC without its AP ON notice and ANS waiting for its topology ("timed out waiting for + * topology from SMC", ANS crashed 10 s into the wake). + */ + if (smc->saved_enabled && !smc->saved_recovery && !smc->saved_fault) + for (i = 0; i < 20000 && smp_load_acquire(&smc->saved_pending); i++) { + apple_rtkit_poll(smc->rtk); + udelay(10); + } if (smc->saved_enabled && (smc->saved_recovery || smc->saved_pending || smc->saved_fault))