diff options
author | Suleiman Souhlal <suleiman@google.com> | 2007-04-10 16:38:37 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-04-10 16:38:37 -0400 |
commit | 23450319e2890986c247ec0aa1442f060e657e6d (patch) | |
tree | c30fc173d8b97343f8ae7b1b1ed511366af256ab /drivers/ide/ide-iops.c | |
parent | 90f30eccf41302a2542f5d374af243061902bd98 (diff) |
ide: correctly prevent IDE timer expiry function to run if request was already handled
It is possible for the timer expiry function to run even though the
request has already been handled: ide_timer_expiry() only checks that
the handler is not NULL, but it is possible that we have handled a
request (thus clearing the handler) and then started a new request
(thus starting the timer again, and setting a handler).
A simple way to exhibit this is to set the DMA timeout to 1 jiffy and
run dd: The kernel will panic after a few minutes because
ide_timer_expiry() tries to add a timer when it's already active.
To fix this, we simply add a request generation count that gets
incremented at every interrupt, and check in ide_timer_expiry() that
we have not already handled a new interrupt before running the expiry
function.
Signed-off-by: Suleiman Souhlal <suleiman@google.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-iops.c')
-rw-r--r-- | drivers/ide/ide-iops.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 1ee53a551c3a..3caa176b3155 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -889,6 +889,7 @@ static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, | |||
889 | hwgroup->handler = handler; | 889 | hwgroup->handler = handler; |
890 | hwgroup->expiry = expiry; | 890 | hwgroup->expiry = expiry; |
891 | hwgroup->timer.expires = jiffies + timeout; | 891 | hwgroup->timer.expires = jiffies + timeout; |
892 | hwgroup->req_gen_timer = hwgroup->req_gen; | ||
892 | add_timer(&hwgroup->timer); | 893 | add_timer(&hwgroup->timer); |
893 | } | 894 | } |
894 | 895 | ||
@@ -929,6 +930,7 @@ void ide_execute_command(ide_drive_t *drive, task_ioreg_t cmd, ide_handler_t *ha | |||
929 | hwgroup->handler = handler; | 930 | hwgroup->handler = handler; |
930 | hwgroup->expiry = expiry; | 931 | hwgroup->expiry = expiry; |
931 | hwgroup->timer.expires = jiffies + timeout; | 932 | hwgroup->timer.expires = jiffies + timeout; |
933 | hwgroup->req_gen_timer = hwgroup->req_gen; | ||
932 | add_timer(&hwgroup->timer); | 934 | add_timer(&hwgroup->timer); |
933 | hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG); | 935 | hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG); |
934 | /* Drive takes 400nS to respond, we must avoid the IRQ being | 936 | /* Drive takes 400nS to respond, we must avoid the IRQ being |