linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] broken mdelay
@ 2006-10-26 14:12 Julian Bradfield
  2006-10-29 18:43 ` Blaisorblade
  0 siblings, 1 reply; 3+ messages in thread
From: Julian Bradfield @ 2006-10-26 14:12 UTC (permalink / raw)
  To: user-mode-linux-devel

A few years ago, I reported a problem with mdelay (that it basically
didn't work) - see

http://marc.theaimsgroup.com/?l=user-mode-linux-devel&m=103774842828993&w=2

and preceding messages.

I see the problem is still there in 2.6.18 (I find it because I insert an
mdelay(1000) into one of the ubd routines to simulate the effect of
busy-waiting on i/o in one of my practical exercises).

Here's the patch I currently use to fix it. I can't remember now how I
produced this patch four years ago, but it should make sense in
conjunction with the above referenced message.

--- arch/um/sys-i386/delay.c.dist	2006-10-26 14:50:38.069023000 +0100
+++ arch/um/sys-i386/delay.c	2006-10-26 14:50:42.527846000 +0100
@@ -3,7 +3,7 @@
 #include <linux/delay.h>
 #include <asm/param.h>
 
-void __delay(unsigned long time)
+static void __loop_delay(unsigned long loops)
 {
 	/* Stolen from the i386 __loop_delay */
 	int d0;
@@ -14,27 +14,28 @@
 		".align 16\n"
 		"2:\tdecl %0\n\tjns 2b"
 		:"=&a" (d0)
-		:"0" (time));
+		:"0" (loops));
 }
 
-void __udelay(unsigned long usecs)
+void __delay(unsigned long loops)
 {
-	int i, n;
-
-	n = (loops_per_jiffy * HZ * usecs) / MILLION;
-        for(i=0;i<n;i++)
-                cpu_relax();
+	__loop_delay(loops);
 }
 
-EXPORT_SYMBOL(__udelay);
-
-void __const_udelay(unsigned long usecs)
+inline void __const_udelay(unsigned long xloops)
 {
-	int i, n;
+	int d0;
+	__asm__("mull %0"
+		:"=d" (xloops), "=&a" (d0)
+		:"1" (xloops),"0" (loops_per_jiffy));
+        __delay(xloops * HZ);
+}
 
-	n = (loops_per_jiffy * HZ * usecs) / MILLION;
-        for(i=0;i<n;i++)
-                cpu_relax();
+void __udelay(unsigned long usecs)
+{
+	__const_udelay(usecs * 0x000010c6);  /* 2**32 / 1000000 */
 }
 
+EXPORT_SYMBOL(__udelay);
+
 EXPORT_SYMBOL(__const_udelay);

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

end of thread, other threads:[~2006-10-30 21:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-26 14:12 [uml-devel] broken mdelay Julian Bradfield
2006-10-29 18:43 ` Blaisorblade
2006-10-30 21:12   ` extmaillist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox