diff options
author | Jiada Wang <jiada_wang@mentor.com> | 2019-04-24 14:11:44 +0900 |
---|---|---|
committer | Ryo Kataoka <ryo.kataoka.wt@renesas.com> | 2019-07-11 21:17:14 +0900 |
commit | 6b92f96d09762a9fe172468ed302290cc4046318 (patch) | |
tree | c1ee604e06f6fcecbe389d6b78ecee66266bad31 | |
parent | 39eee119052a1bb826bab60dcc5531ec34e3b4cf (diff) | |
download | renesas-bsp-6b92f96d09762a9fe172468ed302290cc4046318.tar.gz |
thermal: rcar_gen3_thermal: fix interrupt type
Currently IRQF_SHARED type interrupt line is allocated, but it
is not appropriate, as the interrupt line isn't shared between
different devices, instead IRQF_ONESHOT is the proper type.
By changing interrupt type to IRQF_ONESHOT, now irq handler is
no longer needed, as clear of interrupt status can be done in
threaded interrupt context.
Because IRQF_ONESHOT type interrupt line is kept disabled until
the threaded handler has been run, so there is no need to protect
read/write of REG_GEN3_IRQSTR with lock.
Fixes: 7d4b269776ec6 ("enable hardware interrupts for trip points")
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Tested-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
(cherry picked from commit 2c0928c9e004589dc9e7672c40a38d6c4ca12701)
Signed-off-by: The Kinh Nguyen <the.nguyen.vx@renesas.com>
-rw-r--r-- | drivers/thermal/rcar_gen3_thermal.c | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index b3fa15bae4166..bba6af707aec4 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -24,7 +24,6 @@ #include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> -#include <linux/spinlock.h> #include <linux/sys_soc.h> #include <linux/thermal.h> #include <linux/of.h> @@ -145,7 +144,6 @@ struct rcar_gen3_thermal_tsc { struct rcar_gen3_thermal_priv { struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM]; unsigned int num_tscs; - spinlock_t lock; /* Protect interrupts on and off */ void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc); }; @@ -397,9 +395,7 @@ static irqreturn_t rcar_gen3_thermal_irq(int irq, void *data) { struct rcar_gen3_thermal_priv *priv = data; u32 status; - int i, ret = IRQ_HANDLED; - - spin_lock(&priv->lock); + int i; if (is_ths_typeA) { for (i = 0; i < priv->num_tscs; i++) { @@ -408,7 +404,8 @@ static irqreturn_t rcar_gen3_thermal_irq(int irq, void *data) rcar_gen3_thermal_write(priv->tscs[i], REG_GEN3_IRQSTR, 0); if (status) - ret = IRQ_WAKE_THREAD; + thermal_zone_device_update(priv->tscs[i]->zone, + THERMAL_EVENT_UNSPECIFIED); } } else { for (i = 0; i < priv->num_tscs; i++) { @@ -417,34 +414,11 @@ static irqreturn_t rcar_gen3_thermal_irq(int irq, void *data) rcar_gen3_thermal_write(priv->tscs[i], REG_GEN3_B_STR, 0); if (status) - ret = IRQ_WAKE_THREAD; + thermal_zone_device_update(priv->tscs[i]->zone, + THERMAL_EVENT_UNSPECIFIED); } } - if (ret == IRQ_WAKE_THREAD) - rcar_thermal_irq_set(priv, false); - - spin_unlock(&priv->lock); - - return ret; -} - -static irqreturn_t rcar_gen3_thermal_irq_thread(int irq, void *data) -{ - struct rcar_gen3_thermal_priv *priv = data; - unsigned long flags; - int i; - - for (i = 0; i < priv->num_tscs; i++) { - rcar_gen3_thermal_set_irq_temp(priv->tscs[i]); - thermal_zone_device_update(priv->tscs[i]->zone, - THERMAL_EVENT_UNSPECIFIED); - } - - spin_lock_irqsave(&priv->lock, flags); - rcar_thermal_irq_set(priv, true); - spin_unlock_irqrestore(&priv->lock, flags); - return IRQ_HANDLED; } @@ -599,7 +573,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) iounmap(ptat_base); } - spin_lock_init(&priv->lock); platform_set_drvdata(pdev, priv); @@ -618,9 +591,9 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) if (!irqname) return -ENOMEM; - ret = devm_request_threaded_irq(dev, irq, rcar_gen3_thermal_irq, - rcar_gen3_thermal_irq_thread, - IRQF_SHARED, irqname, priv); + ret = devm_request_threaded_irq(dev, irq, NULL, + rcar_gen3_thermal_irq, + IRQF_ONESHOT, irqname, priv); if (ret) return ret; } |