linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Gabriele Mazzotta <gabriele.mzt@gmail.com>
Cc: stripathi@apm.com, linux-kernel@vger.kernel.org,
	linux-ide@vger.kernel.org
Subject: Re: [PATCH] libata: Ignore spurious PHY events on LPM policy change
Date: Sat, 25 Apr 2015 11:37:51 -0400	[thread overview]
Message-ID: <20150425153751.GA31335@htj.duckdns.org> (raw)
In-Reply-To: <1429954469-27892-1-git-send-email-gabriele.mzt@gmail.com>

On Sat, Apr 25, 2015 at 11:34:29AM +0200, Gabriele Mazzotta wrote:
> When the LPM policy is set to ATA_LPM_MAX_POWER, the device might
> generate a spurious PHY event that might cause errors on the link.
> Ignore this event if it occurred within 10s after the policy change.
> 
> The timeout was chosen observing that on a Dell XPS13 9333 these
> spurious events can occur up to roughly 6s after the policy change.

Just a couple things.

Can you please add the following tag?

Link: http://lkml.kernel.org/g/<MSG-ID of the first message in this thread>

> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index 61a9c07..59a2517 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -1700,6 +1700,9 @@ static void ahci_handle_port_interrupt(struct ata_port *ap,
>  	struct ahci_port_priv *pp = ap->private_data;
>  	struct ahci_host_priv *hpriv = ap->host->private_data;
>  	int resetting = !!(ap->pflags & ATA_PFLAG_RESETTING);
> +	unsigned long lpm_timeout = ap->link.last_lpm_change +
> +				    msecs_to_jiffies(ATA_TMOUT_SPURIOUS_PHY);
> +	bool ignore_event = false;
>  	u32 qc_active = 0;
>  	int rc;
>  
> @@ -1707,8 +1710,16 @@ static void ahci_handle_port_interrupt(struct ata_port *ap,
>  	if (unlikely(resetting))
>  		status &= ~PORT_IRQ_BAD_PMP;
>  
> +	/* ignore the first PHY event after the LPM policy changed
> +	 * as it is might be spurious
> +	 */
> +	if ((ap->link.flags & ATA_LFLAG_CHANGED) &&
> +	    time_before(jiffies, lpm_timeout))
> +		ignore_event = true;

Maybe the following is better?

	ignore_event = (ap->link.flags & ATA_LFLAG_CHANGED) &&
		       time_before(jiffies, lpm_timeout);

> +
>  	/* if LPM is enabled, PHYRDY doesn't mean anything */
> -	if (ap->link.lpm_policy > ATA_LPM_MAX_POWER) {
> +	if (ap->link.lpm_policy > ATA_LPM_MAX_POWER || ignore_event) {
> +		ap->link.flags &= ~ATA_LFLAG_CHANGED;
>  		status &= ~PORT_IRQ_PHYRDY;
>  		ahci_scr_write(&ap->link, SCR_ERROR, SERR_PHYRDY_CHG);
>  	}

I thought more about it and it's weird to have ATA_LFLAG_CHANGED and
last_lpm_change timestamp in libata core side and then open-code the
actual logic in ahci.  How about implementing a generic helper, say,
bool sata_lpm_ignore_phy_events(link) in libata core and use it in
specific drivers?  It can test both the current lpm_policy and the
timeout (preferably a separate patch to introduce the function and
factor out lpm policy testing).

Thanks.

-- 
tejun

  reply	other threads:[~2015-04-25 15:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-08 19:37 SATA link power management issues Gabriele Mazzotta
2015-01-09 22:00 ` Tejun Heo
2015-01-09 22:02   ` Tejun Heo
2015-01-09 22:05     ` Tejun Heo
2015-01-09 22:50     ` Gabriele Mazzotta
2015-01-12 13:16       ` Tejun Heo
2015-01-12 17:03         ` Gabriele Mazzotta
2015-01-12 17:07           ` Tejun Heo
2015-01-12 17:15             ` Gabriele Mazzotta
2015-01-09 22:40   ` Gabriele Mazzotta
     [not found] ` <CAOHikRDTgVWL7_WUS3Yvce01GyP5TcyRm8ojfAyTHLTZ7xiR7A@mail.gmail.com>
2015-01-12 17:16   ` Suman Tripathi
2015-01-12 20:26     ` Gabriele Mazzotta
     [not found]       ` <CAOHikRCp=m6tgKEmdg2pLj=XB2ugCGhj0rkeqCzF2+DPR8O9sw@mail.gmail.com>
2015-01-12 20:36         ` Gabriele Mazzotta
     [not found]           ` <CAOHikRC43JBMwCahBqT1znJLBnbr3Ui+szKhVQoK8cpfapTQyg@mail.gmail.com>
2015-01-12 20:54             ` Gabriele Mazzotta
2015-01-12 23:05 ` Gabriele Mazzotta
2015-02-22 20:53   ` Gabriele Mazzotta
2015-04-20 20:02     ` Gabriele Mazzotta
2015-04-21 15:31       ` Tejun Heo
2015-04-21 20:29         ` Gabriele Mazzotta
2015-04-21 20:56           ` Tejun Heo
2015-04-21 21:44             ` Gabriele Mazzotta
2015-04-24 21:44               ` Tejun Heo
2015-04-25  9:34                 ` [PATCH] libata: Ignore spurious PHY events on LPM policy change Gabriele Mazzotta
2015-04-25 15:37                   ` Tejun Heo [this message]
2015-04-25 17:57                     ` Gabriele Mazzotta

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=20150425153751.GA31335@htj.duckdns.org \
    --to=tj@kernel.org \
    --cc=gabriele.mzt@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stripathi@apm.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).