Skip to content

Commit

Permalink
x86: explicitly use edx in const delay function.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Glauber Costa authored and Ingo Molnar committed Jul 9, 2008
1 parent a76febe commit 7e58818
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion arch/x86/lib/delay_32.c
Expand Up @@ -114,7 +114,7 @@ inline void __const_udelay(unsigned long xloops)
int d0;

xloops *= 4;
__asm__("mull %0"
__asm__("mull %%edx"
:"=d" (xloops), "=&a" (d0)
:"1" (xloops), "0"
(cpu_data(raw_smp_processor_id()).loops_per_jiffy * (HZ/4)));
Expand Down
11 changes: 9 additions & 2 deletions arch/x86/lib/delay_64.c
Expand Up @@ -103,9 +103,16 @@ EXPORT_SYMBOL(__delay);

inline void __const_udelay(unsigned long xloops)
{
__delay(((xloops * HZ *
cpu_data(raw_smp_processor_id()).loops_per_jiffy) >> 32) + 1);
int d0;
xloops *= 4;
__asm__("mull %%edx"
:"=d" (xloops), "=&a" (d0)
:"1" (xloops), "0"
(cpu_data(raw_smp_processor_id()).loops_per_jiffy * (HZ/4)));

__delay(++xloops);
}

EXPORT_SYMBOL(__const_udelay);

void __udelay(unsigned long usecs)
Expand Down

0 comments on commit 7e58818

Please sign in to comment.