thermal/drivers/qcom: Remove duplicate set next trip point interrupt code

Message ID 20230110103420.2430518-1-daniel.lezcano@kernel.org
State New
Headers
Series thermal/drivers/qcom: Remove duplicate set next trip point interrupt code |

Commit Message

Daniel Lezcano Jan. 10, 2023, 10:34 a.m. UTC
  From: Daniel Lezcano <daniel.lezcano@linaro.org>

The tsens driver reprogram the next trip points in the irq
handler. This function then call thermal_zone_device_update().

However, thermal_zone_device_update() calls thermal_zone_set_trips()
and from there it calls the backend 'set_trips' ops. This one in turn
reprogram the next trip points (low/high).

Consequently, the code setting the next trip points interrupt in the
interrupt handle is not needed and could be removed.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
---
 drivers/thermal/qcom/tsens.c | 46 +-----------------------------------
 1 file changed, 1 insertion(+), 45 deletions(-)
  

Comments

Rafael J. Wysocki Jan. 10, 2023, 1:01 p.m. UTC | #1
On Tue, Jan 10, 2023 at 11:34 AM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
> From: Daniel Lezcano <daniel.lezcano@linaro.org>
>
> The tsens driver reprogram the next trip points in the irq
> handler. This function then call thermal_zone_device_update().
>
> However, thermal_zone_device_update() calls thermal_zone_set_trips()
> and from there it calls the backend 'set_trips' ops. This one in turn
> reprogram the next trip points (low/high).
>
> Consequently, the code setting the next trip points interrupt in the
> interrupt handle is not needed and could be removed.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>

I'm wondering what you wanted to say through these S-o-b tags.

I don't think you have to sign off your own patch again.

> ---
>  drivers/thermal/qcom/tsens.c | 46 +-----------------------------------
>  1 file changed, 1 insertion(+), 45 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index b5b136ff323f..58693ee8c430 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -472,52 +472,8 @@ static irqreturn_t tsens_irq_thread(int irq, void *data)
>                         continue;
>                 if (!tsens_threshold_violated(priv, hw_id, &d))
>                         continue;
> -               ret = get_temp_tsens_valid(s, &temp);
> -               if (ret) {
> -                       dev_err(priv->dev, "[%u] %s: error reading sensor\n",
> -                               hw_id, __func__);
> -                       continue;
> -               }
>
> -               spin_lock_irqsave(&priv->ul_lock, flags);
> -
> -               tsens_read_irq_state(priv, hw_id, s, &d);
> -
> -               if (d.up_viol &&
> -                   !masked_irq(hw_id, d.up_irq_mask, tsens_version(priv))) {
> -                       tsens_set_interrupt(priv, hw_id, UPPER, disable);
> -                       if (d.up_thresh > temp) {
> -                               dev_dbg(priv->dev, "[%u] %s: re-arm upper\n",
> -                                       hw_id, __func__);
> -                               tsens_set_interrupt(priv, hw_id, UPPER, enable);
> -                       } else {
> -                               trigger = true;
> -                               /* Keep irq masked */
> -                       }
> -               } else if (d.low_viol &&
> -                          !masked_irq(hw_id, d.low_irq_mask, tsens_version(priv))) {
> -                       tsens_set_interrupt(priv, hw_id, LOWER, disable);
> -                       if (d.low_thresh < temp) {
> -                               dev_dbg(priv->dev, "[%u] %s: re-arm low\n",
> -                                       hw_id, __func__);
> -                               tsens_set_interrupt(priv, hw_id, LOWER, enable);
> -                       } else {
> -                               trigger = true;
> -                               /* Keep irq masked */
> -                       }
> -               }
> -
> -               spin_unlock_irqrestore(&priv->ul_lock, flags);
> -
> -               if (trigger) {
> -                       dev_dbg(priv->dev, "[%u] %s: TZ update trigger (%d mC)\n",
> -                               hw_id, __func__, temp);
> -                       thermal_zone_device_update(s->tzd,
> -                                                  THERMAL_EVENT_UNSPECIFIED);
> -               } else {
> -                       dev_dbg(priv->dev, "[%u] %s: no violation:  %d\n",
> -                               hw_id, __func__, temp);
> -               }
> +               thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED);
>
>                 if (tsens_version(priv) < VER_0_1) {
>                         /* Constraint: There is only 1 interrupt control register for all
> --
> 2.34.1
>
  
Daniel Lezcano Jan. 10, 2023, 1:15 p.m. UTC | #2
On 10/01/2023 14:01, Rafael J. Wysocki wrote:
> On Tue, Jan 10, 2023 at 11:34 AM Daniel Lezcano
> <daniel.lezcano@linaro.org> wrote:
>>
>> From: Daniel Lezcano <daniel.lezcano@linaro.org>
>>
>> The tsens driver reprogram the next trip points in the irq
>> handler. This function then call thermal_zone_device_update().
>>
>> However, thermal_zone_device_update() calls thermal_zone_set_trips()
>> and from there it calls the backend 'set_trips' ops. This one in turn
>> reprogram the next trip points (low/high).
>>
>> Consequently, the code setting the next trip points interrupt in the
>> interrupt handle is not needed and could be removed.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
> 
> I'm wondering what you wanted to say through these S-o-b tags.
> 
> I don't think you have to sign off your own patch again.

Yes, I changed a configuration in my git tree, something I have to fix. 
That has to be considered as duplicate SoB
  
Bjorn Andersson Jan. 10, 2023, 6:13 p.m. UTC | #3
On Tue, Jan 10, 2023 at 11:34:20AM +0100, Daniel Lezcano wrote:
> From: Daniel Lezcano <daniel.lezcano@linaro.org>
> 
> The tsens driver reprogram the next trip points in the irq
> handler. This function then call thermal_zone_device_update().
> 
> However, thermal_zone_device_update() calls thermal_zone_set_trips()
> and from there it calls the backend 'set_trips' ops. This one in turn
> reprogram the next trip points (low/high).
> 
> Consequently, the code setting the next trip points interrupt in the
> interrupt handle is not needed and could be removed.
> 


Reviewed-by: Bjorn Andersson <andersson@kernel.org>

> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>

The last one should be the address you sent your patch from, and that
was the first one. So I think you should drop this one.

Regards,
Bjorn

> ---
>  drivers/thermal/qcom/tsens.c | 46 +-----------------------------------
>  1 file changed, 1 insertion(+), 45 deletions(-)
> 
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index b5b136ff323f..58693ee8c430 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -472,52 +472,8 @@ static irqreturn_t tsens_irq_thread(int irq, void *data)
>  			continue;
>  		if (!tsens_threshold_violated(priv, hw_id, &d))
>  			continue;
> -		ret = get_temp_tsens_valid(s, &temp);
> -		if (ret) {
> -			dev_err(priv->dev, "[%u] %s: error reading sensor\n",
> -				hw_id, __func__);
> -			continue;
> -		}
>  
> -		spin_lock_irqsave(&priv->ul_lock, flags);
> -
> -		tsens_read_irq_state(priv, hw_id, s, &d);
> -
> -		if (d.up_viol &&
> -		    !masked_irq(hw_id, d.up_irq_mask, tsens_version(priv))) {
> -			tsens_set_interrupt(priv, hw_id, UPPER, disable);
> -			if (d.up_thresh > temp) {
> -				dev_dbg(priv->dev, "[%u] %s: re-arm upper\n",
> -					hw_id, __func__);
> -				tsens_set_interrupt(priv, hw_id, UPPER, enable);
> -			} else {
> -				trigger = true;
> -				/* Keep irq masked */
> -			}
> -		} else if (d.low_viol &&
> -			   !masked_irq(hw_id, d.low_irq_mask, tsens_version(priv))) {
> -			tsens_set_interrupt(priv, hw_id, LOWER, disable);
> -			if (d.low_thresh < temp) {
> -				dev_dbg(priv->dev, "[%u] %s: re-arm low\n",
> -					hw_id, __func__);
> -				tsens_set_interrupt(priv, hw_id, LOWER, enable);
> -			} else {
> -				trigger = true;
> -				/* Keep irq masked */
> -			}
> -		}
> -
> -		spin_unlock_irqrestore(&priv->ul_lock, flags);
> -
> -		if (trigger) {
> -			dev_dbg(priv->dev, "[%u] %s: TZ update trigger (%d mC)\n",
> -				hw_id, __func__, temp);
> -			thermal_zone_device_update(s->tzd,
> -						   THERMAL_EVENT_UNSPECIFIED);
> -		} else {
> -			dev_dbg(priv->dev, "[%u] %s: no violation:  %d\n",
> -				hw_id, __func__, temp);
> -		}
> +		thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED);
>  
>  		if (tsens_version(priv) < VER_0_1) {
>  			/* Constraint: There is only 1 interrupt control register for all
> -- 
> 2.34.1
>
  
Daniel Lezcano Jan. 11, 2023, 11:24 a.m. UTC | #4
On 10/01/2023 19:13, Bjorn Andersson wrote:
> On Tue, Jan 10, 2023 at 11:34:20AM +0100, Daniel Lezcano wrote:
>> From: Daniel Lezcano <daniel.lezcano@linaro.org>
>>
>> The tsens driver reprogram the next trip points in the irq
>> handler. This function then call thermal_zone_device_update().
>>
>> However, thermal_zone_device_update() calls thermal_zone_set_trips()
>> and from there it calls the backend 'set_trips' ops. This one in turn
>> reprogram the next trip points (low/high).
>>
>> Consequently, the code setting the next trip points interrupt in the
>> interrupt handle is not needed and could be removed.
>>
> 
> 
> Reviewed-by: Bjorn Andersson <andersson@kernel.org>
> 
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
> 
> The last one should be the address you sent your patch from, and that
> was the first one. So I think you should drop this one.

Thanks for the review. I'll remove the duplicated SoB.

   -- Daniel
  
Amit Kucheria Jan. 11, 2023, 4:41 p.m. UTC | #5
On Tue, Jan 10, 2023 at 4:04 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
> From: Daniel Lezcano <daniel.lezcano@linaro.org>
>
> The tsens driver reprogram the next trip points in the irq
> handler. This function then call thermal_zone_device_update().
>
> However, thermal_zone_device_update() calls thermal_zone_set_trips()
> and from there it calls the backend 'set_trips' ops. This one in turn
> reprogram the next trip points (low/high).
>
> Consequently, the code setting the next trip points interrupt in the
> interrupt handle is not needed and could be removed.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>

Acked-by: Amit Kucheria <amitk@kernel.org>

> ---
>  drivers/thermal/qcom/tsens.c | 46 +-----------------------------------
>  1 file changed, 1 insertion(+), 45 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index b5b136ff323f..58693ee8c430 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -472,52 +472,8 @@ static irqreturn_t tsens_irq_thread(int irq, void *data)
>                         continue;
>                 if (!tsens_threshold_violated(priv, hw_id, &d))
>                         continue;
> -               ret = get_temp_tsens_valid(s, &temp);
> -               if (ret) {
> -                       dev_err(priv->dev, "[%u] %s: error reading sensor\n",
> -                               hw_id, __func__);
> -                       continue;
> -               }
>
> -               spin_lock_irqsave(&priv->ul_lock, flags);
> -
> -               tsens_read_irq_state(priv, hw_id, s, &d);
> -
> -               if (d.up_viol &&
> -                   !masked_irq(hw_id, d.up_irq_mask, tsens_version(priv))) {
> -                       tsens_set_interrupt(priv, hw_id, UPPER, disable);
> -                       if (d.up_thresh > temp) {
> -                               dev_dbg(priv->dev, "[%u] %s: re-arm upper\n",
> -                                       hw_id, __func__);
> -                               tsens_set_interrupt(priv, hw_id, UPPER, enable);
> -                       } else {
> -                               trigger = true;
> -                               /* Keep irq masked */
> -                       }
> -               } else if (d.low_viol &&
> -                          !masked_irq(hw_id, d.low_irq_mask, tsens_version(priv))) {
> -                       tsens_set_interrupt(priv, hw_id, LOWER, disable);
> -                       if (d.low_thresh < temp) {
> -                               dev_dbg(priv->dev, "[%u] %s: re-arm low\n",
> -                                       hw_id, __func__);
> -                               tsens_set_interrupt(priv, hw_id, LOWER, enable);
> -                       } else {
> -                               trigger = true;
> -                               /* Keep irq masked */
> -                       }
> -               }
> -
> -               spin_unlock_irqrestore(&priv->ul_lock, flags);
> -
> -               if (trigger) {
> -                       dev_dbg(priv->dev, "[%u] %s: TZ update trigger (%d mC)\n",
> -                               hw_id, __func__, temp);
> -                       thermal_zone_device_update(s->tzd,
> -                                                  THERMAL_EVENT_UNSPECIFIED);
> -               } else {
> -                       dev_dbg(priv->dev, "[%u] %s: no violation:  %d\n",
> -                               hw_id, __func__, temp);
> -               }
> +               thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED);
>
>                 if (tsens_version(priv) < VER_0_1) {
>                         /* Constraint: There is only 1 interrupt control register for all
> --
> 2.34.1
>
  

Patch

diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index b5b136ff323f..58693ee8c430 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -472,52 +472,8 @@  static irqreturn_t tsens_irq_thread(int irq, void *data)
 			continue;
 		if (!tsens_threshold_violated(priv, hw_id, &d))
 			continue;
-		ret = get_temp_tsens_valid(s, &temp);
-		if (ret) {
-			dev_err(priv->dev, "[%u] %s: error reading sensor\n",
-				hw_id, __func__);
-			continue;
-		}
 
-		spin_lock_irqsave(&priv->ul_lock, flags);
-
-		tsens_read_irq_state(priv, hw_id, s, &d);
-
-		if (d.up_viol &&
-		    !masked_irq(hw_id, d.up_irq_mask, tsens_version(priv))) {
-			tsens_set_interrupt(priv, hw_id, UPPER, disable);
-			if (d.up_thresh > temp) {
-				dev_dbg(priv->dev, "[%u] %s: re-arm upper\n",
-					hw_id, __func__);
-				tsens_set_interrupt(priv, hw_id, UPPER, enable);
-			} else {
-				trigger = true;
-				/* Keep irq masked */
-			}
-		} else if (d.low_viol &&
-			   !masked_irq(hw_id, d.low_irq_mask, tsens_version(priv))) {
-			tsens_set_interrupt(priv, hw_id, LOWER, disable);
-			if (d.low_thresh < temp) {
-				dev_dbg(priv->dev, "[%u] %s: re-arm low\n",
-					hw_id, __func__);
-				tsens_set_interrupt(priv, hw_id, LOWER, enable);
-			} else {
-				trigger = true;
-				/* Keep irq masked */
-			}
-		}
-
-		spin_unlock_irqrestore(&priv->ul_lock, flags);
-
-		if (trigger) {
-			dev_dbg(priv->dev, "[%u] %s: TZ update trigger (%d mC)\n",
-				hw_id, __func__, temp);
-			thermal_zone_device_update(s->tzd,
-						   THERMAL_EVENT_UNSPECIFIED);
-		} else {
-			dev_dbg(priv->dev, "[%u] %s: no violation:  %d\n",
-				hw_id, __func__, temp);
-		}
+		thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED);
 
 		if (tsens_version(priv) < VER_0_1) {
 			/* Constraint: There is only 1 interrupt control register for all