[PATCH] pata_acpi: Rework the ACPI drivers based upon experience of what the BIOS can do

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Alan Cox <alan@xxxxxxxxxx>

Don't assume the BIOS can validate modes or has any sense at all.
Instead use the BIOS timings to deduce the modes.

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.22-rc6-mm1/drivers/ata/pata_acpi.c linux-2.6.22-rc6-mm1/drivers/ata/pata_acpi.c
--- linux.vanilla-2.6.22-rc6-mm1/drivers/ata/pata_acpi.c	2007-07-02 20:50:11.000000000 +0100
+++ linux-2.6.22-rc6-mm1/drivers/ata/pata_acpi.c	2007-07-18 14:06:47.000000000 +0100
@@ -2,8 +2,6 @@
  *	ACPI PATA driver
  *
  *	(c) 2007 Red Hat  <alan@xxxxxxxxxx>
- *
- *	TODO - restore modes after mode_filter chews them up
  */
 
 #include <linux/kernel.h>
@@ -28,7 +26,7 @@
 #include "libata-acpi.h"
 
 #define DRV_NAME	"pata_acpi"
-#define DRV_VERSION	"0.1.1"
+#define DRV_VERSION	"0.2.1"
 
 struct pata_acpi {
 	void *handle;
@@ -122,59 +120,41 @@
 	if (!(probe.flags & 0x10))
 		unit = 0;
 
-
-	/* In order to generate a valid mode mask as we need cycle through
-	   trying each proposed speed in turn */
+	ata_acpi_gtm(ap. acpi->handle, &probe);
 
 	/* Start by scanning for PIO modes */
 	for (i = 0; i < 7; i++) {
-		probe.drive[unit].pio = pio_cycle[i];
-		ata_acpi_stm(ap, acpi->handle, &probe);
-		ata_acpi_gtm(ap, acpi->handle, &probe);
 		t = probe.drive[unit].pio;
-		if (t == 0xFFFFFFFF || (i &&  t >= pio_cycle[i-1]))
-			mask &= ~(1 << (i + ATA_SHIFT_PIO));
-	}
-
-	/* Select MWDMA */
-	probe.flags &= ~(1 << (2 * unit));
-
-	/* Scan for MWDMA modes */
-	for (i = 0; i < 5; i++) {
-		u32 t;
-		probe.drive[unit].dma = mwdma_cycle[i];
-		ata_acpi_stm(ap, acpi->handle, &probe);
-		ata_acpi_gtm(ap, acpi->handle, &probe);
-
-		t = probe.drive[unit].dma;
-
-		if (t == 0xFFFFFFFF || (i && t >= mwdma_cycle[i-1]))
-			mask &= ~ (1 << (i + ATA_SHIFT_MWDMA));
+		if (t <= pio_cycle[i]) {
+			mask |= (2 << (ATA_SHIFT_PIO + i)) - 1;
+			break;
+		}
 	}
 
-	/* Select UDMA */
-	probe.flags |= (1 << (2 * unit));
-
-	/* Scan for UDMA modes */
-	for (i = 0; i < 7; i++) {
-		u32 t;
-		probe.drive[unit].dma = udma_cycle[i];
-		ata_acpi_stm(ap, acpi->handle, &probe);
-		ata_acpi_gtm(ap, acpi->handle, &probe);
-
-		t = probe.drive[unit].dma;
-
-		if (t == 0xFFFFFFFF || (i && t >= udma_cycle[i-1]))
-			mask &= ~ (1 << (i + ATA_SHIFT_UDMA));
+	/* See if we have MWDMA or UDMA data. We don't bother with MWDMA
+	   if UDMA is availabe as this means the BIOS set UDMA and our
+	   error changedown if it works is UDMA to PIO anyway */
+	if (probe.flags & (1 << (2 * unit))) {
+		/* MWDMA */
+		for (i = 0; i < 5; i++) {
+			t = probe.drive[unit].dma;
+			if (t <= mwdma_cycle[i]) {
+				mask |= (2 << (ATA_SHIFT_MWDMA + i)) - 1;
+				break;
+			}
+		}
+	} else {
+		/* UDMA */
+		for (i = 0; i < 7; i++) {
+			t = probe.drive[unit].dma;
+			if (t <= udma_cycle[i]) {
+				mask |= (2 << (ATA_SHIFT_UDMA + i)) - 1;
+				break;
+			}
+		}
 	}
-
 	if (mask & (0xF8 << ATA_SHIFT_UDMA))
 		ap->cbl = ATA_CBL_PATA80;
-
-	/* Restore the programmed timings */
-	ata_acpi_stm(ap, acpi->handle, &acpi->gtm);
-	/* And finally we can hand back the list of speeds that actually are
-	   supported by the BIOS */
 	return mask;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux