]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
libata: restore SControl on detach
authorTejun Heo <tj@kernel.org>
Thu, 31 Jul 2008 07:09:34 +0000 (16:09 +0900)
committerJeff Garzik <jgarzik@redhat.com>
Fri, 22 Aug 2008 06:19:46 +0000 (02:19 -0400)
Save SControl during probing and restore it on detach.  This prevents
adjustments made by libata drivers to seep into the next driver which
gets attached (be it a libata one or not).

It's not clear whether SControl also needs to be restored on suspend.
The next system to have control (ACPI or kexec'd kernel) would
probably like to see the original SControl value but there's no
guarantee that a link is gonna keep working after SControl is adjusted
without a reset and adding a reset and modified recovery cycle soley
for this is an overkill.  For now, do it only for detach.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/ata/libata-core.c
include/linux/libata.h

index dddcb9fde35af48c18e1cf560d21c47edafe94ac..5f8f57a818fb7a925042dd8050c7d14708bfc36d 100644 (file)
@@ -5199,15 +5199,14 @@ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
  */
 int sata_link_init_spd(struct ata_link *link)
 {
-       u32 scontrol;
        u8 spd;
        int rc;
 
-       rc = sata_scr_read(link, SCR_CONTROL, &scontrol);
+       rc = sata_scr_read(link, SCR_CONTROL, &link->saved_scontrol);
        if (rc)
                return rc;
 
-       spd = (scontrol >> 4) & 0xf;
+       spd = (link->saved_scontrol >> 4) & 0xf;
        if (spd)
                link->hw_sata_spd_limit &= (1 << spd) - 1;
 
@@ -5794,9 +5793,10 @@ static void ata_port_detach(struct ata_port *ap)
        ata_port_wait_eh(ap);
 
        /* EH is now guaranteed to see UNLOADING - EH context belongs
-        * to us.  Disable all existing devices.
+        * to us.  Restore SControl and disable all existing devices.
         */
-       ata_port_for_each_link(link, ap) {
+       __ata_port_for_each_link(link, ap) {
+               sata_scr_write(link, SCR_CONTROL, link->saved_scontrol);
                ata_link_for_each_dev(dev, link)
                        ata_dev_disable(dev);
        }
index 5340d4c83fd90b77bb0bd974430340b859e3549e..80233fdc159f06bb7c6b2635f1a4a6802fb0ca71 100644 (file)
@@ -647,6 +647,7 @@ struct ata_link {
 
        unsigned int            flags;          /* ATA_LFLAG_xxx */
 
+       u32                     saved_scontrol; /* SControl on probe */
        unsigned int            hw_sata_spd_limit;
        unsigned int            sata_spd_limit;
        unsigned int            sata_spd;       /* current SATA PHY speed */