* [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management @ 2020-08-19 12:59 ` Adam Ford 0 siblings, 0 replies; 14+ messages in thread From: Adam Ford @ 2020-08-19 12:59 UTC (permalink / raw) To: linux-pm Cc: aford, hns, Adam Ford, kernel test robot, Tony Lindgren, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, Daniel Lezcano, Amit Kucheria, linux-omap, linux-arm-kernel, linux-kernel The bandgap sensor can be idled when the processor is too, but it isn't currently being done, so the power consumption of OMAP3 boards can elevated if the bangap sensor is enabled. This patch attempts to use some additional power management to idle the clock to the bandgap when not needed. Signed-off-by: Adam Ford <aford173@gmail.com> Reported-by: kernel test robot <lkp@intel.com> --- V2: Fix issue where variable stating the suspend mode isn't being properly set and cleared. diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index ab19ceff6e2a..9404631bea4d 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c @@ -25,10 +25,18 @@ #include <linux/of_platform.h> #include <linux/of_irq.h> #include <linux/io.h> +#include <linux/cpu_pm.h> +#include <linux/device.h> +#include <linux/pm_runtime.h> +#include <linux/pm.h> +#include <linux/of.h> +#include <linux/of_device.h> #include "ti-bandgap.h" static int ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id); +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, + unsigned long cmd, void *v); /*** Helper functions to access registers and their bitfields ***/ @@ -1008,6 +1016,9 @@ int ti_bandgap_probe(struct platform_device *pdev) } } + bgp->nb.notifier_call = bandgap_omap_cpu_notifier; + cpu_pm_register_notifier(&bgp->nb); + return 0; remove_last_cooling: @@ -1041,7 +1052,9 @@ int ti_bandgap_remove(struct platform_device *pdev) struct ti_bandgap *bgp = platform_get_drvdata(pdev); int i; - /* First thing is to remove sensor interfaces */ + cpu_pm_unregister_notifier(&bgp->nb); + + /* Remove sensor interfaces */ for (i = 0; i < bgp->conf->sensor_count; i++) { if (bgp->conf->sensors[i].unregister_cooling) bgp->conf->sensors[i].unregister_cooling(bgp, i); @@ -1150,9 +1163,43 @@ static int ti_bandgap_suspend(struct device *dev) if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) clk_disable_unprepare(bgp->fclock); + bgp->is_suspended = true; + return err; } +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, + unsigned long cmd, void *v) +{ + struct ti_bandgap *bgp; + + bgp = container_of(nb, struct ti_bandgap, nb); + + spin_lock(&bgp->lock); + switch (cmd) { + case CPU_CLUSTER_PM_ENTER: + if (bgp->is_suspended) + break; + ti_bandgap_save_ctxt(bgp); + ti_bandgap_power(bgp, false); + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) + clk_disable(bgp->fclock); + break; + case CPU_CLUSTER_PM_ENTER_FAILED: + case CPU_CLUSTER_PM_EXIT: + if (bgp->is_suspended) + break; + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) + clk_enable(bgp->fclock); + ti_bandgap_power(bgp, true); + ti_bandgap_restore_ctxt(bgp); + break; + } + spin_unlock(&bgp->lock); + + return NOTIFY_OK; +} + static int ti_bandgap_resume(struct device *dev) { struct ti_bandgap *bgp = dev_get_drvdata(dev); @@ -1161,6 +1208,7 @@ static int ti_bandgap_resume(struct device *dev) clk_prepare_enable(bgp->fclock); ti_bandgap_power(bgp, true); + bgp->is_suspended = false; return ti_bandgap_restore_ctxt(bgp); } diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.h b/drivers/thermal/ti-soc-thermal/ti-bandgap.h index fce4657e9486..ed0ea4b17b25 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.h +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.h @@ -12,6 +12,10 @@ #include <linux/spinlock.h> #include <linux/types.h> #include <linux/err.h> +#include <linux/cpu_pm.h> +#include <linux/device.h> +#include <linux/pm_runtime.h> +#include <linux/pm.h> struct gpio_desc; @@ -203,6 +207,8 @@ struct ti_bandgap { int irq; struct gpio_desc *tshut_gpiod; u32 clk_rate; + struct notifier_block nb; + unsigned int is_suspended:1; }; /** -- 2.25.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management @ 2020-08-19 12:59 ` Adam Ford 0 siblings, 0 replies; 14+ messages in thread From: Adam Ford @ 2020-08-19 12:59 UTC (permalink / raw) To: linux-pm Cc: Amit Kucheria, linux-kernel, kernel test robot, Tony Lindgren, hns, Daniel Lezcano, aford, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, linux-omap, Adam Ford, linux-arm-kernel The bandgap sensor can be idled when the processor is too, but it isn't currently being done, so the power consumption of OMAP3 boards can elevated if the bangap sensor is enabled. This patch attempts to use some additional power management to idle the clock to the bandgap when not needed. Signed-off-by: Adam Ford <aford173@gmail.com> Reported-by: kernel test robot <lkp@intel.com> --- V2: Fix issue where variable stating the suspend mode isn't being properly set and cleared. diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index ab19ceff6e2a..9404631bea4d 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c @@ -25,10 +25,18 @@ #include <linux/of_platform.h> #include <linux/of_irq.h> #include <linux/io.h> +#include <linux/cpu_pm.h> +#include <linux/device.h> +#include <linux/pm_runtime.h> +#include <linux/pm.h> +#include <linux/of.h> +#include <linux/of_device.h> #include "ti-bandgap.h" static int ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id); +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, + unsigned long cmd, void *v); /*** Helper functions to access registers and their bitfields ***/ @@ -1008,6 +1016,9 @@ int ti_bandgap_probe(struct platform_device *pdev) } } + bgp->nb.notifier_call = bandgap_omap_cpu_notifier; + cpu_pm_register_notifier(&bgp->nb); + return 0; remove_last_cooling: @@ -1041,7 +1052,9 @@ int ti_bandgap_remove(struct platform_device *pdev) struct ti_bandgap *bgp = platform_get_drvdata(pdev); int i; - /* First thing is to remove sensor interfaces */ + cpu_pm_unregister_notifier(&bgp->nb); + + /* Remove sensor interfaces */ for (i = 0; i < bgp->conf->sensor_count; i++) { if (bgp->conf->sensors[i].unregister_cooling) bgp->conf->sensors[i].unregister_cooling(bgp, i); @@ -1150,9 +1163,43 @@ static int ti_bandgap_suspend(struct device *dev) if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) clk_disable_unprepare(bgp->fclock); + bgp->is_suspended = true; + return err; } +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, + unsigned long cmd, void *v) +{ + struct ti_bandgap *bgp; + + bgp = container_of(nb, struct ti_bandgap, nb); + + spin_lock(&bgp->lock); + switch (cmd) { + case CPU_CLUSTER_PM_ENTER: + if (bgp->is_suspended) + break; + ti_bandgap_save_ctxt(bgp); + ti_bandgap_power(bgp, false); + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) + clk_disable(bgp->fclock); + break; + case CPU_CLUSTER_PM_ENTER_FAILED: + case CPU_CLUSTER_PM_EXIT: + if (bgp->is_suspended) + break; + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) + clk_enable(bgp->fclock); + ti_bandgap_power(bgp, true); + ti_bandgap_restore_ctxt(bgp); + break; + } + spin_unlock(&bgp->lock); + + return NOTIFY_OK; +} + static int ti_bandgap_resume(struct device *dev) { struct ti_bandgap *bgp = dev_get_drvdata(dev); @@ -1161,6 +1208,7 @@ static int ti_bandgap_resume(struct device *dev) clk_prepare_enable(bgp->fclock); ti_bandgap_power(bgp, true); + bgp->is_suspended = false; return ti_bandgap_restore_ctxt(bgp); } diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.h b/drivers/thermal/ti-soc-thermal/ti-bandgap.h index fce4657e9486..ed0ea4b17b25 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.h +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.h @@ -12,6 +12,10 @@ #include <linux/spinlock.h> #include <linux/types.h> #include <linux/err.h> +#include <linux/cpu_pm.h> +#include <linux/device.h> +#include <linux/pm_runtime.h> +#include <linux/pm.h> struct gpio_desc; @@ -203,6 +207,8 @@ struct ti_bandgap { int irq; struct gpio_desc *tshut_gpiod; u32 clk_rate; + struct notifier_block nb; + unsigned int is_suspended:1; }; /** -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V2 2/2] ARM: omap2plus_defconfig: Enable OMAP3_THERMAL 2020-08-19 12:59 ` Adam Ford @ 2020-08-19 12:59 ` Adam Ford -1 siblings, 0 replies; 14+ messages in thread From: Adam Ford @ 2020-08-19 12:59 UTC (permalink / raw) To: linux-pm Cc: aford, hns, Adam Ford, Tony Lindgren, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, Daniel Lezcano, Amit Kucheria, linux-omap, linux-arm-kernel, linux-kernel With the additional power management options enabled, this patch enables OMAP3_THERMAL by default. Signed-off-by: Adam Ford <aford173@gmail.com> --- V2: No change diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig index fe383f5a92fb..efcc46305a47 100644 --- a/arch/arm/configs/omap2plus_defconfig +++ b/arch/arm/configs/omap2plus_defconfig @@ -303,6 +303,7 @@ CONFIG_THERMAL_GOV_FAIR_SHARE=y CONFIG_THERMAL_GOV_USER_SPACE=y CONFIG_CPU_THERMAL=y CONFIG_TI_THERMAL=y +CONFIG_OMAP3_THERMAL=y CONFIG_OMAP4_THERMAL=y CONFIG_OMAP5_THERMAL=y CONFIG_DRA752_THERMAL=y -- 2.25.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V2 2/2] ARM: omap2plus_defconfig: Enable OMAP3_THERMAL @ 2020-08-19 12:59 ` Adam Ford 0 siblings, 0 replies; 14+ messages in thread From: Adam Ford @ 2020-08-19 12:59 UTC (permalink / raw) To: linux-pm Cc: Amit Kucheria, linux-kernel, Tony Lindgren, hns, Daniel Lezcano, aford, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, linux-omap, Adam Ford, linux-arm-kernel With the additional power management options enabled, this patch enables OMAP3_THERMAL by default. Signed-off-by: Adam Ford <aford173@gmail.com> --- V2: No change diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig index fe383f5a92fb..efcc46305a47 100644 --- a/arch/arm/configs/omap2plus_defconfig +++ b/arch/arm/configs/omap2plus_defconfig @@ -303,6 +303,7 @@ CONFIG_THERMAL_GOV_FAIR_SHARE=y CONFIG_THERMAL_GOV_USER_SPACE=y CONFIG_CPU_THERMAL=y CONFIG_TI_THERMAL=y +CONFIG_OMAP3_THERMAL=y CONFIG_OMAP4_THERMAL=y CONFIG_OMAP5_THERMAL=y CONFIG_DRA752_THERMAL=y -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management 2020-08-19 12:59 ` Adam Ford @ 2020-08-19 19:23 ` Andreas Kemnade -1 siblings, 0 replies; 14+ messages in thread From: Andreas Kemnade @ 2020-08-19 19:23 UTC (permalink / raw) To: Adam Ford Cc: linux-pm, aford, hns, kernel test robot, Tony Lindgren, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, Daniel Lezcano, Amit Kucheria, linux-omap, linux-arm-kernel, linux-kernel On Wed, 19 Aug 2020 07:59:23 -0500 Adam Ford <aford173@gmail.com> wrote: > The bandgap sensor can be idled when the processor is too, but it > isn't currently being done, so the power consumption of OMAP3 > boards can elevated if the bangap sensor is enabled. > > This patch attempts to use some additional power management > to idle the clock to the bandgap when not needed. > > Signed-off-by: Adam Ford <aford173@gmail.com> > Reported-by: kernel test robot <lkp@intel.com> > --- > V2: Fix issue where variable stating the suspend mode isn't being > properly set and cleared. > I get root@(none):/# cat /sys/class/thermal/thermal_zone0/type cpu_thermal root@(none):/# cat /sys/class/thermal/thermal_zone0/temp 50000 root@(none):/# cat /sys/class/thermal/thermal_zone1/ available_policies mode subsystem/ integral_cutoff offset sustainable_power k_d passive temp k_i policy type k_po power/ uevent k_pu slope root@(none):/# cat /sys/class/thermal/thermal_zone1/type bq27000-battery root@(none):/# cat /sys/kernel/debug/pm_debug/count usbhost_pwrdm (ON),OFF:3459,RET:635,INA:0,ON:4095,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 sgx_pwrdm (OFF),OFF:1,RET:0,INA:1,ON:2,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 core_pwrdm (ON),OFF:86,RET:7,INA:0,ON:94,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0,RET-MEMBANK2-OFF:0 per_pwrdm (ON),OFF:1518,RET:64,INA:0,ON:1583,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 dss_pwrdm (ON),OFF:3459,RET:635,INA:0,ON:4095,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 cam_pwrdm (OFF),OFF:1,RET:1,INA:0,ON:2,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 neon_pwrdm (ON),OFF:2845,RET:1131,INA:119,ON:4096,RET-LOGIC-OFF:0 mpu_pwrdm (ON),OFF:2845,RET:1130,INA:119,ON:4095,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 iva2_pwrdm (OFF),OFF:1,RET:1,INA:0,ON:2,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0,RET-MEMBANK2-OFF:0,RET-MEMBANK3-OFF:0,RET-MEMBANK4-OFF:0 usbhost_clkdm->usbhost_pwrdm (1) sgx_clkdm->sgx_pwrdm (0) per_clkdm->per_pwrdm (13) cam_clkdm->cam_pwrdm (0) dss_clkdm->dss_pwrdm (1) d2d_clkdm->core_pwrdm (0) iva2_clkdm->iva2_pwrdm (0) mpu_clkdm->mpu_pwrdm (0) core_l4_clkdm->core_pwrdm (20) core_l3_clkdm->core_pwrdm (1) neon_clkdm->neon_pwrdm (0) root@(none):/# So things still turn off. Tested-by: Andreas Kemnade <andreas@kemnade.info> # GTA04 > diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c > index ab19ceff6e2a..9404631bea4d 100644 > --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c > +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c > @@ -25,10 +25,18 @@ > #include <linux/of_platform.h> > #include <linux/of_irq.h> > #include <linux/io.h> > +#include <linux/cpu_pm.h> > +#include <linux/device.h> > +#include <linux/pm_runtime.h> > +#include <linux/pm.h> > +#include <linux/of.h> > +#include <linux/of_device.h> > > #include "ti-bandgap.h" > > static int ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id); > +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, > + unsigned long cmd, void *v); > > /*** Helper functions to access registers and their bitfields ***/ > > @@ -1008,6 +1016,9 @@ int ti_bandgap_probe(struct platform_device *pdev) > } > } > > + bgp->nb.notifier_call = bandgap_omap_cpu_notifier; > + cpu_pm_register_notifier(&bgp->nb); > + > return 0; > > remove_last_cooling: > @@ -1041,7 +1052,9 @@ int ti_bandgap_remove(struct platform_device *pdev) > struct ti_bandgap *bgp = platform_get_drvdata(pdev); > int i; > > - /* First thing is to remove sensor interfaces */ > + cpu_pm_unregister_notifier(&bgp->nb); > + > + /* Remove sensor interfaces */ > for (i = 0; i < bgp->conf->sensor_count; i++) { > if (bgp->conf->sensors[i].unregister_cooling) > bgp->conf->sensors[i].unregister_cooling(bgp, i); > @@ -1150,9 +1163,43 @@ static int ti_bandgap_suspend(struct device *dev) > if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) > clk_disable_unprepare(bgp->fclock); > > + bgp->is_suspended = true; > + > return err; > } > > +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, > + unsigned long cmd, void *v) > +{ > + struct ti_bandgap *bgp; > + > + bgp = container_of(nb, struct ti_bandgap, nb); > + > + spin_lock(&bgp->lock); > + switch (cmd) { > + case CPU_CLUSTER_PM_ENTER: > + if (bgp->is_suspended) > + break; > + ti_bandgap_save_ctxt(bgp); > + ti_bandgap_power(bgp, false); > + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) > + clk_disable(bgp->fclock); > + break; > + case CPU_CLUSTER_PM_ENTER_FAILED: > + case CPU_CLUSTER_PM_EXIT: > + if (bgp->is_suspended) > + break; > + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) > + clk_enable(bgp->fclock); > + ti_bandgap_power(bgp, true); > + ti_bandgap_restore_ctxt(bgp); > + break; > + } > + spin_unlock(&bgp->lock); > + > + return NOTIFY_OK; > +} > + > static int ti_bandgap_resume(struct device *dev) > { > struct ti_bandgap *bgp = dev_get_drvdata(dev); > @@ -1161,6 +1208,7 @@ static int ti_bandgap_resume(struct device *dev) > clk_prepare_enable(bgp->fclock); > > ti_bandgap_power(bgp, true); > + bgp->is_suspended = false; > > return ti_bandgap_restore_ctxt(bgp); > } > diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.h b/drivers/thermal/ti-soc-thermal/ti-bandgap.h > index fce4657e9486..ed0ea4b17b25 100644 > --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.h > +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.h > @@ -12,6 +12,10 @@ > #include <linux/spinlock.h> > #include <linux/types.h> > #include <linux/err.h> > +#include <linux/cpu_pm.h> > +#include <linux/device.h> > +#include <linux/pm_runtime.h> > +#include <linux/pm.h> > > struct gpio_desc; > > @@ -203,6 +207,8 @@ struct ti_bandgap { > int irq; > struct gpio_desc *tshut_gpiod; > u32 clk_rate; > + struct notifier_block nb; > + unsigned int is_suspended:1; > }; > > /** ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management @ 2020-08-19 19:23 ` Andreas Kemnade 0 siblings, 0 replies; 14+ messages in thread From: Andreas Kemnade @ 2020-08-19 19:23 UTC (permalink / raw) To: Adam Ford Cc: Amit Kucheria, linux-kernel, kernel test robot, linux-pm, Tony Lindgren, hns, Daniel Lezcano, aford, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, linux-omap, linux-arm-kernel On Wed, 19 Aug 2020 07:59:23 -0500 Adam Ford <aford173@gmail.com> wrote: > The bandgap sensor can be idled when the processor is too, but it > isn't currently being done, so the power consumption of OMAP3 > boards can elevated if the bangap sensor is enabled. > > This patch attempts to use some additional power management > to idle the clock to the bandgap when not needed. > > Signed-off-by: Adam Ford <aford173@gmail.com> > Reported-by: kernel test robot <lkp@intel.com> > --- > V2: Fix issue where variable stating the suspend mode isn't being > properly set and cleared. > I get root@(none):/# cat /sys/class/thermal/thermal_zone0/type cpu_thermal root@(none):/# cat /sys/class/thermal/thermal_zone0/temp 50000 root@(none):/# cat /sys/class/thermal/thermal_zone1/ available_policies mode subsystem/ integral_cutoff offset sustainable_power k_d passive temp k_i policy type k_po power/ uevent k_pu slope root@(none):/# cat /sys/class/thermal/thermal_zone1/type bq27000-battery root@(none):/# cat /sys/kernel/debug/pm_debug/count usbhost_pwrdm (ON),OFF:3459,RET:635,INA:0,ON:4095,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 sgx_pwrdm (OFF),OFF:1,RET:0,INA:1,ON:2,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 core_pwrdm (ON),OFF:86,RET:7,INA:0,ON:94,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0,RET-MEMBANK2-OFF:0 per_pwrdm (ON),OFF:1518,RET:64,INA:0,ON:1583,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 dss_pwrdm (ON),OFF:3459,RET:635,INA:0,ON:4095,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 cam_pwrdm (OFF),OFF:1,RET:1,INA:0,ON:2,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 neon_pwrdm (ON),OFF:2845,RET:1131,INA:119,ON:4096,RET-LOGIC-OFF:0 mpu_pwrdm (ON),OFF:2845,RET:1130,INA:119,ON:4095,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0 iva2_pwrdm (OFF),OFF:1,RET:1,INA:0,ON:2,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0,RET-MEMBANK2-OFF:0,RET-MEMBANK3-OFF:0,RET-MEMBANK4-OFF:0 usbhost_clkdm->usbhost_pwrdm (1) sgx_clkdm->sgx_pwrdm (0) per_clkdm->per_pwrdm (13) cam_clkdm->cam_pwrdm (0) dss_clkdm->dss_pwrdm (1) d2d_clkdm->core_pwrdm (0) iva2_clkdm->iva2_pwrdm (0) mpu_clkdm->mpu_pwrdm (0) core_l4_clkdm->core_pwrdm (20) core_l3_clkdm->core_pwrdm (1) neon_clkdm->neon_pwrdm (0) root@(none):/# So things still turn off. Tested-by: Andreas Kemnade <andreas@kemnade.info> # GTA04 > diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c > index ab19ceff6e2a..9404631bea4d 100644 > --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c > +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c > @@ -25,10 +25,18 @@ > #include <linux/of_platform.h> > #include <linux/of_irq.h> > #include <linux/io.h> > +#include <linux/cpu_pm.h> > +#include <linux/device.h> > +#include <linux/pm_runtime.h> > +#include <linux/pm.h> > +#include <linux/of.h> > +#include <linux/of_device.h> > > #include "ti-bandgap.h" > > static int ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id); > +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, > + unsigned long cmd, void *v); > > /*** Helper functions to access registers and their bitfields ***/ > > @@ -1008,6 +1016,9 @@ int ti_bandgap_probe(struct platform_device *pdev) > } > } > > + bgp->nb.notifier_call = bandgap_omap_cpu_notifier; > + cpu_pm_register_notifier(&bgp->nb); > + > return 0; > > remove_last_cooling: > @@ -1041,7 +1052,9 @@ int ti_bandgap_remove(struct platform_device *pdev) > struct ti_bandgap *bgp = platform_get_drvdata(pdev); > int i; > > - /* First thing is to remove sensor interfaces */ > + cpu_pm_unregister_notifier(&bgp->nb); > + > + /* Remove sensor interfaces */ > for (i = 0; i < bgp->conf->sensor_count; i++) { > if (bgp->conf->sensors[i].unregister_cooling) > bgp->conf->sensors[i].unregister_cooling(bgp, i); > @@ -1150,9 +1163,43 @@ static int ti_bandgap_suspend(struct device *dev) > if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) > clk_disable_unprepare(bgp->fclock); > > + bgp->is_suspended = true; > + > return err; > } > > +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, > + unsigned long cmd, void *v) > +{ > + struct ti_bandgap *bgp; > + > + bgp = container_of(nb, struct ti_bandgap, nb); > + > + spin_lock(&bgp->lock); > + switch (cmd) { > + case CPU_CLUSTER_PM_ENTER: > + if (bgp->is_suspended) > + break; > + ti_bandgap_save_ctxt(bgp); > + ti_bandgap_power(bgp, false); > + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) > + clk_disable(bgp->fclock); > + break; > + case CPU_CLUSTER_PM_ENTER_FAILED: > + case CPU_CLUSTER_PM_EXIT: > + if (bgp->is_suspended) > + break; > + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) > + clk_enable(bgp->fclock); > + ti_bandgap_power(bgp, true); > + ti_bandgap_restore_ctxt(bgp); > + break; > + } > + spin_unlock(&bgp->lock); > + > + return NOTIFY_OK; > +} > + > static int ti_bandgap_resume(struct device *dev) > { > struct ti_bandgap *bgp = dev_get_drvdata(dev); > @@ -1161,6 +1208,7 @@ static int ti_bandgap_resume(struct device *dev) > clk_prepare_enable(bgp->fclock); > > ti_bandgap_power(bgp, true); > + bgp->is_suspended = false; > > return ti_bandgap_restore_ctxt(bgp); > } > diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.h b/drivers/thermal/ti-soc-thermal/ti-bandgap.h > index fce4657e9486..ed0ea4b17b25 100644 > --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.h > +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.h > @@ -12,6 +12,10 @@ > #include <linux/spinlock.h> > #include <linux/types.h> > #include <linux/err.h> > +#include <linux/cpu_pm.h> > +#include <linux/device.h> > +#include <linux/pm_runtime.h> > +#include <linux/pm.h> > > struct gpio_desc; > > @@ -203,6 +207,8 @@ struct ti_bandgap { > int irq; > struct gpio_desc *tshut_gpiod; > u32 clk_rate; > + struct notifier_block nb; > + unsigned int is_suspended:1; > }; > > /** _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management 2020-08-19 12:59 ` Adam Ford @ 2020-08-20 0:51 ` kernel test robot -1 siblings, 0 replies; 14+ messages in thread From: kernel test robot @ 2020-08-20 0:51 UTC (permalink / raw) To: Adam Ford, linux-pm Cc: kbuild-all, aford, hns, Adam Ford, kernel test robot, Tony Lindgren, Russell King, Eduardo Valentin, Keerthy, Zhang Rui [-- Attachment #1: Type: text/plain, Size: 1430 bytes --] Hi Adam, Thank you for the patch! Yet something to improve: [auto build test ERROR on omap/for-next] [also build test ERROR on linus/master v5.9-rc1 next-20200819] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Adam-Ford/thermal-ti-soc-thermal-Enable-addition-power-management/20200819-210657 base: https://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git for-next config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>, old ones prefixed by <<): >> ERROR: modpost: "bandgap_omap_cpu_notifier" [drivers/thermal/ti-soc-thermal/ti-soc-thermal.ko] undefined! ERROR: modpost: "__delay" [drivers/net/phy/mdio-cavium.ko] undefined! --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 52700 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management @ 2020-08-20 0:51 ` kernel test robot 0 siblings, 0 replies; 14+ messages in thread From: kernel test robot @ 2020-08-20 0:51 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 1463 bytes --] Hi Adam, Thank you for the patch! Yet something to improve: [auto build test ERROR on omap/for-next] [also build test ERROR on linus/master v5.9-rc1 next-20200819] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Adam-Ford/thermal-ti-soc-thermal-Enable-addition-power-management/20200819-210657 base: https://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git for-next config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>, old ones prefixed by <<): >> ERROR: modpost: "bandgap_omap_cpu_notifier" [drivers/thermal/ti-soc-thermal/ti-soc-thermal.ko] undefined! ERROR: modpost: "__delay" [drivers/net/phy/mdio-cavium.ko] undefined! --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 52700 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management 2020-08-19 12:59 ` Adam Ford @ 2020-09-10 18:01 ` Andreas Kemnade -1 siblings, 0 replies; 14+ messages in thread From: Andreas Kemnade @ 2020-09-10 18:01 UTC (permalink / raw) To: Adam Ford Cc: linux-pm, aford, hns, kernel test robot, Tony Lindgren, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, Daniel Lezcano, Amit Kucheria, linux-omap, linux-arm-kernel, linux-kernel On Wed, 19 Aug 2020 07:59:23 -0500 Adam Ford <aford173@gmail.com> wrote: > The bandgap sensor can be idled when the processor is too, but it > isn't currently being done, so the power consumption of OMAP3 > boards can elevated if the bangap sensor is enabled. > > This patch attempts to use some additional power management > to idle the clock to the bandgap when not needed. > > Signed-off-by: Adam Ford <aford173@gmail.com> > Reported-by: kernel test robot <lkp@intel.com> > --- > V2: Fix issue where variable stating the suspend mode isn't being > properly set and cleared. > hmm, it is not in linux-next. Can we expect that for v5.10? Regards, Andreas ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management @ 2020-09-10 18:01 ` Andreas Kemnade 0 siblings, 0 replies; 14+ messages in thread From: Andreas Kemnade @ 2020-09-10 18:01 UTC (permalink / raw) To: Adam Ford Cc: Amit Kucheria, linux-kernel, kernel test robot, linux-pm, Tony Lindgren, hns, Daniel Lezcano, aford, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, linux-omap, linux-arm-kernel On Wed, 19 Aug 2020 07:59:23 -0500 Adam Ford <aford173@gmail.com> wrote: > The bandgap sensor can be idled when the processor is too, but it > isn't currently being done, so the power consumption of OMAP3 > boards can elevated if the bangap sensor is enabled. > > This patch attempts to use some additional power management > to idle the clock to the bandgap when not needed. > > Signed-off-by: Adam Ford <aford173@gmail.com> > Reported-by: kernel test robot <lkp@intel.com> > --- > V2: Fix issue where variable stating the suspend mode isn't being > properly set and cleared. > hmm, it is not in linux-next. Can we expect that for v5.10? Regards, Andreas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management 2020-09-10 18:01 ` Andreas Kemnade @ 2020-09-10 19:14 ` Daniel Lezcano -1 siblings, 0 replies; 14+ messages in thread From: Daniel Lezcano @ 2020-09-10 19:14 UTC (permalink / raw) To: Andreas Kemnade, Adam Ford Cc: linux-pm, aford, hns, kernel test robot, Tony Lindgren, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, Amit Kucheria, linux-omap, linux-arm-kernel, linux-kernel On 10/09/2020 20:01, Andreas Kemnade wrote: > On Wed, 19 Aug 2020 07:59:23 -0500 > Adam Ford <aford173@gmail.com> wrote: > >> The bandgap sensor can be idled when the processor is too, but it >> isn't currently being done, so the power consumption of OMAP3 >> boards can elevated if the bangap sensor is enabled. >> >> This patch attempts to use some additional power management >> to idle the clock to the bandgap when not needed. >> >> Signed-off-by: Adam Ford <aford173@gmail.com> >> Reported-by: kernel test robot <lkp@intel.com> >> --- >> V2: Fix issue where variable stating the suspend mode isn't being >> properly set and cleared. >> > hmm, it is not in linux-next. Can we expect that for v5.10? The reason I did not pick this patch is because lkp reported an error on it. https://marc.info/?l=linux-pm&m=159788472017308&w=2 -- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management @ 2020-09-10 19:14 ` Daniel Lezcano 0 siblings, 0 replies; 14+ messages in thread From: Daniel Lezcano @ 2020-09-10 19:14 UTC (permalink / raw) To: Andreas Kemnade, Adam Ford Cc: linux-kernel, kernel test robot, linux-pm, Tony Lindgren, hns, Amit Kucheria, aford, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, linux-omap, linux-arm-kernel On 10/09/2020 20:01, Andreas Kemnade wrote: > On Wed, 19 Aug 2020 07:59:23 -0500 > Adam Ford <aford173@gmail.com> wrote: > >> The bandgap sensor can be idled when the processor is too, but it >> isn't currently being done, so the power consumption of OMAP3 >> boards can elevated if the bangap sensor is enabled. >> >> This patch attempts to use some additional power management >> to idle the clock to the bandgap when not needed. >> >> Signed-off-by: Adam Ford <aford173@gmail.com> >> Reported-by: kernel test robot <lkp@intel.com> >> --- >> V2: Fix issue where variable stating the suspend mode isn't being >> properly set and cleared. >> > hmm, it is not in linux-next. Can we expect that for v5.10? The reason I did not pick this patch is because lkp reported an error on it. https://marc.info/?l=linux-pm&m=159788472017308&w=2 -- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <CAHCN7xLUrh7xr0pr5Bz0unWQXGkiKDK88hZKx7WXGyr2RBWTVg@mail.gmail.com>]
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management [not found] ` <CAHCN7xLUrh7xr0pr5Bz0unWQXGkiKDK88hZKx7WXGyr2RBWTVg@mail.gmail.com> @ 2020-09-10 19:48 ` Andreas Kemnade 0 siblings, 0 replies; 14+ messages in thread From: Andreas Kemnade @ 2020-09-10 19:48 UTC (permalink / raw) To: Adam Ford Cc: Daniel Lezcano, linux-pm, Adam Ford-BE, H. Nikolaus Schaller, kernel test robot, Tony Lindgren, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, Amit Kucheria, Linux-OMAP, arm-soc, Linux Kernel Mailing List On Thu, 10 Sep 2020 14:33:13 -0500 Adam Ford <aford173@gmail.com> wrote: > On Thu, Sep 10, 2020 at 2:14 PM Daniel Lezcano <daniel.lezcano@linaro.org> > wrote: > > > On 10/09/2020 20:01, Andreas Kemnade wrote: > > > On Wed, 19 Aug 2020 07:59:23 -0500 > > > Adam Ford <aford173@gmail.com> wrote: > > > > > >> The bandgap sensor can be idled when the processor is too, but it > > >> isn't currently being done, so the power consumption of OMAP3 > > >> boards can elevated if the bangap sensor is enabled. > > >> > > >> This patch attempts to use some additional power management > > >> to idle the clock to the bandgap when not needed. > > >> > > >> Signed-off-by: Adam Ford <aford173@gmail.com> > > >> Reported-by: kernel test robot <lkp@intel.com> > > >> --- > > >> V2: Fix issue where variable stating the suspend mode isn't being > > >> properly set and cleared. > > >> > > > hmm, it is not in linux-next. Can we expect that for v5.10? > > > > The reason I did not pick this patch is because lkp reported an error on > > it. > > > > https://marc.info/?l=linux-pm&m=159788472017308&w=2 > > > > > > > That error message shows it's trying to be built with 'sh' cross compiler, > but should be build with an ARM. > > I can run a manual test of the patch against a different branch if > necessary, but I had built and tested it, so I know it worked at one time. > hmm, what about compile-testing without CONFIG_PM_SLEEP? The function definition is guarded by that. So it is not a sh-specific problem. Regards, Andreas ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management @ 2020-09-10 19:48 ` Andreas Kemnade 0 siblings, 0 replies; 14+ messages in thread From: Andreas Kemnade @ 2020-09-10 19:48 UTC (permalink / raw) To: Adam Ford Cc: Amit Kucheria, Linux Kernel Mailing List, kernel test robot, linux-pm, Tony Lindgren, H. Nikolaus Schaller, Daniel Lezcano, Adam Ford-BE, Russell King, Eduardo Valentin, Keerthy, Zhang Rui, Linux-OMAP, arm-soc On Thu, 10 Sep 2020 14:33:13 -0500 Adam Ford <aford173@gmail.com> wrote: > On Thu, Sep 10, 2020 at 2:14 PM Daniel Lezcano <daniel.lezcano@linaro.org> > wrote: > > > On 10/09/2020 20:01, Andreas Kemnade wrote: > > > On Wed, 19 Aug 2020 07:59:23 -0500 > > > Adam Ford <aford173@gmail.com> wrote: > > > > > >> The bandgap sensor can be idled when the processor is too, but it > > >> isn't currently being done, so the power consumption of OMAP3 > > >> boards can elevated if the bangap sensor is enabled. > > >> > > >> This patch attempts to use some additional power management > > >> to idle the clock to the bandgap when not needed. > > >> > > >> Signed-off-by: Adam Ford <aford173@gmail.com> > > >> Reported-by: kernel test robot <lkp@intel.com> > > >> --- > > >> V2: Fix issue where variable stating the suspend mode isn't being > > >> properly set and cleared. > > >> > > > hmm, it is not in linux-next. Can we expect that for v5.10? > > > > The reason I did not pick this patch is because lkp reported an error on > > it. > > > > https://marc.info/?l=linux-pm&m=159788472017308&w=2 > > > > > > > That error message shows it's trying to be built with 'sh' cross compiler, > but should be build with an ARM. > > I can run a manual test of the patch against a different branch if > necessary, but I had built and tested it, so I know it worked at one time. > hmm, what about compile-testing without CONFIG_PM_SLEEP? The function definition is guarded by that. So it is not a sh-specific problem. Regards, Andreas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-09-10 19:50 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-08-19 12:59 [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management Adam Ford 2020-08-19 12:59 ` Adam Ford 2020-08-19 12:59 ` [PATCH V2 2/2] ARM: omap2plus_defconfig: Enable OMAP3_THERMAL Adam Ford 2020-08-19 12:59 ` Adam Ford 2020-08-19 19:23 ` [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management Andreas Kemnade 2020-08-19 19:23 ` Andreas Kemnade 2020-08-20 0:51 ` kernel test robot 2020-08-20 0:51 ` kernel test robot 2020-09-10 18:01 ` Andreas Kemnade 2020-09-10 18:01 ` Andreas Kemnade 2020-09-10 19:14 ` Daniel Lezcano 2020-09-10 19:14 ` Daniel Lezcano [not found] ` <CAHCN7xLUrh7xr0pr5Bz0unWQXGkiKDK88hZKx7WXGyr2RBWTVg@mail.gmail.com> 2020-09-10 19:48 ` Andreas Kemnade 2020-09-10 19:48 ` Andreas Kemnade
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.