linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI / CPPC: Use 64-bit arithmetic instead of 32-bit
@ 2018-02-06 23:36 Gustavo A. R. Silva
  2018-02-08  9:49 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-02-06 23:36 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown
  Cc: linux-acpi, linux-kernel, Gustavo A. R. Silva

Add suffix ULL to constant 500 in order to give the compiler complete
information about the proper arithmetic to use. Notice that this
constant is used in a context that expects an expression of type
u64 (64 bits, unsigned).

The expression NUM_RETRIES * cppc_ss->latency at line 578, which at
preprocessing time translates to 500 * cppc_ss->latency is currently
being evaluated using 32-bit arithmetic.

Addresses-Coverity-ID: 1382602
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Notice that another option is to cast NUM_RETRIES to u64 at line 578,
but as there is only one instace in which this macro is being used I
think adding the ULL is just enough.

 drivers/acpi/cppc_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 06ea474..0afbb26 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -119,7 +119,7 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
  * to PCC commands. Keeping it high enough to cover emulators where
  * the processors run painfully slow.
  */
-#define NUM_RETRIES 500
+#define NUM_RETRIES 500ULL
 
 struct cppc_attr {
 	struct attribute attr;
-- 
2.7.4


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

* Re: [PATCH] ACPI / CPPC: Use 64-bit arithmetic instead of 32-bit
  2018-02-06 23:36 [PATCH] ACPI / CPPC: Use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
@ 2018-02-08  9:49 ` Rafael J. Wysocki
  2018-02-08 16:40   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2018-02-08  9:49 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Len Brown, linux-acpi, linux-kernel, Gustavo A. R. Silva

On Wednesday, February 7, 2018 12:36:17 AM CET Gustavo A. R. Silva wrote:
> Add suffix ULL to constant 500 in order to give the compiler complete
> information about the proper arithmetic to use. Notice that this
> constant is used in a context that expects an expression of type
> u64 (64 bits, unsigned).
> 
> The expression NUM_RETRIES * cppc_ss->latency at line 578, which at
> preprocessing time translates to 500 * cppc_ss->latency is currently
> being evaluated using 32-bit arithmetic.
> 
> Addresses-Coverity-ID: 1382602
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Notice that another option is to cast NUM_RETRIES to u64 at line 578,
> but as there is only one instace in which this macro is being used I
> think adding the ULL is just enough.
> 
>  drivers/acpi/cppc_acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index 06ea474..0afbb26 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -119,7 +119,7 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
>   * to PCC commands. Keeping it high enough to cover emulators where
>   * the processors run painfully slow.
>   */
> -#define NUM_RETRIES 500
> +#define NUM_RETRIES 500ULL
>  
>  struct cppc_attr {
>  	struct attribute attr;
> 

Applied, thanks!



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

* Re: [PATCH] ACPI / CPPC: Use 64-bit arithmetic instead of 32-bit
  2018-02-08  9:49 ` Rafael J. Wysocki
@ 2018-02-08 16:40   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-02-08 16:40 UTC (permalink / raw)
  To: Rafael J. Wysocki, Gustavo A. R. Silva
  Cc: Len Brown, linux-acpi, linux-kernel



On 02/08/2018 03:49 AM, Rafael J. Wysocki wrote:
> On Wednesday, February 7, 2018 12:36:17 AM CET Gustavo A. R. Silva wrote:
>> Add suffix ULL to constant 500 in order to give the compiler complete
>> information about the proper arithmetic to use. Notice that this
>> constant is used in a context that expects an expression of type
>> u64 (64 bits, unsigned).
>>
>> The expression NUM_RETRIES * cppc_ss->latency at line 578, which at
>> preprocessing time translates to 500 * cppc_ss->latency is currently
>> being evaluated using 32-bit arithmetic.
>>
>> Addresses-Coverity-ID: 1382602
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> Notice that another option is to cast NUM_RETRIES to u64 at line 578,
>> but as there is only one instace in which this macro is being used I
>> think adding the ULL is just enough.
>>
>>   drivers/acpi/cppc_acpi.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
>> index 06ea474..0afbb26 100644
>> --- a/drivers/acpi/cppc_acpi.c
>> +++ b/drivers/acpi/cppc_acpi.c
>> @@ -119,7 +119,7 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
>>    * to PCC commands. Keeping it high enough to cover emulators where
>>    * the processors run painfully slow.
>>    */
>> -#define NUM_RETRIES 500
>> +#define NUM_RETRIES 500ULL
>>   
>>   struct cppc_attr {
>>   	struct attribute attr;
>>
> 
> Applied, thanks!
> 
> 

Thank you, Rafael.

-- 
Gustavo

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

end of thread, other threads:[~2018-02-08 17:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-06 23:36 [PATCH] ACPI / CPPC: Use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
2018-02-08  9:49 ` Rafael J. Wysocki
2018-02-08 16:40   ` Gustavo A. R. Silva

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