* [PATCH 0/3] thermal: Fix workqueue-related issues in drivers
@ 2018-09-27 11:32 Geert Uytterhoeven
2018-09-27 11:32 ` [PATCH 1/3] thermal: rcar_thermal: Prevent hardware access during system suspend Geert Uytterhoeven
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2018-09-27 11:32 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin, Kuninori Morimoto,
Support Opensource, Daniel Lezcano
Cc: Rafael J . Wysocki, Arjan van de Ven, Jacob Pan, linux-pm,
linux-renesas-soc, linux-kernel, Geert Uytterhoeven
Hi,
This patch series fixes workqueue-related issues in the Renesas R-Car
Thermal and Dialog DA9062/9061 PMIC drivers, where the workqueue may run
while the device is suspended, or unbound.
The R-Car Thermal driver fixes have been tested on R-Car M2-W and R-Mobile
APE6.
The DA9062/9061 fixes have been compile-tested only.
Note: The Intel PowerClamp driver also uses schedule_delayed_work(), but I
believe that is OK, as the thermal registers are part of the CPU.
Thanks!
Geert Uytterhoeven (3):
thermal: rcar_thermal: Prevent hardware access during system suspend
thermal: rcar_thermal: Prevent doing work after unbind
thermal: da9062/61: Prevent hardware access during system suspend
drivers/thermal/da9062-thermal.c | 4 ++--
drivers/thermal/rcar_thermal.c | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
--
2.17.1
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] thermal: rcar_thermal: Prevent hardware access during system suspend
2018-09-27 11:32 [PATCH 0/3] thermal: Fix workqueue-related issues in drivers Geert Uytterhoeven
@ 2018-09-27 11:32 ` Geert Uytterhoeven
2018-09-28 8:51 ` Niklas Söderlund
2018-09-27 11:32 ` [PATCH 2/3] thermal: rcar_thermal: Prevent doing work after unbind Geert Uytterhoeven
2018-09-27 11:32 ` [PATCH 3/3] thermal: da9062/61: Prevent hardware access during system suspend Geert Uytterhoeven
2 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2018-09-27 11:32 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin, Kuninori Morimoto,
Support Opensource, Daniel Lezcano
Cc: Rafael J . Wysocki, Arjan van de Ven, Jacob Pan, linux-pm,
linux-renesas-soc, linux-kernel, Geert Uytterhoeven
On r8a7791/koelsch, sometimes the following message is printed during
system suspend:
rcar_thermal e61f0000.thermal: thermal sensor was broken
This happens if the workqueue runs while the device is already
suspended. Fix this by using the freezable system workqueue instead,
cfr. commit 51e20d0e3a60cf46 ("thermal: Prevent polling from happening
during system suspend").
Fixes: e0a5172e9eec7f0d ("thermal: rcar: add interrupt support")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/thermal/rcar_thermal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 78f932822d381c9d..ea132e122b174757 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -434,8 +434,8 @@ static irqreturn_t rcar_thermal_irq(int irq, void *data)
rcar_thermal_for_each_priv(priv, common) {
if (rcar_thermal_had_changed(priv, status)) {
rcar_thermal_irq_disable(priv);
- schedule_delayed_work(&priv->work,
- msecs_to_jiffies(300));
+ queue_delayed_work(system_freezable_wq, &priv->work,
+ msecs_to_jiffies(300));
}
}
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] thermal: rcar_thermal: Prevent doing work after unbind
2018-09-27 11:32 [PATCH 0/3] thermal: Fix workqueue-related issues in drivers Geert Uytterhoeven
2018-09-27 11:32 ` [PATCH 1/3] thermal: rcar_thermal: Prevent hardware access during system suspend Geert Uytterhoeven
@ 2018-09-27 11:32 ` Geert Uytterhoeven
2018-09-28 9:00 ` Niklas Söderlund
2018-09-27 11:32 ` [PATCH 3/3] thermal: da9062/61: Prevent hardware access during system suspend Geert Uytterhoeven
2 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2018-09-27 11:32 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin, Kuninori Morimoto,
Support Opensource, Daniel Lezcano
Cc: Rafael J . Wysocki, Arjan van de Ven, Jacob Pan, linux-pm,
linux-renesas-soc, linux-kernel, Geert Uytterhoeven
When testing bind/unbind on r8a7791/koelsch:
WARNING: CPU: 1 PID: 697 at lib/debugobjects.c:329 debug_print_object+0x8c/0xb4
ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x10
This happens if the workqueue runs after the device has been unbound.
Fix this by cancelling any queued work during remove.
Fixes: e0a5172e9eec7f0d ("thermal: rcar: add interrupt support")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/thermal/rcar_thermal.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index ea132e122b174757..616ba2fccf410d3b 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -453,6 +453,7 @@ static int rcar_thermal_remove(struct platform_device *pdev)
rcar_thermal_for_each_priv(priv, common) {
rcar_thermal_irq_disable(priv);
+ cancel_delayed_work_sync(&priv->work);
if (priv->chip->use_of_thermal)
thermal_remove_hwmon_sysfs(priv->zone);
else
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] thermal: da9062/61: Prevent hardware access during system suspend
2018-09-27 11:32 [PATCH 0/3] thermal: Fix workqueue-related issues in drivers Geert Uytterhoeven
2018-09-27 11:32 ` [PATCH 1/3] thermal: rcar_thermal: Prevent hardware access during system suspend Geert Uytterhoeven
2018-09-27 11:32 ` [PATCH 2/3] thermal: rcar_thermal: Prevent doing work after unbind Geert Uytterhoeven
@ 2018-09-27 11:32 ` Geert Uytterhoeven
2 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2018-09-27 11:32 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin, Kuninori Morimoto,
Support Opensource, Daniel Lezcano
Cc: Rafael J . Wysocki, Arjan van de Ven, Jacob Pan, linux-pm,
linux-renesas-soc, linux-kernel, Geert Uytterhoeven
The workqueue used for monitoring the hardware may run while the device
is already suspended. Fix this by using the freezable system workqueue
instead, cfr. commit 51e20d0e3a60cf46 ("thermal: Prevent polling from
happening during system suspend").
Fixes: 608567aac3206ae8 ("thermal: da9062/61: Thermal junction temperature monitoring driver")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Untested due to lack of hardware.
---
drivers/thermal/da9062-thermal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-thermal.c
index dd8dd947b7f0737c..01b0cb9944577851 100644
--- a/drivers/thermal/da9062-thermal.c
+++ b/drivers/thermal/da9062-thermal.c
@@ -106,7 +106,7 @@ static void da9062_thermal_poll_on(struct work_struct *work)
THERMAL_EVENT_UNSPECIFIED);
delay = msecs_to_jiffies(thermal->zone->passive_delay);
- schedule_delayed_work(&thermal->work, delay);
+ queue_delayed_work(system_freezable_wq, &thermal->work, delay);
return;
}
@@ -125,7 +125,7 @@ static irqreturn_t da9062_thermal_irq_handler(int irq, void *data)
struct da9062_thermal *thermal = data;
disable_irq_nosync(thermal->irq);
- schedule_delayed_work(&thermal->work, 0);
+ queue_delayed_work(system_freezable_wq, &thermal->work, 0);
return IRQ_HANDLED;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] thermal: rcar_thermal: Prevent hardware access during system suspend
2018-09-27 11:32 ` [PATCH 1/3] thermal: rcar_thermal: Prevent hardware access during system suspend Geert Uytterhoeven
@ 2018-09-28 8:51 ` Niklas Söderlund
0 siblings, 0 replies; 6+ messages in thread
From: Niklas Söderlund @ 2018-09-28 8:51 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Zhang Rui, Eduardo Valentin, Kuninori Morimoto,
Support Opensource, Daniel Lezcano, Rafael J . Wysocki,
Arjan van de Ven, Jacob Pan, linux-pm, linux-renesas-soc,
linux-kernel
Hi Geert,
Thanks for your patch.
On 2018-09-27 13:32:33 +0200, Geert Uytterhoeven wrote:
> On r8a7791/koelsch, sometimes the following message is printed during
> system suspend:
>
> rcar_thermal e61f0000.thermal: thermal sensor was broken
>
> This happens if the workqueue runs while the device is already
> suspended. Fix this by using the freezable system workqueue instead,
> cfr. commit 51e20d0e3a60cf46 ("thermal: Prevent polling from happening
> during system suspend").
>
> Fixes: e0a5172e9eec7f0d ("thermal: rcar: add interrupt support")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> drivers/thermal/rcar_thermal.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 78f932822d381c9d..ea132e122b174757 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -434,8 +434,8 @@ static irqreturn_t rcar_thermal_irq(int irq, void *data)
> rcar_thermal_for_each_priv(priv, common) {
> if (rcar_thermal_had_changed(priv, status)) {
> rcar_thermal_irq_disable(priv);
> - schedule_delayed_work(&priv->work,
> - msecs_to_jiffies(300));
> + queue_delayed_work(system_freezable_wq, &priv->work,
> + msecs_to_jiffies(300));
> }
> }
>
> --
> 2.17.1
>
--
Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] thermal: rcar_thermal: Prevent doing work after unbind
2018-09-27 11:32 ` [PATCH 2/3] thermal: rcar_thermal: Prevent doing work after unbind Geert Uytterhoeven
@ 2018-09-28 9:00 ` Niklas Söderlund
0 siblings, 0 replies; 6+ messages in thread
From: Niklas Söderlund @ 2018-09-28 9:00 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Zhang Rui, Eduardo Valentin, Kuninori Morimoto,
Support Opensource, Daniel Lezcano, Rafael J . Wysocki,
Arjan van de Ven, Jacob Pan, linux-pm, linux-renesas-soc,
linux-kernel
Hi Geert,
Thanks for your work.
On 2018-09-27 13:32:34 +0200, Geert Uytterhoeven wrote:
> When testing bind/unbind on r8a7791/koelsch:
>
> WARNING: CPU: 1 PID: 697 at lib/debugobjects.c:329 debug_print_object+0x8c/0xb4
> ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x10
>
> This happens if the workqueue runs after the device has been unbound.
> Fix this by cancelling any queued work during remove.
>
> Fixes: e0a5172e9eec7f0d ("thermal: rcar: add interrupt support")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> drivers/thermal/rcar_thermal.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index ea132e122b174757..616ba2fccf410d3b 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -453,6 +453,7 @@ static int rcar_thermal_remove(struct platform_device *pdev)
>
> rcar_thermal_for_each_priv(priv, common) {
> rcar_thermal_irq_disable(priv);
> + cancel_delayed_work_sync(&priv->work);
> if (priv->chip->use_of_thermal)
> thermal_remove_hwmon_sysfs(priv->zone);
> else
> --
> 2.17.1
>
--
Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-09-28 9:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-27 11:32 [PATCH 0/3] thermal: Fix workqueue-related issues in drivers Geert Uytterhoeven
2018-09-27 11:32 ` [PATCH 1/3] thermal: rcar_thermal: Prevent hardware access during system suspend Geert Uytterhoeven
2018-09-28 8:51 ` Niklas Söderlund
2018-09-27 11:32 ` [PATCH 2/3] thermal: rcar_thermal: Prevent doing work after unbind Geert Uytterhoeven
2018-09-28 9:00 ` Niklas Söderlund
2018-09-27 11:32 ` [PATCH 3/3] thermal: da9062/61: Prevent hardware access during system suspend Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).