memory: tegra: Wire up system sleep PM ops
Subsystems (2)
PATCH 1/1 memory: tegra: Wire up system sleep PM ops
The tegra-mc platform driver does not register any dev_pm_ops, so the the SoC-specific ->resume() is never invoked (e.g. tegra186_mc_resume) on system wake. On Tegra186 and later this means MC client Stream-ID override registers are not reprogrammed.
Register a dev_pm_ops on the tegra-mc driver and route the system resume callback into mc->soc->ops->resume() so the existing SID restore path runs again on wake.
The MC interrupt mask registers also lose state across SC7, so re-apply them on resume. Factor the existing intmask programming out of tegra_mc_probe() into tegra_mc_setup_intmask() and reuse it from both probe and resume to avoid duplicating the loop.
No suspend callback is needed as the resume path reprograms all MC state from the static SoC tables, so there is nothing to save.
--- drivers/memory/tegra/mc.c | 46 +++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-)
drivers/memory/tegra/mc.c +39 -7
@@ -13,6 +13,7 @@#include <linux/of.h> #include <linux/of_platform.h> #include <linux/platform_device.h> +#include <linux/pm.h> #include <linux/slab.h> #include <linux/sort.h> #include <linux/tegra-icc.h>
@@ -910,6 +911,19 @@ static void tegra_mc_num_channel_enabled(struct tegra_mc *mc) } } +static void tegra_mc_setup_intmask (struct tegra_mc *mc) +{ +unsigned int i; + +for (i =0 ; i < mc->soc->num_intmasks; i++) { +if (mc->soc->num_channels) +mc_ch_writel (mc,MC_BROADCAST_CHANNEL , mc->soc->intmasks[i].mask, + mc->soc->intmasks[i].reg); +else +mc_writel (mc, mc->soc->intmasks[i].mask, mc->soc->intmasks[i].reg); + } +} +static int tegra_mc_probe (struct platform_device *pdev) {struct tegra_mc *mc;
@@ -970,13 +984,7 @@ static int tegra_mc_probe(struct platform_device *pdev) } } -for (i =0 ; i < mc->soc->num_intmasks; i++) { -if (mc->soc->num_channels) -mc_ch_writel (mc,MC_BROADCAST_CHANNEL , mc->soc->intmasks[i].mask, - mc->soc->intmasks[i].reg); -else -mc_writel (mc, mc->soc->intmasks[i].mask, mc->soc->intmasks[i].reg); - } +tegra_mc_setup_intmask (mc); }if (mc->soc->reset_ops) {
@@ -1010,10 +1018,34 @@ static void tegra_mc_sync_state(struct device *dev)icc_sync_state (dev); } +static int tegra_mc_resume (struct device *dev) +{ +struct tegra_mc *mc =dev_get_drvdata (dev); +int err; + +if (mc->soc->ops && mc->soc->ops->resume) { + err = mc->soc->ops->resume (mc); +if (err) +return err; + } + +tegra_mc_setup_intmask (mc); + +return 0 ; +} + +/* +* No suspend callback is needed because the resume path reinitializes all +* necessary MC register state (SID overrides, interrupt masks) from static +* SoC data tables rather than from saved runtime state. +*/ +static DEFINE_SIMPLE_DEV_PM_OPS(tegra_mc_pm_ops, NULL, tegra_mc_resume); +static struct platform_driver tegra_mc_driver = { .driver = { .name ="tegra-mc" , .of_match_table = tegra_mc_of_match, + .pm =pm_sleep_ptr (&tegra_mc_pm_ops), .suppress_bind_attrs = true, .sync_state = tegra_mc_sync_state, },
Signature · 1 line
2.50.1
Jon Hunter
maintainerQuoted 9 lines · Ashish Mhetre
The tegra-mc platform driver does not register any
dev_pm_ops, so the the SoC-specific ->resume() is never invoked (e.g.tegra186_mc_resume) on system wake. On Tegra186 and later this means MC client Stream-ID override registers are not reprogrammed.Register a
dev_pm_opson the tegra-mc driver and route the system resume callback intomc->soc->ops->resume()so the existing SID restore path runs again on wake.
Quoted 7 lines
The MC interrupt mask registers also lose state across SC7, so re-apply them on resume. Factor the existing intmask programming out of
tegra_mc_probe()intotegra_mc_setup_intmask()and reuse it from both probe and resume to avoid duplicating the loop.No suspend callback is needed as the resume path reprograms all MC state from the static SoC tables, so there is nothing to save.
Technically, this appears to be two fixes ...
1. Register the PM ops so that the existing SoC specific resume is called.
2. Reprogram the MC interrupt masks for all SoCs on resume.
So ideally this should be split. The first part appears to be a fix for fe3b082a6eb8 ("memory: tegra: Add SID override programming for MC clients"). Although the 2nd part is a fix too, it is only applicable after 9f2614510960 ("memory: tegra: Prepare for supporting multiple intmask registers") so may be a fixes tag is not appropriate here.
Quoted 77 lines
Signed-off-by Ashish Mhetre <[email protected]>--- drivers/memory/tegra/mc.c | 46 +++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-)drivers/memory/tegra/mc.c +36
-7@@ -13,6 +13,7 @@#include <linux/of.h> #include <linux/of_platform.h> #include <linux/platform_device.h> +#include <linux/pm.h> #include <linux/slab.h> #include <linux/sort.h> #include <linux/tegra-icc.h> @@ -910,6 +911,19 @@ static void tegra_mc_num_channel_enabled(struct tegra_mc *mc) } } +static void tegra_mc_setup_intmask (struct tegra_mc *mc) +{ +unsigned int i; + +for (i =0 ; i < mc->soc->num_intmasks; i++) { +if (mc->soc->num_channels) +mc_ch_writel (mc,MC_BROADCAST_CHANNEL , mc->soc->intmasks[i].mask, + mc->soc->intmasks[i].reg); +else +mc_writel (mc, mc->soc->intmasks[i].mask, mc->soc->intmasks[i].reg); + } +} +static int tegra_mc_probe (struct platform_device *pdev) {struct tegra_mc *mc;@@ -970,13 +984,7 @@ static int tegra_mc_probe(struct platform_device *pdev) } } -for (i =0 ; i < mc->soc->num_intmasks; i++) { -if (mc->soc->num_channels) -mc_ch_writel (mc,MC_BROADCAST_CHANNEL , mc->soc->intmasks[i].mask, - mc->soc->intmasks[i].reg); -else -mc_writel (mc, mc->soc->intmasks[i].mask, mc->soc->intmasks[i].reg); - } +tegra_mc_setup_intmask (mc); }if (mc->soc->reset_ops) {@@ -1010,10 +1018,34 @@ static void tegra_mc_sync_state(struct device *dev)icc_sync_state (dev); } +static int tegra_mc_resume (struct device *dev) +{ +struct tegra_mc *mc =dev_get_drvdata (dev); +int err; + +if (mc->soc->ops && mc->soc->ops->resume) { + err = mc->soc->ops->resume (mc); +if (err) +return err; + } + +tegra_mc_setup_intmask (mc); + +return 0 ; +} + +/* +* No suspend callback is needed because the resume path reinitializes all +* necessary MC register state (SID overrides, interrupt masks) from static +* SoC data tables rather than from saved runtime state. +*/
drivers/memory/tegra/mc.c static void tegra_mc_sync_state(struct device *dev) · line 1051
Quoted 10 lines
drivers/memory/tegra/mc.c +3
-0+static DEFINE_SIMPLE_DEV_PM_OPS(tegra_mc_pm_ops, NULL, tegra_mc_resume); +static struct platform_driver tegra_mc_driver = { .driver = { .name ="tegra-mc" , .of_match_table = tegra_mc_of_match, + .pm =pm_sleep_ptr (&tegra_mc_pm_ops), .suppress_bind_attrs = true, .sync_state = tegra_mc_sync_state, },
Otherwise, the change looks fine.
Jon
Signature · 1 line
nvpublic
Quoted 19 lines · Jon Hunter
Quoted 9 lines · Ashish Mhetre
The tegra-mc platform driver does not register any
dev_pm_ops, so the the SoC-specific ->resume() is never invoked (e.g.tegra186_mc_resume) on system wake. On Tegra186 and later this means MC client Stream-ID override registers are not reprogrammed.Register a
dev_pm_opson the tegra-mc driver and route the system resume callback intomc->soc->ops->resume()so the existing SID restore path runs again on wake.Quoted 7 lines
The MC interrupt mask registers also lose state across SC7, so re-apply them on resume. Factor the existing intmask programming out of
tegra_mc_probe()intotegra_mc_setup_intmask()and reuse it from both probe and resume to avoid duplicating the loop.No suspend callback is needed as the resume path reprograms all MC state from the static SoC tables, so there is nothing to save.
Quoted 9 lines
Technically, this appears to be two fixes ...
1. Register the PM ops so that the existing SoC specific resume is called.
2. Reprogram the MC interrupt masks for all SoCs on resume.So ideally this should be split. The first part appears to be a fix for
fe3b082a6eb8("memory: tegra: Add SID override programming for MC clients"). Although the 2nd part is a fix too, it is only applicable after9f2614510960("memory: tegra: Prepare for supporting multiple intmask registers") so may be a fixes tag is not appropriate here.
Sure Jon, I'll split the patch in two and resend.
Quoted 97 lines
Quoted 85 lines
Signed-off-by Ashish Mhetre <[email protected]>---
drivers/memory/tegra/mc.c| 46 +++++++++++++++++++++++++++++++++------1 file changed, 39 insertions(+), 7 deletions(-)drivers/memory/tegra/mc.c +13
-0@@ -13,6 +13,7 @@ #include <linux/of.h> #include <linux/of_platform.h> #include <linux/platform_device.h> +#include <linux/pm.h> #include <linux/slab.h> #include <linux/sort.h> #include <linux/tegra-icc.h>@@ -910,6 +911,19 @@ static void tegra_mc_num_channel_enabled(struct tegra_mc *mc) } } +static void tegra_mc_setup_intmask(struct tegra_mc *mc) +{ + unsigned int i; + + for (i = 0; i < mc->soc->num_intmasks; i++) { + if (mc->soc->num_channels) + mc_ch_writel(mc, MC_BROADCAST_CHANNEL, mc->soc->intmasks[i].mask, + mc->soc->intmasks[i].reg); + else + mc_writel(mc, mc->soc->intmasks[i].mask, mc->soc->intmasks[i].reg); + } +} +static int
tegra_mc_probe(struct platform_device *pdev){
structtegra_mc*mc;drivers/memory/tegra/mc.c +1
-6@@ -970,13 +984,7 @@ static int tegra_mc_probe(struct platform_device *pdev) } } - for (i = 0; i < mc->soc->num_intmasks; i++) { - if (mc->soc->num_channels) - mc_ch_writel(mc, MC_BROADCAST_CHANNEL, mc->soc->intmasks[i].mask, - mc->soc->intmasks[i].reg); - else - mc_writel(mc, mc->soc->intmasks[i].mask, mc->soc->intmasks[i].reg); - } + tegra_mc_setup_intmask(mc);}
if (mc->soc->reset_ops) {drivers/memory/tegra/mc.c +17
-0@@ -1010,10 +1018,34 @@ static void tegra_mc_sync_state(struct device *dev) icc_sync_state(dev); } +static int tegra_mc_resume(struct device *dev) +{ + struct tegra_mc *mc = dev_get_drvdata(dev); + int err; + + if (mc->soc->ops && mc->soc->ops->resume) { + err = mc->soc->ops->resume(mc); + if (err) + return err; + } + + tegra_mc_setup_intmask(mc); + + return 0; +} + +/* +* No suspend callback is needed because the resume path reinitializes all
+ * necessary MC register state (SID overrides, interrupt masks) from static
+ * SoC data tables rather than from saved runtime state.
+ */
+staticDEFINE_SIMPLE_DEV_PM_OPS(tegra_mc_pm_ops, NULL, tegra_mc_resume);
+Quoted 8 lines
static struct
platform_drivertegra_mc_driver= { .driver = {
.name = "tegra-mc", .of_match_table =tegra_mc_of_match, + .pm =pm_sleep_ptr(&tegra_mc_pm_ops), .suppress_bind_attrs = true, .sync_state =tegra_mc_sync_state, },Otherwise, the change looks fine.
Jon