From 750daf2748419ba290d367eced117b9373b745e6 Mon Sep 17 00:00:00 2001 From: Markus Schneider-Pargmann Date: Thu, 11 Jul 2024 15:16:00 +0200 Subject: [PATCH] remoteproc: k3-m4: Move suspend to suspend_late The remote core has to be able to query the DM for the next system mode in the suspend path. To support this, ti_sci.c has to send the prepare_sleep command before the suspend message is sent to the remote core. This patch moves the suspend to suspend_late to be executed after ti_sci's suspend call. Signed-off-by: Markus Schneider-Pargmann --- drivers/remoteproc/ti_k3_m4_remoteproc.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 7208d4b3a8b3..3a2dc5a832e9 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -819,7 +819,7 @@ static int m4_pm_notifier_call(struct notifier_block *bl, unsigned long state, v case PM_HIBERNATION_PREPARE: case PM_RESTORE_PREPARE: case PM_SUSPEND_PREPARE: - return k3_m4_suspend(rproc); + break; case PM_POST_HIBERNATION: case PM_POST_RESTORE: @@ -831,6 +831,20 @@ static int m4_pm_notifier_call(struct notifier_block *bl, unsigned long state, v return 0; } +static int k3_m4_suspend_late(struct device *dev) +{ + struct rproc *rproc = dev_get_drvdata(dev); + struct k3_m4_rproc *kproc = rproc->priv; + + /* Check if pm notifier call is set. if it is, suspend/resume is + * supported + */ + if (!kproc->pm_notifier.notifier_call) + return 0; + + return k3_m4_suspend(rproc); +} + static const struct rproc_ops k3_m4_rproc_ops = { .start = k3_m4_rproc_start, .stop = k3_m4_rproc_stop, @@ -952,6 +966,8 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) } } + dev_set_drvdata(dev, rproc); + ret = devm_rproc_add(dev, rproc); if (ret) return dev_err_probe(dev, ret, @@ -977,10 +993,15 @@ static const struct of_device_id k3_m4_of_match[] = { }; MODULE_DEVICE_TABLE(of, k3_m4_of_match); +static const struct dev_pm_ops k3_m4_pm_ops = { + LATE_SYSTEM_SLEEP_PM_OPS(k3_m4_suspend_late, NULL) +}; + static struct platform_driver k3_m4_rproc_driver = { .probe = k3_m4_rproc_probe, .driver = { .name = "k3-m4-rproc", + .pm = &k3_m4_pm_ops, .of_match_table = k3_m4_of_match, }, };