linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -mm 2/6] cpu_relax(): ide_wait_stat()
@ 2006-06-21 20:59 Andreas Mohr
  2006-06-21 22:19 ` Alan Cox
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Mohr @ 2006-06-21 20:59 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-ide, linux-kernel


Add cpu_relax() to drivers/ide/ide-iops.c/ide_wait_stat().
Tiny whitespace fix.


Should be quite useful.

Tested on 2.6.17-mm1.

Signed-off-by: Andreas Mohr <andi@lisas.de>


diff -urN linux-2.6.17-mm1.orig/drivers/ide/ide-iops.c linux-2.6.17-mm1.my/drivers/ide/ide-iops.c
--- linux-2.6.17-mm1.orig/drivers/ide/ide-iops.c	2006-06-21 14:28:16.000000000 +0200
+++ linux-2.6.17-mm1.my/drivers/ide/ide-iops.c	2006-06-21 22:00:02.000000000 +0200
@@ -542,7 +542,7 @@
 	u8 stat;
 	int i;
 	unsigned long flags;
- 
+
 	/* bail early if we've exceeded max_failures */
 	if (drive->max_failures && (drive->failures > drive->max_failures)) {
 		*startstop = ide_stopped;
@@ -554,6 +554,7 @@
 		local_irq_set(flags);
 		timeout += jiffies;
 		while ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) {
+			cpu_relax();
 			if (time_after(jiffies, timeout)) {
 				/*
 				 * One last read after the timeout in case

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

* Re: [PATCH -mm 2/6] cpu_relax(): ide_wait_stat()
  2006-06-21 20:59 [PATCH -mm 2/6] cpu_relax(): ide_wait_stat() Andreas Mohr
@ 2006-06-21 22:19 ` Alan Cox
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2006-06-21 22:19 UTC (permalink / raw)
  To: Andreas Mohr; +Cc: Andrew Morton, linux-ide, linux-kernel

Ar Mer, 2006-06-21 am 22:59 +0200, ysgrifennodd Andreas Mohr:
> Add cpu_relax() to drivers/ide/ide-iops.c/ide_wait_stat().

You don't need cpu_relax() when the loop contains a reference to
external memory busses. The CPU will stall on the inb() anyway, and when
this occurs processors with multiple-threads will do the right thing
implicitly. If you could look at the instruction stream it would look
something like

dec count
jump out if zero
inb
read request to the bus
[stall]
then to the PCI bridge
[stall]
then eventually to the device
[Huge mindbogglingly relativley long period of time stalled]
answer finally arrives back over the PCI bus
compare
...


Same comment for floppy. Rest look ok

Perhaps this needs documenting however.

Alan


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

end of thread, other threads:[~2006-06-21 22:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-21 20:59 [PATCH -mm 2/6] cpu_relax(): ide_wait_stat() Andreas Mohr
2006-06-21 22:19 ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).