public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/2] memory: tegra: Restore MC state on system resume
@ 2026-04-30  7:09 Ashish Mhetre
  2026-04-30  7:09 ` [PATCH V2 1/2] memory: tegra: Wire up system sleep PM ops Ashish Mhetre
  2026-04-30  7:09 ` [PATCH V2 2/2] memory: tegra: Restore MC interrupt masks on resume Ashish Mhetre
  0 siblings, 2 replies; 5+ messages in thread
From: Ashish Mhetre @ 2026-04-30  7:09 UTC (permalink / raw)
  To: krzk, thierry.reding, jonathanh
  Cc: ketanp, linux-kernel, linux-tegra, Ashish Mhetre

The tegra-mc platform driver does not register any dev_pm_ops, so 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.

Changes in V2:
- Split the original single patch into two - register the PM ops and
  reprogram the MC interrupt masks on resume.

Ashish Mhetre (2):
  memory: tegra: Wire up system sleep PM ops
  memory: tegra: Restore MC interrupt masks on resume

 drivers/memory/tegra/mc.c | 41 ++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 1/2] memory: tegra: Wire up system sleep PM ops
  2026-04-30  7:09 [PATCH V2 0/2] memory: tegra: Restore MC state on system resume Ashish Mhetre
@ 2026-04-30  7:09 ` Ashish Mhetre
  2026-04-30  8:39   ` Jon Hunter
  2026-04-30  7:09 ` [PATCH V2 2/2] memory: tegra: Restore MC interrupt masks on resume Ashish Mhetre
  1 sibling, 1 reply; 5+ messages in thread
From: Ashish Mhetre @ 2026-04-30  7:09 UTC (permalink / raw)
  To: krzk, thierry.reding, jonathanh
  Cc: ketanp, linux-kernel, linux-tegra, 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_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.

No suspend callback is needed as the resume path reprograms all MC
state from the static SoC tables, so there is nothing to save.

Fixes: fe3b082a6eb8 ("memory: tegra: Add SID override programming for MC clients")
Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
 drivers/memory/tegra/mc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
index d620660da331..343ac0018eba 100644
--- a/drivers/memory/tegra/mc.c
+++ b/drivers/memory/tegra/mc.c
@@ -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>
@@ -1010,10 +1011,23 @@ 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);
+
+	if (mc->soc->ops && mc->soc->ops->resume)
+		return mc->soc->ops->resume(mc);
+
+	return 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,
 	},
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH V2 2/2] memory: tegra: Restore MC interrupt masks on resume
  2026-04-30  7:09 [PATCH V2 0/2] memory: tegra: Restore MC state on system resume Ashish Mhetre
  2026-04-30  7:09 ` [PATCH V2 1/2] memory: tegra: Wire up system sleep PM ops Ashish Mhetre
@ 2026-04-30  7:09 ` Ashish Mhetre
  1 sibling, 0 replies; 5+ messages in thread
From: Ashish Mhetre @ 2026-04-30  7:09 UTC (permalink / raw)
  To: krzk, thierry.reding, jonathanh
  Cc: ketanp, linux-kernel, linux-tegra, Ashish Mhetre

The MC interrupt mask registers lose their state across SC7. Without
re-applying them on resume, MC interrupts that were enabled at probe
remain masked after wake, so any post-resume MC error goes unreported.

Factor the existing intmask programming out of tegra_mc_probe() into
tegra_mc_setup_intmask() and reuse it from the system resume callback
so the mask state is restored on wake.

Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
 drivers/memory/tegra/mc.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
index 343ac0018eba..ea7b489d666b 100644
--- a/drivers/memory/tegra/mc.c
+++ b/drivers/memory/tegra/mc.c
@@ -911,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;
@@ -971,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) {
@@ -1014,9 +1021,15 @@ static void tegra_mc_sync_state(struct device *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;
+	}
 
-	if (mc->soc->ops && mc->soc->ops->resume)
-		return mc->soc->ops->resume(mc);
+	tegra_mc_setup_intmask(mc);
 
 	return 0;
 }
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V2 1/2] memory: tegra: Wire up system sleep PM ops
  2026-04-30  7:09 ` [PATCH V2 1/2] memory: tegra: Wire up system sleep PM ops Ashish Mhetre
@ 2026-04-30  8:39   ` Jon Hunter
  2026-04-30  9:39     ` Ashish Mhetre
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Hunter @ 2026-04-30  8:39 UTC (permalink / raw)
  To: Ashish Mhetre, krzk, thierry.reding; +Cc: ketanp, linux-kernel, linux-tegra



On 30/04/2026 08:09, Ashish Mhetre wrote:
> 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.
> 
> No suspend callback is needed as the resume path reprograms all MC
> state from the static SoC tables, so there is nothing to save.
> 
> Fixes: fe3b082a6eb8 ("memory: tegra: Add SID override programming for MC clients")
> Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
> ---
>   drivers/memory/tegra/mc.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
> index d620660da331..343ac0018eba 100644
> --- a/drivers/memory/tegra/mc.c
> +++ b/drivers/memory/tegra/mc.c
> @@ -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>
> @@ -1010,10 +1011,23 @@ 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);
> +
> +	if (mc->soc->ops && mc->soc->ops->resume)
> +		return mc->soc->ops->resume(mc);

I noticed that the tegra186_mc_resume never fails and always returns 0. 
Given that this is the only resume handler, it seem that we should 
change this to a void return type and then we can avoid the extra return 
here. This also simplifies the next patch. So may be we should add one 
more patch to change the return type for this resume callback.

If we ever need to return a error code in the future we can add back, 
but if we don't need it now, then I don't see why we should keep this.

Jon

-- 
nvpublic


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2 1/2] memory: tegra: Wire up system sleep PM ops
  2026-04-30  8:39   ` Jon Hunter
@ 2026-04-30  9:39     ` Ashish Mhetre
  0 siblings, 0 replies; 5+ messages in thread
From: Ashish Mhetre @ 2026-04-30  9:39 UTC (permalink / raw)
  To: Jon Hunter, krzk, thierry.reding; +Cc: ketanp, linux-kernel, linux-tegra



On 4/30/2026 2:09 PM, Jon Hunter wrote:
>
>
> On 30/04/2026 08:09, Ashish Mhetre wrote:
>> 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.
>>
>> No suspend callback is needed as the resume path reprograms all MC
>> state from the static SoC tables, so there is nothing to save.
>>
>> Fixes: fe3b082a6eb8 ("memory: tegra: Add SID override programming for 
>> MC clients")
>> Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
>> ---
>>   drivers/memory/tegra/mc.c | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
>> index d620660da331..343ac0018eba 100644
>> --- a/drivers/memory/tegra/mc.c
>> +++ b/drivers/memory/tegra/mc.c
>> @@ -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>
>> @@ -1010,10 +1011,23 @@ 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);
>> +
>> +    if (mc->soc->ops && mc->soc->ops->resume)
>> +        return mc->soc->ops->resume(mc);
>
> I noticed that the tegra186_mc_resume never fails and always returns 
> 0. Given that this is the only resume handler, it seem that we should 
> change this to a void return type and then we can avoid the extra 
> return here. This also simplifies the next patch. So may be we should 
> add one more patch to change the return type for this resume callback.
>
> If we ever need to return a error code in the future we can add back, 
> but if we don't need it now, then I don't see why we should keep this.
>
> Jon
>

Okay, I'll update the return-type in new patch and send V3.

Thanks,
Ashish Mhetre

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-30  9:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30  7:09 [PATCH V2 0/2] memory: tegra: Restore MC state on system resume Ashish Mhetre
2026-04-30  7:09 ` [PATCH V2 1/2] memory: tegra: Wire up system sleep PM ops Ashish Mhetre
2026-04-30  8:39   ` Jon Hunter
2026-04-30  9:39     ` Ashish Mhetre
2026-04-30  7:09 ` [PATCH V2 2/2] memory: tegra: Restore MC interrupt masks on resume Ashish Mhetre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox