linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: linas@austin.ibm.com
Cc: linux-ide@vger.kernel.org
Subject: [RFT] hpt366: reset DMA state machine on timeouts
Date: Thu, 21 Jun 2007 21:54:47 +0400	[thread overview]
Message-ID: <200706212154.47398.sshtylyov@ru.mvista.com> (raw)

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;


             reply	other threads:[~2007-06-21 17:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-21 17:54 Sergei Shtylyov [this message]
2007-06-21 19:31 ` [RFT] hpt366: reset DMA state machine on timeouts 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200706212154.47398.sshtylyov@ru.mvista.com \
    --to=sshtylyov@ru.mvista.com \
    --cc=linas@austin.ibm.com \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).