[PATCH] libata: add detailed AC_ERR_* flags

Add detailed AC_ERR_* flags and use them.  Long-term goal is to
describe all errors with err_mask and tf combination (tf for failed
sector information, etc...).  After proper error diagnosis is
implemented, sense data should also be generated from err_mask instead
of directly from hardware tf registers as it is currently.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
This commit is contained in:
Tejun Heo 2006-01-23 13:09:36 +09:00 committed by Jeff Garzik
parent 284b6481cc
commit 11a56d2439
5 changed files with 19 additions and 14 deletions

View File

@ -680,7 +680,7 @@ static void ahci_eng_timeout(struct ata_port *ap)
* not being called from the SCSI EH.
*/
qc->scsidone = scsi_finish_command;
qc->err_mask |= AC_ERR_OTHER;
qc->err_mask |= AC_ERR_TIMEOUT;
ata_qc_complete(qc);
}

View File

@ -1142,7 +1142,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
* spurious interrupt. We can live with that.
*/
if (qc->flags & ATA_QCFLAG_ACTIVE) {
qc->err_mask = AC_ERR_OTHER;
qc->err_mask = AC_ERR_TIMEOUT;
ata_qc_complete(qc);
printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n",
ap->id, command);
@ -2917,7 +2917,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
status = ata_chk_status(ap);
if (status & ATA_BUSY) {
if (time_after(jiffies, ap->pio_task_timeout)) {
qc->err_mask |= AC_ERR_ATA_BUS;
qc->err_mask |= AC_ERR_TIMEOUT;
ap->hsm_task_state = HSM_ST_TMOUT;
return 0;
}
@ -3295,7 +3295,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
err_out:
printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n",
ap->id, dev->devno);
qc->err_mask |= AC_ERR_ATA_BUS;
qc->err_mask |= AC_ERR_HSM;
ap->hsm_task_state = HSM_ST_ERR;
}
@ -3353,7 +3353,7 @@ static void ata_pio_block(struct ata_port *ap)
} else {
/* handle BSY=0, DRQ=0 as error */
if ((status & ATA_DRQ) == 0) {
qc->err_mask |= AC_ERR_ATA_BUS;
qc->err_mask |= AC_ERR_HSM;
ap->hsm_task_state = HSM_ST_ERR;
return;
}
@ -4159,14 +4159,14 @@ static void atapi_packet_task(void *_data)
/* sleep-wait for BSY to clear */
DPRINTK("busy wait\n");
if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) {
qc->err_mask |= AC_ERR_ATA_BUS;
qc->err_mask |= AC_ERR_TIMEOUT;
goto err_out;
}
/* make sure DRQ is set */
status = ata_chk_status(ap);
if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) {
qc->err_mask |= AC_ERR_ATA_BUS;
qc->err_mask |= AC_ERR_HSM;
goto err_out;
}

View File

@ -1866,7 +1866,7 @@ static void mv_eng_timeout(struct ata_port *ap)
*/
spin_lock_irqsave(&ap->host_set->lock, flags);
qc->scsidone = scsi_finish_command;
qc->err_mask |= AC_ERR_OTHER;
qc->err_mask |= AC_ERR_TIMEOUT;
ata_qc_complete(qc);
spin_unlock_irqrestore(&ap->host_set->lock, flags);
}

View File

@ -653,7 +653,7 @@ static void sil24_eng_timeout(struct ata_port *ap)
*/
printk(KERN_ERR "ata%u: command timeout\n", ap->id);
qc->scsidone = scsi_finish_command;
qc->err_mask |= AC_ERR_OTHER;
qc->err_mask |= AC_ERR_TIMEOUT;
ata_qc_complete(qc);
sil24_reset_controller(ap);

View File

@ -222,10 +222,15 @@ enum hsm_task_states {
};
enum ata_completion_errors {
AC_ERR_OTHER = (1 << 0),
AC_ERR_DEV = (1 << 1),
AC_ERR_ATA_BUS = (1 << 2),
AC_ERR_HOST_BUS = (1 << 3),
AC_ERR_DEV = (1 << 0), /* device reported error */
AC_ERR_HSM = (1 << 1), /* host state machine violation */
AC_ERR_TIMEOUT = (1 << 2), /* timeout */
AC_ERR_MEDIA = (1 << 3), /* media error */
AC_ERR_ATA_BUS = (1 << 4), /* ATA bus error */
AC_ERR_HOST_BUS = (1 << 5), /* host bus error */
AC_ERR_SYSTEM = (1 << 6), /* system error */
AC_ERR_INVALID = (1 << 7), /* invalid argument */
AC_ERR_OTHER = (1 << 8), /* unknown */
};
/* forward declarations */
@ -833,7 +838,7 @@ static inline int ata_try_flush_cache(const struct ata_device *dev)
static inline unsigned int ac_err_mask(u8 status)
{
if (status & ATA_BUSY)
return AC_ERR_ATA_BUS;
return AC_ERR_HSM;
if (status & (ATA_ERR | ATA_DF))
return AC_ERR_DEV;
return 0;