[ide] piix: fix wrong DMA mode selected

From: Carsten Haustein <chaus@cs.uni-potsdam.de>

A bug in function piix_config_drive_xfer_rate() allows a call of
hwif->ide_dma_on(drive) without prior call of piix_config_drive_for_dma().
This results in harddisk configured for UDMA (default?) whereas the highest
DMA mode supported by PIIX3 is MWORD2.

This bug is supposed to be present in any 2.6.x kernel release and any
2.4.x kernel release since 2.4.21.

bart: this should also fix the same bug for PIIXa and PIIXb

Fixes bugzilla bug #3473.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 5bc481aa
...@@ -561,36 +561,31 @@ static int piix_config_drive_xfer_rate (ide_drive_t *drive) ...@@ -561,36 +561,31 @@ static int piix_config_drive_xfer_rate (ide_drive_t *drive)
drive->init_speed = 0; drive->init_speed = 0;
if ((id->capability & 1) && drive->autodma) { if ((id->capability & 1) && drive->autodma) {
/* Consult the list of known "bad" drives */ /* Consult the list of known "bad" drives */
if (__ide_dma_bad_drive(drive)) if (__ide_dma_bad_drive(drive))
goto fast_ata_pio; goto fast_ata_pio;
if (id->field_valid & 4) {
if (id->dma_ultra & hwif->ultra_mask) { /**
/* Force if Capable UltraDMA */ * Try to turn DMA on if:
if ((id->field_valid & 2) && * - UDMA or EIDE modes are supported or
(!piix_config_drive_for_dma(drive))) * - drive is a known "good" drive
goto try_dma_modes; *
} * Checks for best mode supported are down later by
} else if (id->field_valid & 2) { * piix_config_drive_for_dma() -> ide_dma_speed()
try_dma_modes: */
if ((id->dma_mword & hwif->mwdma_mask) || if ((id->field_valid & (4 | 2)) ||
(id->dma_1word & hwif->swdma_mask)) { (__ide_dma_good_drive(drive) && id->eide_dma_time < 150)) {
/* Force if Capable regular DMA modes */ if (piix_config_drive_for_dma(drive))
if (!piix_config_drive_for_dma(drive)) return hwif->ide_dma_on(drive);
goto no_dma_set;
} }
} else if (__ide_dma_good_drive(drive) &&
(id->eide_dma_time < 150)) { /* For some reason DMA wasn't turned on, so try PIO. */
/* Consult the list of known "good" drives */
if (!piix_config_drive_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)) { } else if ((id->capability & 8) || (id->field_valid & 2)) {
fast_ata_pio: fast_ata_pio:
no_dma_set: /* Find best PIO mode. */
hwif->tuneproc(drive, 255); hwif->tuneproc(drive, 255);
return hwif->ide_dma_off_quietly(drive); return hwif->ide_dma_off_quietly(drive);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment