linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-ide@vger.kernel.org
Subject: Re: [PATCH v5 2/9] ata: libata-scsi: Improve ata_scsi_handle_link_detach()
Date: Fri, 6 Sep 2024 10:32:16 +0200	[thread overview]
Message-ID: <Ztq-EF0jLrn8iCOC@ryzen.lan> (raw)
In-Reply-To: <20240906015847.229539-3-dlemoal@kernel.org>

On Fri, Sep 06, 2024 at 10:58:40AM +0900, Damien Le Moal wrote:
> A struct ata_device flags are always set iand cleared with the device

s/iand/and/

I can see many cases function that currently set or clear dev->flags
withouth holding ap->lock, done by functions that run in EH context,
which will thus not hold ap->lock.

Perhaps rephrase this to:
struct ata_device flags should always be set and cleared with the device


> port locked.  Testing for a flag should thus also be done while holding
> the device port lock. In accordance to this, modify
> ata_scsi_handle_link_detach() to both test and clear the
> ATA_DFLAG_DETACHED flag while holding the device port lock.
> 
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>  drivers/ata/libata-scsi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index a3ffce4b218d..1a135d44286c 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -4616,10 +4616,12 @@ static void ata_scsi_handle_link_detach(struct ata_link *link)
>  	ata_for_each_dev(dev, link, ALL) {
>  		unsigned long flags;
>  
> -		if (!(dev->flags & ATA_DFLAG_DETACHED))
> +		spin_lock_irqsave(ap->lock, flags);
> +		if (!(dev->flags & ATA_DFLAG_DETACHED)) {
> +			spin_unlock_irqrestore(ap->lock, flags);
>  			continue;
> +		}
>  
> -		spin_lock_irqsave(ap->lock, flags);
>  		dev->flags &= ~ATA_DFLAG_DETACHED;
>  		spin_unlock_irqrestore(ap->lock, flags);
>  
> -- 
> 2.46.0
> 

Reviewed-by: Niklas Cassel <cassel@kernel.org>

  reply	other threads:[~2024-09-06  8:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06  1:58 [PATCH v5 0/9] Code cleanup and memory usage reduction Damien Le Moal
2024-09-06  1:58 ` [PATCH v5 1/9] ata: libata: Cleanup libata-transport Damien Le Moal
2024-09-06  1:58 ` [PATCH v5 2/9] ata: libata-scsi: Improve ata_scsi_handle_link_detach() Damien Le Moal
2024-09-06  8:32   ` Niklas Cassel [this message]
2024-09-06  1:58 ` [PATCH v5 3/9] ata: libata: Improve __ata_qc_complete() Damien Le Moal
2024-09-06  1:58 ` [PATCH v5 4/9] ata: libata: Move sata_down_spd_limit() to libata-sata.c Damien Le Moal
2024-09-06  1:58 ` [PATCH v5 5/9] ata: libata: Move sata_std_hardreset() definition " Damien Le Moal
2024-09-06  1:58 ` [PATCH v5 6/9] ata: libata: Rename ata_eh_read_sense_success_ncq_log() Damien Le Moal
2024-09-06  1:58 ` [PATCH v5 7/9] ata: libata: Move sector_buf from struct ata_port to struct ata_device Damien Le Moal
2024-09-06  1:58 ` [PATCH v5 8/9] ata: libata: Introduce ata_dev_free_resources Damien Le Moal
2024-09-06  8:41   ` Niklas Cassel
2024-09-06  1:58 ` [PATCH v5 9/9] ata: libata: Improve CDL resource management Damien Le Moal
2024-09-06  8:51   ` Niklas Cassel
2024-09-06 10:21     ` 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=Ztq-EF0jLrn8iCOC@ryzen.lan \
    --to=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@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;
as well as URLs for NNTP newsgroup(s).