mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
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 <[email protected]> Reported-by: fengxiangjun <[email protected]> Reported-by: Jim Faulkner <[email protected]> Cc: [email protected] Signed-off-by: Jeff Garzik <[email protected]>
This commit is contained in:
parent
0b67c7439f
commit
5040ab67a2
2 changed files with 34 additions and 7 deletions
|
|
@ -3790,21 +3790,45 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
|
|||
int sata_link_resume(struct ata_link *link, const unsigned long *params,
|
||||
unsigned long deadline)
|
||||
{
|
||||
int tries = ATA_LINK_RESUME_TRIES;
|
||||
u32 scontrol, serror;
|
||||
int rc;
|
||||
|
||||
if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
|
||||
return rc;
|
||||
|
||||
scontrol = (scontrol & 0x0f0) | 0x300;
|
||||
|
||||
if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol)))
|
||||
return rc;
|
||||
|
||||
/* Some PHYs react badly if SStatus is pounded immediately
|
||||
* after resuming. Delay 200ms before debouncing.
|
||||
/*
|
||||
* Writes to SControl sometimes get ignored under certain
|
||||
* controllers (ata_piix SIDPR). Make sure DET actually is
|
||||
* cleared.
|
||||
*/
|
||||
msleep(200);
|
||||
do {
|
||||
scontrol = (scontrol & 0x0f0) | 0x300;
|
||||
if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol)))
|
||||
return rc;
|
||||
/*
|
||||
* Some PHYs react badly if SStatus is pounded
|
||||
* immediately after resuming. Delay 200ms before
|
||||
* debouncing.
|
||||
*/
|
||||
msleep(200);
|
||||
|
||||
/* is SControl restored correctly? */
|
||||
if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
|
||||
return rc;
|
||||
} while ((scontrol & 0xf0f) != 0x300 && --tries);
|
||||
|
||||
if ((scontrol & 0xf0f) != 0x300) {
|
||||
ata_link_printk(link, KERN_ERR,
|
||||
"failed to resume link (SControl %X)\n",
|
||||
scontrol);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tries < ATA_LINK_RESUME_TRIES)
|
||||
ata_link_printk(link, KERN_WARNING,
|
||||
"link resume succeeded after %d retries\n",
|
||||
ATA_LINK_RESUME_TRIES - tries);
|
||||
|
||||
if ((rc = sata_link_debounce(link, params, deadline)))
|
||||
return rc;
|
||||
|
|
|
|||
Loading…
Reference in a new issue