Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 29354
b: refs/heads/master
c: 701db69
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Garzik committed Dec 6, 2005
1 parent 11c8f75 commit 4fd79a8
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 76 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6cf5bcaaf9a92225017f7a3f1a630f6b5147ad4a
refs/heads/master: 701db69d6647f61e4660c9102d7f2fd5dffc203d
14 changes: 9 additions & 5 deletions trunk/drivers/scsi/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static const struct ata_port_operations ahci_ops = {
.port_stop = ahci_port_stop,
};

static struct ata_port_info ahci_port_info[] = {
static const struct ata_port_info ahci_port_info[] = {
/* board_ahci */
{
.sht = &ahci_sht,
Expand Down Expand Up @@ -643,7 +643,8 @@ static void ahci_eng_timeout(struct ata_port *ap)
* not being called from the SCSI EH.
*/
qc->scsidone = scsi_finish_command;
ata_qc_complete(qc, AC_ERR_OTHER);
qc->err_mask |= AC_ERR_OTHER;
ata_qc_complete(qc);
}

spin_unlock_irqrestore(&host_set->lock, flags);
Expand All @@ -664,7 +665,8 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
ci = readl(port_mmio + PORT_CMD_ISSUE);
if (likely((ci & 0x1) == 0)) {
if (qc) {
ata_qc_complete(qc, 0);
assert(qc->err_mask == 0);
ata_qc_complete(qc);
qc = NULL;
}
}
Expand All @@ -681,8 +683,10 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
/* command processing has stopped due to error; restart */
ahci_restart_port(ap, status);

if (qc)
ata_qc_complete(qc, err_mask);
if (qc) {
qc->err_mask |= AC_ERR_OTHER;
ata_qc_complete(qc);
}
}

return 1;
Expand Down
69 changes: 47 additions & 22 deletions trunk/drivers/scsi/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ void ata_rwcmd_protocol(struct ata_queued_cmd *qc)
tf->command = ata_rw_cmds[index + lba48 + write];
}

static const char * xfer_mode_str[] = {
static const char * const xfer_mode_str[] = {
"UDMA/16",
"UDMA/25",
"UDMA/33",
Expand Down Expand Up @@ -1054,9 +1054,9 @@ static int ata_qc_wait_err(struct ata_queued_cmd *qc,

if (wait_for_completion_timeout(wait, 30 * HZ) < 1) {
/* timeout handling */
unsigned int err_mask = ac_err_mask(ata_chk_status(qc->ap));
qc->err_mask |= ac_err_mask(ata_chk_status(qc->ap));

if (!err_mask) {
if (!qc->err_mask) {
printk(KERN_WARNING "ata%u: slow completion (cmd %x)\n",
qc->ap->id, qc->tf.command);
} else {
Expand All @@ -1065,7 +1065,7 @@ static int ata_qc_wait_err(struct ata_queued_cmd *qc,
rc = -EIO;
}

ata_qc_complete(qc, err_mask);
ata_qc_complete(qc);
}

return rc;
Expand Down Expand Up @@ -1176,6 +1176,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
qc->cursg_ofs = 0;
qc->cursect = 0;
qc->nsect = 1;
qc->err_mask = 0;
goto retry;
}
}
Expand Down Expand Up @@ -2093,7 +2094,7 @@ static void ata_pr_blacklisted(const struct ata_port *ap,
ap->id, dev->devno);
}

static const char * ata_dma_blacklist [] = {
static const char * const ata_dma_blacklist [] = {
"WDC AC11000H",
"WDC AC22100H",
"WDC AC32500H",
Expand Down Expand Up @@ -2787,14 +2788,14 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
* None. (grabs host lock)
*/

void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
void ata_poll_qc_complete(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
unsigned long flags;

spin_lock_irqsave(&ap->host_set->lock, flags);
ata_irq_on(ap);
ata_qc_complete(qc, err_mask);
ata_qc_complete(qc);
spin_unlock_irqrestore(&ap->host_set->lock, flags);
}

Expand All @@ -2811,10 +2812,14 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)

static unsigned long ata_pio_poll(struct ata_port *ap)
{
struct ata_queued_cmd *qc;
u8 status;
unsigned int poll_state = HSM_ST_UNKNOWN;
unsigned int reg_state = HSM_ST_UNKNOWN;

qc = ata_qc_from_tag(ap, ap->active_tag);
assert(qc != NULL);

switch (ap->hsm_task_state) {
case HSM_ST:
case HSM_ST_POLL:
Expand All @@ -2834,6 +2839,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;
ap->hsm_task_state = HSM_ST_TMOUT;
return 0;
}
Expand Down Expand Up @@ -2869,29 +2875,31 @@ static int ata_pio_complete (struct ata_port *ap)
* msecs, then chk-status again. If still busy, fall back to
* HSM_ST_LAST_POLL state.
*/
drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10);
if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
drv_stat = ata_busy_wait(ap, ATA_BUSY, 10);
if (drv_stat & ATA_BUSY) {
msleep(2);
drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10);
if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
drv_stat = ata_busy_wait(ap, ATA_BUSY, 10);
if (drv_stat & ATA_BUSY) {
ap->hsm_task_state = HSM_ST_LAST_POLL;
ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
return 1;
}
}

qc = ata_qc_from_tag(ap, ap->active_tag);
assert(qc != NULL);

drv_stat = ata_wait_idle(ap);
if (!ata_ok(drv_stat)) {
qc->err_mask |= __ac_err_mask(drv_stat);
ap->hsm_task_state = HSM_ST_ERR;
return 1;
}

qc = ata_qc_from_tag(ap, ap->active_tag);
assert(qc != NULL);

ap->hsm_task_state = HSM_ST_IDLE;

ata_poll_qc_complete(qc, 0);
assert(qc->err_mask == 0);
ata_poll_qc_complete(qc);

/* another command may start at this point */

Expand Down Expand Up @@ -3363,6 +3371,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;
ap->hsm_task_state = HSM_ST_ERR;
}

Expand Down Expand Up @@ -3401,8 +3410,16 @@ static void ata_pio_block(struct ata_port *ap)
qc = ata_qc_from_tag(ap, ap->active_tag);
assert(qc != NULL);

/* check error */
if (status & (ATA_ERR | ATA_DF)) {
qc->err_mask |= AC_ERR_DEV;
ap->hsm_task_state = HSM_ST_ERR;
return;
}

/* transfer data if any */
if (is_atapi_taskfile(&qc->tf)) {
/* no more data to transfer or unsupported ATAPI command */
/* DRQ=0 means no more data to transfer */
if ((status & ATA_DRQ) == 0) {
ap->hsm_task_state = HSM_ST_LAST;
return;
Expand All @@ -3412,6 +3429,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;
ap->hsm_task_state = HSM_ST_ERR;
return;
}
Expand All @@ -3431,9 +3449,14 @@ static void ata_pio_error(struct ata_port *ap)
qc = ata_qc_from_tag(ap, ap->active_tag);
assert(qc != NULL);

/* make sure qc->err_mask is available to
* know what's wrong and recover
*/
assert(qc->err_mask);

ap->hsm_task_state = HSM_ST_IDLE;

ata_poll_qc_complete(qc, AC_ERR_ATA_BUS);
ata_poll_qc_complete(qc);
}

static void ata_pio_task(void *_data)
Expand Down Expand Up @@ -3542,7 +3565,8 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
ap->hsm_task_state = HSM_ST_IDLE;

/* complete taskfile transaction */
ata_qc_complete(qc, ac_err_mask(drv_stat));
qc->err_mask |= ac_err_mask(drv_stat);
ata_qc_complete(qc);
break;
}

Expand Down Expand Up @@ -3641,7 +3665,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
return qc;
}

int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask)
int ata_qc_complete_noop(struct ata_queued_cmd *qc)
{
return 0;
}
Expand Down Expand Up @@ -3700,7 +3724,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
* spin_lock_irqsave(host_set lock)
*/

void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
void ata_qc_complete(struct ata_queued_cmd *qc)
{
int rc;

Expand All @@ -3717,7 +3741,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
qc->flags &= ~ATA_QCFLAG_ACTIVE;

/* call completion callback */
rc = qc->complete_fn(qc, err_mask);
rc = qc->complete_fn(qc);

/* if callback indicates not to complete command (non-zero),
* return immediately
Expand Down Expand Up @@ -4303,7 +4327,8 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
ap->hsm_task_state = HSM_ST_IDLE;

/* complete taskfile transaction */
ata_qc_complete(qc, ac_err_mask(status));
qc->err_mask |= ac_err_mask(status);
ata_qc_complete(qc);
break;

case HSM_ST_ERR:
Expand Down
24 changes: 13 additions & 11 deletions trunk/drivers/scsi/libata-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
int i;

/* Based on the 3ware driver translation table */
static unsigned char sense_table[][4] = {
static const unsigned char sense_table[][4] = {
/* BBD|ECC|ID|MAR */
{0xd1, ABORTED_COMMAND, 0x00, 0x00}, // Device busy Aborted command
/* BBD|ECC|ID */
Expand Down Expand Up @@ -449,7 +449,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
{0x80, MEDIUM_ERROR, 0x11, 0x04}, // Block marked bad Medium error, unrecovered read error
{0xFF, 0xFF, 0xFF, 0xFF}, // END mark
};
static unsigned char stat_table[][4] = {
static const unsigned char stat_table[][4] = {
/* Must be first because BUSY means no other bits valid */
{0x80, ABORTED_COMMAND, 0x47, 0x00}, // Busy, fake parity for now
{0x20, HARDWARE_ERROR, 0x00, 0x00}, // Device fault
Expand Down Expand Up @@ -1203,12 +1203,11 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
return 1;
}

static int ata_scsi_qc_complete(struct ata_queued_cmd *qc,
unsigned int err_mask)
static int ata_scsi_qc_complete(struct ata_queued_cmd *qc)
{
struct scsi_cmnd *cmd = qc->scsicmd;
u8 *cdb = cmd->cmnd;
int need_sense = (err_mask != 0);
int need_sense = (qc->err_mask != 0);

/* For ATA pass thru (SAT) commands, generate a sense block if
* user mandated it or if there's an error. Note that if we
Expand Down Expand Up @@ -1532,7 +1531,7 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
return 0;
}

static const char *inq_83_str = "Linux ATA-SCSI simulator";
static const char * const inq_83_str = "Linux ATA-SCSI simulator";

/**
* ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
Expand Down Expand Up @@ -1955,9 +1954,9 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8
done(cmd);
}

static int atapi_sense_complete(struct ata_queued_cmd *qc,unsigned int err_mask)
static int atapi_sense_complete(struct ata_queued_cmd *qc)
{
if (err_mask && ((err_mask & AC_ERR_DEV) == 0))
if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0))
/* FIXME: not quite right; we don't want the
* translation of taskfile registers into
* a sense descriptors, since that's only
Expand Down Expand Up @@ -2015,15 +2014,18 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)

qc->complete_fn = atapi_sense_complete;

if (ata_qc_issue(qc))
ata_qc_complete(qc, AC_ERR_OTHER);
if (ata_qc_issue(qc)) {
qc->err_mask |= AC_ERR_OTHER;
ata_qc_complete(qc);
}

DPRINTK("EXIT\n");
}

static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
static int atapi_qc_complete(struct ata_queued_cmd *qc)
{
struct scsi_cmnd *cmd = qc->scsicmd;
unsigned int err_mask = qc->err_mask;

VPRINTK("ENTER, err_mask 0x%X\n", err_mask);

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/scsi/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ata_scsi_args {

/* libata-core.c */
extern int atapi_enabled;
extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask);
extern int ata_qc_complete_noop(struct ata_queued_cmd *qc);
extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
struct ata_device *dev);
extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc);
Expand Down
11 changes: 5 additions & 6 deletions trunk/drivers/scsi/pdc_adma.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,12 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
continue;
qc = ata_qc_from_tag(ap, ap->active_tag);
if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
unsigned int err_mask = 0;

if ((status & (aPERR | aPSD | aUIRQ)))
err_mask = AC_ERR_OTHER;
qc->err_mask |= AC_ERR_OTHER;
else if (pp->pkt[0] != cDONE)
err_mask = AC_ERR_OTHER;
qc->err_mask |= AC_ERR_OTHER;

ata_qc_complete(qc, err_mask);
ata_qc_complete(qc);
}
}
return handled;
Expand Down Expand Up @@ -501,7 +499,8 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)

/* complete taskfile transaction */
pp->state = adma_state_idle;
ata_qc_complete(qc, ac_err_mask(status));
qc->err_mask |= ac_err_mask(status);
ata_qc_complete(qc);
handled = 1;
}
}
Expand Down
Loading

0 comments on commit 4fd79a8

Please sign in to comment.