linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT] hpt366: reset DMA state machine on timeouts
@ 2007-06-21 17:54 Sergei Shtylyov
  2007-06-21 19:31 ` Linas Vepstas
  2007-06-22 15:13 ` Linas Vepstas
  0 siblings, 2 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2007-06-21 17:54 UTC (permalink / raw)
  To: linas; +Cc: linux-ide

Reset HPT36x's DMA state machine on a DMA timeout the way it's done for HPT370.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

---
Linas, here's what I've come up with -- this should apply against 2.6.21.y.
Compile-tested only, not for merging.

 drivers/ide/pci/hpt366.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/ide/pci/hpt366.c
===================================================================
--- linux-2.6.orig/drivers/ide/pci/hpt366.c
+++ linux-2.6/drivers/ide/pci/hpt366.c
@@ -752,6 +752,26 @@ static int hpt366_config_drive_xfer_rate
  * This is specific to the HPT366 UDMA chipset
  * by HighPoint|Triones Technologies, Inc.
  */
+static int hpt366_ide_dma_timeout(ide_drive_t *drive)
+{
+	ide_hwif_t *hwif	= HWIF(drive);
+	struct pci_dev *dev	= hwif->pci_dev;
+	u8 mcr1 = 0, mcr2	= 0;
+	u8 dma_cmd		= inb(hwif->dma_command);
+
+	/* Stop DMA */
+	outb(dma_cmd & ~0x01, hwif->dma_command);
+
+	/* Clear bus master state machine and S/G counter */
+	pci_read_config_byte (dev, 0x51, &mcr2);
+	pci_write_config_byte(dev, 0x51, (mcr2 | 0x03));
+	/* Clear buffers 0/1 */
+	pci_read_config_byte (dev, 0x50, &mcr1);
+	pci_write_config_byte(dev, 0x50, (mcr1 | 0x0c));
+
+	return __ide_dma_timeout(drive);
+}
+
 static int hpt366_ide_dma_lostirq(ide_drive_t *drive)
 {
 	struct pci_dev *dev = HWIF(drive)->pci_dev;
@@ -1368,8 +1388,10 @@ static void __devinit init_hwif_hpt366(i
 		hwif->dma_start 	= &hpt370_ide_dma_start;
 		hwif->ide_dma_end	= &hpt370_ide_dma_end;
 		hwif->ide_dma_timeout	= &hpt370_ide_dma_timeout;
-	} else
+	} else {
+		hwif->ide_dma_timeout	= &hpt366_ide_dma_timeout;
 		hwif->ide_dma_lostirq	= &hpt366_ide_dma_lostirq;
+	}
 
 	if (!noautodma)
 		hwif->autodma = 1;


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

end of thread, other threads:[~2007-06-26 13:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-21 17:54 [RFT] hpt366: reset DMA state machine on timeouts Sergei Shtylyov
2007-06-21 19:31 ` Linas Vepstas
2007-06-22 15:13 ` Linas Vepstas
2007-06-22 15:32   ` Sergei Shtylyov
2007-06-22 16:36     ` Linas Vepstas
2007-06-23 18:10       ` Sergei Shtylyov
2007-06-25 21:44         ` Linas Vepstas
2007-06-26 13:57           ` Sergei Shtylyov
2007-06-22 15:54   ` Alan Cox
2007-06-22 16:03     ` Linas Vepstas
2007-06-22 16:33       ` 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).