patch 2/2: Do the dma status clearing in ide_intr() and add a new hwif->ide_dma_clear_irq such that LLDD could override it.
Signed-off-by: Albert Lee <[EMAIL PROTECTED]> --- Tested ok on ICH4 and pdc20275. Not sure if this would have bad effect for other adapters. Patch against 2.6.20-rc5, for your review, thanks. diff -Nrup 01_remove_from_ide_cd/drivers/ide/ide-dma.c 02_add_to_ide_intr/drivers/ide/ide-dma.c --- 01_remove_from_ide_cd/drivers/ide/ide-dma.c 2006-11-30 05:57:37.000000000 +0800 +++ 02_add_to_ide_intr/drivers/ide/ide-dma.c 2007-01-24 11:07:58.000000000 +0800 @@ -650,6 +650,22 @@ static int __ide_dma_test_irq(ide_drive_ drive->name, __FUNCTION__); return 0; } + +/* returns 1 on error, 0 otherwise */ +int __ide_dma_clear_irq(ide_drive_t *drive) +{ + ide_hwif_t *hwif = HWIF(drive); + u8 dma_stat; + + /* clear the INTR & ERROR bits */ + if (hwif->dma_status) { + dma_stat = hwif->INB(hwif->dma_status); + /* Should we force the bit as well ? */ + hwif->OUTB(dma_stat, hwif->dma_status); + } + + return 0; +} #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ int __ide_dma_bad_drive (ide_drive_t *drive) @@ -928,6 +944,8 @@ void ide_setup_dma (ide_hwif_t *hwif, un hwif->ide_dma_end = &__ide_dma_end; if (!hwif->ide_dma_test_irq) hwif->ide_dma_test_irq = &__ide_dma_test_irq; + if (!hwif->ide_dma_clear_irq) + hwif->ide_dma_clear_irq = &__ide_dma_clear_irq; if (!hwif->ide_dma_timeout) hwif->ide_dma_timeout = &__ide_dma_timeout; if (!hwif->ide_dma_lostirq) diff -Nrup 01_remove_from_ide_cd/drivers/ide/ide-io.c 02_add_to_ide_intr/drivers/ide/ide-io.c --- 01_remove_from_ide_cd/drivers/ide/ide-io.c 2006-11-30 05:57:37.000000000 +0800 +++ 02_add_to_ide_intr/drivers/ide/ide-io.c 2007-01-24 11:21:41.000000000 +0800 @@ -1644,6 +1644,18 @@ irqreturn_t ide_intr (int irq, void *dev } hwgroup->handler = NULL; del_timer(&hwgroup->timer); + + /* Some controllers might set DMA INTR no matter DMA or PIO; + * bmdma status might need to be cleared even for + * PIO interrupts to prevent spurious irq or irq lost. + */ + if (hwif->ide_dma_clear_irq && !(hwif->dma)) + /* ide_dma_end() needs bmdma status for error checking. + * So, skip clearing bmdma status here and leave it + * to ide_dma_end() if this is dma interrupt. + */ + hwif->ide_dma_clear_irq(drive); + spin_unlock(&ide_lock); if (drive->unmask) diff -Nrup 01_remove_from_ide_cd/drivers/ide/ide.c 02_add_to_ide_intr/drivers/ide/ide.c --- 01_remove_from_ide_cd/drivers/ide/ide.c 2007-01-23 11:47:42.000000000 +0800 +++ 02_add_to_ide_intr/drivers/ide/ide.c 2007-01-24 11:00:48.000000000 +0800 @@ -503,6 +503,7 @@ static void ide_hwif_restore(ide_hwif_t hwif->ide_dma_on = tmp_hwif->ide_dma_on; hwif->ide_dma_off_quietly = tmp_hwif->ide_dma_off_quietly; hwif->ide_dma_test_irq = tmp_hwif->ide_dma_test_irq; + hwif->ide_dma_clear_irq = tmp_hwif->ide_dma_clear_irq; hwif->ide_dma_host_on = tmp_hwif->ide_dma_host_on; hwif->ide_dma_host_off = tmp_hwif->ide_dma_host_off; hwif->ide_dma_lostirq = tmp_hwif->ide_dma_lostirq; diff -Nrup 01_remove_from_ide_cd/include/linux/ide.h 02_add_to_ide_intr/include/linux/ide.h --- 01_remove_from_ide_cd/include/linux/ide.h 2007-01-24 11:00:03.000000000 +0800 +++ 02_add_to_ide_intr/include/linux/ide.h 2007-01-24 11:00:48.000000000 +0800 @@ -727,6 +727,7 @@ typedef struct hwif_s { int (*ide_dma_on)(ide_drive_t *drive); int (*ide_dma_off_quietly)(ide_drive_t *drive); int (*ide_dma_test_irq)(ide_drive_t *drive); + int (*ide_dma_clear_irq)(ide_drive_t *drive); int (*ide_dma_host_on)(ide_drive_t *drive); int (*ide_dma_host_off)(ide_drive_t *drive); int (*ide_dma_lostirq)(ide_drive_t *drive); - To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html