This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / ide / pci / cmd64x.c
index aaadb17..abea997 100644 (file)
@@ -441,16 +441,36 @@ static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
        struct hd_driveid *id   = drive->id;
 
        if ((id != NULL) && ((id->capability & 1) != 0) && drive->autodma) {
-
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
+               /* Consult the list of known "bad" drives */
+               if (__ide_dma_bad_drive(drive))
+                       goto fast_ata_pio;
+               if ((id->field_valid & 4) && cmd64x_ratemask(drive)) {
+                       if (id->dma_ultra & hwif->ultra_mask) {
+                               /* Force if Capable UltraDMA */
+                               int dma = config_chipset_for_dma(drive);
+                               if ((id->field_valid & 2) && !dma)
+                                       goto try_dma_modes;
+                       }
+               } else if (id->field_valid & 2) {
+try_dma_modes:
+                       if ((id->dma_mword & hwif->mwdma_mask) ||
+                           (id->dma_1word & hwif->swdma_mask)) {
+                               /* Force if Capable regular DMA modes */
+                               if (!config_chipset_for_dma(drive))
+                                       goto no_dma_set;
+                       }
+               } else if (__ide_dma_good_drive(drive) &&
+                          (id->eide_dma_time < 150)) {
+                       /* Consult the list of known "good" drives */
+                       if (!config_chipset_for_dma(drive))
+                               goto no_dma_set;
+               } else {
+                       goto fast_ata_pio;
                }
-
-               goto fast_ata_pio;
-
+               return hwif->ide_dma_on(drive);
        } else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
+no_dma_set:
                config_chipset_for_pio(drive, 1);
                return hwif->ide_dma_off_quietly(drive);
        }