Commit 6a824c92db4d606c324272c4eed366fb71672440

Authored by Bartlomiej Zolnierkiewicz
1 parent 2134758d2a

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>

Showing 7 changed files with 45 additions and 39 deletions Side-by-side Diff

drivers/ide/ide-lib.c
... ... @@ -291,11 +291,11 @@
291 291 struct hd_driveid* id = drive->id;
292 292 int overridden = 0;
293 293  
294   - if (mode_wanted != 255) {
295   - pio_mode = mode_wanted;
296   - } else if (!drive->id) {
297   - pio_mode = 0;
298   - } else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
  294 + if (mode_wanted != 255)
  295 + return min_t(u8, mode_wanted, max_mode);
  296 +
  297 + if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0 &&
  298 + (pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
299 299 printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name);
300 300 } else {
301 301 pio_mode = id->tPIO;
... ... @@ -324,7 +324,8 @@
324 324 /*
325 325 * Conservative "downgrade" for all pre-ATA2 drives
326 326 */
327   - if (pio_mode && pio_mode < 4) {
  327 + if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_DOWNGRADE) == 0 &&
  328 + pio_mode && pio_mode < 4) {
328 329 pio_mode--;
329 330 printk(KERN_INFO "%s: applying conservative "
330 331 "PIO \"downgrade\"\n", drive->name);
drivers/ide/ide-timing.h
... ... @@ -106,21 +106,6 @@
106 106 #define XFER_EPIO 0x01
107 107 #define XFER_PIO 0x00
108 108  
109   -static short ide_find_best_pio_mode(ide_drive_t *drive)
110   -{
111   - struct hd_driveid *id = drive->id;
112   - short best = 0;
113   -
114   - /* EIDE PIO modes */
115   - if ((id->field_valid & 2) && (id->capability & 8)) {
116   - if ((best = (drive->id->eide_pio_modes & 4) ? XFER_PIO_5 :
117   - (drive->id->eide_pio_modes & 2) ? XFER_PIO_4 :
118   - (drive->id->eide_pio_modes & 1) ? XFER_PIO_3 : 0)) return best;
119   - }
120   -
121   - return XFER_PIO_0 + min_t(u8, id->tPIO, 2);
122   -}
123   -
124 109 static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT)
125 110 {
126 111 q->setup = EZ(t->setup * 1000, T);
... ... @@ -210,7 +195,8 @@
210 195 */
211 196  
212 197 if ((speed & XFER_MODE) != XFER_PIO) {
213   - ide_timing_compute(drive, ide_find_best_pio_mode(drive), &p, T, UT);
  198 + u8 pio = ide_get_best_pio_mode(drive, 255, 5);
  199 + ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT);
214 200 ide_timing_merge(&p, t, t, IDE_TIMING_ALL);
215 201 }
216 202  
... ... @@ -455,6 +455,8 @@
455 455 hwif->straight8 = tmp_hwif->straight8;
456 456 hwif->bus_state = tmp_hwif->bus_state;
457 457  
  458 + hwif->host_flags = tmp_hwif->host_flags;
  459 +
458 460 hwif->atapi_dma = tmp_hwif->atapi_dma;
459 461 hwif->ultra_mask = tmp_hwif->ultra_mask;
460 462 hwif->mwdma_mask = tmp_hwif->mwdma_mask;
drivers/ide/pci/amd74xx.c
1 1 /*
2   - * Version 2.20
  2 + * Version 2.21
3 3 *
4 4 * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04
5 5 * IDE driver for Linux.
... ... @@ -272,10 +272,8 @@
272 272  
273 273 static void amd74xx_tune_drive(ide_drive_t *drive, u8 pio)
274 274 {
275   - if (pio == 255) {
276   - amd_set_drive(drive, ide_find_best_pio_mode(drive));
277   - return;
278   - }
  275 + if (pio == 255)
  276 + pio = ide_get_best_pio_mode(drive, 255, 5);
279 277  
280 278 amd_set_drive(drive, XFER_PIO_0 + min_t(byte, pio, 5));
281 279 }
282 280  
... ... @@ -284,12 +282,14 @@
284 282 {
285 283 u8 speed = ide_max_dma_mode(drive);
286 284  
287   - if (speed == 0)
288   - speed = ide_find_best_pio_mode(drive);
  285 + if (speed == 0) {
  286 + amd74xx_tune_drive(drive, 255);
  287 + return -1;
  288 + }
289 289  
290 290 amd_set_drive(drive, speed);
291 291  
292   - if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
  292 + if (drive->autodma)
293 293 return 0;
294 294  
295 295 return -1;
... ... @@ -451,6 +451,8 @@
451 451 .autodma = AUTODMA, \
452 452 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \
453 453 .bootable = ON_BOARD, \
  454 + .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST \
  455 + | IDE_HFLAG_PIO_NO_DOWNGRADE, \
454 456 }
455 457  
456 458 #define DECLARE_NV_DEV(name_str) \
... ... @@ -461,6 +463,8 @@
461 463 .autodma = AUTODMA, \
462 464 .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \
463 465 .bootable = ON_BOARD, \
  466 + .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST \
  467 + | IDE_HFLAG_PIO_NO_DOWNGRADE, \
464 468 }
465 469  
466 470 static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
drivers/ide/pci/via82cxxx.c
1 1 /*
2 2 *
3   - * Version 3.45
  3 + * Version 3.46
4 4 *
5 5 * VIA IDE driver for Linux. Supported southbridges:
6 6 *
... ... @@ -203,10 +203,8 @@
203 203  
204 204 static void via82cxxx_tune_drive(ide_drive_t *drive, u8 pio)
205 205 {
206   - if (pio == 255) {
207   - via_set_drive(drive, ide_find_best_pio_mode(drive));
208   - return;
209   - }
  206 + if (pio == 255)
  207 + pio = ide_get_best_pio_mode(drive, 255, 5);
210 208  
211 209 via_set_drive(drive, XFER_PIO_0 + min_t(u8, pio, 5));
212 210 }
213 211  
... ... @@ -223,12 +221,14 @@
223 221 {
224 222 u8 speed = ide_max_dma_mode(drive);
225 223  
226   - if (speed == 0)
227   - speed = ide_find_best_pio_mode(drive);
  224 + if (speed == 0) {
  225 + via82cxxx_tune_drive(drive, 255);
  226 + return -1;
  227 + }
228 228  
229 229 via_set_drive(drive, speed);
230 230  
231   - if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
  231 + if (drive->autodma)
232 232 return 0;
233 233  
234 234 return -1;
... ... @@ -500,7 +500,9 @@
500 500 .init_hwif = init_hwif_via82cxxx,
501 501 .autodma = NOAUTODMA,
502 502 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
503   - .bootable = ON_BOARD
  503 + .bootable = ON_BOARD,
  504 + .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST
  505 + | IDE_HFLAG_PIO_NO_DOWNGRADE,
504 506 },{ /* 1 */
505 507 .name = "VP_IDE",
506 508 .init_chipset = init_chipset_via82cxxx,
... ... @@ -508,6 +510,8 @@
508 510 .autodma = AUTODMA,
509 511 .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
510 512 .bootable = ON_BOARD,
  513 + .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST
  514 + | IDE_HFLAG_PIO_NO_DOWNGRADE,
511 515 }
512 516 };
513 517  
drivers/ide/setup-pci.c
... ... @@ -613,6 +613,8 @@
613 613 else
614 614 ide_hwif_setup_dma(dev, d, hwif);
615 615 bypass_legacy_dma:
  616 + hwif->host_flags = d->host_flags;
  617 +
616 618 if (d->init_hwif)
617 619 /* Call chipset-specific routine
618 620 * for each enabled hwif
... ... @@ -681,6 +681,8 @@
681 681 u8 straight8; /* Alan's straight 8 check */
682 682 u8 bus_state; /* power state of the IDE bus */
683 683  
  684 + u8 host_flags;
  685 +
684 686 u8 atapi_dma; /* host supports atapi_dma */
685 687 u8 ultra_mask;
686 688 u8 mwdma_mask;
687 689  
... ... @@ -1245,7 +1247,12 @@
1245 1247 enum {
1246 1248 /* Uses ISA control ports not PCI ones. */
1247 1249 IDE_HFLAG_ISA_PORTS = (1 << 0),
  1250 + /* single port device */
1248 1251 IDE_HFLAG_SINGLE = (1 << 1),
  1252 + /* don't use legacy PIO blacklist */
  1253 + IDE_HFLAG_PIO_NO_BLACKLIST = (1 << 2),
  1254 + /* don't use conservative PIO "downgrade" */
  1255 + IDE_HFLAG_PIO_NO_DOWNGRADE = (1 << 3),
1249 1256 };
1250 1257  
1251 1258 typedef struct ide_pci_device_s {