linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Phillip Susi <phill@thesusis.net>, linux-ide@vger.kernel.org
Cc: Sergey Shtylyov <s.shtylyov@omp.ru>
Subject: Re: [PATCH 2/3] libata: only wake a drive once on system resume
Date: Mon, 8 Jan 2024 15:04:27 +0900	[thread overview]
Message-ID: <e21eca15-fc58-491f-bae2-6df627d6cdce@kernel.org> (raw)
In-Reply-To: <20240107180258.360886-3-phill@thesusis.net>

On 1/8/24 03:02, Phillip Susi wrote:
> In the event that more than one pass of EH is needed during system resume,
> only request the drive be started once ( if the first time worked ).

See my comment on patch 3/3. You need this only and only because of how you
handle PUIS state, forcing (an invalid) transition to sleep state.

> ---
>  drivers/ata/libata-core.c | 9 +++++----
>  drivers/ata/libata-eh.c   | 8 +++-----
>  drivers/ata/libata.h      | 2 +-
>  3 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index 6c5269de4bf2..ef6a2349a6f8 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -2080,7 +2080,7 @@ static bool ata_dev_power_is_active(struct ata_device *dev)
>   *	LOCKING:
>   *	Kernel thread context (may sleep).
>   */
> -void ata_dev_power_set_active(struct ata_device *dev)
> +unsigned int ata_dev_power_set_active(struct ata_device *dev)
>  {
>  	struct ata_taskfile tf;
>  	unsigned int err_mask;
> @@ -2090,14 +2090,14 @@ void ata_dev_power_set_active(struct ata_device *dev)
>  	 * if supported by the device.
>  	 */
>  	if (!ata_dev_power_init_tf(dev, &tf, true))
> -		return;
> +		return AC_ERR_OK;
>  
>  	/*
>  	 * Check the device power state & condition and force a spinup with
>  	 * VERIFY command only if the drive is not already ACTIVE or IDLE.
>  	 */
>  	if (ata_dev_power_is_active(dev))
> -		return;
> +		return AC_ERR_OK;
>  
>  	ata_dev_notice(dev, "Entering active power mode\n");
>  
> @@ -2105,6 +2105,7 @@ void ata_dev_power_set_active(struct ata_device *dev)
>  	if (err_mask)
>  		ata_dev_err(dev, "VERIFY failed (err_mask=0x%x)\n",
>  			    err_mask);
> +	return err_mask;
>  }
>  
>  /**
> @@ -5277,7 +5278,7 @@ static int ata_port_pm_poweroff(struct device *dev)
>  static void ata_port_resume(struct ata_port *ap, pm_message_t mesg,
>  			    bool async)
>  {
> -	ata_port_request_pm(ap, mesg, ATA_EH_RESET,
> +	ata_port_request_pm(ap, mesg, ATA_EH_RESET | ATA_EH_SET_ACTIVE,
>  			    ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET,
>  			    async);
>  }
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index b0d6e69c4a5b..799a1b8bc384 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -710,10 +710,6 @@ void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap)
>  			ehc->saved_xfer_mode[devno] = dev->xfer_mode;
>  			if (ata_ncq_enabled(dev))
>  				ehc->saved_ncq_enabled |= 1 << devno;
> -
> -			/* If we are resuming, wake up the device */
> -			if (ap->pflags & ATA_PFLAG_RESUMING)
> -				ehc->i.dev_action[devno] |= ATA_EH_SET_ACTIVE;
>  		}
>  	}
>  
> @@ -3853,7 +3849,9 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
>  		 */
>  		ata_for_each_dev(dev, link, ENABLED) {
>  			if (ehc->i.dev_action[dev->devno] & ATA_EH_SET_ACTIVE) {
> -				ata_dev_power_set_active(dev);
> +				unsigned int err_mask = ata_dev_power_set_active(dev);
> +				if (err_mask)
> +					link->eh_info.dev_action[dev->devno] |= ATA_EH_SET_ACTIVE;
>  				ata_eh_done(link, dev, ATA_EH_SET_ACTIVE);
>  			}
>  		}
> diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
> index 5c685bb1939e..43ad1ef9b63a 100644
> --- a/drivers/ata/libata.h
> +++ b/drivers/ata/libata.h
> @@ -65,7 +65,7 @@ extern int ata_dev_configure(struct ata_device *dev);
>  extern bool ata_dev_power_init_tf(struct ata_device *dev,
>  				  struct ata_taskfile *tf, bool set_active);
>  extern void ata_dev_power_set_standby(struct ata_device *dev);
> -extern void ata_dev_power_set_active(struct ata_device *dev);
> +extern unsigned int ata_dev_power_set_active(struct ata_device *dev);
>  extern int sata_down_spd_limit(struct ata_link *link, u32 spd_limit);
>  extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
>  extern unsigned int ata_dev_set_feature(struct ata_device *dev,

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2024-01-08  6:04 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-25 15:19 [PATCH 0/1] Only activate drive once during system resume Phillip Susi
2023-12-25 15:19 ` [PATCH 1/1] libata: only wake a drive once on " Phillip Susi
2023-12-30 18:21 ` [PATCH 0/1 v2] Only activate drive once during " Phillip Susi
2023-12-30 18:21   ` [PATCH 1/1] libata: only wake a drive once on " Phillip Susi
2023-12-30 19:42     ` Sergey Shtylyov
2024-01-02 23:17     ` Damien Le Moal
2024-01-03 21:00       ` Phillip Susi
2024-01-04  1:21         ` Damien Le Moal
2024-01-04 14:05           ` Phillip Susi
2024-01-04 22:39             ` [PATCH 1/4] " Phillip Susi
2024-01-04 22:39               ` [PATCH 2/4] libata: don't wake sleeping disk during system suspend Phillip Susi
2024-01-05 12:25                 ` Damien Le Moal
2024-01-05 16:18                   ` Phillip Susi
2024-01-04 22:39               ` [PATCH 3/4] libata: avoid waking disk for several commands Phillip Susi
2024-01-05  8:46                 ` Sergei Shtylyov
2024-01-05 16:24                   ` Phillip Susi
2024-01-05 18:33                     ` Sergei Shtylyov
2024-01-06 19:49                       ` Phillip Susi
2024-01-06 20:29                   ` Phillip Susi
2024-01-08  8:57                     ` Sergei Shtylyov
2024-01-05 12:29                 ` Damien Le Moal
2024-01-05 16:30                   ` Phillip Susi
2024-01-06 23:14                     ` Damien Le Moal
2024-01-07 17:57                       ` Phillip Susi
2024-01-07 18:02                         ` [PATCH 0/3] Let sleeping disks lie Phillip Susi
2024-01-07 18:02                           ` [PATCH 1/3] libata: avoid waking disk for several commands Phillip Susi
2024-01-08  6:25                             ` Damien Le Moal
2024-01-08 13:27                               ` Phillip Susi
2024-01-10  2:39                                 ` Damien Le Moal
2024-01-16 17:06                                   ` Phillip Susi
2024-01-19 20:43                                     ` Phillip Susi
2024-01-20 18:08                                       ` Phillip Susi
2024-01-21  0:37                                         ` Damien Le Moal
2024-01-21  0:37                                       ` Damien Le Moal
2024-01-24 16:04                                         ` Phillip Susi
2024-01-24 21:51                                           ` Damien Le Moal
2024-02-01 20:01                                             ` Phillip Susi
2024-02-02  1:08                                               ` Damien Le Moal
2024-02-02 19:53                                                 ` Phillip Susi
2024-02-02 23:17                                                   ` Damien Le Moal
2024-02-05 19:52                                                     ` Phillip Susi
2024-01-08  8:48                             ` Sergey Shtylyov
2024-01-08 13:30                               ` Phillip Susi
2024-01-07 18:02                           ` [PATCH 2/3] libata: only wake a drive once on system resume Phillip Susi
2024-01-08  6:04                             ` Damien Le Moal [this message]
2024-01-07 18:02                           ` [PATCH 3/3] libata: don't start PuiS disks on resume Phillip Susi
2024-01-08  6:03                             ` Damien Le Moal
2024-01-08 13:39                               ` Phillip Susi
2024-01-10  2:19                                 ` Damien Le Moal
2024-01-16 17:13                                   ` Phillip Susi
2024-01-04 22:39               ` [PATCH 4/4] " Phillip Susi
2024-01-05  8:57                 ` Sergei Shtylyov
2024-01-05 12:42                 ` Damien Le Moal
2024-01-05 16:44                   ` Phillip Susi
2024-01-05 12:13               ` [PATCH 1/4] libata: only wake a drive once on system resume Damien Le Moal
2024-01-05 17:03                 ` Phillip Susi
2024-01-06 23:06                   ` Damien Le Moal
2024-01-05 12:44               ` Damien Le Moal
2024-01-09 15:20   ` [PATCH 0/1 v2] Only activate drive once during " Niklas Cassel
2024-01-16 17:23     ` Phillip Susi
2024-01-02 22:46 ` [PATCH 0/1] " Damien Le Moal

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=e21eca15-fc58-491f-bae2-6df627d6cdce@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=phill@thesusis.net \
    --cc=s.shtylyov@omp.ru \
    /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).