]> err.no Git - linux-2.6/commitdiff
ide: filter out "default" transfer mode values in set_xfer_rate()
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Wed, 23 Jul 2008 17:55:56 +0000 (19:55 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Wed, 23 Jul 2008 17:55:56 +0000 (19:55 +0200)
* Filter out "default" transfer mode values (0x00 - default PIO mode,
  0x01 - default PIO mode w/ IORDY disabled) in write handler for obsoleted
  /proc/ide/hd?/settings:current_speed setting.

  Allowing "default" transfer mode values is a dangerous thing to do as
  we don't support programming controller to the "default" transfer mode
  and devices often use different values for the default and maximum PIO
  mode (i.e. PIO2 default and PIO4 maximum) so the controller will stay
  programmed for higher PIO mode while device will use the lower PIO mode.

  There is no functionality loss as by using special IOCTLs device can
  still be programmed to "default" transfer modes (it is only useful for
  debugging/testing purposes anyway).

* Remove no longer needed IDE_HFLAG_ABUSE_SET_DMA_MODE host flag, it was
  previously used by few host drivers to program the controller to PIO0
  timings for "default" transfer mode == 0x01 (although some host drivers
  would program invalid PIO timings instead).

* Cleanup ide_set_xfer_rate() and add BUG_ON().

Suggested-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
13 files changed:
drivers/ide/ide-lib.c
drivers/ide/ide-proc.c
drivers/ide/pci/aec62xx.c
drivers/ide/pci/amd74xx.c
drivers/ide/pci/cs5520.c
drivers/ide/pci/cs5535.c
drivers/ide/pci/hpt34x.c
drivers/ide/pci/hpt366.c
drivers/ide/pci/pdc202xx_old.c
drivers/ide/pci/serverworks.c
drivers/ide/pci/tc86c001.c
drivers/ide/pci/via82cxxx.c
include/linux/ide.h

index 13af72f09ec499571d0125ce3784cc8b26baabdd..7ac44d51547075f0e81aff9a38ec695e2c64f25b 100644 (file)
@@ -266,22 +266,11 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
 
        rate = ide_rate_filter(drive, rate);
 
+       BUG_ON(rate < XFER_PIO_0);
+
        if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5)
                return ide_set_pio_mode(drive, rate);
 
-       /*
-        * TODO: transfer modes 0x00-0x07 passed from the user-space are
-        * currently handled here which needs fixing (please note that such
-        * case could happen iff the transfer mode has already been set on
-        * the device by ide-proc.c::set_xfer_rate()).
-        */
-       if (rate < XFER_PIO_0) {
-               if (hwif->host_flags & IDE_HFLAG_ABUSE_SET_DMA_MODE)
-                       return ide_set_dma_mode(drive, rate);
-               else
-                       return ide_config_drive_speed(drive, rate);
-       }
-
        return ide_set_dma_mode(drive, rate);
 }
 
index 54d57a15d59eb3dac55dab7259ffd2a24cfff641..151c91e933dab156adb2606f4a55384fc4866ad0 100644 (file)
@@ -345,7 +345,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg)
        ide_task_t task;
        int err;
 
-       if (arg < 0 || (arg > 1 && arg < XFER_PIO_0) || arg > XFER_UDMA_6)
+       if (arg < XFER_PIO_0 || arg > XFER_UDMA_6)
                return -EINVAL;
 
        memset(&task, 0, sizeof(task));
@@ -357,7 +357,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg)
 
        err = ide_no_data_taskfile(drive, &task);
 
-       if (!err && arg) {
+       if (!err) {
                ide_set_xfer_rate(drive, (u8) arg);
                ide_driveid_update(drive);
        }
index ae7a4329a581065dc10f1f18c83b1d5a7daedb1d..fbc43e121e6b19856f4ceb528c299d5dd682656e 100644 (file)
@@ -195,7 +195,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
                .host_flags     = IDE_HFLAG_SERIALIZE |
                                  IDE_HFLAG_NO_ATAPI_DMA |
                                  IDE_HFLAG_NO_DSC |
-                                 IDE_HFLAG_ABUSE_SET_DMA_MODE |
                                  IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
                .mwdma_mask     = ATA_MWDMA2,
@@ -205,7 +204,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
                .init_chipset   = init_chipset_aec62xx,
                .port_ops       = &atp86x_port_ops,
                .host_flags     = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA |
-                                 IDE_HFLAG_ABUSE_SET_DMA_MODE |
                                  IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
                .mwdma_mask     = ATA_MWDMA2,
@@ -216,7 +214,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
                .enablebits     = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
                .port_ops       = &atp86x_port_ops,
                .host_flags     = IDE_HFLAG_NO_ATAPI_DMA |
-                                 IDE_HFLAG_ABUSE_SET_DMA_MODE |
                                  IDE_HFLAG_NON_BOOTABLE,
                .pio_mask       = ATA_PIO4,
                .mwdma_mask     = ATA_MWDMA2,
@@ -226,7 +223,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
                .init_chipset   = init_chipset_aec62xx,
                .port_ops       = &atp86x_port_ops,
                .host_flags     = IDE_HFLAG_NO_ATAPI_DMA |
-                                 IDE_HFLAG_ABUSE_SET_DMA_MODE |
                                  IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
                .mwdma_mask     = ATA_MWDMA2,
@@ -237,7 +233,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
                .enablebits     = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
                .port_ops       = &atp86x_port_ops,
                .host_flags     = IDE_HFLAG_NO_ATAPI_DMA |
-                                 IDE_HFLAG_ABUSE_SET_DMA_MODE |
                                  IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
                .mwdma_mask     = ATA_MWDMA2,
index 0bfcdd0e77b318a94691c69da0f7a6bdb8d261a6..ef7d971031eee6bad1aef03c49aedec4e6369c78 100644 (file)
@@ -218,7 +218,6 @@ static const struct ide_port_ops amd_port_ops = {
 
 #define IDE_HFLAGS_AMD \
        (IDE_HFLAG_PIO_NO_BLACKLIST | \
-        IDE_HFLAG_ABUSE_SET_DMA_MODE | \
         IDE_HFLAG_POST_SET_MODE | \
         IDE_HFLAG_IO_32BIT | \
         IDE_HFLAG_UNMASK_IRQS)
index d30cb4d99c45ad952d1be154b92655004c6151cb..e8e7df1915bf2a08ffc87984208ebe9f3584520a 100644 (file)
@@ -97,8 +97,7 @@ static const struct ide_port_ops cs5520_port_ops = {
                .name           = name_str,                     \
                .port_ops       = &cs5520_port_ops,             \
                .host_flags     = IDE_HFLAG_ISA_PORTS |         \
-                                 IDE_HFLAG_CS5520 |            \
-                                 IDE_HFLAG_ABUSE_SET_DMA_MODE, \
+                                 IDE_HFLAG_CS5520,             \
                .pio_mask       = ATA_PIO4,                     \
        }
 
index dc97c48623f3fc438fb2237d259d55eb2046d985..5404fe4f701d79cc4bc651c99548ce35da9d4c67 100644 (file)
@@ -171,8 +171,7 @@ static const struct ide_port_ops cs5535_port_ops = {
 static const struct ide_port_info cs5535_chipset __devinitdata = {
        .name           = "CS5535",
        .port_ops       = &cs5535_port_ops,
-       .host_flags     = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE |
-                         IDE_HFLAG_ABUSE_SET_DMA_MODE,
+       .host_flags     = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE,
        .pio_mask       = ATA_PIO4,
        .mwdma_mask     = ATA_MWDMA2,
        .udma_mask      = ATA_UDMA4,
index 84c36c117194cb731e24e2ea60ee7b67e2df5681..9e1d1c4741da5567509c28a671ea9e82aa410139 100644 (file)
@@ -123,7 +123,6 @@ static const struct ide_port_ops hpt34x_port_ops = {
 #define IDE_HFLAGS_HPT34X \
        (IDE_HFLAG_NO_ATAPI_DMA | \
         IDE_HFLAG_NO_DSC | \
-        IDE_HFLAG_ABUSE_SET_DMA_MODE | \
         IDE_HFLAG_NO_AUTODMA)
 
 static const struct ide_port_info hpt34x_chipsets[] __devinitdata = {
index e5651cefa3956c3adaa0288e022feb51fce30ed3..1f1135ce7cd6616f9626c062013168e6d5b3af9c 100644 (file)
@@ -1409,7 +1409,6 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2)
 
 #define IDE_HFLAGS_HPT3XX \
        (IDE_HFLAG_NO_ATAPI_DMA | \
-        IDE_HFLAG_ABUSE_SET_DMA_MODE | \
         IDE_HFLAG_OFF_BOARD)
 
 static const struct ide_port_ops hpt3xx_port_ops = {
index 1c2f9df311293f2cae2d0d57a5c94b07491885e5..e54dc653b8c4aa609edbb6d16a0ab85e0bfa034b 100644 (file)
@@ -312,7 +312,6 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
 
 #define IDE_HFLAGS_PDC202XX \
        (IDE_HFLAG_ERROR_STOPS_FIFO | \
-        IDE_HFLAG_ABUSE_SET_DMA_MODE | \
         IDE_HFLAG_OFF_BOARD)
 
 static const struct ide_port_ops pdc20246_port_ops = {
index a1fb20826a5b817244d500db92c921a054c9ddee..127ccb45e261c23cb799bcb1e886141155f4b779 100644 (file)
@@ -349,9 +349,7 @@ static const struct ide_port_ops svwks_port_ops = {
        .cable_detect           = svwks_cable_detect,
 };
 
-#define IDE_HFLAGS_SVWKS \
-       (IDE_HFLAG_LEGACY_IRQS | \
-        IDE_HFLAG_ABUSE_SET_DMA_MODE)
+#define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS
 
 static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
        {       /* 0 */
index a81d47c55ce141437aa770396b3901c17e07d6d7..477e1979010230d4f1662af093b535520d9ccd95 100644 (file)
@@ -206,8 +206,7 @@ static const struct ide_port_info tc86c001_chipset __devinitdata = {
        .init_hwif      = init_hwif_tc86c001,
        .port_ops       = &tc86c001_port_ops,
        .dma_ops        = &tc86c001_dma_ops,
-       .host_flags     = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD |
-                         IDE_HFLAG_ABUSE_SET_DMA_MODE,
+       .host_flags     = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD,
        .pio_mask       = ATA_PIO4,
        .mwdma_mask     = ATA_MWDMA2,
        .udma_mask      = ATA_UDMA4,
index e47384c70c40bee808d79ef4fc2f127418bb8e47..09dc4803ef9d282c528240dee980f4d55f080a79 100644 (file)
@@ -425,7 +425,6 @@ static const struct ide_port_info via82cxxx_chipset __devinitdata = {
        .enablebits     = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } },
        .port_ops       = &via_port_ops,
        .host_flags     = IDE_HFLAG_PIO_NO_BLACKLIST |
-                         IDE_HFLAG_ABUSE_SET_DMA_MODE |
                          IDE_HFLAG_POST_SET_MODE |
                          IDE_HFLAG_IO_32BIT,
        .pio_mask       = ATA_PIO5,
index 3f28894002505678f39e870fa1abcc565b990b7b..260e871ae880aef320595cf79f15fdca4e368fb9 100644 (file)
@@ -1085,7 +1085,6 @@ enum {
        IDE_HFLAG_IO_32BIT              = (1 << 24),
        /* unmask IRQs */
        IDE_HFLAG_UNMASK_IRQS           = (1 << 25),
-       IDE_HFLAG_ABUSE_SET_DMA_MODE    = (1 << 26),
        /* serialize ports if DMA is possible (for sl82c105) */
        IDE_HFLAG_SERIALIZE_DMA         = (1 << 27),
        /* force host out of "simplex" mode */