[patch 21/37] ata_piix: verify SIDPR access before enabling it

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg KH
Date: Tuesday, May 13, 2008 - 1:12 pm

2.6.25-stable review patch.  If anyone has any objections, please let us
know.

------------------
From: Tejun Heo <htejun@gmail.com>

commit cb6716c879ecf49e2af344926c6a476821812061 upstream

On certain configurations (certain macbooks), even though all the
conditions for SIDPR access described in the datasheet are met,
actually reading those registers just returns 0 and have no effect on
write.  Verify SIDPR is actually working before enabling it.

This is reported by Ryan Roth in bz#10512.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Ryan Roth <ryan.roth@ch2m.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/ata/ata_piix.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1531,6 +1531,8 @@ static void __devinit piix_init_sidpr(st
 {
 	struct pci_dev *pdev = to_pci_dev(host->dev);
 	struct piix_host_priv *hpriv = host->private_data;
+	struct ata_device *dev0 = &host->ports[0]->link.device[0];
+	u32 scontrol;
 	int i;
 
 	/* check for availability */
@@ -1549,6 +1551,29 @@ static void __devinit piix_init_sidpr(st
 		return;
 
 	hpriv->sidpr = pcim_iomap_table(pdev)[PIIX_SIDPR_BAR];
+
+	/* SCR access via SIDPR doesn't work on some configurations.
+	 * Give it a test drive by inhibiting power save modes which
+	 * we'll do anyway.
+	 */
+	scontrol = piix_sidpr_read(dev0, SCR_CONTROL);
+
+	/* if IPM is already 3, SCR access is probably working.  Don't
+	 * un-inhibit power save modes as BIOS might have inhibited
+	 * them for a reason.
+	 */
+	if ((scontrol & 0xf00) != 0x300) {
+		scontrol |= 0x300;
+		piix_sidpr_write(dev0, SCR_CONTROL, scontrol);
+		scontrol = piix_sidpr_read(dev0, SCR_CONTROL);
+
+		if ((scontrol & 0xf00) != 0x300) {
+			dev_printk(KERN_INFO, host->dev, "SCR access via "
+				   "SIDPR is available but doesn't work\n");
+			return;
+		}
+	}
+
 	host->ports[0]->ops = &piix_sidpr_sata_ops;
 	host->ports[1]->ops = &piix_sidpr_sata_ops;
 }

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/37] 2.6.25.4 -stable review, Greg KH, (Tue May 13, 1:10 pm)
[patch 06/37] sparc: sunzilog uart order, Greg KH, (Tue May 13, 1:11 pm)
[patch 21/37] ata_piix: verify SIDPR access before enabling it, Greg KH, (Tue May 13, 1:12 pm)
[patch 24/37] sparc: Fix ptrace() detach., Greg KH, (Tue May 13, 1:12 pm)
[patch 37/37] md: fix raid5 repair operations, Greg KH, (Tue May 13, 1:12 pm)
Re: [patch 20/37] {nfnetlink, ip, ip6}_queue: fix skb_over ..., Gustavo Guillermo Perez, (Wed May 14, 9:45 am)
Hardware designt to prevent Damages... [WAS: [patch 23/37] ..., Michelle Konzack, (Wed May 14, 12:52 pm)
Re: Hardware designt to prevent Damages... [WAS: [patch 23 ..., linux-os (Dick Johnson), (Thu May 15, 10:57 am)
Re: [patch 22/37] x86: sysfs cpu?/topology is empty in 2.6 ..., Vaidyanathan Srinivasan, (Thu May 15, 11:06 am)