linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libata-pmp: add schedule timeout to support some PMP cards
@ 2011-10-31  3:57 r66093
  2011-11-03 16:07 ` Tejun Heo
  0 siblings, 1 reply; 14+ messages in thread
From: r66093 @ 2011-10-31  3:57 UTC (permalink / raw)
  To: linux-ide; +Cc: Jerry Huang

From: Jerry Huang <r66093freescale.com>

With Freescale SATA controller, some PMP cards(e.g JMB393 PMP card)
can't work on some platforms (e.g mpc837x, p1022):
During PMP initialize, when reading the PMP SCR, we will observe the TIMEOUT
error because PMP card SCR is not ready.
Therefore, we need enough time to wait for the PMP card ready for SCR read:
1. read the SCR after 1ms sleep,
2. if failed, looping until read success or timeout (count = 0)

below is the error log:
fsl-sata e0018000.sata: Sata FSL Platform/CSB Driver init
scsi0 : sata_fsl
ata1: SATA max UDMA/133 irq 44
ata1: Signature Update detected @ 504 msecs
ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata2.15: Port Multiplier 1.2, 0x197b:0x0325 r0, 15 ports, feat 0x5/0xf
ata2.00: hard resetting link
ata2.15: qc timeout (cmd 0xe4)
ata2.00: failed to read SCR 0 (Emask=0x4)
ata2.00: failed to read SCR 0 (Emask=0x40)
ata2.00: failed to read SCR 0 (Emask=0x40)
ata2: ATA_SRST issue failed
ata2.00: failed to read SCR 0 (Emask=0x40)
ata2.00: reset failed, giving up
ata2.15: hard resetting link
ata2: Hardreset failed, not off-lined 0
ata2: No Signature Update
ata2.15: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata2.00: hard resetting link
ata2.15: qc timeout (cmd 0xe4)
ata2.00: failed to read SCR 0 (Emask=0x4)
ata2.00: failed to read SCR 0 (Emask=0x40)
ata2.00: failed to read SCR 0 (Emask=0x40)
ata2: ATA_SRST issue failed
ata2.00: failed to read SCR 0 (Emask=0x40)
ata2.00: reset failed, giving up
ata2.15: hard resetting link
ata2: Hardreset failed, not off-lined 0
ata2: No Signature Update
ata2.15: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata2.00: hard resetting link
ata2.15: qc timeout (cmd 0xe4)
ata2.00: failed to read SCR 0 (Emask=0x4)
ata2.00: failed to read SCR 0 (Emask=0x40)
ata2.00: failed to read SCR 0 (Emask=0x40)
ata2: ATA_SRST issue failed
ata2.00: failed to read SCR 0 (Emask=0x40)
ata2.00: reset failed, giving up
ata2.00: failed to recover link after 3 tries, disabling
ata2.15: hard resetting link
ata2: Hardreset failed, not off-lined 0
ata2: No Signature Update
ata2.15: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata2.15: qc timeout (cmd 0xe4)
ata2.00: failed to read SCR 0 (Emask=0x4)
ata2.00: failed to write SCR 1 (Emask=0x40)
ata2.00: failed to clear SError.N (errno=-5)
ata2.15: hard resetting link
ata2: Hardreset failed, not off-lined 0
ata2: No Signature Update
ata2.15: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata2.01: hard resetting link
ata2.01: failed to resume link (SControl 0)
ata2.01: SATA link down (SStatus 0 SControl 0)
ata2.02: hard resetting link
ata2.02: failed to resume link (SControl 0)
ata2.02: SATA link down (SStatus 0 SControl 0)
......
ata2.14: hard resetting link
ata2.14: failed to resume link (SControl 0)
ata2.14: SATA link down (SStatus 0 SControl 0)
ata2: EH complete

Signed-off-by: Jerry Huang <r66093@freescale.com>
---
 drivers/ata/libata-pmp.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 224faab..18d5f8e 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -140,11 +140,19 @@ int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc)
 int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *r_val)
 {
 	unsigned int err_mask;
+	int count = 20;	/* try 20 times */
 
 	if (reg > SATA_PMP_PSCR_CONTROL)
 		return -EINVAL;
 
-	err_mask = sata_pmp_read(link, reg, r_val);
+	do {
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(1 * HZ / 1000); /* sleep 1 msecond */
+		set_current_state(TASK_RUNNING);
+
+		err_mask = sata_pmp_read(link, reg, r_val);
+	} while ((count--) && err_mask);
+
 	if (err_mask) {
 		ata_link_printk(link, KERN_WARNING, "failed to read SCR %d "
 				"(Emask=0x%x)\n", reg, err_mask);
-- 
1.7.4.1



^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-12-16 11:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-31  3:57 [PATCH] libata-pmp: add schedule timeout to support some PMP cards r66093
2011-11-03 16:07 ` Tejun Heo
2011-11-10  8:07   ` Huang Changming-R66093
2011-11-10 15:20     ` Tejun Heo
2011-11-15  8:43       ` Huang Changming-R66093
2011-11-15 14:51         ` Tejun Heo
2011-11-15 15:24           ` Mark Lord
2011-11-15 16:04             ` Mark Lord
2011-11-16  9:00               ` Huang Changming-R66093
2011-11-16 14:20                 ` Mark Lord
2011-12-16 10:58                   ` Huang Changming-R66093
2011-12-16 11:00                     ` Huang Changming-R66093
2011-12-16 11:10                       ` Huang Changming-R66093
2011-11-16  9:13               ` Huang Changming-R66093

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).