public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal: of: fix cooling_spec.args for 64bit
@ 2015-05-07  4:29 Wei Ni
  2015-05-07  9:51 ` Punit Agrawal
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Ni @ 2015-05-07  4:29 UTC (permalink / raw)
  To: edubezval, rui.zhang; +Cc: linux-pm, Wei Ni

The THERMAL_NO_LIMIT is defined as -1UL, when it is set in DT,
the of-thermal will use of_parse_phandle_with_args() to parse it.
Since the args is uint32_t, so in 32bit system, the of framework
will read it as 0xffffffff, it's the expected value "-1".
But in 64bit system, this value is read as 0x00000000ffffffff,
it's not a negative value, it will cause problems.

This change can fix this issue.

Signed-off-by: Wei Ni <wni@nvidia.com>
---
 drivers/thermal/of-thermal.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 9e8c614103ef..8d6b4070dea3 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -613,8 +613,10 @@ static int thermal_of_populate_bind_params(struct device_node *np,
 	}
 	__tbp->cooling_device = cooling_spec.np;
 	if (cooling_spec.args_count >= 2) { /* at least min and max */
-		__tbp->min = cooling_spec.args[0];
-		__tbp->max = cooling_spec.args[1];
+		__tbp->min = cooling_spec.args[0] == -1U ?
+			THERMAL_NO_LIMIT : cooling_spec.args[0];
+		__tbp->max = cooling_spec.args[1] == -1U ?
+			THERMAL_NO_LIMIT : cooling_spec.args[1];
 	} else {
 		pr_err("wrong reference to cooling device, missing limits\n");
 	}
-- 
1.9.1


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

* Re: [PATCH] thermal: of: fix cooling_spec.args for 64bit
  2015-05-07  4:29 [PATCH] thermal: of: fix cooling_spec.args for 64bit Wei Ni
@ 2015-05-07  9:51 ` Punit Agrawal
  2015-05-07 10:21   ` Wei Ni
  0 siblings, 1 reply; 3+ messages in thread
From: Punit Agrawal @ 2015-05-07  9:51 UTC (permalink / raw)
  To: Wei Ni; +Cc: edubezval, rui.zhang, linux-pm

Wei Ni <wni@nvidia.com> writes:

> The THERMAL_NO_LIMIT is defined as -1UL, when it is set in DT,
> the of-thermal will use of_parse_phandle_with_args() to parse it.
> Since the args is uint32_t, so in 32bit system, the of framework
> will read it as 0xffffffff, it's the expected value "-1".
> But in 64bit system, this value is read as 0x00000000ffffffff,
> it's not a negative value, it will cause problems.
>
> This change can fix this issue.

If I understand the issue correctly, a patch fixing this is already
merged. Does "commit a940cb34f: thermal: Fix cdev registration with
THERMAL_NO_LIMIT on 64bit" not work for you?

>
> Signed-off-by: Wei Ni <wni@nvidia.com>
> ---
>  drivers/thermal/of-thermal.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index 9e8c614103ef..8d6b4070dea3 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -613,8 +613,10 @@ static int thermal_of_populate_bind_params(struct device_node *np,
>  	}
>  	__tbp->cooling_device = cooling_spec.np;
>  	if (cooling_spec.args_count >= 2) { /* at least min and max */
> -		__tbp->min = cooling_spec.args[0];
> -		__tbp->max = cooling_spec.args[1];
> +		__tbp->min = cooling_spec.args[0] == -1U ?
> +			THERMAL_NO_LIMIT : cooling_spec.args[0];
> +		__tbp->max = cooling_spec.args[1] == -1U ?
> +			THERMAL_NO_LIMIT : cooling_spec.args[1];
>  	} else {
>  		pr_err("wrong reference to cooling device, missing limits\n");
>  	}

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

* Re: [PATCH] thermal: of: fix cooling_spec.args for 64bit
  2015-05-07  9:51 ` Punit Agrawal
@ 2015-05-07 10:21   ` Wei Ni
  0 siblings, 0 replies; 3+ messages in thread
From: Wei Ni @ 2015-05-07 10:21 UTC (permalink / raw)
  To: Punit Agrawal; +Cc: edubezval, rui.zhang, linux-pm



On 2015年05月07日 17:51, Punit Agrawal wrote:
> Wei Ni <wni@nvidia.com> writes:
> 
>> The THERMAL_NO_LIMIT is defined as -1UL, when it is set in DT,
>> the of-thermal will use of_parse_phandle_with_args() to parse it.
>> Since the args is uint32_t, so in 32bit system, the of framework
>> will read it as 0xffffffff, it's the expected value "-1".
>> But in 64bit system, this value is read as 0x00000000ffffffff,
>> it's not a negative value, it will cause problems.
>>
>> This change can fix this issue.
> 
> If I understand the issue correctly, a patch fixing this is already
> merged. Does "commit a940cb34f: thermal: Fix cdev registration with
> THERMAL_NO_LIMIT on 64bit" not work for you?

Hmm, yes, this fix can work for me.
I made a mistake, and didn't notice this change.
Sorry, please ignore my patch.

Wei.

> 
>>
>> Signed-off-by: Wei Ni <wni@nvidia.com>
>> ---
>>  drivers/thermal/of-thermal.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
>> index 9e8c614103ef..8d6b4070dea3 100644
>> --- a/drivers/thermal/of-thermal.c
>> +++ b/drivers/thermal/of-thermal.c
>> @@ -613,8 +613,10 @@ static int thermal_of_populate_bind_params(struct device_node *np,
>>  	}
>>  	__tbp->cooling_device = cooling_spec.np;
>>  	if (cooling_spec.args_count >= 2) { /* at least min and max */
>> -		__tbp->min = cooling_spec.args[0];
>> -		__tbp->max = cooling_spec.args[1];
>> +		__tbp->min = cooling_spec.args[0] == -1U ?
>> +			THERMAL_NO_LIMIT : cooling_spec.args[0];
>> +		__tbp->max = cooling_spec.args[1] == -1U ?
>> +			THERMAL_NO_LIMIT : cooling_spec.args[1];
>>  	} else {
>>  		pr_err("wrong reference to cooling device, missing limits\n");
>>  	}
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

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

end of thread, other threads:[~2015-05-07 10:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-07  4:29 [PATCH] thermal: of: fix cooling_spec.args for 64bit Wei Ni
2015-05-07  9:51 ` Punit Agrawal
2015-05-07 10:21   ` Wei Ni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox