* [PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case
@ 2017-02-08 16:00 Andy Shevchenko
2017-02-10 4:24 ` Rajneesh Bhardwaj
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2017-02-08 16:00 UTC (permalink / raw)
To: linux-kernel, platform-driver-x86
Cc: Andy Shevchenko, Shanth Murthy, Rajneesh Bhardwaj, Zha Qipeng,
Darren Hart, Andy Shevchenko
On 32-bit x86 platforms we can't do 64-bit divisions:
ERROR: "__udivdi3" [drivers/platform/x86/intel_pmc_ipc.ko] undefined!
Replace plain division by do_div() macro call.
Reported-by: Darren Hart <dvhart@infradead.org>
Cc: Shanth Murthy <shanth.murthy@intel.com>
Cc: Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/platform/x86/intel_pmc_ipc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 46202b6e7c87..8ad4d7b43423 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -62,7 +62,12 @@
#define GCR_TELEM_SHLW_S0IX_OFFSET 0x1080
/* Residency with clock rate at 19.2MHz to usecs */
-#define S0IX_RESIDENCY_IN_USECS(d, s) (((d) + (s)) * 10 / 192)
+#define S0IX_RESIDENCY_IN_USECS(d, s) \
+({ \
+ u64 result = 10ull * ((d) + (s)); \
+ do_div(result, 192); \
+ result; \
+})
/*
* 16-byte buffer for sending data associated with IPC command.
--
2.11.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case
2017-02-08 16:00 [PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case Andy Shevchenko
@ 2017-02-10 4:24 ` Rajneesh Bhardwaj
2017-02-10 11:52 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Rajneesh Bhardwaj @ 2017-02-10 4:24 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-kernel, platform-driver-x86, Shanth Murthy, Zha Qipeng,
Darren Hart, Andy Shevchenko
On Wed, Feb 08, 2017 at 06:00:28PM +0200, Andy Shevchenko wrote:
> On 32-bit x86 platforms we can't do 64-bit divisions:
>
> ERROR: "__udivdi3" [drivers/platform/x86/intel_pmc_ipc.ko] undefined!
>
> Replace plain division by do_div() macro call.
>
> Reported-by: Darren Hart <dvhart@infradead.org>
> Cc: Shanth Murthy <shanth.murthy@intel.com>
> Cc: Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/platform/x86/intel_pmc_ipc.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
> index 46202b6e7c87..8ad4d7b43423 100644
> --- a/drivers/platform/x86/intel_pmc_ipc.c
> +++ b/drivers/platform/x86/intel_pmc_ipc.c
> @@ -62,7 +62,12 @@
> #define GCR_TELEM_SHLW_S0IX_OFFSET 0x1080
>
> /* Residency with clock rate at 19.2MHz to usecs */
> -#define S0IX_RESIDENCY_IN_USECS(d, s) (((d) + (s)) * 10 / 192)
> +#define S0IX_RESIDENCY_IN_USECS(d, s) \
> +({ \
> + u64 result = 10ull * ((d) + (s)); \
> + do_div(result, 192); \
> + result; \
> +})
>
Looks good, we verified it. We are planning to squash this one and send V2.
Hope thats fine?
> /*
> * 16-byte buffer for sending data associated with IPC command.
> --
> 2.11.0
>
--
Best Regards,
Rajneesh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case
2017-02-10 4:24 ` Rajneesh Bhardwaj
@ 2017-02-10 11:52 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2017-02-10 11:52 UTC (permalink / raw)
To: Rajneesh Bhardwaj
Cc: Andy Shevchenko, linux-kernel, Platform Driver, Shanth Murthy,
Zha Qipeng, Darren Hart, Andy Shevchenko
On Fri, Feb 10, 2017 at 6:24 AM, Rajneesh Bhardwaj
<rajneesh.bhardwaj@intel.com> wrote:
> On Wed, Feb 08, 2017 at 06:00:28PM +0200, Andy Shevchenko wrote:
>> On 32-bit x86 platforms we can't do 64-bit divisions:
>>
>> ERROR: "__udivdi3" [drivers/platform/x86/intel_pmc_ipc.ko] undefined!
>>
>> Replace plain division by do_div() macro call.
>>
>> Reported-by: Darren Hart <dvhart@infradead.org>
>> Cc: Shanth Murthy <shanth.murthy@intel.com>
>> Cc: Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> ---
>> drivers/platform/x86/intel_pmc_ipc.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
>> index 46202b6e7c87..8ad4d7b43423 100644
>> --- a/drivers/platform/x86/intel_pmc_ipc.c
>> +++ b/drivers/platform/x86/intel_pmc_ipc.c
>> @@ -62,7 +62,12 @@
>> #define GCR_TELEM_SHLW_S0IX_OFFSET 0x1080
>>
>> /* Residency with clock rate at 19.2MHz to usecs */
>> -#define S0IX_RESIDENCY_IN_USECS(d, s) (((d) + (s)) * 10 / 192)
>> +#define S0IX_RESIDENCY_IN_USECS(d, s) \
>> +({ \
>> + u64 result = 10ull * ((d) + (s)); \
>> + do_div(result, 192); \
>> + result; \
>> +})
>>
>
> Looks good, we verified it. We are planning to squash this one and send V2.
> Hope thats fine?
Please, do!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-10 12:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-08 16:00 [PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case Andy Shevchenko
2017-02-10 4:24 ` Rajneesh Bhardwaj
2017-02-10 11:52 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®