aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2006-01-27 02:29:20 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-01-27 02:29:20 -0500
commit628e386e27674906326455f01d87878a5f0cbce7 (patch)
tree932163636366f5dcd6f9b3ee90a37fe0f21285b0 /drivers
parent8dd2e3bd57c3b389febba1de6b10372ef507f985 (diff)
parent77853bf2b48e34449e826a9ef4df5ea0dbe947f4 (diff)
Merge branch 'tmp'
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/libata-core.c75
-rw-r--r--drivers/scsi/libata-scsi.c14
2 files changed, 31 insertions, 58 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 857f535c8190..20bccabb54fc 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -73,7 +73,6 @@ static int fgb(u32 bitmap);
73static int ata_choose_xfer_mode(const struct ata_port *ap, 73static int ata_choose_xfer_mode(const struct ata_port *ap,
74 u8 *xfer_mode_out, 74 u8 *xfer_mode_out,
75 unsigned int *xfer_shift_out); 75 unsigned int *xfer_shift_out);
76static void __ata_qc_complete(struct ata_queued_cmd *qc);
77static void ata_pio_error(struct ata_port *ap); 76static void ata_pio_error(struct ata_port *ap);
78 77
79static unsigned int ata_unique_id = 1; 78static unsigned int ata_unique_id = 1;
@@ -1074,24 +1073,12 @@ static unsigned int ata_pio_modes(const struct ata_device *adev)
1074 timing API will get this right anyway */ 1073 timing API will get this right anyway */
1075} 1074}
1076 1075
1077struct ata_exec_internal_arg { 1076void ata_qc_complete_internal(struct ata_queued_cmd *qc)
1078 unsigned int err_mask;
1079 struct ata_taskfile *tf;
1080 struct completion *waiting;
1081};
1082
1083int ata_qc_complete_internal(struct ata_queued_cmd *qc)
1084{ 1077{
1085 struct ata_exec_internal_arg *arg = qc->private_data; 1078 struct completion *waiting = qc->private_data;
1086 struct completion *waiting = arg->waiting;
1087 1079
1088 if (!(qc->err_mask & ~AC_ERR_DEV)) 1080 qc->ap->ops->tf_read(qc->ap, &qc->tf);
1089 qc->ap->ops->tf_read(qc->ap, arg->tf);
1090 arg->err_mask = qc->err_mask;
1091 arg->waiting = NULL;
1092 complete(waiting); 1081 complete(waiting);
1093
1094 return 0;
1095} 1082}
1096 1083
1097/** 1084/**
@@ -1122,7 +1109,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
1122 struct ata_queued_cmd *qc; 1109 struct ata_queued_cmd *qc;
1123 DECLARE_COMPLETION(wait); 1110 DECLARE_COMPLETION(wait);
1124 unsigned long flags; 1111 unsigned long flags;
1125 struct ata_exec_internal_arg arg; 1112 unsigned int err_mask;
1126 1113
1127 spin_lock_irqsave(&ap->host_set->lock, flags); 1114 spin_lock_irqsave(&ap->host_set->lock, flags);
1128 1115
@@ -1136,9 +1123,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
1136 qc->nsect = buflen / ATA_SECT_SIZE; 1123 qc->nsect = buflen / ATA_SECT_SIZE;
1137 } 1124 }
1138 1125
1139 arg.waiting = &wait; 1126 qc->private_data = &wait;
1140 arg.tf = tf;
1141 qc->private_data = &arg;
1142 qc->complete_fn = ata_qc_complete_internal; 1127 qc->complete_fn = ata_qc_complete_internal;
1143 1128
1144 if (ata_qc_issue(qc)) 1129 if (ata_qc_issue(qc))
@@ -1155,7 +1140,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
1155 * before the caller cleans up, it will result in a 1140 * before the caller cleans up, it will result in a
1156 * spurious interrupt. We can live with that. 1141 * spurious interrupt. We can live with that.
1157 */ 1142 */
1158 if (arg.waiting) { 1143 if (qc->flags & ATA_QCFLAG_ACTIVE) {
1159 qc->err_mask = AC_ERR_OTHER; 1144 qc->err_mask = AC_ERR_OTHER;
1160 ata_qc_complete(qc); 1145 ata_qc_complete(qc);
1161 printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n", 1146 printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n",
@@ -1165,7 +1150,12 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
1165 spin_unlock_irqrestore(&ap->host_set->lock, flags); 1150 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1166 } 1151 }
1167 1152
1168 return arg.err_mask; 1153 *tf = qc->tf;
1154 err_mask = qc->err_mask;
1155
1156 ata_qc_free(qc);
1157
1158 return err_mask;
1169 1159
1170 issue_fail: 1160 issue_fail:
1171 ata_qc_free(qc); 1161 ata_qc_free(qc);
@@ -3779,21 +3769,6 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
3779 return qc; 3769 return qc;
3780} 3770}
3781 3771
3782static void __ata_qc_complete(struct ata_queued_cmd *qc)
3783{
3784 struct ata_port *ap = qc->ap;
3785 unsigned int tag;
3786
3787 qc->flags = 0;
3788 tag = qc->tag;
3789 if (likely(ata_tag_valid(tag))) {
3790 if (tag == ap->active_tag)
3791 ap->active_tag = ATA_TAG_POISON;
3792 qc->tag = ATA_TAG_POISON;
3793 clear_bit(tag, &ap->qactive);
3794 }
3795}
3796
3797/** 3772/**
3798 * ata_qc_free - free unused ata_queued_cmd 3773 * ata_qc_free - free unused ata_queued_cmd
3799 * @qc: Command to complete 3774 * @qc: Command to complete
@@ -3806,9 +3781,19 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc)
3806 */ 3781 */
3807void ata_qc_free(struct ata_queued_cmd *qc) 3782void ata_qc_free(struct ata_queued_cmd *qc)
3808{ 3783{
3784 struct ata_port *ap = qc->ap;
3785 unsigned int tag;
3786
3809 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ 3787 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */
3810 3788
3811 __ata_qc_complete(qc); 3789 qc->flags = 0;
3790 tag = qc->tag;
3791 if (likely(ata_tag_valid(tag))) {
3792 if (tag == ap->active_tag)
3793 ap->active_tag = ATA_TAG_POISON;
3794 qc->tag = ATA_TAG_POISON;
3795 clear_bit(tag, &ap->qactive);
3796 }
3812} 3797}
3813 3798
3814/** 3799/**
@@ -3825,8 +3810,6 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3825 3810
3826void ata_qc_complete(struct ata_queued_cmd *qc) 3811void ata_qc_complete(struct ata_queued_cmd *qc)
3827{ 3812{
3828 int rc;
3829
3830 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ 3813 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */
3831 assert(qc->flags & ATA_QCFLAG_ACTIVE); 3814 assert(qc->flags & ATA_QCFLAG_ACTIVE);
3832 3815
@@ -3840,17 +3823,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
3840 qc->flags &= ~ATA_QCFLAG_ACTIVE; 3823 qc->flags &= ~ATA_QCFLAG_ACTIVE;
3841 3824
3842 /* call completion callback */ 3825 /* call completion callback */
3843 rc = qc->complete_fn(qc); 3826 qc->complete_fn(qc);
3844
3845 /* if callback indicates not to complete command (non-zero),
3846 * return immediately
3847 */
3848 if (rc != 0)
3849 return;
3850
3851 __ata_qc_complete(qc);
3852
3853 VPRINTK("EXIT\n");
3854} 3827}
3855 3828
3856static inline int ata_should_dma_map(struct ata_queued_cmd *qc) 3829static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 0e65bfe92e6f..ce3fe928a386 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -1219,7 +1219,7 @@ nothing_to_do:
1219 return 1; 1219 return 1;
1220} 1220}
1221 1221
1222static int ata_scsi_qc_complete(struct ata_queued_cmd *qc) 1222static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1223{ 1223{
1224 struct scsi_cmnd *cmd = qc->scsicmd; 1224 struct scsi_cmnd *cmd = qc->scsicmd;
1225 u8 *cdb = cmd->cmnd; 1225 u8 *cdb = cmd->cmnd;
@@ -1256,7 +1256,7 @@ static int ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1256 1256
1257 qc->scsidone(cmd); 1257 qc->scsidone(cmd);
1258 1258
1259 return 0; 1259 ata_qc_free(qc);
1260} 1260}
1261 1261
1262/** 1262/**
@@ -1982,7 +1982,7 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8
1982 done(cmd); 1982 done(cmd);
1983} 1983}
1984 1984
1985static int atapi_sense_complete(struct ata_queued_cmd *qc) 1985static void atapi_sense_complete(struct ata_queued_cmd *qc)
1986{ 1986{
1987 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) 1987 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0))
1988 /* FIXME: not quite right; we don't want the 1988 /* FIXME: not quite right; we don't want the
@@ -1993,7 +1993,7 @@ static int atapi_sense_complete(struct ata_queued_cmd *qc)
1993 ata_gen_ata_desc_sense(qc); 1993 ata_gen_ata_desc_sense(qc);
1994 1994
1995 qc->scsidone(qc->scsicmd); 1995 qc->scsidone(qc->scsicmd);
1996 return 0; 1996 ata_qc_free(qc);
1997} 1997}
1998 1998
1999/* is it pointless to prefer PIO for "safety reasons"? */ 1999/* is it pointless to prefer PIO for "safety reasons"? */
@@ -2050,7 +2050,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2050 DPRINTK("EXIT\n"); 2050 DPRINTK("EXIT\n");
2051} 2051}
2052 2052
2053static int atapi_qc_complete(struct ata_queued_cmd *qc) 2053static void atapi_qc_complete(struct ata_queued_cmd *qc)
2054{ 2054{
2055 struct scsi_cmnd *cmd = qc->scsicmd; 2055 struct scsi_cmnd *cmd = qc->scsicmd;
2056 unsigned int err_mask = qc->err_mask; 2056 unsigned int err_mask = qc->err_mask;
@@ -2060,7 +2060,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc)
2060 if (unlikely(err_mask & AC_ERR_DEV)) { 2060 if (unlikely(err_mask & AC_ERR_DEV)) {
2061 cmd->result = SAM_STAT_CHECK_CONDITION; 2061 cmd->result = SAM_STAT_CHECK_CONDITION;
2062 atapi_request_sense(qc); 2062 atapi_request_sense(qc);
2063 return 1; 2063 return;
2064 } 2064 }
2065 2065
2066 else if (unlikely(err_mask)) 2066 else if (unlikely(err_mask))
@@ -2100,7 +2100,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc)
2100 } 2100 }
2101 2101
2102 qc->scsidone(cmd); 2102 qc->scsidone(cmd);
2103 return 0; 2103 ata_qc_free(qc);
2104} 2104}
2105/** 2105/**
2106 * atapi_xlat - Initialize PACKET taskfile 2106 * atapi_xlat - Initialize PACKET taskfile