]> err.no Git - linux-2.6/commitdiff
ide: add ide_use_fast_pio() helper (v3)
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sat, 17 Feb 2007 01:40:25 +0000 (02:40 +0100)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sat, 17 Feb 2007 01:40:25 +0000 (02:40 +0100)
* add ide_use_fast_pio() helper for use by host drivers

* add DMA capability and hwif->autodma checks to ide_use_dma()

  - au1xxx-ide/it8213/it821x drivers didn't check for (id->capability & 1)

    [ for the IT8211/2 in SMART mode this check shouldn't be made but since
      in it821x_fixups() we set DMA bit explicitly:

               if(strstr(id->model, "Integrated Technology Express")) {
                       /* In raid mode the ident block is slightly buggy
                          We need to set the bits so that the IDE layer knows
                          LBA28. LBA48 and DMA ar valid */
                       id->capability |= 3;            /* LBA28, DMA */

       we are better off using generic helper if we can ]

  - ide-cris driver didn't set ->autodma

    [ before the patch hwif->autodma was only checked in the chipset specific
      hwif->ide_dma_check implementations, for ide-cris it is cris_dma_check()
      function so there no behavior change here ]

v2:
* updated patch description (thanks to Alan Cox for the feedback)

v3:
* updated for scc_pata driver

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
20 files changed:
drivers/ide/cris/ide-cris.c
drivers/ide/ide-dma.c
drivers/ide/ide-lib.c
drivers/ide/pci/aec62xx.c
drivers/ide/pci/atiixp.c
drivers/ide/pci/cmd64x.c
drivers/ide/pci/cs5535.c
drivers/ide/pci/hpt34x.c
drivers/ide/pci/hpt366.c
drivers/ide/pci/pdc202xx_new.c
drivers/ide/pci/pdc202xx_old.c
drivers/ide/pci/piix.c
drivers/ide/pci/serverworks.c
drivers/ide/pci/siimage.c
drivers/ide/pci/sis5513.c
drivers/ide/pci/slc90e66.c
drivers/ide/pci/tc86c001.c
drivers/ide/pci/triflex.c
drivers/ide/ppc/scc_pata.c
include/linux/ide.h

index 5797e0b5a1327f4e87a41e772bdd568d6180abce..7afb715b86e5b34926bb9214d19d6469c662c48b 100644 (file)
@@ -821,6 +821,9 @@ init_e100_ide (void)
                hwif->ultra_mask = cris_ultra_mask;
                hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */
                hwif->swdma_mask = 0x07; /* Singleword DMA 0-2 */
+               hwif->autodma = 1;
+               hwif->drives[0].autodma = 1;
+               hwif->drives[1].autodma = 1;
        }
 
        /* Reset pulse */
@@ -1046,14 +1049,9 @@ static ide_startstop_t cris_dma_intr (ide_drive_t *drive)
 static int cris_dma_check(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = drive->hwif;
-       struct hd_driveid* id = drive->id;
 
-       if (id && (id->capability & 1)) {
-               if (ide_use_dma(drive)) {
-                       if (cris_config_drive_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-       }
+       if (ide_use_dma(drive) && cris_config_drive_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
        return hwif->ide_dma_off_quietly(drive);
 }
index 56efed6742d4d32945a1072203fea57b833d1df5..941846c216245ccf33d9e257d51307708f70a296 100644 (file)
@@ -680,6 +680,9 @@ int ide_use_dma(ide_drive_t *drive)
        struct hd_driveid *id = drive->id;
        ide_hwif_t *hwif = drive->hwif;
 
+       if ((id->capability & 1) == 0 || drive->autodma == 0)
+               return 0;
+
        /* consult the list of known "bad" drives */
        if (__ide_dma_bad_drive(drive))
                return 0;
index bea5e13ee3613bd8ead4a800bf333ac7589829ef..8afce4ceea310c6e47eea9ff1c715bdb39916591 100644 (file)
@@ -205,6 +205,21 @@ int ide_dma_enable (ide_drive_t *drive)
 
 EXPORT_SYMBOL(ide_dma_enable);
 
+int ide_use_fast_pio(ide_drive_t *drive)
+{
+       struct hd_driveid *id = drive->id;
+
+       if ((id->capability & 1) && drive->autodma)
+               return 1;
+
+       if ((id->capability & 8) || (id->field_valid & 2))
+               return 1;
+
+       return 0;
+}
+
+EXPORT_SYMBOL_GPL(ide_use_fast_pio);
+
 /*
  * Standard (generic) timings for PIO modes, from ATA2 specification.
  * These timings are for access to the IDE data port register *only*.
index cac12c38b940e31abd2f65fd8ab9de6dce3a585f..199507391ae872e7384f605cd7b69d24fb7ee90e 100644 (file)
@@ -210,19 +210,11 @@ static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio)
 static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
-       if ((id->capability & 1) && drive->autodma) {
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-
-               goto fast_ata_pio;
-
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                aec62xx_tune_drive(drive, 5);
                return hwif->ide_dma_off_quietly(drive);
        }
index 922b315da4a03ffc39b7543a6dc4e075388ea3bd..dfc738c42228f0126184a29b01d85daf2f3718eb 100644 (file)
@@ -253,22 +253,14 @@ static int atiixp_config_drive_for_dma(ide_drive_t *drive)
 static int atiixp_dma_check(ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
        u8 tspeed, speed;
 
        drive->init_speed = 0;
 
-       if ((id->capability & 1) && drive->autodma) {
+       if (ide_use_dma(drive) && atiixp_config_drive_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-               if (ide_use_dma(drive)) {
-                       if (atiixp_config_drive_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-
-               goto fast_ata_pio;
-
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                tspeed = ide_get_best_pio_mode(drive, 255, 5, NULL);
                speed = atiixp_dma_2_pio(XFER_PIO_0 + tspeed) + XFER_PIO_0;
                hwif->speedproc(drive, speed);
index 009fc9168443aefd4ad0328e80c17b790cf69714..b1f9f5f3615e1d0d3681d083113a38ab447785db 100644 (file)
@@ -475,19 +475,11 @@ static int config_chipset_for_dma (ide_drive_t *drive)
 static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
-       if ((id != NULL) && ((id->capability & 1) != 0) && drive->autodma) {
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-
-               goto fast_ata_pio;
-
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                config_chipset_for_pio(drive, 1);
                return hwif->ide_dma_off_quietly(drive);
        }
index 5c5aec28e6717f3d9e7c81d243bc711ebf8b455b..e47653f4d1dd2881bbe0714a889b46654398d819 100644 (file)
@@ -196,21 +196,14 @@ static int cs5535_config_drive_for_dma(ide_drive_t *drive)
 static int cs5535_dma_check(ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = drive->hwif;
-       struct hd_driveid *id   = drive->id;
        u8 speed;
 
        drive->init_speed = 0;
 
-       if ((id->capability & 1) && drive->autodma) {
-               if (ide_use_dma(drive)) {
-                       if (cs5535_config_drive_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-
-               goto fast_ata_pio;
+       if (ide_use_dma(drive) && cs5535_config_drive_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                speed = ide_get_best_pio_mode(drive, 255, 4, NULL);
                cs5535_set_drive(drive, speed);
                return hwif->ide_dma_off_quietly(drive);
index 0de3b61cabe33a3183a57edd17c0bba71a1fe6bd..0830089c77fd547938474b9fe138dbe14a6c35df 100644 (file)
@@ -110,25 +110,17 @@ static int config_chipset_for_dma (ide_drive_t *drive)
 static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
        drive->init_speed = 0;
 
-       if (id && (id->capability & 1) && drive->autodma) {
-
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
 #ifndef CONFIG_HPT34X_AUTODMA
-                               return hwif->ide_dma_off_quietly(drive);
+               return hwif->ide_dma_off_quietly(drive);
 #else
-                               return hwif->ide_dma_on(drive);
+               return hwif->ide_dma_on(drive);
 #endif
-               }
-
-               goto fast_ata_pio;
 
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                hpt34x_tune_drive(drive, 255);
                return hwif->ide_dma_off_quietly(drive);
        }
index 06dce09991059a1604f4dc3faa8f1ada92174ed1..d3f6f9da96b27fdf7ff7fd907e1444bff77c149a 100644 (file)
@@ -737,18 +737,13 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
 static int hpt366_config_drive_xfer_rate(ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
        drive->init_speed = 0;
 
-       if ((id->capability & 1) && drive->autodma) {
-               if (ide_use_dma(drive) && config_chipset_for_dma(drive))
-                       return hwif->ide_dma_on(drive);
-
-               goto fast_ata_pio;
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                hpt3xx_tune_drive(drive, 255);
                return hwif->ide_dma_off_quietly(drive);
        }
index 236a03144a2796c04e35e23ae137755e6a495abd..b13a06c5cb2dd1935a97c304454dd9f6a3047002 100644 (file)
@@ -282,19 +282,13 @@ static int config_chipset_for_dma(ide_drive_t *drive)
 static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
        drive->init_speed = 0;
 
-       if ((id->capability & 1) && drive->autodma) {
-
-               if (ide_use_dma(drive) && config_chipset_for_dma(drive))
-                       return hwif->ide_dma_on(drive);
-
-               goto fast_ata_pio;
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                hwif->tuneproc(drive, 255);
                return hwif->ide_dma_off_quietly(drive);
        }
index 80eb6d271330ecbe74be02baa021a6b66b13d973..a2be3d2fd3f658809d88962f180068d7cd024d15 100644 (file)
@@ -323,21 +323,13 @@ chipset_is_set:
 static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
        drive->init_speed = 0;
 
-       if (id && (id->capability & 1) && drive->autodma) {
-
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-
-               goto fast_ata_pio;
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                pdc202xx_tune_drive(drive, 255);
                return hwif->ide_dma_off_quietly(drive);
        }
index 247334473519a778620a92bd95a505e927edd17c..85e8a78e10ad81f6538f7ce7870174d1b3cd3760 100644 (file)
@@ -387,19 +387,13 @@ static int piix_config_drive_for_dma (ide_drive_t *drive)
 static int piix_config_drive_xfer_rate (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
        drive->init_speed = 0;
 
-       if ((id->capability & 1) && drive->autodma) {
+       if (ide_use_dma(drive) && piix_config_drive_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-               if (ide_use_dma(drive) && piix_config_drive_for_dma(drive))
-                       return hwif->ide_dma_on(drive);
-
-               goto fast_ata_pio;
-
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                /* Find best PIO mode. */
                (void) hwif->speedproc(drive, XFER_PIO_0 +
                                       ide_get_best_pio_mode(drive, 255, 4, NULL));
index 81a0742c45946570c7d89442fb42a65886817853..9e92e7ba0227a2230c099c64d6d9fab32f89bfe6 100644 (file)
@@ -316,21 +316,13 @@ static int config_chipset_for_dma (ide_drive_t *drive)
 static int svwks_config_drive_xfer_rate (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
        drive->init_speed = 0;
 
-       if ((id->capability & 1) && drive->autodma) {
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-
-               goto fast_ata_pio;
-
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                config_chipset_for_pio(drive);
                //      hwif->tuneproc(drive, 5);
                return hwif->ide_dma_off_quietly(drive);
index ad98510026a5fb449342f10b4db393035e854353..367733c8c1de1b2c102762164725f60ef7ebad29 100644 (file)
@@ -415,19 +415,11 @@ static int config_chipset_for_dma (ide_drive_t *drive)
 static int siimage_config_drive_for_dma (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
-       if ((id->capability & 1) != 0 && drive->autodma) {
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-
-               goto fast_ata_pio;
-
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                config_chipset_for_pio(drive, 1);
                return hwif->ide_dma_off_quietly(drive);
        }
index e71552e64ae4ba8f52494713eab345be7ca145f4..4fff663a643209e56caafda2d71993abc6787af4 100644 (file)
@@ -670,23 +670,15 @@ static int config_chipset_for_dma (ide_drive_t *drive)
 static int sis5513_config_xfer_rate(ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
        config_art_rwp_pio(drive, 5);
 
        drive->init_speed = 0;
 
-       if (id && (id->capability & 1) && drive->autodma) {
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-
-               goto fast_ata_pio;
-
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                sis5513_tune_drive(drive, 5);
                return hwif->ide_dma_off_quietly(drive);
        }
index 2663ddbd9b67408bbdb68db54eece1c2beec552b..4042fd8e2308688b56bdc14bb1d8f80e371c63ff 100644 (file)
@@ -180,19 +180,13 @@ static int slc90e66_config_drive_for_dma (ide_drive_t *drive)
 static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
        drive->init_speed = 0;
 
-       if ((id->capability & 1) && drive->autodma) {
+       if (ide_use_dma(drive) && slc90e66_config_drive_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-               if (ide_use_dma(drive) && slc90e66_config_drive_for_dma(drive))
-                       return hwif->ide_dma_on(drive);
-
-               goto fast_ata_pio;
-
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                (void) hwif->speedproc(drive, XFER_PIO_0 +
                                       ide_get_best_pio_mode(drive, 255, 4, NULL));
                return hwif->ide_dma_off_quietly(drive);
index 2ad72bbda34217bb3b351bda50065ee5d5385b4f..4e893808f063ca1906df354aaf9ba485a9cd7f83 100644 (file)
@@ -186,17 +186,11 @@ static int config_chipset_for_dma(ide_drive_t *drive)
 static int tc86c001_config_drive_xfer_rate(ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
-       if ((id->capability & 1) && drive->autodma) {
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-               if (ide_use_dma(drive) && config_chipset_for_dma(drive))
-                       return hwif->ide_dma_on(drive);
-
-               goto fast_ata_pio;
-
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                tc86c001_tune_drive(drive, 255);
                return hwif->ide_dma_off_quietly(drive);
        }
index b0d29cd7123aa3a8329e5a9c58b532b82eef22c6..1f5f6759fef8201cd285a3c8d589f50179c8b9bf 100644 (file)
@@ -114,14 +114,9 @@ static int triflex_config_drive_for_dma(ide_drive_t *drive)
 static int triflex_config_drive_xfer_rate(ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
-       if ((id->capability & 1) && drive->autodma) {
-               if (ide_use_dma(drive)) {
-                       if (triflex_config_drive_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-       }
+       if (ide_use_dma(drive) && triflex_config_drive_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
        hwif->tuneproc(drive, 255);
        return hwif->ide_dma_off_quietly(drive);
index 65ad8ab34598d7d160b6d7b12a78715db005d004..0ab26ea5a35a7bd66cc348318b312a5cf66a9414 100644 (file)
@@ -383,16 +383,11 @@ static int scc_config_chipset_for_dma(ide_drive_t *drive)
 static int scc_config_drive_for_dma(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = HWIF(drive);
-       struct hd_driveid *id = drive->id;
 
-       if ((id->capability & 1) != 0 && drive->autodma) {
-               if (ide_use_dma(drive)) {
-                       if (scc_config_chipset_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
-               goto fast_ata_pio;
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-       fast_ata_pio:
+       if (ide_use_dma(drive) && scc_config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
+
+       if (ide_use_fast_pio(drive)) {
                hwif->tuneproc(drive, 4);
                hwif->ide_dma_off_quietly(drive);
        }
index 40b5fa2f26271ed544dc2a117b2445979b2df1e7..9e1a8b9ce1825b8c10ad7cb598aa5cc84032c7a1 100644 (file)
@@ -1352,6 +1352,7 @@ extern int ide_dma_enable(ide_drive_t *drive);
 extern char *ide_xfer_verbose(u8 xfer_rate);
 extern void ide_toggle_bounce(ide_drive_t *drive, int on);
 extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
+int ide_use_fast_pio(ide_drive_t *);
 
 u8 ide_dump_status(ide_drive_t *, const char *, u8);