linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 v3] libata-pmp: add schedule timeout to support some PMP cards
@ 2011-12-19  2:35 r66093
  2011-12-19  2:35 ` [PATCH 2/2] FSL SATA: fix the controller operating mode r66093
  2012-02-23  6:35 ` [PATCH 1/2 v3] libata-pmp: add schedule timeout to support some PMP cards Huang Changming-R66093
  0 siblings, 2 replies; 4+ messages in thread
From: r66093 @ 2011-12-19  2:35 UTC (permalink / raw)
  To: linux-ide; +Cc: Jerry Huang, Jeff Garzik

From: Jerry Huang <Chang-Ming.Huang@freescale.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.

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 <Chang-Ming.Huang@freescale.com>
CC: Jeff Garzik <jgarzik@pobox.com>
---
changes for v2:
	- use function msecs_to_jiffies to calculate the jiffies for 1ms
	- cleanup the code
changes for v3:
	- add the quirks to support pmp card
	- add the CC

 drivers/ata/libata-pmp.c |   12 ++++++++++++
 include/linux/libata.h   |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 21b80c5..d7d4bb5 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -146,6 +146,13 @@ int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *r_val)
 	if (reg > SATA_PMP_PSCR_CONTROL)
 		return -EINVAL;
 
+	/* For some PMP card, we need delay some time */
+	if (link->flags & ATA_LFLAG_DELAY) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		/* sleep 50 msecond */
+		schedule_timeout(msecs_to_jiffies(50));
+	}
+
 	err_mask = sata_pmp_read(link, reg, r_val);
 	if (err_mask) {
 		ata_link_warn(link, "failed to read SCR %d (Emask=0x%x)\n",
@@ -456,6 +463,11 @@ static void sata_pmp_quirks(struct ata_port *ap)
 				       ATA_LFLAG_NO_SRST |
 				       ATA_LFLAG_ASSUME_ATA;
 		}
+	} else if (vendor == 0x197b && devid == 0x0325) {
+		/* For jmicron JMB393 card, need some time to ready the PMP */
+		ata_for_each_link(link, ap, EDGE) {
+			link->flags |= ATA_LFLAG_DELAY;
+		}
 	}
 }
 
diff --git a/include/linux/libata.h b/include/linux/libata.h
index cafc09a..c23ddf9 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -182,6 +182,7 @@ enum {
 	ATA_LFLAG_DISABLED	= (1 << 6), /* link is disabled */
 	ATA_LFLAG_SW_ACTIVITY	= (1 << 7), /* keep activity stats */
 	ATA_LFLAG_NO_LPM	= (1 << 8), /* disable LPM on this link */
+	ATA_LFLAG_DELAY		= (1 << 9), /* delay some time */
 
 	/* struct ata_port flags */
 	ATA_FLAG_SLAVE_POSS	= (1 << 0), /* host supports slave dev */
-- 
1.7.5.4



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

* [PATCH 2/2] FSL SATA: fix the controller operating mode
  2011-12-19  2:35 [PATCH 1/2 v3] libata-pmp: add schedule timeout to support some PMP cards r66093
@ 2011-12-19  2:35 ` r66093
  2011-12-19 12:15   ` Sergei Shtylyov
  2012-02-23  6:35 ` [PATCH 1/2 v3] libata-pmp: add schedule timeout to support some PMP cards Huang Changming-R66093
  1 sibling, 1 reply; 4+ messages in thread
From: r66093 @ 2011-12-19  2:35 UTC (permalink / raw)
  To: linux-ide; +Cc: Jerry Huang, Yutaka Ando, Jeff Garzik

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

Configure the FSL SATA controller to the enterprise mode

Signed-off-by: Yutaka Ando <r46913@freescale.com>
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Jeff Garzik <jgarzik@pobox.com>
---
 drivers/ata/sata_fsl.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 78ae7b6..48c9978 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -140,6 +140,7 @@ enum {
 	 */
 	HCONTROL_ONLINE_PHY_RST = (1 << 31),
 	HCONTROL_FORCE_OFFLINE = (1 << 30),
+	HCONTROL_LEGACY = (1 << 28),
 	HCONTROL_PARITY_PROT_MOD = (1 << 14),
 	HCONTROL_DPATH_PARITY = (1 << 12),
 	HCONTROL_SNOOP_ENABLE = (1 << 10),
@@ -1223,6 +1224,10 @@ static int sata_fsl_init_controller(struct ata_host *host)
 	 * part of the port_start() callback
 	 */
 
+	/* sata controller to operate in enterprise mode */
+	temp = ioread32(hcr_base + HCONTROL);
+	iowrite32((temp & ~HCONTROL_LEGACY), hcr_base + HCONTROL);
+
 	/* ack. any pending IRQs for this controller/port */
 	temp = ioread32(hcr_base + HSTATUS);
 	if (temp & 0x3F)
@@ -1421,6 +1426,12 @@ static int sata_fsl_resume(struct platform_device *op)
 	/* Recovery the CHBA register in host controller cmd register set */
 	iowrite32(pp->cmdslot_paddr & 0xffffffff, hcr_base + CHBA);
 
+	iowrite32((ioread32(hcr_base + HCONTROL)
+				| HCONTROL_ONLINE_PHY_RST
+				| HCONTROL_SNOOP_ENABLE
+				| HCONTROL_PMP_ATTACHED),
+			hcr_base+HCONTROL);
+
 	ata_host_resume(host);
 	return 0;
 }
-- 
1.7.5.4



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

* Re: [PATCH 2/2] FSL SATA: fix the controller operating mode
  2011-12-19  2:35 ` [PATCH 2/2] FSL SATA: fix the controller operating mode r66093
@ 2011-12-19 12:15   ` Sergei Shtylyov
  0 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2011-12-19 12:15 UTC (permalink / raw)
  To: r66093; +Cc: linux-ide, Jerry Huang, Yutaka Ando, Jeff Garzik

Hello.

On 19-12-2011 6:35, r66093@freescale.com wrote:

> From: Jerry Huang<Chang-Ming.Huang@freescale.com>

> Configure the FSL SATA controller to the enterprise mode

> Signed-off-by: Yutaka Ando<r46913@freescale.com>
> Signed-off-by: Jerry Huang<Chang-Ming.Huang@freescale.com>
> CC: Jeff Garzik<jgarzik@pobox.com>
> ---
>   drivers/ata/sata_fsl.c |   11 +++++++++++
>   1 files changed, 11 insertions(+), 0 deletions(-)

> diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
> index 78ae7b6..48c9978 100644
> --- a/drivers/ata/sata_fsl.c
> +++ b/drivers/ata/sata_fsl.c
[...]
> @@ -1223,6 +1224,10 @@ static int sata_fsl_init_controller(struct ata_host *host)
>   	 * part of the port_start() callback
>   	 */
>
> +	/* sata controller to operate in enterprise mode */
> +	temp = ioread32(hcr_base + HCONTROL);
> +	iowrite32((temp & ~HCONTROL_LEGACY), hcr_base + HCONTROL);

    Parens around & not needed.

> @@ -1421,6 +1426,12 @@ static int sata_fsl_resume(struct platform_device *op)
>   	/* Recovery the CHBA register in host controller cmd register set */
>   	iowrite32(pp->cmdslot_paddr&  0xffffffff, hcr_base + CHBA);
>
> +	iowrite32((ioread32(hcr_base + HCONTROL)
> +				| HCONTROL_ONLINE_PHY_RST
> +				| HCONTROL_SNOOP_ENABLE
> +				| HCONTROL_PMP_ATTACHED),
> +			hcr_base+HCONTROL);

    Spaces around +, please.

MBR, Sergei

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

* RE: [PATCH 1/2 v3] libata-pmp: add schedule timeout to support some PMP cards
  2011-12-19  2:35 [PATCH 1/2 v3] libata-pmp: add schedule timeout to support some PMP cards r66093
  2011-12-19  2:35 ` [PATCH 2/2] FSL SATA: fix the controller operating mode r66093
@ 2012-02-23  6:35 ` Huang Changming-R66093
  1 sibling, 0 replies; 4+ messages in thread
From: Huang Changming-R66093 @ 2012-02-23  6:35 UTC (permalink / raw)
  To: linux-ide@vger.kernel.org, Jeff Garzik; +Cc: Huang Changming-R66093

Hi, Jeff
Could you have any comment about this patch?
There is no any feedback since 12/20/2011.

Thanks
Jerry Huang


> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Monday, December 19, 2011 10:36 AM
> To: linux-ide@vger.kernel.org
> Cc: Huang Changming-R66093; Jeff Garzik
> Subject: [PATCH 1/2 v3] libata-pmp: add schedule timeout to support some
> PMP cards
> 
> From: Jerry Huang <Chang-Ming.Huang@freescale.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.
> 
> 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 <Chang-Ming.Huang@freescale.com>
> CC: Jeff Garzik <jgarzik@pobox.com>
> ---
> changes for v2:
> 	- use function msecs_to_jiffies to calculate the jiffies for 1ms
> 	- cleanup the code
> changes for v3:
> 	- add the quirks to support pmp card
> 	- add the CC
> 
>  drivers/ata/libata-pmp.c |   12 ++++++++++++
>  include/linux/libata.h   |    1 +
>  2 files changed, 13 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
> index 21b80c5..d7d4bb5 100644
> --- a/drivers/ata/libata-pmp.c
> +++ b/drivers/ata/libata-pmp.c
> @@ -146,6 +146,13 @@ int sata_pmp_scr_read(struct ata_link *link, int reg,
> u32 *r_val)
>  	if (reg > SATA_PMP_PSCR_CONTROL)
>  		return -EINVAL;
> 
> +	/* For some PMP card, we need delay some time */
> +	if (link->flags & ATA_LFLAG_DELAY) {
> +		set_current_state(TASK_INTERRUPTIBLE);
> +		/* sleep 50 msecond */
> +		schedule_timeout(msecs_to_jiffies(50));
> +	}
> +
>  	err_mask = sata_pmp_read(link, reg, r_val);
>  	if (err_mask) {
>  		ata_link_warn(link, "failed to read SCR %d (Emask=0x%x)\n",
> @@ -456,6 +463,11 @@ static void sata_pmp_quirks(struct ata_port *ap)
>  				       ATA_LFLAG_NO_SRST |
>  				       ATA_LFLAG_ASSUME_ATA;
>  		}
> +	} else if (vendor == 0x197b && devid == 0x0325) {
> +		/* For jmicron JMB393 card, need some time to ready the PMP
> */
> +		ata_for_each_link(link, ap, EDGE) {
> +			link->flags |= ATA_LFLAG_DELAY;
> +		}
>  	}
>  }
> 
> diff --git a/include/linux/libata.h b/include/linux/libata.h
> index cafc09a..c23ddf9 100644
> --- a/include/linux/libata.h
> +++ b/include/linux/libata.h
> @@ -182,6 +182,7 @@ enum {
>  	ATA_LFLAG_DISABLED	= (1 << 6), /* link is disabled */
>  	ATA_LFLAG_SW_ACTIVITY	= (1 << 7), /* keep activity stats */
>  	ATA_LFLAG_NO_LPM	= (1 << 8), /* disable LPM on this link */
> +	ATA_LFLAG_DELAY		= (1 << 9), /* delay some time */
> 
>  	/* struct ata_port flags */
>  	ATA_FLAG_SLAVE_POSS	= (1 << 0), /* host supports slave dev */
> --
> 1.7.5.4



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

end of thread, other threads:[~2012-02-23  6:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-19  2:35 [PATCH 1/2 v3] libata-pmp: add schedule timeout to support some PMP cards r66093
2011-12-19  2:35 ` [PATCH 2/2] FSL SATA: fix the controller operating mode r66093
2011-12-19 12:15   ` Sergei Shtylyov
2012-02-23  6:35 ` [PATCH 1/2 v3] libata-pmp: add schedule timeout to support some PMP cards 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).