From 3f3791d30036a367f05b9d0be28ce7ff2e017a5a Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Tue, 16 Aug 2005 14:25:38 +0800 Subject: [PATCH] [PATCH] libata: Clear ATA_QCFLAG_ACTIVE flag before calling the completion callback Description: After calling the completion callback, the libata error handler might be running and getting atapi sense data. Clearing the ATA_QCFLAG_ACTIVE flag at this point might interfere with the libata error handler. Changes: - Clear the ATA_QCFLAG_ACTIVE flag before calling the completion callback (and also before the error handler) - Add some comment Signed-off-by: Albert Lee Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 3544f5d020..9a6aacf467 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -3213,9 +3213,14 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) if (likely(qc->flags & ATA_QCFLAG_DMAMAP)) ata_sg_clean(qc); + /* 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) + */ + qc->flags &= ~ATA_QCFLAG_ACTIVE; + /* call completion callback */ rc = qc->complete_fn(qc, drv_stat); - qc->flags &= ~ATA_QCFLAG_ACTIVE; /* if callback indicates not to complete command (non-zero), * return immediately -- 2.39.2