scc_pata: bugfix for checking DMA IRQ status

On Tuesday 27 February 2007, Akira Iguchi wrote:
>
> But since I sent the first patch, I found a bug for checking DMA IRQ status.
> (http://www.spinics.net/lists/linux-ide/msg06903.html)
> Then I sent the fixed patch for libata only. So my drivers/ide patch
> still has same bug and I want to fix it, too.
>
> The following patch fixes this bug. Please apply this patch.

From: Akira Iguchi <akira2.iguchi@toshiba.co.jp>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

authored by Akira Iguchi and committed by Bartlomiej Zolnierkiewicz 06a9952b 846c11ab

+27
+27
drivers/ide/ppc/scc_pata.c
··· 509 509 return __ide_dma_end(drive); 510 510 } 511 511 512 + /* returns 1 if dma irq issued, 0 otherwise */ 513 + static int scc_dma_test_irq(ide_drive_t *drive) 514 + { 515 + ide_hwif_t *hwif = HWIF(drive); 516 + u8 dma_stat = hwif->INB(hwif->dma_status); 517 + 518 + /* return 1 if INTR asserted */ 519 + if ((dma_stat & 4) == 4) 520 + return 1; 521 + 522 + /* Workaround for PTERADD: emulate DMA_INTR when 523 + * - IDE_STATUS[ERR] = 1 524 + * - INT_STATUS[INTRQ] = 1 525 + * - DMA_STATUS[IORACTA] = 1 526 + */ 527 + if (in_be32((void __iomem *)IDE_ALTSTATUS_REG) & ERR_STAT && 528 + in_be32((void __iomem *)(hwif->dma_base + 0x014)) & INTSTS_INTRQ && 529 + dma_stat & 1) 530 + return 1; 531 + 532 + if (!drive->waiting_for_dma) 533 + printk(KERN_WARNING "%s: (%s) called while not waiting\n", 534 + drive->name, __FUNCTION__); 535 + return 0; 536 + } 537 + 512 538 /** 513 539 * setup_mmio_scc - map CTRL/BMID region 514 540 * @dev: PCI device we are configuring ··· 738 712 hwif->speedproc = scc_tune_chipset; 739 713 hwif->tuneproc = scc_tuneproc; 740 714 hwif->ide_dma_check = scc_config_drive_for_dma; 715 + hwif->ide_dma_test_irq = scc_dma_test_irq; 741 716 742 717 hwif->drives[0].autotune = IDE_TUNE_AUTO; 743 718 hwif->drives[1].autotune = IDE_TUNE_AUTO;