Commit 5bb52d92 authored by Damien Le Moal's avatar Damien Le Moal

ata: libata: Improve __ata_qc_complete()

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: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarNiklas Cassel <cassel@kernel.org>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
parent a1695151
...@@ -4829,8 +4829,9 @@ void __ata_qc_complete(struct ata_queued_cmd *qc) ...@@ -4829,8 +4829,9 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
struct ata_port *ap; struct ata_port *ap;
struct ata_link *link; struct ata_link *link;
WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */ if (WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE)))
WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE)); return;
ap = qc->ap; ap = qc->ap;
link = qc->dev->link; link = qc->dev->link;
...@@ -4852,9 +4853,10 @@ void __ata_qc_complete(struct ata_queued_cmd *qc) ...@@ -4852,9 +4853,10 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
ap->excl_link == link)) ap->excl_link == link))
ap->excl_link = NULL; ap->excl_link = NULL;
/* atapi: mark qc as inactive to prevent the interrupt handler /*
* from completing the command twice later, before the error handler * Mark qc as inactive to prevent the port interrupt handler from
* is called. (when rc != 0 and atapi request sense is needed) * completing the command twice later, before the error handler is
* called.
*/ */
qc->flags &= ~ATA_QCFLAG_ACTIVE; qc->flags &= ~ATA_QCFLAG_ACTIVE;
ap->qc_active &= ~(1ULL << qc->tag); ap->qc_active &= ~(1ULL << qc->tag);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment