diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2006-10-03 04:14:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-03 11:04:08 -0400 |
commit | 5ac24697699b394cdebac0a2329ce3af247d6a3b (patch) | |
tree | 6c60f82870321757f2b354fb2562769d77467fdf /drivers | |
parent | 14e0a193209aeea810ad3d66388f422dc79c5b40 (diff) |
[PATCH] ide: backport piix fixes from libata into the legacy driver
There are three flags being set by default by the PIIX driver for speeds >
PIO 1, and one not being cleared properly on fallback to PIO0. The most
important one is the prefetch/post write control which only works for ATA
and can do bad things with ATAPI.
The patch does its best to set the flags correctly for drivers/ide. Its
not 100% perfect but its closer than the original. 100% perfect requires
proper IORDY handling but this isn't critical (and its not right in libata
either .. yet)
Sergei Shtylyov <sshtylyov@ru.mvista.com> said:
> + { 0, 0 },
> + { 0, 0 },
> + { 1, 0 },
> + { 2, 1 },
> + { 2, 3 }, };
>
> pio = ide_get_best_pio_mode(drive, pio, 5, NULL);
BTW, there's quite obvious error here which leads to access outside of
timings[] if somebody passes PIO mode 5 (or autotuning code finds out that
drive supports PIO mode 5). Could have been fixed while at it... Those drives
should be rare, though...
> + }
> master_data = master_data | (timings[pio][0] << 12) | (timings[pio][1] << 8);
> }
> pci_write_config_word(dev, master_port, master_data);
Actually, there's one more serious issue with piix_tune_drive() -- it
doesn't actually set the drive's own transfer mode.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/pci/piix.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index eb5bab1890cd..cdc3aab9ebcb 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
@@ -222,13 +222,15 @@ static void piix_tune_drive (ide_drive_t *drive, u8 pio) | |||
222 | u16 master_data; | 222 | u16 master_data; |
223 | u8 slave_data; | 223 | u8 slave_data; |
224 | static DEFINE_SPINLOCK(tune_lock); | 224 | static DEFINE_SPINLOCK(tune_lock); |
225 | int control = 0; | ||
225 | 226 | ||
226 | /* ISP RTC */ | 227 | /* ISP RTC */ |
227 | u8 timings[][2] = { { 0, 0 }, | 228 | static const u8 timings[][2]= { |
228 | { 0, 0 }, | 229 | { 0, 0 }, |
229 | { 1, 0 }, | 230 | { 0, 0 }, |
230 | { 2, 1 }, | 231 | { 1, 0 }, |
231 | { 2, 3 }, }; | 232 | { 2, 1 }, |
233 | { 2, 3 }, }; | ||
232 | 234 | ||
233 | pio = ide_get_best_pio_mode(drive, pio, 5, NULL); | 235 | pio = ide_get_best_pio_mode(drive, pio, 5, NULL); |
234 | 236 | ||
@@ -239,19 +241,30 @@ static void piix_tune_drive (ide_drive_t *drive, u8 pio) | |||
239 | */ | 241 | */ |
240 | spin_lock_irqsave(&tune_lock, flags); | 242 | spin_lock_irqsave(&tune_lock, flags); |
241 | pci_read_config_word(dev, master_port, &master_data); | 243 | pci_read_config_word(dev, master_port, &master_data); |
244 | |||
245 | if (pio >= 2) | ||
246 | control |= 1; /* Programmable timing on */ | ||
247 | if (drive->media == ide_disk) | ||
248 | control |= 4; /* Prefetch, post write */ | ||
249 | if (pio >= 3) | ||
250 | control |= 2; /* IORDY */ | ||
242 | if (is_slave) { | 251 | if (is_slave) { |
243 | master_data = master_data | 0x4000; | 252 | master_data = master_data | 0x4000; |
244 | if (pio > 1) | 253 | if (pio > 1) { |
245 | /* enable PPE, IE and TIME */ | 254 | /* enable PPE, IE and TIME */ |
246 | master_data = master_data | 0x0070; | 255 | master_data = master_data | (control << 4); |
256 | } else { | ||
257 | master_data &= ~0x0070; | ||
258 | } | ||
247 | pci_read_config_byte(dev, slave_port, &slave_data); | 259 | pci_read_config_byte(dev, slave_port, &slave_data); |
248 | slave_data = slave_data & (hwif->channel ? 0x0f : 0xf0); | 260 | slave_data = slave_data & (hwif->channel ? 0x0f : 0xf0); |
249 | slave_data = slave_data | (((timings[pio][0] << 2) | timings[pio][1]) << (hwif->channel ? 4 : 0)); | 261 | slave_data = slave_data | (((timings[pio][0] << 2) | timings[pio][1]) << (hwif->channel ? 4 : 0)); |
250 | } else { | 262 | } else { |
251 | master_data = master_data & 0xccf8; | 263 | master_data = master_data & 0xccf8; |
252 | if (pio > 1) | 264 | if (pio > 1) { |
253 | /* enable PPE, IE and TIME */ | 265 | /* enable PPE, IE and TIME */ |
254 | master_data = master_data | 0x0007; | 266 | master_data = master_data | control; |
267 | } | ||
255 | master_data = master_data | (timings[pio][0] << 12) | (timings[pio][1] << 8); | 268 | master_data = master_data | (timings[pio][0] << 12) | (timings[pio][1] << 8); |
256 | } | 269 | } |
257 | pci_write_config_word(dev, master_port, master_data); | 270 | pci_write_config_word(dev, master_port, master_data); |