diff options
Diffstat (limited to 'drivers/scsi/aha152x.c')
| -rw-r--r-- | drivers/scsi/aha152x.c | 169 |
1 files changed, 89 insertions, 80 deletions
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 85f2394ffc3e..d30a30786dda 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c | |||
| @@ -289,18 +289,18 @@ static LIST_HEAD(aha152x_host_list); | |||
| 289 | if(spin_is_locked(&QLOCK)) { \ | 289 | if(spin_is_locked(&QLOCK)) { \ |
| 290 | DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \ | 290 | DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \ |
| 291 | } \ | 291 | } \ |
| 292 | DPRINTK(debug_locks, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ | 292 | DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ |
| 293 | spin_lock_irqsave(&QLOCK,flags); \ | 293 | spin_lock_irqsave(&QLOCK,flags); \ |
| 294 | DPRINTK(debug_locks, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ | 294 | DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ |
| 295 | QLOCKER=__FUNCTION__; \ | 295 | QLOCKER=__FUNCTION__; \ |
| 296 | QLOCKERL=__LINE__; \ | 296 | QLOCKERL=__LINE__; \ |
| 297 | } while(0) | 297 | } while(0) |
| 298 | 298 | ||
| 299 | #define DO_UNLOCK(flags) \ | 299 | #define DO_UNLOCK(flags) \ |
| 300 | do { \ | 300 | do { \ |
| 301 | DPRINTK(debug_locks, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \ | 301 | DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \ |
| 302 | spin_unlock_irqrestore(&QLOCK,flags); \ | 302 | spin_unlock_irqrestore(&QLOCK,flags); \ |
| 303 | DPRINTK(debug_locks, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ | 303 | DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ |
| 304 | QLOCKER="(not locked)"; \ | 304 | QLOCKER="(not locked)"; \ |
| 305 | QLOCKERL=0; \ | 305 | QLOCKERL=0; \ |
| 306 | } while(0) | 306 | } while(0) |
| @@ -322,6 +322,12 @@ static LIST_HEAD(aha152x_host_list); | |||
| 322 | (cmd) ? ((cmd)->device->id & 0x0f) : -1, \ | 322 | (cmd) ? ((cmd)->device->id & 0x0f) : -1, \ |
| 323 | (cmd) ? ((cmd)->device->lun & 0x07) : -1 | 323 | (cmd) ? ((cmd)->device->lun & 0x07) : -1 |
| 324 | 324 | ||
| 325 | static inline void | ||
| 326 | CMD_INC_RESID(struct scsi_cmnd *cmd, int inc) | ||
| 327 | { | ||
| 328 | scsi_set_resid(cmd, scsi_get_resid(cmd) + inc); | ||
| 329 | } | ||
| 330 | |||
| 325 | #define DELAY_DEFAULT 1000 | 331 | #define DELAY_DEFAULT 1000 |
| 326 | 332 | ||
| 327 | #if defined(PCMCIA) | 333 | #if defined(PCMCIA) |
| @@ -552,14 +558,11 @@ struct aha152x_hostdata { | |||
| 552 | struct aha152x_scdata { | 558 | struct aha152x_scdata { |
| 553 | Scsi_Cmnd *next; /* next sc in queue */ | 559 | Scsi_Cmnd *next; /* next sc in queue */ |
| 554 | struct completion *done;/* semaphore to block on */ | 560 | struct completion *done;/* semaphore to block on */ |
| 555 | unsigned char cmd_len; | 561 | unsigned char aha_orig_cmd_len; |
| 556 | unsigned char cmnd[MAX_COMMAND_SIZE]; | 562 | unsigned char aha_orig_cmnd[MAX_COMMAND_SIZE]; |
| 557 | unsigned short use_sg; | 563 | int aha_orig_resid; |
| 558 | unsigned request_bufflen; | ||
| 559 | void *request_buffer; | ||
| 560 | }; | 564 | }; |
| 561 | 565 | ||
| 562 | |||
| 563 | /* access macros for hostdata */ | 566 | /* access macros for hostdata */ |
| 564 | 567 | ||
| 565 | #define HOSTDATA(shpnt) ((struct aha152x_hostdata *) &shpnt->hostdata) | 568 | #define HOSTDATA(shpnt) ((struct aha152x_hostdata *) &shpnt->hostdata) |
| @@ -978,15 +981,15 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, | |||
| 978 | #if defined(AHA152X_DEBUG) | 981 | #if defined(AHA152X_DEBUG) |
| 979 | if (HOSTDATA(shpnt)->debug & debug_queue) { | 982 | if (HOSTDATA(shpnt)->debug & debug_queue) { |
| 980 | printk(INFO_LEAD "queue: %p; cmd_len=%d pieces=%d size=%u cmnd=", | 983 | printk(INFO_LEAD "queue: %p; cmd_len=%d pieces=%d size=%u cmnd=", |
| 981 | CMDINFO(SCpnt), SCpnt, SCpnt->cmd_len, SCpnt->use_sg, SCpnt->request_bufflen); | 984 | CMDINFO(SCpnt), SCpnt, SCpnt->cmd_len, |
| 985 | scsi_sg_count(SCpnt), scsi_bufflen(SCpnt)); | ||
| 982 | __scsi_print_command(SCpnt->cmnd); | 986 | __scsi_print_command(SCpnt->cmnd); |
| 983 | } | 987 | } |
| 984 | #endif | 988 | #endif |
| 985 | 989 | ||
| 986 | SCpnt->scsi_done = done; | 990 | SCpnt->scsi_done = done; |
| 987 | SCpnt->resid = SCpnt->request_bufflen; | ||
| 988 | SCpnt->SCp.phase = not_issued | phase; | 991 | SCpnt->SCp.phase = not_issued | phase; |
| 989 | SCpnt->SCp.Status = CHECK_CONDITION; | 992 | SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */ |
| 990 | SCpnt->SCp.Message = 0; | 993 | SCpnt->SCp.Message = 0; |
| 991 | SCpnt->SCp.have_data_in = 0; | 994 | SCpnt->SCp.have_data_in = 0; |
| 992 | SCpnt->SCp.sent_command = 0; | 995 | SCpnt->SCp.sent_command = 0; |
| @@ -997,20 +1000,11 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, | |||
| 997 | return FAILED; | 1000 | return FAILED; |
| 998 | } | 1001 | } |
| 999 | } else { | 1002 | } else { |
| 1000 | struct aha152x_scdata *sc; | ||
| 1001 | |||
| 1002 | SCpnt->host_scribble = kmalloc(sizeof(struct aha152x_scdata), GFP_ATOMIC); | 1003 | SCpnt->host_scribble = kmalloc(sizeof(struct aha152x_scdata), GFP_ATOMIC); |
| 1003 | if(SCpnt->host_scribble==0) { | 1004 | if(SCpnt->host_scribble==0) { |
| 1004 | printk(ERR_LEAD "allocation failed\n", CMDINFO(SCpnt)); | 1005 | printk(ERR_LEAD "allocation failed\n", CMDINFO(SCpnt)); |
| 1005 | return FAILED; | 1006 | return FAILED; |
| 1006 | } | 1007 | } |
| 1007 | |||
| 1008 | sc = SCDATA(SCpnt); | ||
| 1009 | memcpy(sc->cmnd, SCpnt->cmnd, sizeof(sc->cmnd)); | ||
| 1010 | sc->request_buffer = SCpnt->request_buffer; | ||
| 1011 | sc->request_bufflen = SCpnt->request_bufflen; | ||
| 1012 | sc->use_sg = SCpnt->use_sg; | ||
| 1013 | sc->cmd_len = SCpnt->cmd_len; | ||
| 1014 | } | 1008 | } |
| 1015 | 1009 | ||
| 1016 | SCNEXT(SCpnt) = NULL; | 1010 | SCNEXT(SCpnt) = NULL; |
| @@ -1022,16 +1016,25 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, | |||
| 1022 | SCp.buffer : next buffer | 1016 | SCp.buffer : next buffer |
| 1023 | SCp.buffers_residual : left buffers in list | 1017 | SCp.buffers_residual : left buffers in list |
| 1024 | SCp.phase : current state of the command */ | 1018 | SCp.phase : current state of the command */ |
| 1025 | if (SCpnt->use_sg) { | 1019 | |
| 1026 | SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->request_buffer; | 1020 | if ((phase & (check_condition|resetting)) || !scsi_sglist(SCpnt)) { |
| 1027 | SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer); | 1021 | if (phase & check_condition) { |
| 1028 | SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; | 1022 | SCpnt->SCp.ptr = SCpnt->sense_buffer; |
| 1029 | SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1; | 1023 | SCpnt->SCp.this_residual = sizeof(SCpnt->sense_buffer); |
| 1030 | } else { | 1024 | scsi_set_resid(SCpnt, sizeof(SCpnt->sense_buffer)); |
| 1031 | SCpnt->SCp.ptr = (char *) SCpnt->request_buffer; | 1025 | } else { |
| 1032 | SCpnt->SCp.this_residual = SCpnt->request_bufflen; | 1026 | SCpnt->SCp.ptr = NULL; |
| 1027 | SCpnt->SCp.this_residual = 0; | ||
| 1028 | scsi_set_resid(SCpnt, 0); | ||
| 1029 | } | ||
| 1033 | SCpnt->SCp.buffer = NULL; | 1030 | SCpnt->SCp.buffer = NULL; |
| 1034 | SCpnt->SCp.buffers_residual = 0; | 1031 | SCpnt->SCp.buffers_residual = 0; |
| 1032 | } else { | ||
| 1033 | scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); | ||
| 1034 | SCpnt->SCp.buffer = scsi_sglist(SCpnt); | ||
| 1035 | SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer); | ||
| 1036 | SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; | ||
| 1037 | SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1; | ||
| 1035 | } | 1038 | } |
| 1036 | 1039 | ||
| 1037 | DO_LOCK(flags); | 1040 | DO_LOCK(flags); |
| @@ -1150,9 +1153,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt) | |||
| 1150 | DECLARE_COMPLETION(done); | 1153 | DECLARE_COMPLETION(done); |
| 1151 | int ret, issued, disconnected; | 1154 | int ret, issued, disconnected; |
| 1152 | unsigned char old_cmd_len = SCpnt->cmd_len; | 1155 | unsigned char old_cmd_len = SCpnt->cmd_len; |
| 1153 | unsigned short old_use_sg = SCpnt->use_sg; | ||
| 1154 | void *old_buffer = SCpnt->request_buffer; | ||
| 1155 | unsigned old_bufflen = SCpnt->request_bufflen; | ||
| 1156 | unsigned long flags; | 1156 | unsigned long flags; |
| 1157 | unsigned long timeleft; | 1157 | unsigned long timeleft; |
| 1158 | 1158 | ||
| @@ -1174,9 +1174,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt) | |||
| 1174 | DO_UNLOCK(flags); | 1174 | DO_UNLOCK(flags); |
| 1175 | 1175 | ||
| 1176 | SCpnt->cmd_len = 0; | 1176 | SCpnt->cmd_len = 0; |
| 1177 | SCpnt->use_sg = 0; | ||
| 1178 | SCpnt->request_buffer = NULL; | ||
| 1179 | SCpnt->request_bufflen = 0; | ||
| 1180 | 1177 | ||
| 1181 | aha152x_internal_queue(SCpnt, &done, resetting, reset_done); | 1178 | aha152x_internal_queue(SCpnt, &done, resetting, reset_done); |
| 1182 | 1179 | ||
| @@ -1189,9 +1186,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt) | |||
| 1189 | } | 1186 | } |
| 1190 | 1187 | ||
| 1191 | SCpnt->cmd_len = old_cmd_len; | 1188 | SCpnt->cmd_len = old_cmd_len; |
| 1192 | SCpnt->use_sg = old_use_sg; | ||
| 1193 | SCpnt->request_buffer = old_buffer; | ||
| 1194 | SCpnt->request_bufflen = old_bufflen; | ||
| 1195 | 1189 | ||
| 1196 | DO_LOCK(flags); | 1190 | DO_LOCK(flags); |
| 1197 | 1191 | ||
| @@ -1531,8 +1525,8 @@ static void busfree_run(struct Scsi_Host *shpnt) | |||
| 1531 | /* target sent DISCONNECT */ | 1525 | /* target sent DISCONNECT */ |
| 1532 | DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n", | 1526 | DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n", |
| 1533 | CMDINFO(CURRENT_SC), | 1527 | CMDINFO(CURRENT_SC), |
| 1534 | CURRENT_SC->resid, | 1528 | scsi_get_resid(CURRENT_SC), |
| 1535 | CURRENT_SC->request_bufflen); | 1529 | scsi_bufflen(CURRENT_SC)); |
| 1536 | #if defined(AHA152X_STAT) | 1530 | #if defined(AHA152X_STAT) |
| 1537 | HOSTDATA(shpnt)->disconnections++; | 1531 | HOSTDATA(shpnt)->disconnections++; |
| 1538 | #endif | 1532 | #endif |
| @@ -1568,18 +1562,16 @@ static void busfree_run(struct Scsi_Host *shpnt) | |||
| 1568 | #endif | 1562 | #endif |
| 1569 | 1563 | ||
| 1570 | /* restore old command */ | 1564 | /* restore old command */ |
| 1571 | memcpy(cmd->cmnd, sc->cmnd, sizeof(sc->cmnd)); | 1565 | memcpy(cmd->cmnd, sc->aha_orig_cmnd, sizeof(cmd->cmnd)); |
| 1572 | cmd->request_buffer = sc->request_buffer; | 1566 | cmd->cmd_len = sc->aha_orig_cmd_len; |
| 1573 | cmd->request_bufflen = sc->request_bufflen; | 1567 | scsi_set_resid(cmd, sc->aha_orig_resid); |
| 1574 | cmd->use_sg = sc->use_sg; | ||
| 1575 | cmd->cmd_len = sc->cmd_len; | ||
| 1576 | 1568 | ||
| 1577 | cmd->SCp.Status = 0x02; | 1569 | cmd->SCp.Status = SAM_STAT_CHECK_CONDITION; |
| 1578 | 1570 | ||
| 1579 | HOSTDATA(shpnt)->commands--; | 1571 | HOSTDATA(shpnt)->commands--; |
| 1580 | if (!HOSTDATA(shpnt)->commands) | 1572 | if (!HOSTDATA(shpnt)->commands) |
| 1581 | SETPORT(PORTA, 0); /* turn led off */ | 1573 | SETPORT(PORTA, 0); /* turn led off */ |
| 1582 | } else if(DONE_SC->SCp.Status==0x02) { | 1574 | } else if(DONE_SC->SCp.Status==SAM_STAT_CHECK_CONDITION) { |
| 1583 | #if defined(AHA152X_STAT) | 1575 | #if defined(AHA152X_STAT) |
| 1584 | HOSTDATA(shpnt)->busfree_with_check_condition++; | 1576 | HOSTDATA(shpnt)->busfree_with_check_condition++; |
| 1585 | #endif | 1577 | #endif |
| @@ -1587,13 +1579,23 @@ static void busfree_run(struct Scsi_Host *shpnt) | |||
| 1587 | DPRINTK(debug_eh, ERR_LEAD "CHECK CONDITION found\n", CMDINFO(DONE_SC)); | 1579 | DPRINTK(debug_eh, ERR_LEAD "CHECK CONDITION found\n", CMDINFO(DONE_SC)); |
| 1588 | #endif | 1580 | #endif |
| 1589 | 1581 | ||
| 1590 | if(!(DONE_SC->SCp.Status & not_issued)) { | 1582 | if(!(DONE_SC->SCp.phase & not_issued)) { |
| 1583 | struct aha152x_scdata *sc; | ||
| 1591 | Scsi_Cmnd *ptr = DONE_SC; | 1584 | Scsi_Cmnd *ptr = DONE_SC; |
| 1592 | DONE_SC=NULL; | 1585 | DONE_SC=NULL; |
| 1593 | #if 0 | 1586 | #if 0 |
| 1594 | DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr)); | 1587 | DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr)); |
| 1595 | #endif | 1588 | #endif |
| 1596 | 1589 | ||
| 1590 | /* save old command */ | ||
| 1591 | sc = SCDATA(ptr); | ||
| 1592 | /* It was allocated in aha152x_internal_queue? */ | ||
| 1593 | BUG_ON(!sc); | ||
| 1594 | memcpy(sc->aha_orig_cmnd, ptr->cmnd, | ||
| 1595 | sizeof(ptr->cmnd)); | ||
| 1596 | sc->aha_orig_cmd_len = ptr->cmd_len; | ||
| 1597 | sc->aha_orig_resid = scsi_get_resid(ptr); | ||
| 1598 | |||
| 1597 | ptr->cmnd[0] = REQUEST_SENSE; | 1599 | ptr->cmnd[0] = REQUEST_SENSE; |
| 1598 | ptr->cmnd[1] = 0; | 1600 | ptr->cmnd[1] = 0; |
| 1599 | ptr->cmnd[2] = 0; | 1601 | ptr->cmnd[2] = 0; |
| @@ -1601,10 +1603,7 @@ static void busfree_run(struct Scsi_Host *shpnt) | |||
| 1601 | ptr->cmnd[4] = sizeof(ptr->sense_buffer); | 1603 | ptr->cmnd[4] = sizeof(ptr->sense_buffer); |
| 1602 | ptr->cmnd[5] = 0; | 1604 | ptr->cmnd[5] = 0; |
| 1603 | ptr->cmd_len = 6; | 1605 | ptr->cmd_len = 6; |
| 1604 | ptr->use_sg = 0; | 1606 | |
| 1605 | ptr->request_buffer = ptr->sense_buffer; | ||
| 1606 | ptr->request_bufflen = sizeof(ptr->sense_buffer); | ||
| 1607 | |||
| 1608 | DO_UNLOCK(flags); | 1607 | DO_UNLOCK(flags); |
| 1609 | aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done); | 1608 | aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done); |
| 1610 | DO_LOCK(flags); | 1609 | DO_LOCK(flags); |
| @@ -2180,7 +2179,8 @@ static void datai_init(struct Scsi_Host *shpnt) | |||
| 2180 | DATA_LEN=0; | 2179 | DATA_LEN=0; |
| 2181 | DPRINTK(debug_datai, | 2180 | DPRINTK(debug_datai, |
| 2182 | DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n", | 2181 | DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n", |
| 2183 | CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid); | 2182 | CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC), |
| 2183 | scsi_get_resid(CURRENT_SC)); | ||
| 2184 | } | 2184 | } |
| 2185 | 2185 | ||
| 2186 | static void datai_run(struct Scsi_Host *shpnt) | 2186 | static void datai_run(struct Scsi_Host *shpnt) |
| @@ -2293,11 +2293,12 @@ static void datai_run(struct Scsi_Host *shpnt) | |||
| 2293 | 2293 | ||
| 2294 | static void datai_end(struct Scsi_Host *shpnt) | 2294 | static void datai_end(struct Scsi_Host *shpnt) |
| 2295 | { | 2295 | { |
| 2296 | CURRENT_SC->resid -= GETSTCNT(); | 2296 | CMD_INC_RESID(CURRENT_SC, -GETSTCNT()); |
| 2297 | 2297 | ||
| 2298 | DPRINTK(debug_datai, | 2298 | DPRINTK(debug_datai, |
| 2299 | DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n", | 2299 | DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n", |
| 2300 | CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid, GETSTCNT()); | 2300 | CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC), |
| 2301 | scsi_get_resid(CURRENT_SC), GETSTCNT()); | ||
| 2301 | 2302 | ||
| 2302 | SETPORT(SXFRCTL0, CH1|CLRSTCNT); | 2303 | SETPORT(SXFRCTL0, CH1|CLRSTCNT); |
| 2303 | SETPORT(DMACNTRL0, 0); | 2304 | SETPORT(DMACNTRL0, 0); |
| @@ -2318,11 +2319,12 @@ static void datao_init(struct Scsi_Host *shpnt) | |||
| 2318 | SETPORT(SIMODE0, 0); | 2319 | SETPORT(SIMODE0, 0); |
| 2319 | SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE ); | 2320 | SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE ); |
| 2320 | 2321 | ||
| 2321 | DATA_LEN = CURRENT_SC->resid; | 2322 | DATA_LEN = scsi_get_resid(CURRENT_SC); |
| 2322 | 2323 | ||
| 2323 | DPRINTK(debug_datao, | 2324 | DPRINTK(debug_datao, |
| 2324 | DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n", | 2325 | DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n", |
| 2325 | CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid); | 2326 | CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC), |
| 2327 | scsi_get_resid(CURRENT_SC)); | ||
| 2326 | } | 2328 | } |
| 2327 | 2329 | ||
| 2328 | static void datao_run(struct Scsi_Host *shpnt) | 2330 | static void datao_run(struct Scsi_Host *shpnt) |
| @@ -2346,7 +2348,7 @@ static void datao_run(struct Scsi_Host *shpnt) | |||
| 2346 | SETPORT(DMACNTRL0,WRITE_READ|ENDMA|_8BIT); | 2348 | SETPORT(DMACNTRL0,WRITE_READ|ENDMA|_8BIT); |
| 2347 | SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++); | 2349 | SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++); |
| 2348 | CURRENT_SC->SCp.this_residual--; | 2350 | CURRENT_SC->SCp.this_residual--; |
| 2349 | CURRENT_SC->resid--; | 2351 | CMD_INC_RESID(CURRENT_SC, -1); |
| 2350 | SETPORT(DMACNTRL0,WRITE_READ|ENDMA); | 2352 | SETPORT(DMACNTRL0,WRITE_READ|ENDMA); |
| 2351 | } | 2353 | } |
| 2352 | 2354 | ||
| @@ -2355,7 +2357,7 @@ static void datao_run(struct Scsi_Host *shpnt) | |||
| 2355 | outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); | 2357 | outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); |
| 2356 | CURRENT_SC->SCp.ptr += 2 * data_count; | 2358 | CURRENT_SC->SCp.ptr += 2 * data_count; |
| 2357 | CURRENT_SC->SCp.this_residual -= 2 * data_count; | 2359 | CURRENT_SC->SCp.this_residual -= 2 * data_count; |
| 2358 | CURRENT_SC->resid -= 2 * data_count; | 2360 | CMD_INC_RESID(CURRENT_SC, -2 * data_count); |
| 2359 | } | 2361 | } |
| 2360 | 2362 | ||
| 2361 | if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { | 2363 | if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { |
| @@ -2381,35 +2383,34 @@ static void datao_run(struct Scsi_Host *shpnt) | |||
| 2381 | static void datao_end(struct Scsi_Host *shpnt) | 2383 | static void datao_end(struct Scsi_Host *shpnt) |
| 2382 | { | 2384 | { |
| 2383 | if(TESTLO(DMASTAT, DFIFOEMP)) { | 2385 | if(TESTLO(DMASTAT, DFIFOEMP)) { |
| 2384 | int data_count = (DATA_LEN - CURRENT_SC->resid) - GETSTCNT(); | 2386 | int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - |
| 2387 | GETSTCNT(); | ||
| 2385 | 2388 | ||
| 2386 | DPRINTK(debug_datao, DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n", | 2389 | DPRINTK(debug_datao, DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n", |
| 2387 | CMDINFO(CURRENT_SC), | 2390 | CMDINFO(CURRENT_SC), |
| 2388 | data_count, | 2391 | data_count, |
| 2389 | DATA_LEN-CURRENT_SC->resid, | 2392 | DATA_LEN - scsi_get_resid(CURRENT_SC), |
| 2390 | GETSTCNT()); | 2393 | GETSTCNT()); |
| 2391 | 2394 | ||
| 2392 | CURRENT_SC->resid += data_count; | 2395 | CMD_INC_RESID(CURRENT_SC, data_count); |
| 2393 | 2396 | ||
| 2394 | if(CURRENT_SC->use_sg) { | 2397 | data_count -= CURRENT_SC->SCp.ptr - |
| 2395 | data_count -= CURRENT_SC->SCp.ptr - SG_ADDRESS(CURRENT_SC->SCp.buffer); | 2398 | SG_ADDRESS(CURRENT_SC->SCp.buffer); |
| 2396 | while(data_count>0) { | 2399 | while(data_count>0) { |
| 2397 | CURRENT_SC->SCp.buffer--; | 2400 | CURRENT_SC->SCp.buffer--; |
| 2398 | CURRENT_SC->SCp.buffers_residual++; | 2401 | CURRENT_SC->SCp.buffers_residual++; |
| 2399 | data_count -= CURRENT_SC->SCp.buffer->length; | 2402 | data_count -= CURRENT_SC->SCp.buffer->length; |
| 2400 | } | ||
| 2401 | CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - data_count; | ||
| 2402 | CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + data_count; | ||
| 2403 | } else { | ||
| 2404 | CURRENT_SC->SCp.ptr -= data_count; | ||
| 2405 | CURRENT_SC->SCp.this_residual += data_count; | ||
| 2406 | } | 2403 | } |
| 2404 | CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - | ||
| 2405 | data_count; | ||
| 2406 | CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + | ||
| 2407 | data_count; | ||
| 2407 | } | 2408 | } |
| 2408 | 2409 | ||
| 2409 | DPRINTK(debug_datao, DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n", | 2410 | DPRINTK(debug_datao, DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n", |
| 2410 | CMDINFO(CURRENT_SC), | 2411 | CMDINFO(CURRENT_SC), |
| 2411 | CURRENT_SC->request_bufflen, | 2412 | scsi_bufflen(CURRENT_SC), |
| 2412 | CURRENT_SC->resid, | 2413 | scsi_get_resid(CURRENT_SC), |
| 2413 | GETSTCNT()); | 2414 | GETSTCNT()); |
| 2414 | 2415 | ||
| 2415 | SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); | 2416 | SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); |
| @@ -2936,7 +2937,7 @@ static void show_command(Scsi_Cmnd *ptr) | |||
| 2936 | __scsi_print_command(ptr->cmnd); | 2937 | __scsi_print_command(ptr->cmnd); |
| 2937 | 2938 | ||
| 2938 | printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |", | 2939 | printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |", |
| 2939 | ptr->request_bufflen, ptr->resid); | 2940 | scsi_bufflen(ptr), scsi_get_resid(ptr)); |
| 2940 | 2941 | ||
| 2941 | if (ptr->SCp.phase & not_issued) | 2942 | if (ptr->SCp.phase & not_issued) |
| 2942 | printk("not issued|"); | 2943 | printk("not issued|"); |
| @@ -3006,7 +3007,8 @@ static int get_command(char *pos, Scsi_Cmnd * ptr) | |||
| 3006 | SPRINTF("0x%02x ", ptr->cmnd[i]); | 3007 | SPRINTF("0x%02x ", ptr->cmnd[i]); |
| 3007 | 3008 | ||
| 3008 | SPRINTF("); resid=%d; residual=%d; buffers=%d; phase |", | 3009 | SPRINTF("); resid=%d; residual=%d; buffers=%d; phase |", |
| 3009 | ptr->resid, ptr->SCp.this_residual, ptr->SCp.buffers_residual); | 3010 | scsi_get_resid(ptr), ptr->SCp.this_residual, |
| 3011 | ptr->SCp.buffers_residual); | ||
| 3010 | 3012 | ||
| 3011 | if (ptr->SCp.phase & not_issued) | 3013 | if (ptr->SCp.phase & not_issued) |
| 3012 | SPRINTF("not issued|"); | 3014 | SPRINTF("not issued|"); |
| @@ -3395,7 +3397,7 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start | |||
| 3395 | PDEBUG(debug_datai, "data in"); | 3397 | PDEBUG(debug_datai, "data in"); |
| 3396 | PDEBUG(debug_datao, "data out"); | 3398 | PDEBUG(debug_datao, "data out"); |
| 3397 | PDEBUG(debug_eh, "eh"); | 3399 | PDEBUG(debug_eh, "eh"); |
| 3398 | PDEBUG(debug_locks, "locks"); | 3400 | PDEBUG(debug_locking, "locks"); |
| 3399 | PDEBUG(debug_phases, "phases"); | 3401 | PDEBUG(debug_phases, "phases"); |
| 3400 | 3402 | ||
| 3401 | SPRINTF("\n"); | 3403 | SPRINTF("\n"); |
| @@ -3474,6 +3476,12 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start | |||
| 3474 | return thislength < length ? thislength : length; | 3476 | return thislength < length ? thislength : length; |
| 3475 | } | 3477 | } |
| 3476 | 3478 | ||
| 3479 | static int aha152x_adjust_queue(struct scsi_device *device) | ||
| 3480 | { | ||
| 3481 | blk_queue_bounce_limit(device->request_queue, BLK_BOUNCE_HIGH); | ||
| 3482 | return 0; | ||
| 3483 | } | ||
| 3484 | |||
| 3477 | static struct scsi_host_template aha152x_driver_template = { | 3485 | static struct scsi_host_template aha152x_driver_template = { |
| 3478 | .module = THIS_MODULE, | 3486 | .module = THIS_MODULE, |
| 3479 | .name = AHA152X_REVID, | 3487 | .name = AHA152X_REVID, |
| @@ -3490,6 +3498,7 @@ static struct scsi_host_template aha152x_driver_template = { | |||
| 3490 | .sg_tablesize = SG_ALL, | 3498 | .sg_tablesize = SG_ALL, |
| 3491 | .cmd_per_lun = 1, | 3499 | .cmd_per_lun = 1, |
| 3492 | .use_clustering = DISABLE_CLUSTERING, | 3500 | .use_clustering = DISABLE_CLUSTERING, |
| 3501 | .slave_alloc = aha152x_adjust_queue, | ||
| 3493 | }; | 3502 | }; |
| 3494 | 3503 | ||
| 3495 | #if !defined(PCMCIA) | 3504 | #if !defined(PCMCIA) |
