Patchwork [U-Boot,5/7] ahci: handle COMINIT received during spin-up

login
register
mail settings
Submitter Rob Herring
Date May 21, 2013, 10:44 p.m.
Message ID <1369176276-1895-5-git-send-email-robherring2@gmail.com>
Download mbox | patch
Permalink /patch/245443/
State Changes Requested
Delegated to: Tom Rini
Headers show

Comments

Rob Herring - May 21, 2013, 10:44 p.m.
From: Rob Herring <rob.herring@calxeda.com>

Some Intel SSDs can send a COMINIT after the initial COMRESET. This causes
the link to go down and we need to re-initialize the link.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 drivers/block/ahci.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Tom Rini - May 24, 2013, 1:47 p.m.
On Tue, May 21, 2013 at 05:44:34PM -0500, Rob Herring wrote:

> From: Rob Herring <rob.herring@calxeda.com>
> 
> Some Intel SSDs can send a COMINIT after the initial COMRESET. This causes
> the link to go down and we need to re-initialize the link.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
[snip]
> +			tmp = readl(port_mmio + PORT_SCR_STAT) & 0xf;
> +			if (tmp == 0x1)
> +				break;
>  			j++;
>  		}
> +
> +		tmp = readl(port_mmio + PORT_SCR_STAT) & 0xf;
> +		if (tmp == 0x1) {
> +			debug("SATA link %d down (COMINIT received), retrying...\n", i);
> +			i--;
> +			continue;
> +		}

0xf and 0x1 are already defined to some MASK and command name I would
hope, if not please define.  Thanks!

Patch

diff --git a/drivers/block/ahci.c b/drivers/block/ahci.c
index 79710ef..5ffdf95 100644
--- a/drivers/block/ahci.c
+++ b/drivers/block/ahci.c
@@ -260,8 +260,19 @@  static int ahci_host_init(struct ahci_probe_ent *probe_ent)
 			if (!(tmp & (ATA_STAT_BUSY | ATA_STAT_DRQ)))
 				break;
 			udelay(1000);
+			tmp = readl(port_mmio + PORT_SCR_STAT) & 0xf;
+			if (tmp == 0x1)
+				break;
 			j++;
 		}
+
+		tmp = readl(port_mmio + PORT_SCR_STAT) & 0xf;
+		if (tmp == 0x1) {
+			debug("SATA link %d down (COMINIT received), retrying...\n", i);
+			i--;
+			continue;
+		}
+
 		printf("Target spinup took %d ms.\n", j);
 		if (j == WAIT_MS_SPINUP)
 			debug("timeout.\n");