Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / ide / ide-iops.c
index 31448ab..77703ac 100644 (file)
@@ -6,7 +6,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/string.h>
@@ -24,6 +23,7 @@
 #include <linux/hdreg.h>
 #include <linux/ide.h>
 #include <linux/bitops.h>
+#include <linux/nmi.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
@@ -104,8 +104,6 @@ void default_hwif_iops (ide_hwif_t *hwif)
        hwif->INSL      = ide_insl;
 }
 
-EXPORT_SYMBOL(default_hwif_iops);
-
 /*
  *     MMIO operations, typically used for SATA controllers
  */
@@ -329,8 +327,6 @@ void default_hwif_transport(ide_hwif_t *hwif)
        hwif->atapi_output_bytes        = atapi_output_bytes;
 }
 
-EXPORT_SYMBOL(default_hwif_transport);
-
 /*
  * Beginning of Taskfile OPCODE Library and feature sets.
  */
@@ -529,8 +525,6 @@ int wait_for_ready (ide_drive_t *drive, int timeout)
        return 0;
 }
 
-EXPORT_SYMBOL(wait_for_ready);
-
 /*
  * This routine busy-waits for the drive status to be not "busy".
  * It then checks the status for all of the "good" bits and none
@@ -601,44 +595,19 @@ EXPORT_SYMBOL(ide_wait_stat);
  */
 u8 eighty_ninty_three (ide_drive_t *drive)
 {
-#if 0
-       if (!HWIF(drive)->udma_four)
+       if(HWIF(drive)->udma_four == 0)
                return 0;
 
-       if (drive->id->major_rev_num) {
-               int hssbd = 0;
-               int i;
-               /*
-                * Determine highest Supported SPEC
-                */
-               for (i=1; i<=15; i++)
-                       if (drive->id->major_rev_num & (1<<i))
-                               hssbd++;
-
-               switch (hssbd) {
-                       case 7:
-                       case 6:
-                       case 5:
-               /* ATA-4 and older do not support above Ultra 33 */
-                       default:
-                               return 0;
-               }
-       }
-
-       return ((u8) (
-#ifndef CONFIG_IDEDMA_IVB
-               (drive->id->hw_config & 0x4000) &&
-#endif /* CONFIG_IDEDMA_IVB */
-                (drive->id->hw_config & 0x6000)) ? 1 : 0);
-
-#else
-
-       return ((u8) ((HWIF(drive)->udma_four) &&
+       /* Check for SATA but only if we are ATA5 or higher */
+       if (drive->id->hw_config == 0 && (drive->id->major_rev_num & 0x7FE0))
+               return 1;
+       if (!(drive->id->hw_config & 0x6000))
+               return 0;
 #ifndef CONFIG_IDEDMA_IVB
-                       (drive->id->hw_config & 0x4000) &&
+       if(!(drive->id->hw_config & 0x4000))
+               return 0;
 #endif /* CONFIG_IDEDMA_IVB */
-                       (drive->id->hw_config & 0x6000)) ? 1 : 0);
-#endif
+       return 1;
 }
 
 EXPORT_SYMBOL(eighty_ninty_three);
@@ -974,8 +943,7 @@ void ide_execute_command(ide_drive_t *drive, task_ioreg_t cmd, ide_handler_t *ha
        
        spin_lock_irqsave(&ide_lock, flags);
        
-       if(hwgroup->handler)
-               BUG();
+       BUG_ON(hwgroup->handler);
        hwgroup->handler        = handler;
        hwgroup->expiry         = expiry;
        hwgroup->timer.expires  = jiffies + timeout;
@@ -1016,8 +984,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
                printk("%s: ATAPI reset complete\n", drive->name);
        } else {
                if (time_before(jiffies, hwgroup->poll_timeout)) {
-                       if (HWGROUP(drive)->handler != NULL)
-                               BUG();
+                       BUG_ON(HWGROUP(drive)->handler != NULL);
                        ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
                        /* continue polling */
                        return ide_started;
@@ -1056,8 +1023,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
 
        if (!OK_STAT(tmp = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) {
                if (time_before(jiffies, hwgroup->poll_timeout)) {
-                       if (HWGROUP(drive)->handler != NULL)
-                               BUG();
+                       BUG_ON(HWGROUP(drive)->handler != NULL);
                        ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
                        /* continue polling */
                        return ide_started;
@@ -1107,9 +1073,27 @@ static void check_dma_crc(ide_drive_t *drive)
 #endif
 }
 
+static void ide_disk_pre_reset(ide_drive_t *drive)
+{
+       int legacy = (drive->id->cfs_enable_2 & 0x0400) ? 0 : 1;
+
+       drive->special.all = 0;
+       drive->special.b.set_geometry = legacy;
+       drive->special.b.recalibrate  = legacy;
+       if (OK_TO_RESET_CONTROLLER)
+               drive->mult_count = 0;
+       if (!drive->keep_settings && !drive->using_dma)
+               drive->mult_req = 0;
+       if (drive->mult_req != drive->mult_count)
+               drive->special.b.set_multmode = 1;
+}
+
 static void pre_reset(ide_drive_t *drive)
 {
-       DRIVER(drive)->pre_reset(drive);
+       if (drive->media == ide_disk)
+               ide_disk_pre_reset(drive);
+       else
+               drive->post_reset = 1;
 
        if (!drive->keep_settings) {
                if (drive->using_dma) {
@@ -1155,15 +1139,15 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
        hwgroup = HWGROUP(drive);
 
        /* We must not reset with running handlers */
-       if(hwgroup->handler != NULL)
-               BUG();
+       BUG_ON(hwgroup->handler != NULL);
 
        /* For an ATAPI device, first try an ATAPI SRST. */
        if (drive->media != ide_disk && !do_not_try_atapi) {
                pre_reset(drive);
                SELECT_DRIVE(drive);
                udelay (20);
-               hwif->OUTB(WIN_SRST, IDE_COMMAND_REG);
+               hwif->OUTBSYNC(drive, WIN_SRST, IDE_COMMAND_REG);
+               ndelay(400);
                hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
                hwgroup->polling = 1;
                __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
@@ -1259,6 +1243,8 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
                 */
                if (stat == 0xff)
                        return -ENODEV;
+               touch_softlockup_watchdog();
+               touch_nmi_watchdog();
        }
        return -EBUSY;
 }