* [PATCH] 2.5.53 : drivers/char/ftape/lowlevel/ftape-calibr.c
@ 2002-12-29 2:04 Frank Davis
0 siblings, 0 replies; only message in thread
From: Frank Davis @ 2002-12-29 2:04 UTC (permalink / raw)
To: linux-kernel; +Cc: fdavis
Hello all,
The following patch swaps the save_flags/cli/restore_flags combo with a
spinlock. Please review.
Regards,
Frank
--- linux/drivers/char/ftape/lowlevel/ftape-calibr.c.old Sat Oct 19 12:04:19 2002
+++ linux/drivers/char/ftape/lowlevel/ftape-calibr.c Sat Dec 28 21:01:01 2002
@@ -35,9 +35,10 @@
# include <linux/timex.h>
#endif
#include <linux/ftape.h>
-#include "../lowlevel/ftape-tracing.h"
-#include "../lowlevel/ftape-calibr.h"
-#include "../lowlevel/fdc-io.h"
+#include "ftape-tracing.h"
+#include "ftape-calibr.h"
+#include "fdc-io.h"
+#include <linux/spinlock.h>
#undef DEBUG
@@ -62,6 +63,7 @@
* it will overflow only once per 30 seconds (on a 200MHz machine),
* which is plenty.
*/
+static spinlock_t ftape_calibar_lock = SPIN_LOCK_UNLOCKED;
unsigned int ftape_timestamp(void)
{
@@ -75,13 +77,12 @@
__u16 lo;
__u16 hi;
- save_flags(flags);
- cli();
+ spin_lock_irqsave(&ftape_calibar_lock, flags);
outb_p(0x00, 0x43); /* latch the count ASAP */
lo = inb_p(0x40); /* read the latched count */
lo |= inb(0x40) << 8;
hi = jiffies;
- restore_flags(flags);
+ spin_lock_irqrestore(&ftape_calibar_lock, flags);
return ((hi + 1) * (unsigned int) LATCH) - lo; /* downcounter ! */
#endif
}
@@ -94,12 +95,11 @@
unsigned int count;
unsigned long flags;
- save_flags(flags);
- cli();
+ spin_lock_irqsave(&ftape_calibar_lock, flags);
outb_p(0x00, 0x43); /* latch the count ASAP */
count = inb_p(0x40); /* read the latched count */
count |= inb(0x40) << 8;
- restore_flags(flags);
+ spin_unlock_irqrestore(&ftape_calibar_lock, flags);
return (LATCH - count); /* normal: downcounter */
#endif
}
@@ -150,14 +150,13 @@
int status;
TRACE_FUN(ft_t_any);
- save_flags(flags);
- cli();
+ spin_lock_irqsave(&ftape_calibar_lock, flags);
t0 = short_ftape_timestamp();
for (i = 0; i < 1000; ++i) {
status = inb(fdc.msr);
}
t1 = short_ftape_timestamp();
- restore_flags(flags);
+ spin_unlock_irqrestore(&ftape_calibar_lock, flags);
TRACE(ft_t_info, "inb() duration: %d nsec", ftape_timediff(t0, t1));
TRACE_EXIT;
}
@@ -241,8 +240,7 @@
*calibr_count =
*calibr_time = count; /* set TC to 1 */
- save_flags(flags);
- cli();
+ spin_lock_irqsave(&ftape_calibar_lock, flags);
fun(0); /* dummy, get code into cache */
t0 = short_ftape_timestamp();
fun(0); /* overhead + one test */
@@ -252,7 +250,7 @@
fun(count); /* overhead + count tests */
t1 = short_ftape_timestamp();
multiple = diff(t0, t1);
- restore_flags(flags);
+ spin_unlock_irqrestore(&ftape_calibar_lock, flags);
time = ftape_timediff(0, multiple - once);
tc = (1000 * time) / (count - 1);
TRACE(ft_t_any, "once:%3d us,%6d times:%6d us, TC:%5d ns",
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-12-29 2:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-29 2:04 [PATCH] 2.5.53 : drivers/char/ftape/lowlevel/ftape-calibr.c Frank Davis
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®