linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: r66093@freescale.com
Cc: linux-ide@vger.kernel.org
Subject: Re: [PATCH] libata-pmp: add schedule timeout to support some PMP cards
Date: Thu, 3 Nov 2011 09:07:59 -0700	[thread overview]
Message-ID: <20111103160759.GI4417@google.com> (raw)
In-Reply-To: <1320033440-1106-1-git-send-email-r66093@freescale.com>

Hello,

On Mon, Oct 31, 2011 at 11:57:20AM +0800, r66093@freescale.com wrote:
> 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)
...
> 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);

Ummm... We can't really issue commands after failure without going
through recovery.  For ahci, it probably works.  For other
controllers, it may not.  Where does this delay come from?  Is there
any other way to wait for device readiness?

Thanks.

-- 
tejun

  reply	other threads:[~2011-11-03 16:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-31  3:57 [PATCH] libata-pmp: add schedule timeout to support some PMP cards r66093
2011-11-03 16:07 ` Tejun Heo [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111103160759.GI4417@google.com \
    --to=tj@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=r66093@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).