Skip to content

Commit b1f6603

Browse files
superm1jwrdegoede
authored andcommitted
platform/x86: amd-pmc: Move to later in the suspend process
The `OS_HINT` message is supposed to indicate that everything else that is supposed to go into the deepest state has done so. This assumption is invalid as: 1) The CPUs will still go in and out of the deepest state 2) Other devices may still run their `noirq` suspend routines 3) The LPS0 ACPI device will still run To more closely mirror how this works on other operating systems, move the `amd-pmc` suspend to the very last thing before the s2idle loop via an lps0 callback. Fixes: 8d89835 ("PM: suspend: Do not pause cpuidle in the suspend-to-idle path") Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://lore.kernel.org/r/20220317141445.6498-2-mario.limonciello@amd.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 20e1d64 commit b1f6603

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

drivers/platform/x86/amd-pmc.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,9 @@ static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg)
639639
return rc;
640640
}
641641

642-
static int __maybe_unused amd_pmc_suspend(struct device *dev)
642+
static void amd_pmc_s2idle_prepare(void)
643643
{
644-
struct amd_pmc_dev *pdev = dev_get_drvdata(dev);
644+
struct amd_pmc_dev *pdev = &pmc;
645645
int rc;
646646
u8 msg;
647647
u32 arg = 1;
@@ -658,7 +658,7 @@ static int __maybe_unused amd_pmc_suspend(struct device *dev)
658658
}
659659

660660
/* Dump the IdleMask before we send hint to SMU */
661-
amd_pmc_idlemask_read(pdev, dev, NULL);
661+
amd_pmc_idlemask_read(pdev, pdev->dev, NULL);
662662
msg = amd_pmc_get_os_hint(pdev);
663663
rc = amd_pmc_send_cmd(pdev, arg, NULL, msg, 0);
664664
if (rc) {
@@ -672,18 +672,16 @@ static int __maybe_unused amd_pmc_suspend(struct device *dev)
672672
dev_err(pdev->dev, "error writing to STB\n");
673673
goto fail;
674674
}
675-
676-
return 0;
675+
return;
677676
fail:
678677
if (pdev->cpu_id == AMD_CPU_ID_CZN)
679678
cpu_latency_qos_update_request(&pdev->amd_pmc_pm_qos_req,
680679
PM_QOS_DEFAULT_VALUE);
681-
return rc;
682680
}
683681

684-
static int __maybe_unused amd_pmc_resume(struct device *dev)
682+
static void amd_pmc_s2idle_restore(void)
685683
{
686-
struct amd_pmc_dev *pdev = dev_get_drvdata(dev);
684+
struct amd_pmc_dev *pdev = &pmc;
687685
int rc;
688686
u8 msg;
689687

@@ -696,7 +694,7 @@ static int __maybe_unused amd_pmc_resume(struct device *dev)
696694
amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_DUMP_DATA, 0);
697695

698696
/* Dump the IdleMask to see the blockers */
699-
amd_pmc_idlemask_read(pdev, dev, NULL);
697+
amd_pmc_idlemask_read(pdev, pdev->dev, NULL);
700698

701699
/* Write data incremented by 1 to distinguish in stb_read */
702700
if (enable_stb)
@@ -711,13 +709,11 @@ static int __maybe_unused amd_pmc_resume(struct device *dev)
711709

712710
/* Notify on failed entry */
713711
amd_pmc_validate_deepest(pdev);
714-
715-
return rc;
716712
}
717713

718-
static const struct dev_pm_ops amd_pmc_pm_ops = {
719-
.suspend_noirq = amd_pmc_suspend,
720-
.resume_noirq = amd_pmc_resume,
714+
static struct acpi_s2idle_dev_ops amd_pmc_s2idle_dev_ops = {
715+
.prepare = amd_pmc_s2idle_prepare,
716+
.restore = amd_pmc_s2idle_restore,
721717
};
722718

723719
static const struct pci_device_id pmc_pci_ids[] = {
@@ -884,6 +880,10 @@ static int amd_pmc_probe(struct platform_device *pdev)
884880

885881
amd_pmc_get_smu_version(dev);
886882
platform_set_drvdata(pdev, dev);
883+
err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops);
884+
if (err)
885+
dev_warn(dev->dev, "failed to register LPS0 sleep handler, expect increased power consumption\n");
886+
887887
amd_pmc_dbgfs_register(dev);
888888
cpu_latency_qos_add_request(&dev->amd_pmc_pm_qos_req, PM_QOS_DEFAULT_VALUE);
889889
return 0;
@@ -897,6 +897,7 @@ static int amd_pmc_remove(struct platform_device *pdev)
897897
{
898898
struct amd_pmc_dev *dev = platform_get_drvdata(pdev);
899899

900+
acpi_unregister_lps0_dev(&amd_pmc_s2idle_dev_ops);
900901
amd_pmc_dbgfs_unregister(dev);
901902
pci_dev_put(dev->rdev);
902903
mutex_destroy(&dev->lock);
@@ -917,7 +918,6 @@ static struct platform_driver amd_pmc_driver = {
917918
.driver = {
918919
.name = "amd_pmc",
919920
.acpi_match_table = amd_pmc_acpi_ids,
920-
.pm = &amd_pmc_pm_ops,
921921
},
922922
.probe = amd_pmc_probe,
923923
.remove = amd_pmc_remove,

0 commit comments

Comments
 (0)