libata: restore SControl on detach

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>

authored by Tejun Heo and committed by Jeff Garzik d127ea7b da0e21d3

+6 -5
+5 -5
drivers/ata/libata-core.c
··· 5199 5199 */ 5200 5200 int sata_link_init_spd(struct ata_link *link) 5201 5201 { 5202 - u32 scontrol; 5203 5202 u8 spd; 5204 5203 int rc; 5205 5204 5206 - rc = sata_scr_read(link, SCR_CONTROL, &scontrol); 5205 + rc = sata_scr_read(link, SCR_CONTROL, &link->saved_scontrol); 5207 5206 if (rc) 5208 5207 return rc; 5209 5208 5210 - spd = (scontrol >> 4) & 0xf; 5209 + spd = (link->saved_scontrol >> 4) & 0xf; 5211 5210 if (spd) 5212 5211 link->hw_sata_spd_limit &= (1 << spd) - 1; 5213 5212 ··· 5793 5794 ata_port_wait_eh(ap); 5794 5795 5795 5796 /* EH is now guaranteed to see UNLOADING - EH context belongs 5796 - * to us. Disable all existing devices. 5797 + * to us. Restore SControl and disable all existing devices. 5797 5798 */ 5798 - ata_port_for_each_link(link, ap) { 5799 + __ata_port_for_each_link(link, ap) { 5800 + sata_scr_write(link, SCR_CONTROL, link->saved_scontrol); 5799 5801 ata_link_for_each_dev(dev, link) 5800 5802 ata_dev_disable(dev); 5801 5803 }
+1
include/linux/libata.h
··· 647 647 648 648 unsigned int flags; /* ATA_LFLAG_xxx */ 649 649 650 + u32 saved_scontrol; /* SControl on probe */ 650 651 unsigned int hw_sata_spd_limit; 651 652 unsigned int sata_spd_limit; 652 653 unsigned int sata_spd; /* current SATA PHY speed */