Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 29366
b: refs/heads/master
c: 628e386
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Garzik committed Jan 27, 2006
1 parent 3106357 commit b2fe2fe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 60 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: 8dd2e3bd57c3b389febba1de6b10372ef507f985
refs/heads/master: 628e386e27674906326455f01d87878a5f0cbce7
75 changes: 24 additions & 51 deletions trunk/drivers/scsi/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ static int fgb(u32 bitmap);
static int ata_choose_xfer_mode(const struct ata_port *ap,
u8 *xfer_mode_out,
unsigned int *xfer_shift_out);
static void __ata_qc_complete(struct ata_queued_cmd *qc);
static void ata_pio_error(struct ata_port *ap);

static unsigned int ata_unique_id = 1;
Expand Down Expand Up @@ -1074,24 +1073,12 @@ static unsigned int ata_pio_modes(const struct ata_device *adev)
timing API will get this right anyway */
}

struct ata_exec_internal_arg {
unsigned int err_mask;
struct ata_taskfile *tf;
struct completion *waiting;
};

int ata_qc_complete_internal(struct ata_queued_cmd *qc)
void ata_qc_complete_internal(struct ata_queued_cmd *qc)
{
struct ata_exec_internal_arg *arg = qc->private_data;
struct completion *waiting = arg->waiting;
struct completion *waiting = qc->private_data;

if (!(qc->err_mask & ~AC_ERR_DEV))
qc->ap->ops->tf_read(qc->ap, arg->tf);
arg->err_mask = qc->err_mask;
arg->waiting = NULL;
qc->ap->ops->tf_read(qc->ap, &qc->tf);
complete(waiting);

return 0;
}

/**
Expand Down Expand Up @@ -1122,7 +1109,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
struct ata_queued_cmd *qc;
DECLARE_COMPLETION(wait);
unsigned long flags;
struct ata_exec_internal_arg arg;
unsigned int err_mask;

spin_lock_irqsave(&ap->host_set->lock, flags);

Expand All @@ -1136,9 +1123,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
qc->nsect = buflen / ATA_SECT_SIZE;
}

arg.waiting = &wait;
arg.tf = tf;
qc->private_data = &arg;
qc->private_data = &wait;
qc->complete_fn = ata_qc_complete_internal;

if (ata_qc_issue(qc))
Expand All @@ -1155,7 +1140,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
* before the caller cleans up, it will result in a
* spurious interrupt. We can live with that.
*/
if (arg.waiting) {
if (qc->flags & ATA_QCFLAG_ACTIVE) {
qc->err_mask = AC_ERR_OTHER;
ata_qc_complete(qc);
printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n",
Expand All @@ -1165,7 +1150,12 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
spin_unlock_irqrestore(&ap->host_set->lock, flags);
}

return arg.err_mask;
*tf = qc->tf;
err_mask = qc->err_mask;

ata_qc_free(qc);

return err_mask;

issue_fail:
ata_qc_free(qc);
Expand Down Expand Up @@ -3779,21 +3769,6 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
return qc;
}

static void __ata_qc_complete(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
unsigned int tag;

qc->flags = 0;
tag = qc->tag;
if (likely(ata_tag_valid(tag))) {
if (tag == ap->active_tag)
ap->active_tag = ATA_TAG_POISON;
qc->tag = ATA_TAG_POISON;
clear_bit(tag, &ap->qactive);
}
}

/**
* ata_qc_free - free unused ata_queued_cmd
* @qc: Command to complete
Expand All @@ -3806,9 +3781,19 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc)
*/
void ata_qc_free(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
unsigned int tag;

assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */

__ata_qc_complete(qc);
qc->flags = 0;
tag = qc->tag;
if (likely(ata_tag_valid(tag))) {
if (tag == ap->active_tag)
ap->active_tag = ATA_TAG_POISON;
qc->tag = ATA_TAG_POISON;
clear_bit(tag, &ap->qactive);
}
}

/**
Expand All @@ -3825,8 +3810,6 @@ void ata_qc_free(struct ata_queued_cmd *qc)

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

assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */
assert(qc->flags & ATA_QCFLAG_ACTIVE);

Expand All @@ -3840,17 +3823,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
qc->flags &= ~ATA_QCFLAG_ACTIVE;

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

/* if callback indicates not to complete command (non-zero),
* return immediately
*/
if (rc != 0)
return;

__ata_qc_complete(qc);

VPRINTK("EXIT\n");
qc->complete_fn(qc);
}

static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
Expand Down
14 changes: 7 additions & 7 deletions trunk/drivers/scsi/libata-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ 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)
static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
{
struct scsi_cmnd *cmd = qc->scsicmd;
u8 *cdb = cmd->cmnd;
Expand Down Expand Up @@ -1256,7 +1256,7 @@ static int ata_scsi_qc_complete(struct ata_queued_cmd *qc)

qc->scsidone(cmd);

return 0;
ata_qc_free(qc);
}

/**
Expand Down Expand Up @@ -1982,7 +1982,7 @@ 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)
static void atapi_sense_complete(struct ata_queued_cmd *qc)
{
if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0))
/* FIXME: not quite right; we don't want the
Expand All @@ -1993,7 +1993,7 @@ static int atapi_sense_complete(struct ata_queued_cmd *qc)
ata_gen_ata_desc_sense(qc);

qc->scsidone(qc->scsicmd);
return 0;
ata_qc_free(qc);
}

/* is it pointless to prefer PIO for "safety reasons"? */
Expand Down Expand Up @@ -2050,7 +2050,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
DPRINTK("EXIT\n");
}

static int atapi_qc_complete(struct ata_queued_cmd *qc)
static void atapi_qc_complete(struct ata_queued_cmd *qc)
{
struct scsi_cmnd *cmd = qc->scsicmd;
unsigned int err_mask = qc->err_mask;
Expand All @@ -2060,7 +2060,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc)
if (unlikely(err_mask & AC_ERR_DEV)) {
cmd->result = SAM_STAT_CHECK_CONDITION;
atapi_request_sense(qc);
return 1;
return;
}

else if (unlikely(err_mask))
Expand Down Expand Up @@ -2100,7 +2100,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc)
}

qc->scsidone(cmd);
return 0;
ata_qc_free(qc);
}
/**
* atapi_xlat - Initialize PACKET taskfile
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ struct ata_port;
struct ata_queued_cmd;

/* typedefs */
typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc);
typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc);

struct ata_ioports {
unsigned long cmd_addr;
Expand Down

0 comments on commit b2fe2fe

Please sign in to comment.