Skip to contentSkip to conversation

hpt366: add hpt3xx_disable_fast_irq() helper

PATCH In review Bartlomiej Zolnierkiewicz 2 participants 5 messages Aug 2, 2008 – Oct 15, 2008 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hpt366: add hpt3xx_disable_fast_irq() helper

* Factor out disabling of "fast interrupt" prediction from init_hwif_hpt366() to hpt3xx_disable_fast_irq() helper.

* Use hpt3xx_disable_fast_irq() in ->init_chipset instead of ->init_hwif method.

This is a preparation for adding proper PCI PM support.

While at it:

* Cache chip type in chip_type variable in hpt3xx_disable_fast_irq().

There should be no functional changes caused by this patch.

---
 drivers/ide/pci/hpt366.c |   58 ++++++++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 25 deletions(-)
drivers/ide/pci/hpt366.c +33 -25
Index: b/drivers/ide/pci/hpt366.c
===================================================================
@@ -969,6 +969,36 @@ static int __devinit hpt37x_calibrate_dp
 	return 1;
 }
 
+static void __devinit hpt3xx_disable_fast_irq(struct pci_dev *dev, u8 mcr_addr)
+{
+	struct ide_host *host	= pci_get_drvdata(dev);
+	struct hpt_info *info	= host->host_priv + (&dev->dev == host->dev[1]);
+	u8  chip_type		= info->chip_type;
+	u8  new_mcr, old_mcr	= 0;
+
+	/*
+	 * Disable the "fast interrupt" prediction.  Don't hold off
+	 * on interrupts. (== 0x01 despite what the docs say)
+	 */
+	pci_read_config_byte(dev, mcr_addr + 1, &old_mcr);
+
+	if (chip_type >= HPT374)
+		new_mcr = old_mcr & ~0x07;
+	else if (chip_type >= HPT370) {
+		new_mcr = old_mcr;
+		new_mcr &= ~0x02;
+#ifdef HPT_DELAY_INTERRUPT
+		new_mcr &= ~0x01;
+#else
+		new_mcr |=  0x01;
+#endif
+	} else					/* HPT366 and HPT368  */
+		new_mcr = old_mcr & ~0x80;
+
+	if (new_mcr != old_mcr)
+		pci_write_config_byte(dev, mcr_addr + 1, new_mcr);
+}
+
 static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev)
 {
 	unsigned long io_base	= pci_resource_start(dev, 4);
@@ -1207,9 +1237,11 @@ static unsigned int __devinit init_chips
 	 * NOTE: This register is only writeable via I/O space.
 	 */
 	if (chip_type == HPT371N && clock == ATA_CLOCK_66MHZ)
-
 		outb(inb(io_base + 0x9c) | 0x04, io_base + 0x9c);
 
+	hpt3xx_disable_fast_irq(dev, 0x50);
+	hpt3xx_disable_fast_irq(dev, 0x54);
+
 	return dev->irq;
 }
 
@@ -1265,7 +1297,6 @@ static void __devinit init_hwif_hpt366(i
 	struct hpt_info *info	= host->host_priv + (hwif->dev == host->dev[1]);
 	int serialize		= HPT_SERIALIZE_IO;
 	u8  chip_type		= info->chip_type;
-	u8  new_mcr, old_mcr	= 0;
 
 	/* Cache the channel's MISC. control registers' offset */
 	hwif->select_data	= hwif->channel ? 0x54 : 0x50;
@@ -1288,29 +1319,6 @@ static void __devinit init_hwif_hpt366(i
 	/* Serialize access to this device if needed */
 	if (serialize && hwif->mate)
 		hwif->serialized = hwif->mate->serialized = 1;
-
-	/*
-	 * Disable the "fast interrupt" prediction.  Don't hold off
-	 * on interrupts. (== 0x01 despite what the docs say)
-	 */
-	pci_read_config_byte(dev, hwif->select_data + 1, &old_mcr);
-
-	if (info->chip_type >= HPT374)
-		new_mcr = old_mcr & ~0x07;
-	else if (info->chip_type >= HPT370) {
-		new_mcr = old_mcr;
-		new_mcr &= ~0x02;
-
-#ifdef HPT_DELAY_INTERRUPT
-		new_mcr &= ~0x01;
-#else
-		new_mcr |=  0x01;
-#endif
-	} else					/* HPT366 and HPT368  */
-		new_mcr = old_mcr & ~0x80;
-
-	if (new_mcr != old_mcr)
-		pci_write_config_byte(dev, hwif->select_data + 1, new_mcr);
 }
 
 static int __devinit init_dma_hpt366(ide_hwif_t *hwif,
#1 lore raw

Hello.

Quoted 6 lines · Bartlomiej Zolnierkiewicz

* Factor out disabling of "fast interrupt" prediction from init_hwif_hpt366() to hpt3xx_disable_fast_irq() helper.

* Use hpt3xx_disable_fast_irq() in ->init_chipset instead of ->init_hwif method.

Quoted 7 lines

This is a preparation for adding proper PCI PM support.

While at it:

* Cache chip type in chip_type variable in hpt3xx_disable_fast_irq().

There should be no functional changes caused by this patch.

Except a warning. ;-)

Quoted 33 lines

Index: b/drivers/ide/pci/hpt366.c
===================================================================

drivers/ide/pci/hpt366.c +0 -15
@@ -1265,7 +1297,6 @@ static void __devinit init_hwif_hpt366(i
 	struct hpt_info *info	= host->host_priv + (hwif->dev == host->dev[1]);
 	int serialize		= HPT_SERIALIZE_IO;
 	u8  chip_type		= info->chip_type;
-	u8  new_mcr, old_mcr	= 0;
 
 	/* Cache the channel's MISC. control registers' offset */
 	hwif->select_data	= hwif->channel ? 0x54 : 0x50;
@@ -1288,29 +1319,6 @@ static void __devinit init_hwif_hpt366(i
 	/* Serialize access to this device if needed */
 	if (serialize && hwif->mate)
 		hwif->serialized = hwif->mate->serialized = 1;
-
-	/*
-	 * Disable the "fast interrupt" prediction.  Don't hold off
-	 * on interrupts. (== 0x01 despite what the docs say)
-	 */
-	pci_read_config_byte(dev, hwif->select_data + 1, &old_mcr);
-
-	if (info->chip_type >= HPT374)
-		new_mcr = old_mcr & ~0x07;
-	else if (info->chip_type >= HPT370) {
-		new_mcr = old_mcr;
-		new_mcr &= ~0x02;
-
-#ifdef HPT_DELAY_INTERRUPT

drivers/ide/pci/hpt366.c static void __devinit init_hwif_hpt366(i · line 1322

Quoted 10 lines
drivers/ide/pci/hpt366.c +0 -9
-		new_mcr &= ~0x01;
-#else
-		new_mcr |=  0x01;
-#endif
-	} else					/* HPT366 and HPT368  */
-		new_mcr = old_mcr & ~0x80;
-
-	if (new_mcr != old_mcr)
-		pci_write_config_byte(dev, hwif->select_data + 1, new_mcr);
 }

CC drivers/ide/pci/hpt366.o
drivers/ide/pci/hpt366.c: In function `init_hwif_hpt366':
drivers/ide/pci/hpt366.c:1290: warning: unused variable `dev'

You've removed the users of that variable but left the variable itself...
alas, it's too late to fix the patch. :-/

MBR, Sergei

#2 lore raw
Quoted 12 lines · Sergei Shtylyov

Hello.

Quoted 7 lines · Bartlomiej Zolnierkiewicz

* Factor out disabling of "fast interrupt" prediction from init_hwif_hpt366() to hpt3xx_disable_fast_irq() helper.

* Use hpt3xx_disable_fast_irq() in ->init_chipset instead of ->init_hwif method.

This is a preparation for adding proper PCI PM support.

Quoted 7 lines
Quoted 5 lines

While at it:

* Cache chip type in chip_type variable in hpt3xx_disable_fast_irq().

There should be no functional changes caused by this patch.

Except a warning. ;-)

Sorry for that but... shit happens. ;)

Quoted 48 lines
Quoted 33 lines

Index: b/drivers/ide/pci/hpt366.c
===================================================================

drivers/ide/pci/hpt366.c +0 -15
@@ -1265,7 +1297,6 @@ static void __devinit init_hwif_hpt366(i
 	struct hpt_info *info	= host->host_priv + (hwif->dev == host->dev[1]);
 	int serialize		= HPT_SERIALIZE_IO;
 	u8  chip_type		= info->chip_type;
-	u8  new_mcr, old_mcr	= 0;
 
 	/* Cache the channel's MISC. control registers' offset */
 	hwif->select_data	= hwif->channel ? 0x54 : 0x50;
@@ -1288,29 +1319,6 @@ static void __devinit init_hwif_hpt366(i
 	/* Serialize access to this device if needed */
 	if (serialize && hwif->mate)
 		hwif->serialized = hwif->mate->serialized = 1;
-
-	/*
-	 * Disable the "fast interrupt" prediction.  Don't hold off
-	 * on interrupts. (== 0x01 despite what the docs say)
-	 */
-	pci_read_config_byte(dev, hwif->select_data + 1, &old_mcr);
-
-	if (info->chip_type >= HPT374)
-		new_mcr = old_mcr & ~0x07;
-	else if (info->chip_type >= HPT370) {
-		new_mcr = old_mcr;
-		new_mcr &= ~0x02;
-
-#ifdef HPT_DELAY_INTERRUPT

drivers/ide/pci/hpt366.c static void __devinit init_hwif_hpt366(i · line 1322

Quoted 10 lines
drivers/ide/pci/hpt366.c +0 -9
-		new_mcr &= ~0x01;
-#else
-		new_mcr |=  0x01;
-#endif
-	} else					/* HPT366 and HPT368  */
-		new_mcr = old_mcr & ~0x80;
-
-	if (new_mcr != old_mcr)
-		pci_write_config_byte(dev, hwif->select_data + 1, new_mcr);
 }

CC drivers/ide/pci/hpt366.o
drivers/ide/pci/hpt366.c: In function `init_hwif_hpt366':
drivers/ide/pci/hpt366.c:1290: warning: unused variable `dev'

Quoted 2 lines

You've removed the users of that variable but left the variable itself...
alas, it's too late to fix the patch. :-/

Not such a big deal, we just have to make an another one...

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] hpt366: fix compile warning

Fixup for commit 1785192b5310ee25165768f5bb80f13146788e3e ("hpt366: add hpt3xx_disable_fast_irq() helper"):

   CC      drivers/ide/pci/hpt366.o drivers/ide/pci/hpt366.c: In function `init_hwif_hpt366':
drivers/ide/pci/hpt366.c:1290: warning: unused variable `dev'

---
 drivers/ide/pci/hpt366.c |    1 -
 1 file changed, 1 deletion(-)
drivers/ide/pci/hpt366.c +0 -1
Index: b/drivers/ide/pci/hpt366.c
===================================================================
@@ -1289,7 +1289,6 @@ static u8 hpt3xx_cable_detect(ide_hwif_t
 
 static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
 {
-	struct pci_dev *dev	= to_pci_dev(hwif->dev);
 	struct hpt_info *info	= hpt3xx_get_info(hwif->dev);
 	int serialize		= HPT_SERIALIZE_IO;
 	u8  chip_type		= info->chip_type;
#3 lore raw

Hello.

Quoted 10 lines · Bartlomiej Zolnierkiewicz
Quoted 10 lines
Quoted 10 lines

* Factor out disabling of "fast interrupt" prediction from init_hwif_hpt366() to hpt3xx_disable_fast_irq() helper.

* Use hpt3xx_disable_fast_irq() in ->init_chipset instead of ->init_hwif method.

This is a preparation for adding proper PCI PM support.

While at it:

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

* Cache chip type in chip_type variable in hpt3xx_disable_fast_irq().

There should be no functional changes caused by this patch.

Except a warning. ;-)

Sorry for that but... shit happens. ;)

Compile testing the patches would have helped. ;-)

Quoted 12 lines
Quoted 3 lines

You've removed the users of that variable but left the variable itself...
alas, it's too late to fix the patch. :-/

Not such a big deal, we just have to make an another one...

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] hpt366: fix compile warning

Fixup for commit 1785192b5310ee25165768f5bb80f13146788e3e ("hpt366: add hpt3xx_disable_fast_irq() helper"):

Quoted 7 lines

CC drivers/ide/pci/hpt366.o
drivers/ide/pci/hpt366.c: In function `init_hwif_hpt366':
drivers/ide/pci/hpt366.c:1290: warning: unused variable `dev'

Duh. I've posted this patch a bit earlier. ;-)

MBR, Sergei

#4 lore raw
Quoted 12 lines · I just
Quoted 12 lines

Not such a big deal, we just have to make an another one...

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] hpt366: fix compile warning

Fixup for commit 1785192b5310ee25165768f5bb80f13146788e3e ("hpt366: add hpt3xx_disable_fast_irq() helper"):

CC drivers/ide/pci/hpt366.o
drivers/ide/pci/hpt366.c: In function `init_hwif_hpt366':
drivers/ide/pci/hpt366.c:1290: warning: unused variable `dev'

Quoted 5 lines
Quoted 3 lines

Duh. I've posted this patch a bit earlier. ;-)

No, you were the first, so just add my:

MBR, Sergei