Skip to content

Commit

Permalink
libata: improve AC_ERR_DEV handling for ->post_internal_cmd
Browse files Browse the repository at this point in the history
->post_internal_cmd is simplified EH for internal commands.  Its
primary mission is to stop the controller such that no rogue memory
access or other activities occur after the internal command is
released.  It may provide error diagnostics by setting qc->err_mask
but this hasn't been a requirement.

To ignore SETXFER failure for CFA devices, libata needs to know
whether a command was failed by the device or for any other reason.
ie. internal command needs to get AC_ERR_DEV right.

This patch makes the following changes to AC_ERR_DEV handling and
->post_internal_cmd semantics to accomodate this need and simplify
callback implementation.

1. As long as the correct bits in the result TF registers are set,
   there is no need to set AC_ERR_DEV explicitly.  libata EH core
   takes care of that for both normal and internal commands.

2. The only requirement for ->post_internal_cmd() is to put the
   controller into quiescent state.  It needs not to set any err_mask.

3. ata_exec_internal_sg() performs minimal error analysis such that
   AC_ERR_DEV is automatically set as long as result_tf is filled
   correctly.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Apr 28, 2007
1 parent 55a6ade commit a51d644
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
5 changes: 1 addition & 4 deletions drivers/ata/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,10 +1430,7 @@ static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);

if (qc->flags & ATA_QCFLAG_FAILED)
qc->err_mask |= AC_ERR_OTHER;

if (qc->err_mask) {
if (qc->flags & ATA_QCFLAG_FAILED) {
/* make DMA engine forget about the failed command */
ahci_stop_engine(port_mmio);
ahci_start_engine(port_mmio);
Expand Down
16 changes: 10 additions & 6 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,12 +1270,16 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
if (ap->ops->post_internal_cmd)
ap->ops->post_internal_cmd(qc);

if ((qc->flags & ATA_QCFLAG_FAILED) && !qc->err_mask) {
if (ata_msg_warn(ap))
ata_dev_printk(dev, KERN_WARNING,
"zero err_mask for failed "
"internal command, assuming AC_ERR_OTHER\n");
qc->err_mask |= AC_ERR_OTHER;
/* perform minimal error analysis */
if (qc->flags & ATA_QCFLAG_FAILED) {
if (qc->result_tf.command & (ATA_ERR | ATA_DF))
qc->err_mask |= AC_ERR_DEV;

if (!qc->err_mask)
qc->err_mask |= AC_ERR_OTHER;

if (qc->err_mask & ~AC_ERR_OTHER)
qc->err_mask &= ~AC_ERR_OTHER;
}

/* finish up */
Expand Down
4 changes: 3 additions & 1 deletion drivers/ata/libata-eh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,9 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
return ATA_EH_SOFTRESET;
}

if (!(qc->err_mask & AC_ERR_DEV))
if (stat & (ATA_ERR | ATA_DF))
qc->err_mask |= AC_ERR_DEV;
else
return 0;

switch (qc->dev->class) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/sata_inic162x.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ static void inic_error_handler(struct ata_port *ap)
static void inic_post_internal_cmd(struct ata_queued_cmd *qc)
{
/* make DMA engine forget about the failed command */
if (qc->err_mask)
if (qc->flags & ATA_QCFLAG_FAILED)
inic_reset_port(inic_port_base(qc->ap));
}

Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/sata_promise.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,8 @@ static void pdc_post_internal_cmd(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;

if (qc->flags & ATA_QCFLAG_FAILED)
qc->err_mask |= AC_ERR_OTHER;

/* make DMA engine forget about the failed command */
if (qc->err_mask)
if (qc->flags & ATA_QCFLAG_FAILED)
pdc_reset_port(ap);
}

Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/sata_sil24.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,11 +924,8 @@ static void sil24_post_internal_cmd(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;

if (qc->flags & ATA_QCFLAG_FAILED)
qc->err_mask |= AC_ERR_OTHER;

/* make DMA engine forget about the failed command */
if (qc->err_mask)
if (qc->flags & ATA_QCFLAG_FAILED)
sil24_init_port(ap);
}

Expand Down

0 comments on commit a51d644

Please sign in to comment.