Skip to content

Commit ba5f9fa

Browse files
Dong AishengJassiBrar
authored andcommitted
mailbox: imx: Add context save/restore for suspend/resume
For "mem" mode suspend on i.MX8 SoCs, MU settings could be lost because its power is off, so save/restore is needed for MU settings during suspend/resume. However, the restore can ONLY be done when MU settings are actually lost, for the scenario of settings NOT lost in "freeze" mode suspend, since there could be still IPC going on multiple CPUs, restoring the MU settings could overwrite the TIE by mistake and cause system freeze, so need to make sure ONLY restore the MU settings when it is powered off, Anson fixes this by checking whether restore is actually needed when resume. Signed-off-by: Dong Aisheng <[email protected]> Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent d61b799 commit ba5f9fa

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/mailbox/imx-mailbox.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ struct imx_mu_priv {
6767
struct clk *clk;
6868
int irq;
6969

70+
u32 xcr;
71+
7072
bool side_b;
7173
};
7274

@@ -589,12 +591,45 @@ static const struct of_device_id imx_mu_dt_ids[] = {
589591
};
590592
MODULE_DEVICE_TABLE(of, imx_mu_dt_ids);
591593

594+
static int imx_mu_suspend_noirq(struct device *dev)
595+
{
596+
struct imx_mu_priv *priv = dev_get_drvdata(dev);
597+
598+
priv->xcr = imx_mu_read(priv, priv->dcfg->xCR);
599+
600+
return 0;
601+
}
602+
603+
static int imx_mu_resume_noirq(struct device *dev)
604+
{
605+
struct imx_mu_priv *priv = dev_get_drvdata(dev);
606+
607+
/*
608+
* ONLY restore MU when context lost, the TIE could
609+
* be set during noirq resume as there is MU data
610+
* communication going on, and restore the saved
611+
* value will overwrite the TIE and cause MU data
612+
* send failed, may lead to system freeze. This issue
613+
* is observed by testing freeze mode suspend.
614+
*/
615+
if (!imx_mu_read(priv, priv->dcfg->xCR))
616+
imx_mu_write(priv, priv->xcr, priv->dcfg->xCR);
617+
618+
return 0;
619+
}
620+
621+
static const struct dev_pm_ops imx_mu_pm_ops = {
622+
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx_mu_suspend_noirq,
623+
imx_mu_resume_noirq)
624+
};
625+
592626
static struct platform_driver imx_mu_driver = {
593627
.probe = imx_mu_probe,
594628
.remove = imx_mu_remove,
595629
.driver = {
596630
.name = "imx_mu",
597631
.of_match_table = imx_mu_dt_ids,
632+
.pm = &imx_mu_pm_ops,
598633
},
599634
};
600635
module_platform_driver(imx_mu_driver);

0 commit comments

Comments
 (0)