Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Niklas Cassel <cassel@kernel.org>
Cc: stable@vger.kernel.org, Niklas Cassel <niklas.cassel@wdc.com>,
	linux-ide@vger.kernel.org
Subject: Re: [PATCH] ata: libata-core: Do not call ata_dev_power_set_standby() twice
Date: Fri, 16 Feb 2024 21:16:23 +0900	[thread overview]
Message-ID: <c2054321-401d-4b16-9c20-20ea11929f49@kernel.org> (raw)
In-Reply-To: <20240216112008.1112538-1-cassel@kernel.org>

On 2/16/24 20:20, Niklas Cassel wrote:
> From: Damien Le Moal <dlemoal@kernel.org>
> 
> For regular system shutdown, ata_dev_power_set_standby() will be
> executed twice: once the scsi device is removed and another when
> ata_pci_shutdown_one() executes and EH completes unloading the devices.
> 
> Make the second call to ata_dev_power_set_standby() do nothing by using
> ata_dev_power_is_active() and return if the device is already in
> standby.
> 
> Fixes: 2da4c5e24e86 ("ata: libata-core: Improve ata_dev_power_set_active()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> This fix was originally part of patch that contained both a fix and
> a revert in a single patch:
> https://lore.kernel.org/linux-ide/20240111115123.1258422-3-dlemoal@kernel.org/
> 
> This patch contains the only the fix (as it is valid even without the
> revert), without the revert.
> 
> Updated the Fixes tag to point to a more appropriate commit, since we
> no longer revert any code.
> 
>  drivers/ata/libata-core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index d9f80f4f70f5..af2334bc806d 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -85,6 +85,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev,
>  static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
>  static void ata_dev_xfermask(struct ata_device *dev);
>  static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
> +static bool ata_dev_power_is_active(struct ata_device *dev);

I forgot what I did originally but didn't I move the code of
ata_dev_power_is_active() before ata_dev_power_set_standby() to avoid this
forward declaration ?

With that, the code is a little odd as ata_dev_power_is_active() is defined
between ata_dev_power_set_standby() and ata_dev_power_set_active() but both
functions use it...

>  
>  atomic_t ata_print_id = ATOMIC_INIT(0);
>  
> @@ -2017,8 +2018,9 @@ void ata_dev_power_set_standby(struct ata_device *dev)
>  	struct ata_taskfile tf;
>  	unsigned int err_mask;
>  
> -	/* If the device is already sleeping, do nothing. */
> -	if (dev->flags & ATA_DFLAG_SLEEPING)
> +	/* If the device is already sleeping or in standby, do nothing. */
> +	if ((dev->flags & ATA_DFLAG_SLEEPING) ||
> +	    !ata_dev_power_is_active(dev))
>  		return;
>  
>  	/*

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2024-02-16 12:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-16 11:20 [PATCH] ata: libata-core: Do not call ata_dev_power_set_standby() twice Niklas Cassel
2024-02-16 12:16 ` Damien Le Moal [this message]
2024-02-16 12:33   ` Niklas Cassel
2024-02-16 22:44     ` 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=c2054321-401d-4b16-9c20-20ea11929f49@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=cassel@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=niklas.cassel@wdc.com \
    --cc=stable@vger.kernel.org \
    /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