diff mbox

[2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore

Message ID 1526483821-25585-3-git-send-email-j-keerthy@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

J, KEERTHY May 16, 2018, 3:16 p.m. UTC
Inroduce cpu_pm notifiers for context save/restore. This will be
needed for am43xx family in case of rtc only mode with ddr in
self-refresh.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/mach-omap2/clockdomain.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Tony Lindgren May 17, 2018, 9:43 p.m. UTC | #1
* Keerthy <j-keerthy@ti.com> [180516 15:21]:
> Inroduce cpu_pm notifiers for context save/restore. This will be
> needed for am43xx family in case of rtc only mode with ddr in
> self-refresh.
...
> +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
> +{
> +	switch (cmd) {
> +	case CPU_CLUSTER_PM_ENTER:
> +		if (enable_off_mode)
> +			clkdm_save_context();
> +		break;
> +	case CPU_CLUSTER_PM_EXIT:
> +		if (enable_off_mode)
> +			clkdm_restore_context();
> +		break;
> +	}
> +
> +	return NOTIFY_OK;
> +}

Can you do this too only on suspend instead of the cpu notifier?
If you need to call this eventually from cpuidle also then yeah
the notifier makes sense.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
J, KEERTHY May 18, 2018, 5:57 a.m. UTC | #2
On Friday 18 May 2018 03:13 AM, Tony Lindgren wrote:
> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>> Inroduce cpu_pm notifiers for context save/restore. This will be
>> needed for am43xx family in case of rtc only mode with ddr in
>> self-refresh.
> ...
>> +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
>> +{
>> +	switch (cmd) {
>> +	case CPU_CLUSTER_PM_ENTER:
>> +		if (enable_off_mode)
>> +			clkdm_save_context();
>> +		break;
>> +	case CPU_CLUSTER_PM_EXIT:
>> +		if (enable_off_mode)
>> +			clkdm_restore_context();
>> +		break;
>> +	}
>> +
>> +	return NOTIFY_OK;
>> +}
> 
> Can you do this too only on suspend instead of the cpu notifier?
> If you need to call this eventually from cpuidle also then yeah
> the notifier makes sense.

Clockdomain under omap2 does not have suspend/resume calls as its still
not a driver. The initial version of this patch had save/restore calls
directly from pm33xx-core during suspend/resume platform ops are called.

Are you suggesting that?

> 
> Regards,
> 
> Tony
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tero Kristo May 18, 2018, 8:38 a.m. UTC | #3
On 18/05/18 08:57, Keerthy wrote:
> 
> 
> On Friday 18 May 2018 03:13 AM, Tony Lindgren wrote:
>> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>>> Inroduce cpu_pm notifiers for context save/restore. This will be
>>> needed for am43xx family in case of rtc only mode with ddr in
>>> self-refresh.
>> ...
>>> +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
>>> +{
>>> +	switch (cmd) {
>>> +	case CPU_CLUSTER_PM_ENTER:
>>> +		if (enable_off_mode)
>>> +			clkdm_save_context();
>>> +		break;
>>> +	case CPU_CLUSTER_PM_EXIT:
>>> +		if (enable_off_mode)
>>> +			clkdm_restore_context();
>>> +		break;
>>> +	}
>>> +
>>> +	return NOTIFY_OK;
>>> +}
>>
>> Can you do this too only on suspend instead of the cpu notifier?
>> If you need to call this eventually from cpuidle also then yeah
>> the notifier makes sense.
> 
> Clockdomain under omap2 does not have suspend/resume calls as its still
> not a driver. The initial version of this patch had save/restore calls
> directly from pm33xx-core during suspend/resume platform ops are called.
> 
> Are you suggesting that?

I think using cpu notifiers would help in eventual transition of this 
under drivers also, as this doesn't need any custom interfaces to be 
exported around. And, as it seems now, this is only needed for AM43xx at 
the moment, no other SoCs need this for any purpose, even if device off 
would be implemented. Only exception would be if we want to implement 
RTC+DDR sort of functionality on any other SoC.

-Tero
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren May 18, 2018, 1:54 p.m. UTC | #4
* Tero Kristo <t-kristo@ti.com> [180518 08:41]:
> On 18/05/18 08:57, Keerthy wrote:
> > 
> > 
> > On Friday 18 May 2018 03:13 AM, Tony Lindgren wrote:
> > > * Keerthy <j-keerthy@ti.com> [180516 15:21]:
> > > > Inroduce cpu_pm notifiers for context save/restore. This will be
> > > > needed for am43xx family in case of rtc only mode with ddr in
> > > > self-refresh.
> > > ...
> > > > +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
> > > > +{
> > > > +	switch (cmd) {
> > > > +	case CPU_CLUSTER_PM_ENTER:
> > > > +		if (enable_off_mode)
> > > > +			clkdm_save_context();
> > > > +		break;
> > > > +	case CPU_CLUSTER_PM_EXIT:
> > > > +		if (enable_off_mode)
> > > > +			clkdm_restore_context();
> > > > +		break;
> > > > +	}
> > > > +
> > > > +	return NOTIFY_OK;
> > > > +}
> > > 
> > > Can you do this too only on suspend instead of the cpu notifier?
> > > If you need to call this eventually from cpuidle also then yeah
> > > the notifier makes sense.
> > 
> > Clockdomain under omap2 does not have suspend/resume calls as its still
> > not a driver. The initial version of this patch had save/restore calls
> > directly from pm33xx-core during suspend/resume platform ops are called.
> > 
> > Are you suggesting that?
> 
> I think using cpu notifiers would help in eventual transition of this under
> drivers also, as this doesn't need any custom interfaces to be exported
> around. And, as it seems now, this is only needed for AM43xx at the moment,
> no other SoCs need this for any purpose, even if device off would be
> implemented. Only exception would be if we want to implement RTC+DDR sort of
> functionality on any other SoC.

OK thanks makes sense. Applying all these into omap-for-v4.18/soc.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index 0906380..6d44fe0 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -23,6 +23,7 @@ 
 #include <linux/limits.h>
 #include <linux/err.h>
 #include <linux/clk-provider.h>
+#include <linux/cpu_pm.h>
 
 #include <linux/io.h>
 
@@ -31,6 +32,7 @@ 
 #include "soc.h"
 #include "clock.h"
 #include "clockdomain.h"
+#include "pm.h"
 
 /* clkdm_list contains all registered struct clockdomains */
 static LIST_HEAD(clkdm_list);
@@ -39,6 +41,8 @@ 
 static struct clkdm_autodep *autodeps;
 
 static struct clkdm_ops *arch_clkdm;
+void clkdm_save_context(void);
+void clkdm_restore_context(void);
 
 /* Private functions */
 
@@ -449,6 +453,22 @@  int clkdm_register_autodeps(struct clkdm_autodep *ia)
 	return 0;
 }
 
+static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
+{
+	switch (cmd) {
+	case CPU_CLUSTER_PM_ENTER:
+		if (enable_off_mode)
+			clkdm_save_context();
+		break;
+	case CPU_CLUSTER_PM_EXIT:
+		if (enable_off_mode)
+			clkdm_restore_context();
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
 /**
  * clkdm_complete_init - set up the clockdomain layer
  *
@@ -460,6 +480,7 @@  int clkdm_register_autodeps(struct clkdm_autodep *ia)
 int clkdm_complete_init(void)
 {
 	struct clockdomain *clkdm;
+	static struct notifier_block nb;
 
 	if (list_empty(&clkdm_list))
 		return -EACCES;
@@ -474,6 +495,12 @@  int clkdm_complete_init(void)
 		clkdm_clear_all_sleepdeps(clkdm);
 	}
 
+	/* Only AM43XX can lose clkdm context during rtc-ddr suspend */
+	if (soc_is_am43xx()) {
+		nb.notifier_call = cpu_notifier;
+		cpu_pm_register_notifier(&nb);
+	}
+
 	return 0;
 }