From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-ide@vger.kernel.org
Subject: Re: [PATCH 2/7] ata: libata: Improve __ata_qc_complete()
Date: Mon, 26 Aug 2024 16:39:28 +0200 [thread overview]
Message-ID: <ZsyToLN_idabIFIa@ryzen.lan> (raw)
In-Reply-To: <20240826073106.56918-3-dlemoal@kernel.org>
On Mon, Aug 26, 2024 at 04:31:01PM +0900, Damien Le Moal wrote:
> The function __ata_qc_complete() is always called with a qc that already
> has been dereferenced and so is guaranteed to be non-NULL (as otherwise
> the kernel would have crashed). So remove the warning for a NULL qc as
> it is useless.
>
> Furthermore, the qc passed to __ata_qc_complete() must always be marked
> as active with the ATA_QCFLAG_ACTIVE flag. If that is not the case, in
> addition to the existing warning, return early so that we do not attempt
> to complete an invalid qc.
>
> Finally, fix the comment related to clearing the qc active flag as that
> operation applies to all devices, not just ATAPI ones.
>
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> drivers/ata/libata-core.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index e4023fc288ac..5acc37397f4b 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -4829,8 +4829,9 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
> struct ata_port *ap;
> struct ata_link *link;
>
> - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
> - WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
> + if (WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE)))
> + return;
> +
> ap = qc->ap;
> link = qc->dev->link;
>
> @@ -4852,9 +4853,10 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
> ap->excl_link == link))
> ap->excl_link = NULL;
>
> - /* atapi: mark qc as inactive to prevent the interrupt handler
> - * from completing the command twice later, before the error handler
> - * is called. (when rc != 0 and atapi request sense is needed)
> + /*
> + * Mark qc as inactive to prevent the port interrupt handler from
> + * completing the command twice later, before the error handler is
> + * called.
> */
> qc->flags &= ~ATA_QCFLAG_ACTIVE;
> ap->qc_active &= ~(1ULL << qc->tag);
> --
> 2.46.0
>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
next prev parent reply other threads:[~2024-08-26 14:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 7:30 [PATCH 0/7] Code cleanup and CDL memory usage reduction Damien Le Moal
2024-08-26 7:31 ` [PATCH 1/7] ata: libata: Fix ata_tdev_free() kdoc comment Damien Le Moal
2024-08-26 14:38 ` Niklas Cassel
2024-08-26 7:31 ` [PATCH 2/7] ata: libata: Improve __ata_qc_complete() Damien Le Moal
2024-08-26 14:39 ` Niklas Cassel [this message]
2024-08-26 7:31 ` [PATCH 3/7] ata: libata: Move sata_down_spd_limit() to libata-sata.c Damien Le Moal
2024-08-26 14:39 ` Niklas Cassel
2024-08-26 7:31 ` [PATCH 4/7] ata: libata: Move sata_std_hardreset() definition " Damien Le Moal
2024-08-26 14:39 ` Niklas Cassel
2024-08-26 7:31 ` [PATCH 5/7] ata: libata: Rename ata_eh_read_sense_success_ncq_log() Damien Le Moal
2024-08-26 14:39 ` Niklas Cassel
2024-08-26 7:31 ` [PATCH 6/7] ata: libata: Move ncq_sense_buf to struct ata_device Damien Le Moal
2024-08-26 14:48 ` Niklas Cassel
2024-08-27 7:50 ` Damien Le Moal
2024-08-27 9:21 ` Niklas Cassel
2024-08-26 7:31 ` [PATCH 7/7] ata: libata: Improve CDL resource management Damien Le Moal
2024-08-26 15:37 ` Niklas Cassel
2024-08-26 22:07 ` Damien Le Moal
2024-08-26 14:32 ` [PATCH 0/7] Code cleanup and CDL memory usage reduction Niklas Cassel
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=ZsyToLN_idabIFIa@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.