Commit 8e0e694a authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik

[PATCH] libata: make ata_qc_issue complete failed qcs

There is no reason for the issuer to diddle with a failed qc as the
issuer has complete control over when a qc gets freed (usually in
->complete_fn).  Make ata_qc_issue() responsible for completing qcs
which failed to issue.
Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent e4a70e76
...@@ -989,9 +989,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, ...@@ -989,9 +989,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
qc->private_data = &wait; qc->private_data = &wait;
qc->complete_fn = ata_qc_complete_internal; qc->complete_fn = ata_qc_complete_internal;
qc->err_mask = ata_qc_issue(qc); ata_qc_issue(qc);
if (qc->err_mask)
ata_qc_complete(qc);
spin_unlock_irqrestore(&ap->host_set->lock, flags); spin_unlock_irqrestore(&ap->host_set->lock, flags);
...@@ -3997,12 +3995,8 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc) ...@@ -3997,12 +3995,8 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
* *
* LOCKING: * LOCKING:
* spin_lock_irqsave(host_set lock) * spin_lock_irqsave(host_set lock)
*
* RETURNS:
* Zero on success, AC_ERR_* mask on failure
*/ */
void ata_qc_issue(struct ata_queued_cmd *qc)
unsigned int ata_qc_issue(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
...@@ -4023,14 +4017,18 @@ unsigned int ata_qc_issue(struct ata_queued_cmd *qc) ...@@ -4023,14 +4017,18 @@ unsigned int ata_qc_issue(struct ata_queued_cmd *qc)
ap->ops->qc_prep(qc); ap->ops->qc_prep(qc);
return ap->ops->qc_issue(qc); qc->err_mask |= ap->ops->qc_issue(qc);
if (unlikely(qc->err_mask))
goto err;
return;
sg_err: sg_err:
qc->flags &= ~ATA_QCFLAG_DMAMAP; qc->flags &= ~ATA_QCFLAG_DMAMAP;
return AC_ERR_SYSTEM; qc->err_mask |= AC_ERR_SYSTEM;
err:
ata_qc_complete(qc);
} }
/** /**
* ata_qc_issue_prot - issue taskfile to device in proto-dependent manner * ata_qc_issue_prot - issue taskfile to device in proto-dependent manner
* @qc: command to issue to device * @qc: command to issue to device
......
...@@ -1431,9 +1431,7 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev, ...@@ -1431,9 +1431,7 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev,
goto early_finish; goto early_finish;
/* select device, send command to hardware */ /* select device, send command to hardware */
qc->err_mask = ata_qc_issue(qc); ata_qc_issue(qc);
if (qc->err_mask)
ata_qc_complete(qc);
VPRINTK("EXIT\n"); VPRINTK("EXIT\n");
return; return;
...@@ -2199,9 +2197,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc) ...@@ -2199,9 +2197,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
qc->complete_fn = atapi_sense_complete; qc->complete_fn = atapi_sense_complete;
qc->err_mask = ata_qc_issue(qc); ata_qc_issue(qc);
if (qc->err_mask)
ata_qc_complete(qc);
DPRINTK("EXIT\n"); DPRINTK("EXIT\n");
} }
......
...@@ -47,7 +47,7 @@ extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, ...@@ -47,7 +47,7 @@ extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc);
extern void ata_port_flush_task(struct ata_port *ap); extern void ata_port_flush_task(struct ata_port *ap);
extern void ata_qc_free(struct ata_queued_cmd *qc); extern void ata_qc_free(struct ata_queued_cmd *qc);
extern unsigned int ata_qc_issue(struct ata_queued_cmd *qc); extern void ata_qc_issue(struct ata_queued_cmd *qc);
extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
extern void ata_dev_select(struct ata_port *ap, unsigned int device, extern void ata_dev_select(struct ata_port *ap, unsigned int device,
unsigned int wait, unsigned int can_sleep); unsigned int wait, unsigned int can_sleep);
......
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