aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-01-10 21:14:44 -0500
committerJeff Garzik <jgarzik@redhat.com>2010-01-12 14:34:14 -0500
commit5040ab67a2c6d5710ba497dc52a8f7035729d7b0 (patch)
treedea2290e50111fde938bfcbb83de0377e7c4d94a /drivers/ata
parent0b67c7439fe2a5d76602de36854c88e2beab00b0 (diff)
libata: retry link resume if necessary
Interestingly, when SIDPR is used in ata_piix, writes to DET in SControl sometimes get ignored leading to detection failure. Update sata_link_resume() such that it reads back SControl after clearing DET and retry if it's not clear. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: fengxiangjun <fengxiangjun@neusoft.com> Reported-by: Jim Faulkner <jfaulkne@ccs.neu.edu> Cc: stable@kernel.org Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-core.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 22ff51bdbc8a..6728328f3bea 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3790,21 +3790,45 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
3790int sata_link_resume(struct ata_link *link, const unsigned long *params, 3790int sata_link_resume(struct ata_link *link, const unsigned long *params,
3791 unsigned long deadline) 3791 unsigned long deadline)
3792{ 3792{
3793 int tries = ATA_LINK_RESUME_TRIES;
3793 u32 scontrol, serror; 3794 u32 scontrol, serror;
3794 int rc; 3795 int rc;
3795 3796
3796 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) 3797 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
3797 return rc; 3798 return rc;
3798 3799
3799 scontrol = (scontrol & 0x0f0) | 0x300; 3800 /*
3801 * Writes to SControl sometimes get ignored under certain
3802 * controllers (ata_piix SIDPR). Make sure DET actually is
3803 * cleared.
3804 */
3805 do {
3806 scontrol = (scontrol & 0x0f0) | 0x300;
3807 if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol)))
3808 return rc;
3809 /*
3810 * Some PHYs react badly if SStatus is pounded
3811 * immediately after resuming. Delay 200ms before
3812 * debouncing.
3813 */
3814 msleep(200);
3800 3815
3801 if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol))) 3816 /* is SControl restored correctly? */
3802 return rc; 3817 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
3818 return rc;
3819 } while ((scontrol & 0xf0f) != 0x300 && --tries);
3803 3820
3804 /* Some PHYs react badly if SStatus is pounded immediately 3821 if ((scontrol & 0xf0f) != 0x300) {
3805 * after resuming. Delay 200ms before debouncing. 3822 ata_link_printk(link, KERN_ERR,
3806 */ 3823 "failed to resume link (SControl %X)\n",
3807 msleep(200); 3824 scontrol);
3825 return 0;
3826 }
3827
3828 if (tries < ATA_LINK_RESUME_TRIES)
3829 ata_link_printk(link, KERN_WARNING,
3830 "link resume succeeded after %d retries\n",
3831 ATA_LINK_RESUME_TRIES - tries);
3808 3832
3809 if ((rc = sata_link_debounce(link, params, deadline))) 3833 if ((rc = sata_link_debounce(link, params, deadline)))
3810 return rc; 3834 return rc;