diff options
Diffstat (limited to 'drivers/scsi/aha152x.c')
-rw-r--r-- | drivers/scsi/aha152x.c | 91 |
1 files changed, 47 insertions, 44 deletions
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index cf49ed58476..d30a30786dd 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c | |||
@@ -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) |
@@ -975,13 +981,13 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, | |||
975 | #if defined(AHA152X_DEBUG) | 981 | #if defined(AHA152X_DEBUG) |
976 | if (HOSTDATA(shpnt)->debug & debug_queue) { | 982 | if (HOSTDATA(shpnt)->debug & debug_queue) { |
977 | 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=", |
978 | 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)); | ||
979 | __scsi_print_command(SCpnt->cmnd); | 986 | __scsi_print_command(SCpnt->cmnd); |
980 | } | 987 | } |
981 | #endif | 988 | #endif |
982 | 989 | ||
983 | SCpnt->scsi_done = done; | 990 | SCpnt->scsi_done = done; |
984 | SCpnt->resid = SCpnt->request_bufflen; | ||
985 | SCpnt->SCp.phase = not_issued | phase; | 991 | SCpnt->SCp.phase = not_issued | phase; |
986 | SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */ | 992 | SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */ |
987 | SCpnt->SCp.Message = 0; | 993 | SCpnt->SCp.Message = 0; |
@@ -1011,30 +1017,24 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, | |||
1011 | SCp.buffers_residual : left buffers in list | 1017 | SCp.buffers_residual : left buffers in list |
1012 | SCp.phase : current state of the command */ | 1018 | SCp.phase : current state of the command */ |
1013 | 1019 | ||
1014 | if (phase & (check_condition|resetting)) { | 1020 | if ((phase & (check_condition|resetting)) || !scsi_sglist(SCpnt)) { |
1015 | if (phase & check_condition) { | 1021 | if (phase & check_condition) { |
1016 | SCpnt->SCp.ptr = SCpnt->sense_buffer; | 1022 | SCpnt->SCp.ptr = SCpnt->sense_buffer; |
1017 | SCpnt->SCp.this_residual = sizeof(SCpnt->sense_buffer); | 1023 | SCpnt->SCp.this_residual = sizeof(SCpnt->sense_buffer); |
1018 | SCpnt->resid = sizeof(SCpnt->sense_buffer); | 1024 | scsi_set_resid(SCpnt, sizeof(SCpnt->sense_buffer)); |
1019 | } else { | 1025 | } else { |
1020 | SCpnt->SCp.ptr = NULL; | 1026 | SCpnt->SCp.ptr = NULL; |
1021 | SCpnt->SCp.this_residual = 0; | 1027 | SCpnt->SCp.this_residual = 0; |
1022 | SCpnt->resid = 0; | 1028 | scsi_set_resid(SCpnt, 0); |
1023 | } | 1029 | } |
1024 | SCpnt->SCp.buffer = NULL; | 1030 | SCpnt->SCp.buffer = NULL; |
1025 | SCpnt->SCp.buffers_residual = 0; | 1031 | SCpnt->SCp.buffers_residual = 0; |
1026 | } else { | 1032 | } else { |
1027 | if (SCpnt->use_sg) { | 1033 | scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); |
1028 | SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->request_buffer; | 1034 | SCpnt->SCp.buffer = scsi_sglist(SCpnt); |
1029 | SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer); | 1035 | SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer); |
1030 | SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; | 1036 | SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; |
1031 | SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1; | 1037 | SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1; |
1032 | } else { | ||
1033 | SCpnt->SCp.ptr = (char *) SCpnt->request_buffer; | ||
1034 | SCpnt->SCp.this_residual = SCpnt->request_bufflen; | ||
1035 | SCpnt->SCp.buffer = NULL; | ||
1036 | SCpnt->SCp.buffers_residual = 0; | ||
1037 | } | ||
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | DO_LOCK(flags); | 1040 | DO_LOCK(flags); |
@@ -1525,8 +1525,8 @@ static void busfree_run(struct Scsi_Host *shpnt) | |||
1525 | /* target sent DISCONNECT */ | 1525 | /* target sent DISCONNECT */ |
1526 | DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n", | 1526 | DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n", |
1527 | CMDINFO(CURRENT_SC), | 1527 | CMDINFO(CURRENT_SC), |
1528 | CURRENT_SC->resid, | 1528 | scsi_get_resid(CURRENT_SC), |
1529 | CURRENT_SC->request_bufflen); | 1529 | scsi_bufflen(CURRENT_SC)); |
1530 | #if defined(AHA152X_STAT) | 1530 | #if defined(AHA152X_STAT) |
1531 | HOSTDATA(shpnt)->disconnections++; | 1531 | HOSTDATA(shpnt)->disconnections++; |
1532 | #endif | 1532 | #endif |
@@ -1564,7 +1564,7 @@ static void busfree_run(struct Scsi_Host *shpnt) | |||
1564 | /* restore old command */ | 1564 | /* restore old command */ |
1565 | memcpy(cmd->cmnd, sc->aha_orig_cmnd, sizeof(cmd->cmnd)); | 1565 | memcpy(cmd->cmnd, sc->aha_orig_cmnd, sizeof(cmd->cmnd)); |
1566 | cmd->cmd_len = sc->aha_orig_cmd_len; | 1566 | cmd->cmd_len = sc->aha_orig_cmd_len; |
1567 | cmd->resid = sc->aha_orig_resid; | 1567 | scsi_set_resid(cmd, sc->aha_orig_resid); |
1568 | 1568 | ||
1569 | cmd->SCp.Status = SAM_STAT_CHECK_CONDITION; | 1569 | cmd->SCp.Status = SAM_STAT_CHECK_CONDITION; |
1570 | 1570 | ||
@@ -1594,7 +1594,7 @@ static void busfree_run(struct Scsi_Host *shpnt) | |||
1594 | memcpy(sc->aha_orig_cmnd, ptr->cmnd, | 1594 | memcpy(sc->aha_orig_cmnd, ptr->cmnd, |
1595 | sizeof(ptr->cmnd)); | 1595 | sizeof(ptr->cmnd)); |
1596 | sc->aha_orig_cmd_len = ptr->cmd_len; | 1596 | sc->aha_orig_cmd_len = ptr->cmd_len; |
1597 | sc->aha_orig_resid = ptr->resid; | 1597 | sc->aha_orig_resid = scsi_get_resid(ptr); |
1598 | 1598 | ||
1599 | ptr->cmnd[0] = REQUEST_SENSE; | 1599 | ptr->cmnd[0] = REQUEST_SENSE; |
1600 | ptr->cmnd[1] = 0; | 1600 | ptr->cmnd[1] = 0; |
@@ -2179,7 +2179,8 @@ static void datai_init(struct Scsi_Host *shpnt) | |||
2179 | DATA_LEN=0; | 2179 | DATA_LEN=0; |
2180 | DPRINTK(debug_datai, | 2180 | DPRINTK(debug_datai, |
2181 | DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n", | 2181 | DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n", |
2182 | CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid); | 2182 | CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC), |
2183 | scsi_get_resid(CURRENT_SC)); | ||
2183 | } | 2184 | } |
2184 | 2185 | ||
2185 | static void datai_run(struct Scsi_Host *shpnt) | 2186 | static void datai_run(struct Scsi_Host *shpnt) |
@@ -2292,11 +2293,12 @@ static void datai_run(struct Scsi_Host *shpnt) | |||
2292 | 2293 | ||
2293 | static void datai_end(struct Scsi_Host *shpnt) | 2294 | static void datai_end(struct Scsi_Host *shpnt) |
2294 | { | 2295 | { |
2295 | CURRENT_SC->resid -= GETSTCNT(); | 2296 | CMD_INC_RESID(CURRENT_SC, -GETSTCNT()); |
2296 | 2297 | ||
2297 | DPRINTK(debug_datai, | 2298 | DPRINTK(debug_datai, |
2298 | 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", |
2299 | 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()); | ||
2300 | 2302 | ||
2301 | SETPORT(SXFRCTL0, CH1|CLRSTCNT); | 2303 | SETPORT(SXFRCTL0, CH1|CLRSTCNT); |
2302 | SETPORT(DMACNTRL0, 0); | 2304 | SETPORT(DMACNTRL0, 0); |
@@ -2317,11 +2319,12 @@ static void datao_init(struct Scsi_Host *shpnt) | |||
2317 | SETPORT(SIMODE0, 0); | 2319 | SETPORT(SIMODE0, 0); |
2318 | SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE ); | 2320 | SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE ); |
2319 | 2321 | ||
2320 | DATA_LEN = CURRENT_SC->resid; | 2322 | DATA_LEN = scsi_get_resid(CURRENT_SC); |
2321 | 2323 | ||
2322 | DPRINTK(debug_datao, | 2324 | DPRINTK(debug_datao, |
2323 | DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n", | 2325 | DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n", |
2324 | CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid); | 2326 | CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC), |
2327 | scsi_get_resid(CURRENT_SC)); | ||
2325 | } | 2328 | } |
2326 | 2329 | ||
2327 | static void datao_run(struct Scsi_Host *shpnt) | 2330 | static void datao_run(struct Scsi_Host *shpnt) |
@@ -2345,7 +2348,7 @@ static void datao_run(struct Scsi_Host *shpnt) | |||
2345 | SETPORT(DMACNTRL0,WRITE_READ|ENDMA|_8BIT); | 2348 | SETPORT(DMACNTRL0,WRITE_READ|ENDMA|_8BIT); |
2346 | SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++); | 2349 | SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++); |
2347 | CURRENT_SC->SCp.this_residual--; | 2350 | CURRENT_SC->SCp.this_residual--; |
2348 | CURRENT_SC->resid--; | 2351 | CMD_INC_RESID(CURRENT_SC, -1); |
2349 | SETPORT(DMACNTRL0,WRITE_READ|ENDMA); | 2352 | SETPORT(DMACNTRL0,WRITE_READ|ENDMA); |
2350 | } | 2353 | } |
2351 | 2354 | ||
@@ -2354,7 +2357,7 @@ static void datao_run(struct Scsi_Host *shpnt) | |||
2354 | outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); | 2357 | outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); |
2355 | CURRENT_SC->SCp.ptr += 2 * data_count; | 2358 | CURRENT_SC->SCp.ptr += 2 * data_count; |
2356 | CURRENT_SC->SCp.this_residual -= 2 * data_count; | 2359 | CURRENT_SC->SCp.this_residual -= 2 * data_count; |
2357 | CURRENT_SC->resid -= 2 * data_count; | 2360 | CMD_INC_RESID(CURRENT_SC, -2 * data_count); |
2358 | } | 2361 | } |
2359 | 2362 | ||
2360 | 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) { |
@@ -2380,35 +2383,34 @@ static void datao_run(struct Scsi_Host *shpnt) | |||
2380 | static void datao_end(struct Scsi_Host *shpnt) | 2383 | static void datao_end(struct Scsi_Host *shpnt) |
2381 | { | 2384 | { |
2382 | if(TESTLO(DMASTAT, DFIFOEMP)) { | 2385 | if(TESTLO(DMASTAT, DFIFOEMP)) { |
2383 | int data_count = (DATA_LEN - CURRENT_SC->resid) - GETSTCNT(); | 2386 | int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - |
2387 | GETSTCNT(); | ||
2384 | 2388 | ||
2385 | 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", |
2386 | CMDINFO(CURRENT_SC), | 2390 | CMDINFO(CURRENT_SC), |
2387 | data_count, | 2391 | data_count, |
2388 | DATA_LEN-CURRENT_SC->resid, | 2392 | DATA_LEN - scsi_get_resid(CURRENT_SC), |
2389 | GETSTCNT()); | 2393 | GETSTCNT()); |
2390 | 2394 | ||
2391 | CURRENT_SC->resid += data_count; | 2395 | CMD_INC_RESID(CURRENT_SC, data_count); |
2392 | 2396 | ||
2393 | if(CURRENT_SC->use_sg) { | 2397 | data_count -= CURRENT_SC->SCp.ptr - |
2394 | data_count -= CURRENT_SC->SCp.ptr - SG_ADDRESS(CURRENT_SC->SCp.buffer); | 2398 | SG_ADDRESS(CURRENT_SC->SCp.buffer); |
2395 | while(data_count>0) { | 2399 | while(data_count>0) { |
2396 | CURRENT_SC->SCp.buffer--; | 2400 | CURRENT_SC->SCp.buffer--; |
2397 | CURRENT_SC->SCp.buffers_residual++; | 2401 | CURRENT_SC->SCp.buffers_residual++; |
2398 | data_count -= CURRENT_SC->SCp.buffer->length; | 2402 | data_count -= CURRENT_SC->SCp.buffer->length; |
2399 | } | ||
2400 | CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - data_count; | ||
2401 | CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + data_count; | ||
2402 | } else { | ||
2403 | CURRENT_SC->SCp.ptr -= data_count; | ||
2404 | CURRENT_SC->SCp.this_residual += data_count; | ||
2405 | } | 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; | ||
2406 | } | 2408 | } |
2407 | 2409 | ||
2408 | 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", |
2409 | CMDINFO(CURRENT_SC), | 2411 | CMDINFO(CURRENT_SC), |
2410 | CURRENT_SC->request_bufflen, | 2412 | scsi_bufflen(CURRENT_SC), |
2411 | CURRENT_SC->resid, | 2413 | scsi_get_resid(CURRENT_SC), |
2412 | GETSTCNT()); | 2414 | GETSTCNT()); |
2413 | 2415 | ||
2414 | SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); | 2416 | SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); |
@@ -2935,7 +2937,7 @@ static void show_command(Scsi_Cmnd *ptr) | |||
2935 | __scsi_print_command(ptr->cmnd); | 2937 | __scsi_print_command(ptr->cmnd); |
2936 | 2938 | ||
2937 | printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |", | 2939 | printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |", |
2938 | ptr->request_bufflen, ptr->resid); | 2940 | scsi_bufflen(ptr), scsi_get_resid(ptr)); |
2939 | 2941 | ||
2940 | if (ptr->SCp.phase & not_issued) | 2942 | if (ptr->SCp.phase & not_issued) |
2941 | printk("not issued|"); | 2943 | printk("not issued|"); |
@@ -3005,7 +3007,8 @@ static int get_command(char *pos, Scsi_Cmnd * ptr) | |||
3005 | SPRINTF("0x%02x ", ptr->cmnd[i]); | 3007 | SPRINTF("0x%02x ", ptr->cmnd[i]); |
3006 | 3008 | ||
3007 | SPRINTF("); resid=%d; residual=%d; buffers=%d; phase |", | 3009 | SPRINTF("); resid=%d; residual=%d; buffers=%d; phase |", |
3008 | ptr->resid, ptr->SCp.this_residual, ptr->SCp.buffers_residual); | 3010 | scsi_get_resid(ptr), ptr->SCp.this_residual, |
3011 | ptr->SCp.buffers_residual); | ||
3009 | 3012 | ||
3010 | if (ptr->SCp.phase & not_issued) | 3013 | if (ptr->SCp.phase & not_issued) |
3011 | SPRINTF("not issued|"); | 3014 | SPRINTF("not issued|"); |