diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-07-20 01:11:58 +0200 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-07-20 01:11:58 +0200 |
commit | 6a824c92db4d606c324272c4eed366fb71672440 (patch) | |
tree | 72b398062fd582b85507b665120f0a5315548eaf | |
parent | 2134758d2a5429325cee4d4ce8959af5314eeba1 (diff) |
ide: remove ide_find_best_pio_mode()
* Add ->host_flags to ide_hwif_t to store ide_pci_device_t.host_flags,
assign it in setup-pci.c:ide_pci_setup_ports().
* Add IDE_HFLAG_PIO_NO_{BLACKLIST,DOWNGRADE} to ide_pci_device_t.host_flags
and teach ide_get_best_pio_mode() about them. Also remove needless
!drive->id check while at it (drive->id is always present).
* Convert amd74xx, via82cxxx and ide-timing.h to use ide_get_best_pio_mode()
and then remove no longer needed ide_find_best_pio_mode().
There should be no functionality changes caused by this patch.
Acked-by: Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-lib.c | 13 | ||||
-rw-r--r-- | drivers/ide/ide-timing.h | 18 | ||||
-rw-r--r-- | drivers/ide/ide.c | 2 | ||||
-rw-r--r-- | drivers/ide/pci/amd74xx.c | 20 | ||||
-rw-r--r-- | drivers/ide/pci/via82cxxx.c | 22 | ||||
-rw-r--r-- | drivers/ide/setup-pci.c | 2 | ||||
-rw-r--r-- | include/linux/ide.h | 7 |
7 files changed, 45 insertions, 39 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index df29868209f3..92a6c7bcf527 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -291,11 +291,11 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode) struct hd_driveid* id = drive->id; int overridden = 0; - if (mode_wanted != 255) { - pio_mode = mode_wanted; - } else if (!drive->id) { - pio_mode = 0; - } else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) { + if (mode_wanted != 255) + return min_t(u8, mode_wanted, max_mode); + + if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0 && + (pio_mode = ide_scan_pio_blacklist(id->model)) != -1) { printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name); } else { pio_mode = id->tPIO; @@ -324,7 +324,8 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode) /* * Conservative "downgrade" for all pre-ATA2 drives */ - if (pio_mode && pio_mode < 4) { + if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_DOWNGRADE) == 0 && + pio_mode && pio_mode < 4) { pio_mode--; printk(KERN_INFO "%s: applying conservative " "PIO \"downgrade\"\n", drive->name); diff --git a/drivers/ide/ide-timing.h b/drivers/ide/ide-timing.h index 9b5afebafbf4..daffbb9797e1 100644 --- a/drivers/ide/ide-timing.h +++ b/drivers/ide/ide-timing.h @@ -106,21 +106,6 @@ static struct ide_timing ide_timing[] = { #define XFER_EPIO 0x01 #define XFER_PIO 0x00 -static short ide_find_best_pio_mode(ide_drive_t *drive) -{ - struct hd_driveid *id = drive->id; - short best = 0; - - /* EIDE PIO modes */ - if ((id->field_valid & 2) && (id->capability & 8)) { - if ((best = (drive->id->eide_pio_modes & 4) ? XFER_PIO_5 : - (drive->id->eide_pio_modes & 2) ? XFER_PIO_4 : - (drive->id->eide_pio_modes & 1) ? XFER_PIO_3 : 0)) return best; - } - - return XFER_PIO_0 + min_t(u8, id->tPIO, 2); -} - static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT) { q->setup = EZ(t->setup * 1000, T); @@ -210,7 +195,8 @@ static int ide_timing_compute(ide_drive_t *drive, short speed, struct ide_timing */ if ((speed & XFER_MODE) != XFER_PIO) { - ide_timing_compute(drive, ide_find_best_pio_mode(drive), &p, T, UT); + u8 pio = ide_get_best_pio_mode(drive, 255, 5); + ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT); ide_timing_merge(&p, t, t, IDE_TIMING_ALL); } diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 077fb674a96d..b442b341d52e 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -455,6 +455,8 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) hwif->straight8 = tmp_hwif->straight8; hwif->bus_state = tmp_hwif->bus_state; + hwif->host_flags = tmp_hwif->host_flags; + hwif->atapi_dma = tmp_hwif->atapi_dma; hwif->ultra_mask = tmp_hwif->ultra_mask; hwif->mwdma_mask = tmp_hwif->mwdma_mask; diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 9c3ea90aeb8b..5ed1d485fc7e 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c @@ -1,5 +1,5 @@ /* - * Version 2.20 + * Version 2.21 * * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04 * IDE driver for Linux. @@ -272,10 +272,8 @@ static int amd_set_drive(ide_drive_t *drive, u8 speed) static void amd74xx_tune_drive(ide_drive_t *drive, u8 pio) { - if (pio == 255) { - amd_set_drive(drive, ide_find_best_pio_mode(drive)); - return; - } + if (pio == 255) + pio = ide_get_best_pio_mode(drive, 255, 5); amd_set_drive(drive, XFER_PIO_0 + min_t(byte, pio, 5)); } @@ -284,12 +282,14 @@ static int amd74xx_ide_dma_check(ide_drive_t *drive) { u8 speed = ide_max_dma_mode(drive); - if (speed == 0) - speed = ide_find_best_pio_mode(drive); + if (speed == 0) { + amd74xx_tune_drive(drive, 255); + return -1; + } amd_set_drive(drive, speed); - if (drive->autodma && (speed & XFER_MODE) != XFER_PIO) + if (drive->autodma) return 0; return -1; @@ -451,6 +451,8 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) .autodma = AUTODMA, \ .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ .bootable = ON_BOARD, \ + .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST \ + | IDE_HFLAG_PIO_NO_DOWNGRADE, \ } #define DECLARE_NV_DEV(name_str) \ @@ -461,6 +463,8 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) .autodma = AUTODMA, \ .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ .bootable = ON_BOARD, \ + .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST \ + | IDE_HFLAG_PIO_NO_DOWNGRADE, \ } static ide_pci_device_t amd74xx_chipsets[] __devinitdata = { diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index bfc9b67f8c92..b107ee3588f7 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c @@ -1,6 +1,6 @@ /* * - * Version 3.45 + * Version 3.46 * * VIA IDE driver for Linux. Supported southbridges: * @@ -203,10 +203,8 @@ static int via_set_drive(ide_drive_t *drive, u8 speed) static void via82cxxx_tune_drive(ide_drive_t *drive, u8 pio) { - if (pio == 255) { - via_set_drive(drive, ide_find_best_pio_mode(drive)); - return; - } + if (pio == 255) + pio = ide_get_best_pio_mode(drive, 255, 5); via_set_drive(drive, XFER_PIO_0 + min_t(u8, pio, 5)); } @@ -223,12 +221,14 @@ static int via82cxxx_ide_dma_check (ide_drive_t *drive) { u8 speed = ide_max_dma_mode(drive); - if (speed == 0) - speed = ide_find_best_pio_mode(drive); + if (speed == 0) { + via82cxxx_tune_drive(drive, 255); + return -1; + } via_set_drive(drive, speed); - if (drive->autodma && (speed & XFER_MODE) != XFER_PIO) + if (drive->autodma) return 0; return -1; @@ -500,7 +500,9 @@ static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = { .init_hwif = init_hwif_via82cxxx, .autodma = NOAUTODMA, .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, - .bootable = ON_BOARD + .bootable = ON_BOARD, + .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST + | IDE_HFLAG_PIO_NO_DOWNGRADE, },{ /* 1 */ .name = "VP_IDE", .init_chipset = init_chipset_via82cxxx, @@ -508,6 +510,8 @@ static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = { .autodma = AUTODMA, .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, .bootable = ON_BOARD, + .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST + | IDE_HFLAG_PIO_NO_DOWNGRADE, } }; diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index bfe1f4e59597..e9f3267456e2 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c @@ -613,6 +613,8 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a else ide_hwif_setup_dma(dev, d, hwif); bypass_legacy_dma: + hwif->host_flags = d->host_flags; + if (d->init_hwif) /* Call chipset-specific routine * for each enabled hwif diff --git a/include/linux/ide.h b/include/linux/ide.h index 14a87f619d17..9f72f6e0c954 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -681,6 +681,8 @@ typedef struct hwif_s { u8 straight8; /* Alan's straight 8 check */ u8 bus_state; /* power state of the IDE bus */ + u8 host_flags; + u8 atapi_dma; /* host supports atapi_dma */ u8 ultra_mask; u8 mwdma_mask; @@ -1245,7 +1247,12 @@ typedef struct ide_pci_enablebit_s { enum { /* Uses ISA control ports not PCI ones. */ IDE_HFLAG_ISA_PORTS = (1 << 0), + /* single port device */ IDE_HFLAG_SINGLE = (1 << 1), + /* don't use legacy PIO blacklist */ + IDE_HFLAG_PIO_NO_BLACKLIST = (1 << 2), + /* don't use conservative PIO "downgrade" */ + IDE_HFLAG_PIO_NO_DOWNGRADE = (1 << 3), }; typedef struct ide_pci_device_s { |