linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: samsung: Only update available threshold limits
@ 2014-04-14  5:38 Tushar Behera
  2014-04-24  3:17 ` Tushar Behera
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Tushar Behera @ 2014-04-14  5:38 UTC (permalink / raw)
  To: linux-kernel, linux-samsung-soc, linux-pm; +Cc: rui.zhang, eduardo.valentin

Currently the threshold limits are updated in 2 stages, once for all
software trigger levels and again for hardware trip point.

While updating the software trigger levels, it overwrites the threshold
limit for hardware trip point thereby forcing the Exynos core to issue
an emergency shutdown.

Updating only the required fields in threshold register fixes this issue.

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
Based on v3.15-rc1.

 drivers/thermal/samsung/exynos_tmu.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 0d96a51..ffccc89 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -225,6 +225,8 @@ skip_calib_data:
 			trigger_levs++;
 	}
 
+	rising_threshold = readl(data->base + reg->threshold_th0);
+
 	if (data->soc == SOC_ARCH_EXYNOS4210) {
 		/* Write temperature code for threshold */
 		threshold_code = temp_to_code(data, pdata->threshold);
@@ -249,6 +251,7 @@ skip_calib_data:
 				ret = threshold_code;
 				goto out;
 			}
+			rising_threshold &= ~(0xff << 8 * i);
 			rising_threshold |= threshold_code << 8 * i;
 			if (pdata->threshold_falling) {
 				threshold_code = temp_to_code(data,
@@ -281,6 +284,7 @@ skip_calib_data:
 			}
 			if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
 				/* 1-4 level to be assigned in th0 reg */
+				rising_threshold &= ~(0xff << 8 * i);
 				rising_threshold |= threshold_code << 8 * i;
 				writel(rising_threshold,
 					data->base + reg->threshold_th0);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] thermal: samsung: Only update available threshold limits
  2014-04-14  5:38 [PATCH] thermal: samsung: Only update available threshold limits Tushar Behera
@ 2014-04-24  3:17 ` Tushar Behera
  2014-04-24  6:18 ` Amit Kachhap
  2014-04-24 10:48 ` Bartlomiej Zolnierkiewicz
  2 siblings, 0 replies; 7+ messages in thread
From: Tushar Behera @ 2014-04-24  3:17 UTC (permalink / raw)
  To: linux-kernel, linux-samsung-soc, linux-pm
  Cc: rui.zhang, eduardo.valentin, Amit Daniel Kachhap

On 04/14/2014 11:08 AM, Tushar Behera wrote:
> Currently the threshold limits are updated in 2 stages, once for all
> software trigger levels and again for hardware trip point.
> 
> While updating the software trigger levels, it overwrites the threshold
> limit for hardware trip point thereby forcing the Exynos core to issue
> an emergency shutdown.
> 
> Updating only the required fields in threshold register fixes this issue.
> 
> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
> ---
> Based on v3.15-rc1.
> 
>  drivers/thermal/samsung/exynos_tmu.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 0d96a51..ffccc89 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -225,6 +225,8 @@ skip_calib_data:
>  			trigger_levs++;
>  	}
>  
> +	rising_threshold = readl(data->base + reg->threshold_th0);
> +
>  	if (data->soc == SOC_ARCH_EXYNOS4210) {
>  		/* Write temperature code for threshold */
>  		threshold_code = temp_to_code(data, pdata->threshold);
> @@ -249,6 +251,7 @@ skip_calib_data:
>  				ret = threshold_code;
>  				goto out;
>  			}
> +			rising_threshold &= ~(0xff << 8 * i);
>  			rising_threshold |= threshold_code << 8 * i;
>  			if (pdata->threshold_falling) {
>  				threshold_code = temp_to_code(data,
> @@ -281,6 +284,7 @@ skip_calib_data:
>  			}
>  			if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
>  				/* 1-4 level to be assigned in th0 reg */
> +				rising_threshold &= ~(0xff << 8 * i);
>  				rising_threshold |= threshold_code << 8 * i;
>  				writel(rising_threshold,
>  					data->base + reg->threshold_th0);
> 

Adding Amit to get Samsung specific review.

-- 
Tushar Behera

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] thermal: samsung: Only update available threshold limits
  2014-04-14  5:38 [PATCH] thermal: samsung: Only update available threshold limits Tushar Behera
  2014-04-24  3:17 ` Tushar Behera
@ 2014-04-24  6:18 ` Amit Kachhap
  2014-05-09 11:47   ` Tushar Behera
  2014-05-15  8:45   ` Zhang Rui
  2014-04-24 10:48 ` Bartlomiej Zolnierkiewicz
  2 siblings, 2 replies; 7+ messages in thread
From: Amit Kachhap @ 2014-04-24  6:18 UTC (permalink / raw)
  To: Tushar Behera
  Cc: linux-kernel, linux-samsung-soc, linux-pm, rui.zhang, eduardo.valentin

On 4/14/14, Tushar Behera <tushar.behera@linaro.org> wrote:
> Currently the threshold limits are updated in 2 stages, once for all
> software trigger levels and again for hardware trip point.
I guess the first stage is bootloader as could not find this in this file.
Anyways the changes looks fine to me.

Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com>

>
> While updating the software trigger levels, it overwrites the threshold
> limit for hardware trip point thereby forcing the Exynos core to issue
> an emergency shutdown.
>
> Updating only the required fields in threshold register fixes this issue.
>
> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
> ---
> Based on v3.15-rc1.
>
>  drivers/thermal/samsung/exynos_tmu.c |    4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/thermal/samsung/exynos_tmu.c
> b/drivers/thermal/samsung/exynos_tmu.c
> index 0d96a51..ffccc89 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -225,6 +225,8 @@ skip_calib_data:
>  			trigger_levs++;
>  	}
>
> +	rising_threshold = readl(data->base + reg->threshold_th0);
> +
>  	if (data->soc == SOC_ARCH_EXYNOS4210) {
>  		/* Write temperature code for threshold */
>  		threshold_code = temp_to_code(data, pdata->threshold);
> @@ -249,6 +251,7 @@ skip_calib_data:
>  				ret = threshold_code;
>  				goto out;
>  			}
> +			rising_threshold &= ~(0xff << 8 * i);
>  			rising_threshold |= threshold_code << 8 * i;
>  			if (pdata->threshold_falling) {
>  				threshold_code = temp_to_code(data,
> @@ -281,6 +284,7 @@ skip_calib_data:
>  			}
>  			if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
>  				/* 1-4 level to be assigned in th0 reg */
> +				rising_threshold &= ~(0xff << 8 * i);
>  				rising_threshold |= threshold_code << 8 * i;
>  				writel(rising_threshold,
>  					data->base + reg->threshold_th0);
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc"
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] thermal: samsung: Only update available threshold limits
  2014-04-14  5:38 [PATCH] thermal: samsung: Only update available threshold limits Tushar Behera
  2014-04-24  3:17 ` Tushar Behera
  2014-04-24  6:18 ` Amit Kachhap
@ 2014-04-24 10:48 ` Bartlomiej Zolnierkiewicz
  2014-04-24 11:30   ` Tushar Behera
  2 siblings, 1 reply; 7+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2014-04-24 10:48 UTC (permalink / raw)
  To: Tushar Behera
  Cc: linux-kernel, linux-samsung-soc, linux-pm, rui.zhang, eduardo.valentin


Hi,

On Monday, April 14, 2014 11:08:15 AM Tushar Behera wrote:
> Currently the threshold limits are updated in 2 stages, once for all
> software trigger levels and again for hardware trip point.
> 
> While updating the software trigger levels, it overwrites the threshold
> limit for hardware trip point thereby forcing the Exynos core to issue
> an emergency shutdown.

On what SoC type have you encountered this problem?  It doesn't seem to
happen on older SoCs (at least Exynos4210 and Exynos4x12 ones).

> Updating only the required fields in threshold register fixes this issue.

With the current code there is indeed a time window during which threshold
limit for hardware trip point is set to zero so the fix is correct.

> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
> ---
> Based on v3.15-rc1.
> 
>  drivers/thermal/samsung/exynos_tmu.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 0d96a51..ffccc89 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -225,6 +225,8 @@ skip_calib_data:
>  			trigger_levs++;
>  	}
>  
> +	rising_threshold = readl(data->base + reg->threshold_th0);

You may move this inside "} else {" block as rising_threshold
is not used for data->soc == SOC_ARCH_EXYNOS4210 case.

Also rising_threshold initialization to zero at the beginning of
exynos_tmu_initialize() is not needed anylonger.

> +
>  	if (data->soc == SOC_ARCH_EXYNOS4210) {
>  		/* Write temperature code for threshold */
>  		threshold_code = temp_to_code(data, pdata->threshold);
> @@ -249,6 +251,7 @@ skip_calib_data:
>  				ret = threshold_code;
>  				goto out;
>  			}
> +			rising_threshold &= ~(0xff << 8 * i);
>  			rising_threshold |= threshold_code << 8 * i;
>  			if (pdata->threshold_falling) {
>  				threshold_code = temp_to_code(data,
> @@ -281,6 +284,7 @@ skip_calib_data:
>  			}
>  			if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
>  				/* 1-4 level to be assigned in th0 reg */
> +				rising_threshold &= ~(0xff << 8 * i);
>  				rising_threshold |= threshold_code << 8 * i;
>  				writel(rising_threshold,
>  					data->base + reg->threshold_th0);

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] thermal: samsung: Only update available threshold limits
  2014-04-24 10:48 ` Bartlomiej Zolnierkiewicz
@ 2014-04-24 11:30   ` Tushar Behera
  0 siblings, 0 replies; 7+ messages in thread
From: Tushar Behera @ 2014-04-24 11:30 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: linux-kernel, linux-samsung-soc, linux-pm, rui.zhang, eduardo.valentin

On 04/24/2014 04:18 PM, Bartlomiej Zolnierkiewicz wrote:
> 
> Hi,
> 
> On Monday, April 14, 2014 11:08:15 AM Tushar Behera wrote:
>> Currently the threshold limits are updated in 2 stages, once for all
>> software trigger levels and again for hardware trip point.
>>
>> While updating the software trigger levels, it overwrites the threshold
>> limit for hardware trip point thereby forcing the Exynos core to issue
>> an emergency shutdown.
> 
> On what SoC type have you encountered this problem?  It doesn't seem to
> happen on older SoCs (at least Exynos4210 and Exynos4x12 ones).
> 

I found this issue while testing on Exynos5420 with these patches [1].

[1] https://lkml.org/lkml/2013/8/1/38

>> Updating only the required fields in threshold register fixes this issue.
> 
> With the current code there is indeed a time window during which threshold
> limit for hardware trip point is set to zero so the fix is correct.
> 


-- 
Tushar Behera

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] thermal: samsung: Only update available threshold limits
  2014-04-24  6:18 ` Amit Kachhap
@ 2014-05-09 11:47   ` Tushar Behera
  2014-05-15  8:45   ` Zhang Rui
  1 sibling, 0 replies; 7+ messages in thread
From: Tushar Behera @ 2014-05-09 11:47 UTC (permalink / raw)
  To: rui.zhang, eduardo.valentin
  Cc: Amit Kachhap, linux-kernel, linux-samsung-soc, linux-pm

On 04/24/2014 11:48 AM, Amit Kachhap wrote:
> On 4/14/14, Tushar Behera <tushar.behera@linaro.org> wrote:
>> Currently the threshold limits are updated in 2 stages, once for all
>> software trigger levels and again for hardware trip point.
> I guess the first stage is bootloader as could not find this in this file.
> Anyways the changes looks fine to me.
> 
> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
> 

Can this the patch be merged now?

>>
>> While updating the software trigger levels, it overwrites the threshold
>> limit for hardware trip point thereby forcing the Exynos core to issue
>> an emergency shutdown.
>>
>> Updating only the required fields in threshold register fixes this issue.
>>
>> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
>> ---
>> Based on v3.15-rc1.
>>
>>  drivers/thermal/samsung/exynos_tmu.c |    4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/thermal/samsung/exynos_tmu.c
>> b/drivers/thermal/samsung/exynos_tmu.c
>> index 0d96a51..ffccc89 100644
>> --- a/drivers/thermal/samsung/exynos_tmu.c
>> +++ b/drivers/thermal/samsung/exynos_tmu.c
>> @@ -225,6 +225,8 @@ skip_calib_data:
>>  			trigger_levs++;
>>  	}
>>
>> +	rising_threshold = readl(data->base + reg->threshold_th0);
>> +
>>  	if (data->soc == SOC_ARCH_EXYNOS4210) {
>>  		/* Write temperature code for threshold */
>>  		threshold_code = temp_to_code(data, pdata->threshold);
>> @@ -249,6 +251,7 @@ skip_calib_data:
>>  				ret = threshold_code;
>>  				goto out;
>>  			}
>> +			rising_threshold &= ~(0xff << 8 * i);
>>  			rising_threshold |= threshold_code << 8 * i;
>>  			if (pdata->threshold_falling) {
>>  				threshold_code = temp_to_code(data,
>> @@ -281,6 +284,7 @@ skip_calib_data:
>>  			}
>>  			if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
>>  				/* 1-4 level to be assigned in th0 reg */
>> +				rising_threshold &= ~(0xff << 8 * i);
>>  				rising_threshold |= threshold_code << 8 * i;
>>  				writel(rising_threshold,
>>  					data->base + reg->threshold_th0);
>> --
>> 1.7.9.5
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc"
>> in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>


-- 
Tushar Behera

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] thermal: samsung: Only update available threshold limits
  2014-04-24  6:18 ` Amit Kachhap
  2014-05-09 11:47   ` Tushar Behera
@ 2014-05-15  8:45   ` Zhang Rui
  1 sibling, 0 replies; 7+ messages in thread
From: Zhang Rui @ 2014-05-15  8:45 UTC (permalink / raw)
  To: Amit Kachhap
  Cc: Tushar Behera, linux-kernel, linux-samsung-soc, linux-pm,
	eduardo.valentin

On 四, 2014-04-24 at 11:48 +0530, Amit Kachhap wrote:
> On 4/14/14, Tushar Behera <tushar.behera@linaro.org> wrote:
> > Currently the threshold limits are updated in 2 stages, once for all
> > software trigger levels and again for hardware trip point.
> I guess the first stage is bootloader as could not find this in this file.
> Anyways the changes looks fine to me.
> 
> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com>

applied.

thanks,
rui
> 
> >
> > While updating the software trigger levels, it overwrites the threshold
> > limit for hardware trip point thereby forcing the Exynos core to issue
> > an emergency shutdown.
> >
> > Updating only the required fields in threshold register fixes this issue.
> >
> > Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
> > ---
> > Based on v3.15-rc1.
> >
> >  drivers/thermal/samsung/exynos_tmu.c |    4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > b/drivers/thermal/samsung/exynos_tmu.c
> > index 0d96a51..ffccc89 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.c
> > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > @@ -225,6 +225,8 @@ skip_calib_data:
> >  			trigger_levs++;
> >  	}
> >
> > +	rising_threshold = readl(data->base + reg->threshold_th0);
> > +
> >  	if (data->soc == SOC_ARCH_EXYNOS4210) {
> >  		/* Write temperature code for threshold */
> >  		threshold_code = temp_to_code(data, pdata->threshold);
> > @@ -249,6 +251,7 @@ skip_calib_data:
> >  				ret = threshold_code;
> >  				goto out;
> >  			}
> > +			rising_threshold &= ~(0xff << 8 * i);
> >  			rising_threshold |= threshold_code << 8 * i;
> >  			if (pdata->threshold_falling) {
> >  				threshold_code = temp_to_code(data,
> > @@ -281,6 +284,7 @@ skip_calib_data:
> >  			}
> >  			if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
> >  				/* 1-4 level to be assigned in th0 reg */
> > +				rising_threshold &= ~(0xff << 8 * i);
> >  				rising_threshold |= threshold_code << 8 * i;
> >  				writel(rising_threshold,
> >  					data->base + reg->threshold_th0);
> > --
> > 1.7.9.5
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc"
> > in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-15  8:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-14  5:38 [PATCH] thermal: samsung: Only update available threshold limits Tushar Behera
2014-04-24  3:17 ` Tushar Behera
2014-04-24  6:18 ` Amit Kachhap
2014-05-09 11:47   ` Tushar Behera
2014-05-15  8:45   ` Zhang Rui
2014-04-24 10:48 ` Bartlomiej Zolnierkiewicz
2014-04-24 11:30   ` Tushar Behera

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).