login
Header Space

 
 

Re: Linux 2.6.25-rc4

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Anders Eriksson <aeriksson@...>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@...>, Rafael J. Wysocki <rjw@...>, Jens Axboe <jens.axboe@...>, Ingo Molnar <mingo@...>, Linux Kernel Mailing List <linux-kernel@...>
Date: Tuesday, March 18, 2008 - 11:41 am

On Tue, 18 Mar 2008, Anders Eriksson wrote:

Uhhuh. That's READY_STAT | SRV_STAT. No error, no DRQ, no nothing.

And I think this also explains why your bisect found that old commit
4d977e43d8ae758434e603cf2455d955f71c77c4 to be problematic.

The thing is, that commit - and the taskfile code that it then all got 
replaced with - use this totally bogus check:

	OK_STAT(stat, DRQ_STAT, BAD_R_STAT)
		...

which basically says that the only OK situation is that no error bits are 
set, and DRQ _has_ to be set.

Before that, the code did the right thing in any _combination_ of bits: if 
DRQ wasn't set, it would just say "oh, ok, the command is done", but the 
taskfile code and the 4d977e43d commit code thinks that DRQ not being set 
is an error, and then it gets confused when the actual error bits aren't 
set!

I think that whole way of writing code is totally horribly bad! It's not 
only trying to tie together bits that are independent, but it actually 
gets a lot harder to understand too, because now you have *four* different 
cases ("no error, no drq", "error, no drq", "no error, drq", "error, drq") 
but you use one test to try to find the one you expect, and then the code 
easily messes up on all the other three cases!

I personally think the code should be written more like the suggested 
appended patch, which checks those error and drq bits _separately_, and 
doesn't try to mix them up, because they really are independent.

Anders, does this patch change any behaviour?

It basically does:

 - if the error bits are set, we just error out (and expect ide_error() to 
   flush the data fifo if necessary)

 - if the DRQ bit is *not* set, something unexpected happened, and we go 
   out of line to handle that.

 - otherwise we just do the data in phase and see if we're all done.

Then, in the unexpected case, we try to see what is actually going on, and 
that's where we do the same thing we always used to do (ie the thing that 
commit 4d977e43d messed up): if the drive tells us it's all done, we just 
end the command.

IOW, if we have no errors, no drq, and the drive says "ready and not 
busy", we just finish the command!

I think this is much more readable, and also less fragile, than using that 
OK_STAT() macro to mix up DRQ and errors in odd ways. Keep them separate 
events.

			Linus

---
 drivers/ide/ide-taskfile.c |   36 +++++++++++++++++++++++++++---------
 1 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 0518a2e..4c86a8d 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -423,6 +423,25 @@ void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat)
 }
 
 /*
+ * We got an interrupt on a task_in case, but no errors and no DRQ.
+ *
+ * It might be a spurious irq (shared irq), but it might be a
+ * command that had no output.
+ */
+static ide_startstop_t task_in_unexpected(ide_drive_t *drive, struct request *rq, u8 stat)
+{
+	/* Command all done? */
+	if (OK_STAT(stat, READY_STAT, BUSY_STAT)) {
+		task_end_request(drive, rq, stat);
+		return ide_stopped;
+	}
+
+	/* Assume it was a spurious irq */
+	ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL);
+	return ide_started;
+}
+
+/*
  * Handler for command with PIO data-in phase (Read/Read Multiple).
  */
 static ide_startstop_t task_in_intr(ide_drive_t *drive)
@@ -431,18 +450,17 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive)
 	struct request *rq = HWGROUP(drive)->rq;
 	u8 stat = ide_read_status(drive);
 
-	/* new way for dealing with premature shared PCI interrupts */
-	if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) {
-		if (stat & (ERR_STAT | DRQ_STAT))
-			return task_error(drive, rq, __FUNCTION__, stat);
-		/* No data yet, so wait for another IRQ. */
-		ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL);
-		return ide_started;
-	}
+	/* Error? */
+	if (stat & ERR_STAT)
+		return task_error(drive, rq, __FUNCTION__, stat);
+
+	/* No error, but didn't want any data either? Odd. */
+	if (!(stat & DRQ_STAT))
+		return task_in_unexpected(drive, rq, stat);
 
 	ide_pio_datablock(drive, rq, 0);
 
-	/* If it was the last datablock check status and finish transfer. */
+	/* Are we done? Check status and finish transfer. */
 	if (!hwif->nleft) {
 		stat = wait_drive_not_busy(drive);
 		if (!OK_STAT(stat, 0, BAD_STAT))
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Linux 2.6.25-rc4, Linus Torvalds, (Wed Mar 5, 1:03 am)
Re: [patch] drivers/char/esp.c: fix bootup lockup, Jiri Slaby, (Sun Mar 9, 9:41 am)
Re: [patch] drivers/char/esp.c: fix bootup lockup, Rafael J. Wysocki, (Sun Mar 9, 6:49 pm)
Re: [patch] drivers/char/esp.c: fix bootup lockup, Jiri Slaby, (Sun Mar 9, 7:04 pm)
Re: Linux 2.6.25-rc4, Ingo Molnar, (Thu Mar 6, 5:00 am)
Re: Linux 2.6.25-rc4, Jens Axboe, (Thu Mar 6, 8:59 am)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Thu Mar 6, 9:38 am)
Re: Linux 2.6.25-rc4, Ingo Molnar, (Thu Mar 6, 9:33 am)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Thu Mar 6, 10:06 am)
Re: Linux 2.6.25-rc4, Jens Axboe, (Thu Mar 6, 9:55 am)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Thu Mar 6, 5:17 pm)
Re: Linux 2.6.25-rc4, Jens Axboe, (Fri Mar 7, 4:48 am)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Fri Mar 7, 6:04 pm)
Re: Linux 2.6.25-rc4 , Linus Torvalds, (Sat Mar 8, 4:22 pm)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Sat Mar 8, 5:05 pm)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Mon Mar 10, 4:55 am)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Mon Mar 10, 8:36 am)
Re: Linux 2.6.25-rc4, Rafael J. Wysocki, (Mon Mar 10, 9:10 am)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Mon Mar 10, 10:04 am)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Sun Mar 16, 10:01 am)
Re: Linux 2.6.25-rc4 , Linus Torvalds, (Sun Mar 16, 12:56 pm)
Re: Linux 2.6.25-rc4 , Linus Torvalds, (Sun Mar 16, 1:13 pm)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Sun Mar 16, 2:18 pm)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Sun Mar 16, 2:07 pm)
Re: Linux 2.6.25-rc4, Linus Torvalds, (Sun Mar 16, 2:13 pm)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Sun Mar 16, 3:54 pm)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Sun Mar 16, 6:59 pm)
Re: Linux 2.6.25-rc4 , Linus Torvalds, (Sun Mar 16, 7:27 pm)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Mon Mar 17, 5:09 pm)
Re: Linux 2.6.25-rc4 , Linus Torvalds, (Mon Mar 17, 6:52 pm)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Mon Mar 17, 8:18 pm)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Tue Mar 18, 9:03 am)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Tue Mar 18, 9:32 am)
Re: Linux 2.6.25-rc4 , Linus Torvalds, (Tue Mar 18, 11:41 am)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Tue Mar 18, 9:21 pm)
Re: Linux 2.6.25-rc4, Linus Torvalds, (Tue Mar 18, 9:28 pm)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Tue Mar 18, 11:24 pm)
Re: Linux 2.6.25-rc4, Linus Torvalds, (Tue Mar 18, 11:28 pm)
Re: Linux 2.6.25-rc4, Linus Torvalds, (Tue Mar 18, 11:56 pm)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Wed Mar 19, 12:03 am)
Re: Linux 2.6.25-rc4, Linus Torvalds, (Wed Mar 19, 12:48 am)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Wed Mar 19, 7:14 am)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Tue Mar 18, 12:30 pm)
Re: Linux 2.6.25-rc4 , Linus Torvalds, (Tue Mar 18, 12:47 pm)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Tue Mar 18, 5:02 pm)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Tue Mar 18, 10:48 am)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Tue Mar 18, 11:10 am)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Sun Mar 16, 2:36 pm)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Sun Mar 16, 3:08 pm)
Re: Linux 2.6.25-rc4, Alan Cox, (Sun Mar 16, 2:56 pm)
Re: Linux 2.6.25-rc4, Linus Torvalds, (Sun Mar 16, 3:39 pm)
Re: Linux 2.6.25-rc4, Alan Cox, (Sun Mar 16, 4:31 pm)
Re: Linux 2.6.25-rc4, Mark Lord, (Fri Mar 21, 11:03 am)
Re: Linux 2.6.25-rc4, Alan Cox, (Fri Mar 21, 10:49 am)
Re: Linux 2.6.25-rc4, Linus Torvalds, (Sun Mar 16, 5:06 pm)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Sun Mar 16, 2:26 pm)
Re: Linux 2.6.25-rc4, Jens Axboe, (Mon Mar 17, 3:23 am)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Sun Mar 16, 2:25 pm)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Sun Mar 16, 2:23 pm)
Re: Linux 2.6.25-rc4, Alan Cox, (Sun Mar 16, 2:44 pm)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Sun Mar 16, 10:29 am)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Sun Mar 16, 10:29 am)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Sun Mar 16, 11:14 am)
Re: Linux 2.6.25-rc4 , Anders Eriksson, (Mon Mar 10, 9:19 am)
Re: Linux 2.6.25-rc4, Bartlomiej Zolnierkiewicz..., (Mon Mar 10, 9:56 am)
Re: Linux 2.6.25-rc4, Ingo Molnar, (Thu Mar 6, 9:06 am)
Re: Linux 2.6.25-rc4, Ingo Molnar, (Fri Mar 7, 4:53 am)
Re: Linux 2.6.25-rc4, Pavel Machek, (Sat Mar 8, 7:36 pm)
Re: Linux 2.6.25-rc4, Andi Kleen, (Sun Mar 9, 8:55 am)
Re: Linux 2.6.25-rc4, Pavel Machek, (Mon Mar 10, 6:10 am)
Re: Linux 2.6.25-rc4, Andi Kleen, (Mon Mar 10, 7:52 am)
Re: Linux 2.6.25-rc4, Ingo Molnar, (Sun Mar 9, 7:59 am)
Re: Linux 2.6.25-rc4, Jens Axboe, (Fri Mar 7, 4:57 am)
Re: Linux 2.6.25-rc4, , (Fri Mar 7, 11:20 am)
Re: Linux 2.6.25-rc4, Ingo Molnar, (Fri Mar 7, 5:02 am)
Re: Linux 2.6.25-rc4, Paul Mackerras, (Fri Mar 7, 5:59 am)
Re: Linux 2.6.25-rc4, Jens Axboe, (Thu Mar 6, 9:12 am)
Re: Linux 2.6.25-rc4, FUJITA Tomonori, (Wed Mar 5, 4:09 am)
Re: Linux 2.6.25-rc4, Grant Grundler, (Wed Mar 5, 12:46 pm)
speck-geostationary