Skip to content

Commit 7e58818

Browse files
glommerIngo Molnar
authored andcommitted
x86: explicitly use edx in const delay function.
For x86_64, we can't just use %0, as it would generate a mul against rdx, which is not really what we want (note the ">> 32" in x86_64 version). Using a u64 variable with a shift in i386 generates bad code, so the solution is to explicitly use %%edx in inline assembly for both. Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent a76febe commit 7e58818

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎arch/x86/lib/delay_32.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ inline void __const_udelay(unsigned long xloops)
114114
int d0;
115115

116116
xloops *= 4;
117-
__asm__("mull %0"
117+
__asm__("mull %%edx"
118118
:"=d" (xloops), "=&a" (d0)
119119
:"1" (xloops), "0"
120120
(cpu_data(raw_smp_processor_id()).loops_per_jiffy * (HZ/4)));

‎arch/x86/lib/delay_64.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,16 @@ EXPORT_SYMBOL(__delay);
103103

104104
inline void __const_udelay(unsigned long xloops)
105105
{
106-
__delay(((xloops * HZ *
107-
cpu_data(raw_smp_processor_id()).loops_per_jiffy) >> 32) + 1);
106+
int d0;
107+
xloops *= 4;
108+
__asm__("mull %%edx"
109+
:"=d" (xloops), "=&a" (d0)
110+
:"1" (xloops), "0"
111+
(cpu_data(raw_smp_processor_id()).loops_per_jiffy * (HZ/4)));
112+
113+
__delay(++xloops);
108114
}
115+
109116
EXPORT_SYMBOL(__const_udelay);
110117

111118
void __udelay(unsigned long usecs)

0 commit comments

Comments
 (0)