All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: bzolnier@gmail.com
Cc: linux-ide@vger.kernel.org
Subject: [PATCH] (pata-2.6 fix queue) cmd64x: use interrupt status from MRDMODE register
Date: Fri, 16 Feb 2007 23:21:40 +0300	[thread overview]
Message-ID: <200702162321.40813.sshtylyov@ru.mvista.com> (raw)
In-Reply-To: <200702040004.24918.sshtylyov@ru.mvista.com>

Fold the parts of the ide_dma_end() methods indetical to __ide_dma_end() into a
mere call to it.
Start using faster versions of the ide_dma_end() and ide_dma_test_irq() methods
for the PCI0646U and newer chips that have the duplicate interrupt status bits
in the I/O mapped MRDMODE register, determing what methods to use at the driver
load time.  Do some cleanup/renaming in the "old" ide_dma_test_irq() method.

While at it, fix minor issues with PCI0646 chipset reporting:

- "IRQ workaround enabled" printed out not only for revision 0x01;

- "CMD646: chipset revision" printed twice (by IDE core and the driver itself);

- empty/pointless switch cases for the chips other than PCI0646.

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

---
Warning: this is derived from the specs and completely untested.  Shouldn't
harm though, as those interrupt bits don't seem to really affect anything,
being mere IDE INTR signal latches...

Argh! Forgot the summary -- resending... :-<

 drivers/ide/pci/cmd64x.c |  151 ++++++++++++++++++++++++-----------------------
 1 files changed, 80 insertions(+), 71 deletions(-)

Index: linux-2.6/drivers/ide/pci/cmd64x.c
===================================================================
--- linux-2.6.orig/drivers/ide/pci/cmd64x.c
+++ linux-2.6/drivers/ide/pci/cmd64x.c
@@ -1,6 +1,6 @@
 /* $Id: cmd64x.c,v 1.21 2000/01/30 23:23:16
  *
- * linux/drivers/ide/pci/cmd64x.c		Version 1.46	Feb 15, 2007
+ * linux/drivers/ide/pci/cmd64x.c		Version 1.47	Feb 16, 2007
  *
  * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines.
  *           Note, this driver is not used at all on other systems because
@@ -445,67 +445,80 @@ fast_ata_pio:
 	return 0;
 }
 
-static int cmd64x_alt_dma_status (struct pci_dev *dev)
+static int cmd648_ide_dma_end (ide_drive_t *drive)
 {
-	switch(dev->device) {
-		case PCI_DEVICE_ID_CMD_648:
-		case PCI_DEVICE_ID_CMD_649:
-			return 1;
-		default:
-			break;
-	}
-	return 0;
+	ide_hwif_t *hwif	= HWIF(drive);
+	int err			= __ide_dma_end(drive);
+	u8  irq_mask		= hwif->channel ? MRDMODE_INTR_CH1 :
+						  MRDMODE_INTR_CH0;
+	u8  mrdmode		= inb(hwif->dma_master + 0x01);
+
+	/* clear the interrupt bit */
+	outb(mrdmode | irq_mask, hwif->dma_master + 0x01);
+
+	return err;
 }
 
 static int cmd64x_ide_dma_end (ide_drive_t *drive)
 {
-	u8 dma_stat = 0, dma_cmd = 0;
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct pci_dev *dev	= hwif->pci_dev;
+	int irq_reg		= hwif->channel ? ARTTIM23 : CFR;
+	u8  irq_mask		= hwif->channel ? ARTTIM23_INTR_CH1 :
+						  CFR_INTR_CH0;
+	u8  irq_stat		= 0;
+	int err			= __ide_dma_end(drive);
 
-	drive->waiting_for_dma = 0;
-	/* read DMA command state */
-	dma_cmd = hwif->INB(hwif->dma_command);
-	/* stop DMA */
-	hwif->OUTB((dma_cmd & ~1), hwif->dma_command);
-	/* get DMA status */
-	dma_stat = hwif->INB(hwif->dma_status);
-	/* clear the INTR & ERROR bits */
-	hwif->OUTB(dma_stat|6, hwif->dma_status);
-	if (cmd64x_alt_dma_status(dev)) {
-		u8 dma_intr	= 0;
-		u8 dma_mask	= (hwif->channel) ? ARTTIM23_INTR_CH1 :
-						    CFR_INTR_CH0;
-		u8 dma_reg	= (hwif->channel) ? ARTTIM2 : CFR;
-		(void) pci_read_config_byte(dev, dma_reg, &dma_intr);
-		/* clear the INTR bit */
-		(void) pci_write_config_byte(dev, dma_reg, dma_intr|dma_mask);
-	}
-	/* purge DMA mappings */
-	ide_destroy_dmatable(drive);
-	/* verify good DMA status */
-	return (dma_stat & 7) != 4;
+	(void) pci_read_config_byte(dev, irq_reg, &irq_stat);
+	/* clear the interrupt bit */
+	(void) pci_write_config_byte(dev, irq_reg, irq_stat | irq_mask);
+
+	return err;
+}
+
+static int cmd648_ide_dma_test_irq (ide_drive_t *drive)
+{
+	ide_hwif_t *hwif	= HWIF(drive);
+	u8 irq_mask		= hwif->channel ? MRDMODE_INTR_CH1 :
+						  MRDMODE_INTR_CH0;
+	u8 dma_stat		= inb(hwif->dma_status);
+	u8 mrdmode		= inb(hwif->dma_master + 0x01);
+
+#ifdef DEBUG
+	printk("%s: dma_stat: 0x%02x mrdmode: 0x%02x irq_mask: 0x%02x\n",
+	       drive->name, dma_stat, mrdmode, irq_mask);
+#endif
+	if (!(mrdmode & irq_mask))
+		return 0;
+
+	/* return 1 if INTR asserted */
+	if (dma_stat & 4)
+		return 1;
+
+	return 0;
 }
 
 static int cmd64x_ide_dma_test_irq (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct pci_dev *dev	= hwif->pci_dev;
-	u8 irq_reg		= hwif->channel ? ARTTIM23 : CFR;
-	u8 irq_stat = 0, mask	= hwif->channel ? ARTTIM23_INTR_CH1 : CFR_INTR_CH0;
-	u8 dma_stat		= hwif->INB(hwif->dma_status);
+	int irq_reg		= hwif->channel ? ARTTIM23 : CFR;
+	u8  irq_mask		= hwif->channel ? ARTTIM23_INTR_CH1 :
+						  CFR_INTR_CH0;
+	u8  dma_stat		= inb(hwif->dma_status);
+	u8  irq_stat		= 0;
 
 	(void) pci_read_config_byte(dev, irq_reg, &irq_stat);
 
 #ifdef DEBUG
-	printk("%s: dma_stat: 0x%02x irq_stat: 0x%02x mask: 0x%02x\n",
-	       drive->name, dma_stat, irq_stat, mask);
+	printk("%s: dma_stat: 0x%02x irq_stat: 0x%02x irq_mask: 0x%02x\n",
+	       drive->name, dma_stat, irq_stat, irq_mask);
 #endif
-	if (!(irq_stat & mask))
+	if (!(irq_stat & irq_mask))
 		return 0;
 
 	/* return 1 if INTR asserted */
-	if ((dma_stat & 4) == 4)
+	if (dma_stat & 4)
 		return 1;
 
 	return 0;
@@ -544,32 +557,21 @@ static unsigned int __devinit init_chips
 	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
 	class_rev &= 0xff;
 
-	switch(dev->device) {
-		case PCI_DEVICE_ID_CMD_643:
-			break;
-		case PCI_DEVICE_ID_CMD_646:
-			printk(KERN_INFO "%s: chipset revision 0x%02X, ", name, class_rev);
-			switch(class_rev) {
-				case 0x07:
-				case 0x05:
-					printk("UltraDMA Capable");
-					break;
-				case 0x03:
-					printk("MultiWord DMA Force Limited");
-					break;
-				case 0x01:
-				default:
-					printk("MultiWord DMA Limited, IRQ workaround enabled");
-					break;
-				}
-			printk("\n");
-                        break;
-		case PCI_DEVICE_ID_CMD_648:
-		case PCI_DEVICE_ID_CMD_649:
+	if (dev->device == PCI_DEVICE_ID_CMD_646)
+		switch(class_rev) {
+		case 0x07:
+		case 0x05:
+			printk("%s: UltraDMA capable", name);
 			break;
+		case 0x03:
 		default:
+			printk("%s: MultiWord DMA force limited", name);
 			break;
-	}
+		case 0x01:
+			printk("%s: MultiWord DMA limited, "
+			       "IRQ workaround enabled\n", name);
+			break;
+		}
 
 	/* Set a good latency timer and cache line size value. */
 	(void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
@@ -661,23 +663,30 @@ static void __devinit init_hwif_cmd64x(i
 		hwif->ultra_mask = 0x1f;
 
 	hwif->ide_dma_check = &cmd64x_config_drive_for_dma;
-	if (!(hwif->udma_four))
+	if (!hwif->udma_four)
 		hwif->udma_four = ata66_cmd64x(hwif);
 
-	if (dev->device == PCI_DEVICE_ID_CMD_646) {
+	switch(dev->device) {
+	case PCI_DEVICE_ID_CMD_648:
+	case PCI_DEVICE_ID_CMD_649:
+	alt_irq_bits:
+		hwif->ide_dma_end = &cmd648_ide_dma_end;
+		hwif->ide_dma_test_irq = &cmd648_ide_dma_test_irq;
+		break;
+	case PCI_DEVICE_ID_CMD_646:
 		hwif->chipset = ide_cmd646;
 		if (class_rev == 0x01) {
 			hwif->ide_dma_end = &cmd646_1_ide_dma_end;
-		} else {
-			hwif->ide_dma_end = &cmd64x_ide_dma_end;
-			hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq;
-		}
-	} else {
+			break;
+		} else if (class_rev >= 0x03)
+			goto alt_irq_bits;
+		/* fall thru */
+	default:
 		hwif->ide_dma_end = &cmd64x_ide_dma_end;
 		hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq;
+		break;
 	}
 
-
 	if (!noautodma)
 		hwif->autodma = 1;
 	hwif->drives[0].autodma = hwif->autodma;


  parent reply	other threads:[~2007-02-16 20:21 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-03 20:09 [PATCH] (2.6.20-rc7) cmd64x: fix PIO mode setup Sergei Shtylyov
2007-02-03 21:04 ` [PATCH] (2.6.20-rc7) cmd64x: fix PIO mode setup (take 2) Sergei Shtylyov
2007-02-03 22:25   ` Bartlomiej Zolnierkiewicz
2007-02-05 13:29     ` Sergei Shtylyov
2007-02-05 13:57       ` Sergei Shtylyov
     [not found]         ` <58cb370e0702061459r1b001421gb4592d066793ab46@mail.gmail.com>
2007-02-06 23:44           ` Bartlomiej Zolnierkiewicz
2007-02-07 12:50             ` Sergei Shtylyov
     [not found]       ` <58cb370e0702061459k4a147891v3686b267d8e3001a@mail.gmail.com>
2007-02-06 23:33         ` Bartlomiej Zolnierkiewicz
2007-02-06 14:45   ` [PATCH] (2.6.20) cmd64x: fix PIO mode setup (take 3) Sergei Shtylyov
2007-02-06 21:11     ` Mikael Pettersson
2007-02-07  0:28       ` Bartlomiej Zolnierkiewicz
     [not found]     ` <58cb370e0702061500g3047b8ccpca894962491b588a@mail.gmail.com>
2007-02-06 23:48       ` Bartlomiej Zolnierkiewicz
2007-02-09 22:29   ` [PATCH] (pata-2.6 fix queue) cmd64x: fix recovery time calculation Sergei Shtylyov
2007-02-10  0:14     ` Bartlomiej Zolnierkiewicz
2007-02-14 21:42   ` [PATCH] (pata-2.6 fix queue) cmd64x: interrupt status fixes Sergei Shtylyov
2007-02-14 22:35   ` [PATCH] (pata-2.6 fix queue) cmd64x: add/fix enablebits Sergei Shtylyov
2007-02-19 23:09     ` Bartlomiej Zolnierkiewicz
2007-02-20 14:28       ` Sergei Shtylyov
2007-02-23 20:10         ` Bartlomiej Zolnierkiewicz
2007-04-14 19:31     ` [PATCH pata-2.6] cmd64x: add/fix enablebits (take 2) Sergei Shtylyov
2007-04-23 21:54       ` Bartlomiej Zolnierkiewicz
2007-02-15 13:53   ` [PATCH] (pata-2.6 fix queue) cmd64x: interrupt status fixes (resend) Sergei Shtylyov
2007-02-19 23:04     ` Bartlomiej Zolnierkiewicz
2007-04-14 19:17     ` [PATCH pata-2.6] cmd64x: interrupt status fixes (take 2) Sergei Shtylyov
2007-04-23 21:52       ` Bartlomiej Zolnierkiewicz
2007-02-15 19:17   ` [PATCH] (pata-2.6 fix queue) cmd64x: procfs code fixes/cleanups Sergei Shtylyov
2007-02-19 23:10     ` Bartlomiej Zolnierkiewicz
2007-04-14 19:41     ` [PATCH pata-2.6] cmd64x: procfs code fixes/cleanups (take 2) Sergei Shtylyov
2007-04-23 21:58       ` Bartlomiej Zolnierkiewicz
2007-02-16 20:15   ` [PATCH] (pata-2.6 fix queue) cmd64x: Sergei Shtylyov
2007-02-16 20:21   ` Sergei Shtylyov [this message]
2007-02-23 20:09     ` [PATCH] (pata-2.6 fix queue) cmd64x: use interrupt status from MRDMODE register Bartlomiej Zolnierkiewicz
2007-04-14 19:53     ` [PATCH pata-2.6] cmd64x: use interrupt status from MRDMODE register (take 2) Sergei Shtylyov
2007-04-23 22:03       ` Bartlomiej Zolnierkiewicz
2007-04-18 19:38     ` [PATCH pata-2.6 fix queue] hpt366: fix kernel oops with HPT302N Sergei Shtylyov
2007-04-20 19:54       ` Bartlomiej Zolnierkiewicz
2007-04-22 18:05     ` [PATCH pata-2.6 fix queue] aec62xx: fix PIO/DMA setup issues Sergei Shtylyov
2007-04-23 22:33       ` Bartlomiej Zolnierkiewicz
2007-05-10 20:01     ` [PATCH pata-2.6 fix queue] cmd64x: init. code cleanup Sergei Shtylyov
2007-05-10 20:04     ` Sergei Shtylyov
2007-05-15 21:16       ` Bartlomiej Zolnierkiewicz
2007-05-11 19:31     ` [PATCH pata-2.6 fix queue] aec62xx: rework init_setup_aec6x80() Sergei Shtylyov
2007-05-15 21:31       ` Bartlomiej Zolnierkiewicz
2007-05-11 21:11     ` [PATCH pata-2.6 fix queue] aec62xx: remove init_dma() method Sergei Shtylyov
2007-05-15 21:40       ` Bartlomiej Zolnierkiewicz
2007-05-11 21:22     ` [PATCH pata-2.6 fix queue] aec62xx: kill speedproc() method wrapper Sergei Shtylyov
2007-05-15 21:43       ` Bartlomiej Zolnierkiewicz
2007-05-16 14:20         ` Sergei Shtylyov
2007-05-23 23:33           ` Bartlomiej Zolnierkiewicz
2007-05-24 13:18             ` Sergei Shtylyov
2007-05-24 16:44     ` [PATCH pata-2.6] aec62xx: remove init_dma() method (take 2) Sergei Shtylyov
2007-05-24 16:46     ` [PATCH pata-2.6] aec62xx: kill speedproc() method wrapper " Sergei Shtylyov
2007-05-28 20:44       ` Bartlomiej Zolnierkiewicz
2007-06-05 15:15         ` Sergei Shtylyov
2007-06-08 12:22           ` Bartlomiej Zolnierkiewicz
2007-06-09 10:05             ` Sergei Shtylyov
2007-11-09 11:07     ` [PATCH] cmd64x: don't clear the other channels interrupt Sergei Shtylyov
2007-11-11 21:52       ` Bartlomiej Zolnierkiewicz
2007-11-13 20:58         ` Bartlomiej Zolnierkiewicz
2007-11-15 19:23           ` Martin Rogge
2007-11-16 13:34           ` Sergei Shtylyov
2007-02-26 20:32   ` [PATCH] (pata-2.6 fix queue) cmd64x: fix recovery time calculation (take 2) Sergei Shtylyov
2007-03-02 20:34     ` Bartlomiej Zolnierkiewicz
2007-03-03 20:17     ` [PATCH pata-2.6 fix queue] cmd64x: fix recovery time calculation (take 3) Sergei Shtylyov
2007-03-15 20:29       ` Bartlomiej Zolnierkiewicz
2007-02-27 21:49   ` [PATCH] (pata-2.6 fix queue) cmd64x: fix primary channel address setup time Sergei Shtylyov
2007-02-28 13:27     ` Sergei Shtylyov
2007-02-28 20:52   ` [PATCH] (pata-2.6 fix queue) cmd64x: add back MWDMA support Sergei Shtylyov
2007-03-02 22:03     ` Bartlomiej Zolnierkiewicz

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=200702162321.40813.sshtylyov@ru.mvista.com \
    --to=sshtylyov@ru.mvista.com \
    --cc=bzolnier@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.