platform/x86: intel_pmc_ipc: fix division in 32-bit case
PATCH 1/1 platform/x86: intel_pmc_ipc: fix division in 32-bit case
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.
--- drivers/platform/x86/intel_pmc_ipc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/platform/x86/intel_pmc_ipc.c +6 -1
@@ -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.
Signature · 1 line
2.11.0
Quoted 20 lines · 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 <[email protected]>Cc Shanth Murthy <[email protected]>Cc Rajneesh Bhardwaj <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/platform/x86/intel_pmc_ipc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/platform/x86/intel_pmc_ipc.c +0
-0@@ -62,7 +62,12 @@#define GCR_TELEM_SHLW_S0IX_OFFSET 0x1080
drivers/platform/x86/intel_pmc_ipc.c line 71
Quoted 10 lines
drivers/platform/x86/intel_pmc_ipc.c +6
-1/* 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?
Quoted 5 lines
drivers/platform/x86/intel_pmc_ipc.c +0
-0/* * 16-byte buffer for sending data associated with IPC command. Signature · 1 line
2.11.0
Signature · 2 lines
Best Regards, Rajneesh
Quoted 22 lines · Rajneesh Bhardwaj
Quoted 21 lines · 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 <[email protected]>Cc Shanth Murthy <[email protected]>Cc Rajneesh Bhardwaj <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/platform/x86/intel_pmc_ipc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/platform/x86/intel_pmc_ipc.c +0
-0@@ -62,7 +62,12 @@#define GCR_TELEM_SHLW_S0IX_OFFSET 0x1080
Quoted 12 lines
drivers/platform/x86/intel_pmc_ipc.c line 71
Quoted 9 lines
drivers/platform/x86/intel_pmc_ipc.c +6
-1/* 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!
Signature · 2 lines
With Best Regards, Andy Shevchenko