aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aha152x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/aha152x.c')
-rw-r--r--drivers/scsi/aha152x.c994
1 files changed, 224 insertions, 770 deletions
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index e77b72f78006..2b960b326daf 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -230,7 +230,7 @@
230 * 230 *
231 * 231 *
232 ************************************************************************** 232 **************************************************************************
233 233
234 see Documentation/scsi/aha152x.txt for configuration details 234 see Documentation/scsi/aha152x.txt for configuration details
235 235
236 **************************************************************************/ 236 **************************************************************************/
@@ -279,45 +279,11 @@ static LIST_HEAD(aha152x_host_list);
279#error define AUTOCONF or SETUP0 279#error define AUTOCONF or SETUP0
280#endif 280#endif
281 281
282#if defined(AHA152X_DEBUG)
283#define DEBUG_DEFAULT debug_eh
284
285#define DPRINTK(when,msgs...) \
286 do { if(HOSTDATA(shpnt)->debug & (when)) printk(msgs); } while(0)
287
288#define DO_LOCK(flags) \
289 do { \
290 if(spin_is_locked(&QLOCK)) { \
291 DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \
292 } \
293 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
294 spin_lock_irqsave(&QLOCK,flags); \
295 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
296 QLOCKER=__func__; \
297 QLOCKERL=__LINE__; \
298 } while(0)
299
300#define DO_UNLOCK(flags) \
301 do { \
302 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \
303 spin_unlock_irqrestore(&QLOCK,flags); \
304 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
305 QLOCKER="(not locked)"; \
306 QLOCKERL=0; \
307 } while(0)
308
309#else
310#define DPRINTK(when,msgs...)
311#define DO_LOCK(flags) spin_lock_irqsave(&QLOCK,flags) 282#define DO_LOCK(flags) spin_lock_irqsave(&QLOCK,flags)
312#define DO_UNLOCK(flags) spin_unlock_irqrestore(&QLOCK,flags) 283#define DO_UNLOCK(flags) spin_unlock_irqrestore(&QLOCK,flags)
313#endif
314 284
315#define LEAD "(scsi%d:%d:%d) " 285#define LEAD "(scsi%d:%d:%d) "
316#define WARN_LEAD KERN_WARNING LEAD
317#define INFO_LEAD KERN_INFO LEAD 286#define INFO_LEAD KERN_INFO LEAD
318#define NOTE_LEAD KERN_NOTICE LEAD
319#define ERR_LEAD KERN_ERR LEAD
320#define DEBUG_LEAD KERN_DEBUG LEAD
321#define CMDINFO(cmd) \ 287#define CMDINFO(cmd) \
322 (cmd) ? ((cmd)->device->host->host_no) : -1, \ 288 (cmd) ? ((cmd)->device->host->host_no) : -1, \
323 (cmd) ? ((cmd)->device->id & 0x0f) : -1, \ 289 (cmd) ? ((cmd)->device->id & 0x0f) : -1, \
@@ -345,10 +311,10 @@ CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
345 311
346enum { 312enum {
347 not_issued = 0x0001, /* command not yet issued */ 313 not_issued = 0x0001, /* command not yet issued */
348 selecting = 0x0002, /* target is beeing selected */ 314 selecting = 0x0002, /* target is being selected */
349 identified = 0x0004, /* IDENTIFY was sent */ 315 identified = 0x0004, /* IDENTIFY was sent */
350 disconnected = 0x0008, /* target disconnected */ 316 disconnected = 0x0008, /* target disconnected */
351 completed = 0x0010, /* target sent COMMAND COMPLETE */ 317 completed = 0x0010, /* target sent COMMAND COMPLETE */
352 aborted = 0x0020, /* ABORT was sent */ 318 aborted = 0x0020, /* ABORT was sent */
353 resetted = 0x0040, /* BUS DEVICE RESET was sent */ 319 resetted = 0x0040, /* BUS DEVICE RESET was sent */
354 spiordy = 0x0080, /* waiting for SPIORDY to raise */ 320 spiordy = 0x0080, /* waiting for SPIORDY to raise */
@@ -396,7 +362,6 @@ static int exttrans[] = {0, 0};
396module_param_array(exttrans, int, NULL, 0); 362module_param_array(exttrans, int, NULL, 0);
397MODULE_PARM_DESC(exttrans,"use extended translation"); 363MODULE_PARM_DESC(exttrans,"use extended translation");
398 364
399#if !defined(AHA152X_DEBUG)
400static int aha152x[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0}; 365static int aha152x[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0};
401module_param_array(aha152x, int, NULL, 0); 366module_param_array(aha152x, int, NULL, 0);
402MODULE_PARM_DESC(aha152x, "parameters for first controller"); 367MODULE_PARM_DESC(aha152x, "parameters for first controller");
@@ -404,19 +369,6 @@ MODULE_PARM_DESC(aha152x, "parameters for first controller");
404static int aha152x1[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0}; 369static int aha152x1[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0};
405module_param_array(aha152x1, int, NULL, 0); 370module_param_array(aha152x1, int, NULL, 0);
406MODULE_PARM_DESC(aha152x1, "parameters for second controller"); 371MODULE_PARM_DESC(aha152x1, "parameters for second controller");
407#else
408static int debug[] = {DEBUG_DEFAULT, DEBUG_DEFAULT};
409module_param_array(debug, int, NULL, 0);
410MODULE_PARM_DESC(debug, "flags for driver debugging");
411
412static int aha152x[] = {0, 11, 7, 1, 1, 1, DELAY_DEFAULT, 0, DEBUG_DEFAULT};
413module_param_array(aha152x, int, NULL, 0);
414MODULE_PARM_DESC(aha152x, "parameters for first controller");
415
416static int aha152x1[] = {0, 11, 7, 1, 1, 1, DELAY_DEFAULT, 0, DEBUG_DEFAULT};
417module_param_array(aha152x1, int, NULL, 0);
418MODULE_PARM_DESC(aha152x1, "parameters for second controller");
419#endif /* !defined(AHA152X_DEBUG) */
420#endif /* MODULE */ 372#endif /* MODULE */
421 373
422#ifdef __ISAPNP__ 374#ifdef __ISAPNP__
@@ -446,7 +398,7 @@ static struct scsi_host_template aha152x_driver_template;
446/* 398/*
447 * internal states of the host 399 * internal states of the host
448 * 400 *
449 */ 401 */
450enum aha152x_state { 402enum aha152x_state {
451 idle=0, 403 idle=0,
452 unknown, 404 unknown,
@@ -485,24 +437,16 @@ struct aha152x_hostdata {
485 spinlock_t lock; 437 spinlock_t lock;
486 /* host lock */ 438 /* host lock */
487 439
488#if defined(AHA152X_DEBUG)
489 const char *locker;
490 /* which function has the lock */
491 int lockerl; /* where did it get it */
492
493 int debug; /* current debugging setting */
494#endif
495
496#if defined(AHA152X_STAT) 440#if defined(AHA152X_STAT)
497 int total_commands; 441 int total_commands;
498 int disconnections; 442 int disconnections;
499 int busfree_without_any_action; 443 int busfree_without_any_action;
500 int busfree_without_old_command; 444 int busfree_without_old_command;
501 int busfree_without_new_command; 445 int busfree_without_new_command;
502 int busfree_without_done_command; 446 int busfree_without_done_command;
503 int busfree_with_check_condition; 447 int busfree_with_check_condition;
504 int count[maxstate]; 448 int count[maxstate];
505 int count_trans[maxstate]; 449 int count_trans[maxstate];
506 unsigned long time[maxstate]; 450 unsigned long time[maxstate];
507#endif 451#endif
508 452
@@ -514,7 +458,7 @@ struct aha152x_hostdata {
514 int delay; /* reset out delay */ 458 int delay; /* reset out delay */
515 int ext_trans; /* extended translation enabled */ 459 int ext_trans; /* extended translation enabled */
516 460
517 int swint; /* software-interrupt was fired during detect() */ 461 int swint; /* software-interrupt was fired during detect() */
518 int service; /* bh needs to be run */ 462 int service; /* bh needs to be run */
519 int in_intr; /* bh is running */ 463 int in_intr; /* bh is running */
520 464
@@ -543,7 +487,7 @@ struct aha152x_hostdata {
543 unsigned char msgi[256]; 487 unsigned char msgi[256];
544 /* received message bytes */ 488 /* received message bytes */
545 489
546 int msgo_i, msgo_len; 490 int msgo_i, msgo_len;
547 /* number of sent bytes and length of current messages */ 491 /* number of sent bytes and length of current messages */
548 unsigned char msgo[256]; 492 unsigned char msgo[256];
549 /* pending messages */ 493 /* pending messages */
@@ -689,7 +633,6 @@ static void aha152x_error(struct Scsi_Host *shpnt, char *msg);
689static void done(struct Scsi_Host *shpnt, int error); 633static void done(struct Scsi_Host *shpnt, int error);
690 634
691/* diagnostics */ 635/* diagnostics */
692static void disp_ports(struct Scsi_Host *shpnt);
693static void show_command(Scsi_Cmnd * ptr); 636static void show_command(Scsi_Cmnd * ptr);
694static void show_queues(struct Scsi_Host *shpnt); 637static void show_queues(struct Scsi_Host *shpnt);
695static void disp_enintr(struct Scsi_Host *shpnt); 638static void disp_enintr(struct Scsi_Host *shpnt);
@@ -812,10 +755,6 @@ struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *setup)
812 DELAY = setup->delay; 755 DELAY = setup->delay;
813 EXT_TRANS = setup->ext_trans; 756 EXT_TRANS = setup->ext_trans;
814 757
815#if defined(AHA152X_DEBUG)
816 HOSTDATA(shpnt)->debug = setup->debug;
817#endif
818
819 SETPORT(SCSIID, setup->scsiid << 4); 758 SETPORT(SCSIID, setup->scsiid << 4);
820 shpnt->this_id = setup->scsiid; 759 shpnt->this_id = setup->scsiid;
821 760
@@ -941,31 +880,24 @@ void aha152x_release(struct Scsi_Host *shpnt)
941 * setup controller to generate interrupts depending 880 * setup controller to generate interrupts depending
942 * on current state (lock has to be acquired) 881 * on current state (lock has to be acquired)
943 * 882 *
944 */ 883 */
945static int setup_expected_interrupts(struct Scsi_Host *shpnt) 884static int setup_expected_interrupts(struct Scsi_Host *shpnt)
946{ 885{
947 if(CURRENT_SC) { 886 if(CURRENT_SC) {
948 CURRENT_SC->SCp.phase |= 1 << 16; 887 CURRENT_SC->SCp.phase |= 1 << 16;
949 888
950 if(CURRENT_SC->SCp.phase & selecting) { 889 if(CURRENT_SC->SCp.phase & selecting) {
951 DPRINTK(debug_intr, DEBUG_LEAD "expecting: (seldo) (seltimo) (seldi)\n", CMDINFO(CURRENT_SC));
952 SETPORT(SSTAT1, SELTO); 890 SETPORT(SSTAT1, SELTO);
953 SETPORT(SIMODE0, ENSELDO | (DISCONNECTED_SC ? ENSELDI : 0)); 891 SETPORT(SIMODE0, ENSELDO | (DISCONNECTED_SC ? ENSELDI : 0));
954 SETPORT(SIMODE1, ENSELTIMO); 892 SETPORT(SIMODE1, ENSELTIMO);
955 } else { 893 } else {
956 DPRINTK(debug_intr, DEBUG_LEAD "expecting: (phase change) (busfree) %s\n", CMDINFO(CURRENT_SC), CURRENT_SC->SCp.phase & spiordy ? "(spiordy)" : "");
957 SETPORT(SIMODE0, (CURRENT_SC->SCp.phase & spiordy) ? ENSPIORDY : 0); 894 SETPORT(SIMODE0, (CURRENT_SC->SCp.phase & spiordy) ? ENSPIORDY : 0);
958 SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE); 895 SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE);
959 } 896 }
960 } else if(STATE==seldi) { 897 } else if(STATE==seldi) {
961 DPRINTK(debug_intr, DEBUG_LEAD "expecting: (phase change) (identify)\n", CMDINFO(CURRENT_SC));
962 SETPORT(SIMODE0, 0); 898 SETPORT(SIMODE0, 0);
963 SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE); 899 SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE);
964 } else { 900 } else {
965 DPRINTK(debug_intr, DEBUG_LEAD "expecting: %s %s\n",
966 CMDINFO(CURRENT_SC),
967 DISCONNECTED_SC ? "(reselection)" : "",
968 ISSUE_SC ? "(busfree)" : "");
969 SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0); 901 SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
970 SETPORT(SIMODE1, ENSCSIRST | ( (ISSUE_SC||DONE_SC) ? ENBUSFREE : 0)); 902 SETPORT(SIMODE1, ENSCSIRST | ( (ISSUE_SC||DONE_SC) ? ENBUSFREE : 0));
971 } 903 }
@@ -977,7 +909,7 @@ static int setup_expected_interrupts(struct Scsi_Host *shpnt)
977} 909}
978 910
979 911
980/* 912/*
981 * Queue a command and setup interrupts for a free bus. 913 * Queue a command and setup interrupts for a free bus.
982 */ 914 */
983static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, 915static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
@@ -986,15 +918,6 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
986 struct Scsi_Host *shpnt = SCpnt->device->host; 918 struct Scsi_Host *shpnt = SCpnt->device->host;
987 unsigned long flags; 919 unsigned long flags;
988 920
989#if defined(AHA152X_DEBUG)
990 if (HOSTDATA(shpnt)->debug & debug_queue) {
991 printk(INFO_LEAD "queue: %p; cmd_len=%d pieces=%d size=%u cmnd=",
992 CMDINFO(SCpnt), SCpnt, SCpnt->cmd_len,
993 scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
994 __scsi_print_command(SCpnt->cmnd);
995 }
996#endif
997
998 SCpnt->scsi_done = done; 921 SCpnt->scsi_done = done;
999 SCpnt->SCp.phase = not_issued | phase; 922 SCpnt->SCp.phase = not_issued | phase;
1000 SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */ 923 SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */
@@ -1004,13 +927,13 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
1004 927
1005 if(SCpnt->SCp.phase & (resetting|check_condition)) { 928 if(SCpnt->SCp.phase & (resetting|check_condition)) {
1006 if (!SCpnt->host_scribble || SCSEM(SCpnt) || SCNEXT(SCpnt)) { 929 if (!SCpnt->host_scribble || SCSEM(SCpnt) || SCNEXT(SCpnt)) {
1007 printk(ERR_LEAD "cannot reuse command\n", CMDINFO(SCpnt)); 930 scmd_printk(KERN_ERR, SCpnt, "cannot reuse command\n");
1008 return FAILED; 931 return FAILED;
1009 } 932 }
1010 } else { 933 } else {
1011 SCpnt->host_scribble = kmalloc(sizeof(struct aha152x_scdata), GFP_ATOMIC); 934 SCpnt->host_scribble = kmalloc(sizeof(struct aha152x_scdata), GFP_ATOMIC);
1012 if(!SCpnt->host_scribble) { 935 if(!SCpnt->host_scribble) {
1013 printk(ERR_LEAD "allocation failed\n", CMDINFO(SCpnt)); 936 scmd_printk(KERN_ERR, SCpnt, "allocation failed\n");
1014 return FAILED; 937 return FAILED;
1015 } 938 }
1016 } 939 }
@@ -1066,15 +989,6 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
1066 */ 989 */
1067static int aha152x_queue_lck(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 990static int aha152x_queue_lck(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
1068{ 991{
1069#if 0
1070 if(*SCpnt->cmnd == REQUEST_SENSE) {
1071 SCpnt->result = 0;
1072 done(SCpnt);
1073
1074 return 0;
1075 }
1076#endif
1077
1078 return aha152x_internal_queue(SCpnt, NULL, 0, done); 992 return aha152x_internal_queue(SCpnt, NULL, 0, done);
1079} 993}
1080 994
@@ -1082,15 +996,10 @@ static DEF_SCSI_QCMD(aha152x_queue)
1082 996
1083 997
1084/* 998/*
1085 *
1086 * 999 *
1087 */ 1000 */
1088static void reset_done(Scsi_Cmnd *SCpnt) 1001static void reset_done(Scsi_Cmnd *SCpnt)
1089{ 1002{
1090#if 0
1091 struct Scsi_Host *shpnt = SCpnt->host;
1092 DPRINTK(debug_eh, INFO_LEAD "reset_done called\n", CMDINFO(SCpnt));
1093#endif
1094 if(SCSEM(SCpnt)) { 1003 if(SCSEM(SCpnt)) {
1095 complete(SCSEM(SCpnt)); 1004 complete(SCSEM(SCpnt));
1096 } else { 1005 } else {
@@ -1108,20 +1017,11 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt)
1108 Scsi_Cmnd *ptr; 1017 Scsi_Cmnd *ptr;
1109 unsigned long flags; 1018 unsigned long flags;
1110 1019
1111#if defined(AHA152X_DEBUG)
1112 if(HOSTDATA(shpnt)->debug & debug_eh) {
1113 printk(DEBUG_LEAD "abort(%p)", CMDINFO(SCpnt), SCpnt);
1114 show_queues(shpnt);
1115 }
1116#endif
1117
1118 DO_LOCK(flags); 1020 DO_LOCK(flags);
1119 1021
1120 ptr=remove_SC(&ISSUE_SC, SCpnt); 1022 ptr=remove_SC(&ISSUE_SC, SCpnt);
1121 1023
1122 if(ptr) { 1024 if(ptr) {
1123 DPRINTK(debug_eh, DEBUG_LEAD "not yet issued - SUCCESS\n", CMDINFO(SCpnt));
1124
1125 HOSTDATA(shpnt)->commands--; 1025 HOSTDATA(shpnt)->commands--;
1126 if (!HOSTDATA(shpnt)->commands) 1026 if (!HOSTDATA(shpnt)->commands)
1127 SETPORT(PORTA, 0); 1027 SETPORT(PORTA, 0);
@@ -1131,7 +1031,7 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt)
1131 SCpnt->host_scribble=NULL; 1031 SCpnt->host_scribble=NULL;
1132 1032
1133 return SUCCESS; 1033 return SUCCESS;
1134 } 1034 }
1135 1035
1136 DO_UNLOCK(flags); 1036 DO_UNLOCK(flags);
1137 1037
@@ -1142,7 +1042,8 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt)
1142 * 1042 *
1143 */ 1043 */
1144 1044
1145 printk(ERR_LEAD "cannot abort running or disconnected command\n", CMDINFO(SCpnt)); 1045 scmd_printk(KERN_ERR, SCpnt,
1046 "cannot abort running or disconnected command\n");
1146 1047
1147 return FAILED; 1048 return FAILED;
1148} 1049}
@@ -1160,15 +1061,8 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
1160 unsigned long flags; 1061 unsigned long flags;
1161 unsigned long timeleft; 1062 unsigned long timeleft;
1162 1063
1163#if defined(AHA152X_DEBUG)
1164 if(HOSTDATA(shpnt)->debug & debug_eh) {
1165 printk(INFO_LEAD "aha152x_device_reset(%p)", CMDINFO(SCpnt), SCpnt);
1166 show_queues(shpnt);
1167 }
1168#endif
1169
1170 if(CURRENT_SC==SCpnt) { 1064 if(CURRENT_SC==SCpnt) {
1171 printk(ERR_LEAD "cannot reset current device\n", CMDINFO(SCpnt)); 1065 scmd_printk(KERN_ERR, SCpnt, "cannot reset current device\n");
1172 return FAILED; 1066 return FAILED;
1173 } 1067 }
1174 1068
@@ -1208,7 +1102,7 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
1208 } else if(disconnected) { 1102 } else if(disconnected) {
1209 append_SC(&DISCONNECTED_SC, SCpnt); 1103 append_SC(&DISCONNECTED_SC, SCpnt);
1210 } 1104 }
1211 1105
1212 ret = FAILED; 1106 ret = FAILED;
1213 } 1107 }
1214 1108
@@ -1227,12 +1121,12 @@ static void free_hard_reset_SCs(struct Scsi_Host *shpnt, Scsi_Cmnd **SCs)
1227 if(SCDATA(ptr)) { 1121 if(SCDATA(ptr)) {
1228 next = SCNEXT(ptr); 1122 next = SCNEXT(ptr);
1229 } else { 1123 } else {
1230 printk(DEBUG_LEAD "queue corrupted at %p\n", CMDINFO(ptr), ptr); 1124 scmd_printk(KERN_DEBUG, ptr,
1125 "queue corrupted at %p\n", ptr);
1231 next = NULL; 1126 next = NULL;
1232 } 1127 }
1233 1128
1234 if (!ptr->device->soft_reset) { 1129 if (!ptr->device->soft_reset) {
1235 DPRINTK(debug_eh, DEBUG_LEAD "disconnected command %p removed\n", CMDINFO(ptr), ptr);
1236 remove_SC(SCs, ptr); 1130 remove_SC(SCs, ptr);
1237 HOSTDATA(shpnt)->commands--; 1131 HOSTDATA(shpnt)->commands--;
1238 kfree(ptr->host_scribble); 1132 kfree(ptr->host_scribble);
@@ -1253,25 +1147,14 @@ static int aha152x_bus_reset_host(struct Scsi_Host *shpnt)
1253 1147
1254 DO_LOCK(flags); 1148 DO_LOCK(flags);
1255 1149
1256#if defined(AHA152X_DEBUG)
1257 if(HOSTDATA(shpnt)->debug & debug_eh) {
1258 printk(KERN_DEBUG "scsi%d: bus reset", shpnt->host_no);
1259 show_queues(shpnt);
1260 }
1261#endif
1262
1263 free_hard_reset_SCs(shpnt, &ISSUE_SC); 1150 free_hard_reset_SCs(shpnt, &ISSUE_SC);
1264 free_hard_reset_SCs(shpnt, &DISCONNECTED_SC); 1151 free_hard_reset_SCs(shpnt, &DISCONNECTED_SC);
1265 1152
1266 DPRINTK(debug_eh, KERN_DEBUG "scsi%d: resetting bus\n", shpnt->host_no);
1267
1268 SETPORT(SCSISEQ, SCSIRSTO); 1153 SETPORT(SCSISEQ, SCSIRSTO);
1269 mdelay(256); 1154 mdelay(256);
1270 SETPORT(SCSISEQ, 0); 1155 SETPORT(SCSISEQ, 0);
1271 mdelay(DELAY); 1156 mdelay(DELAY);
1272 1157
1273 DPRINTK(debug_eh, KERN_DEBUG "scsi%d: bus resetted\n", shpnt->host_no);
1274
1275 setup_expected_interrupts(shpnt); 1158 setup_expected_interrupts(shpnt);
1276 if(HOSTDATA(shpnt)->commands==0) 1159 if(HOSTDATA(shpnt)->commands==0)
1277 SETPORT(PORTA, 0); 1160 SETPORT(PORTA, 0);
@@ -1333,11 +1216,7 @@ static void reset_ports(struct Scsi_Host *shpnt)
1333 */ 1216 */
1334int aha152x_host_reset_host(struct Scsi_Host *shpnt) 1217int aha152x_host_reset_host(struct Scsi_Host *shpnt)
1335{ 1218{
1336 DPRINTK(debug_eh, KERN_DEBUG "scsi%d: host reset\n", shpnt->host_no);
1337
1338 aha152x_bus_reset_host(shpnt); 1219 aha152x_bus_reset_host(shpnt);
1339
1340 DPRINTK(debug_eh, KERN_DEBUG "scsi%d: resetting ports\n", shpnt->host_no);
1341 reset_ports(shpnt); 1220 reset_ports(shpnt);
1342 1221
1343 return SUCCESS; 1222 return SUCCESS;
@@ -1345,7 +1224,7 @@ int aha152x_host_reset_host(struct Scsi_Host *shpnt)
1345 1224
1346/* 1225/*
1347 * Reset the host (bus and controller) 1226 * Reset the host (bus and controller)
1348 * 1227 *
1349 */ 1228 */
1350static int aha152x_host_reset(Scsi_Cmnd *SCpnt) 1229static int aha152x_host_reset(Scsi_Cmnd *SCpnt)
1351{ 1230{
@@ -1411,7 +1290,9 @@ static void done(struct Scsi_Host *shpnt, int error)
1411{ 1290{
1412 if (CURRENT_SC) { 1291 if (CURRENT_SC) {
1413 if(DONE_SC) 1292 if(DONE_SC)
1414 printk(ERR_LEAD "there's already a completed command %p - will cause abort\n", CMDINFO(CURRENT_SC), DONE_SC); 1293 scmd_printk(KERN_ERR, CURRENT_SC,
1294 "there's already a completed command %p "
1295 "- will cause abort\n", DONE_SC);
1415 1296
1416 DONE_SC = CURRENT_SC; 1297 DONE_SC = CURRENT_SC;
1417 CURRENT_SC = NULL; 1298 CURRENT_SC = NULL;
@@ -1466,7 +1347,7 @@ static irqreturn_t intr(int irqno, void *dev_id)
1466 return IRQ_NONE; 1347 return IRQ_NONE;
1467 1348
1468 if( TESTLO(DMASTAT, INTSTAT) ) 1349 if( TESTLO(DMASTAT, INTSTAT) )
1469 return IRQ_NONE; 1350 return IRQ_NONE;
1470 1351
1471 /* no more interrupts from the controller, while we're busy. 1352 /* no more interrupts from the controller, while we're busy.
1472 INTEN is restored by the BH handler */ 1353 INTEN is restored by the BH handler */
@@ -1501,7 +1382,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
1501 SETPORT(SXFRCTL0, CH1); 1382 SETPORT(SXFRCTL0, CH1);
1502 1383
1503 SETPORT(SSTAT1, CLRBUSFREE); 1384 SETPORT(SSTAT1, CLRBUSFREE);
1504 1385
1505 if(CURRENT_SC) { 1386 if(CURRENT_SC) {
1506#if defined(AHA152X_STAT) 1387#if defined(AHA152X_STAT)
1507 action++; 1388 action++;
@@ -1513,19 +1394,13 @@ static void busfree_run(struct Scsi_Host *shpnt)
1513 done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_OK << 16)); 1394 done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_OK << 16));
1514 1395
1515 } else if(CURRENT_SC->SCp.phase & aborted) { 1396 } else if(CURRENT_SC->SCp.phase & aborted) {
1516 DPRINTK(debug_eh, DEBUG_LEAD "ABORT sent\n", CMDINFO(CURRENT_SC));
1517 done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_ABORT << 16)); 1397 done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_ABORT << 16));
1518 1398
1519 } else if(CURRENT_SC->SCp.phase & resetted) { 1399 } else if(CURRENT_SC->SCp.phase & resetted) {
1520 DPRINTK(debug_eh, DEBUG_LEAD "BUS DEVICE RESET sent\n", CMDINFO(CURRENT_SC));
1521 done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_RESET << 16)); 1400 done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_RESET << 16));
1522 1401
1523 } else if(CURRENT_SC->SCp.phase & disconnected) { 1402 } else if(CURRENT_SC->SCp.phase & disconnected) {
1524 /* target sent DISCONNECT */ 1403 /* target sent DISCONNECT */
1525 DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n",
1526 CMDINFO(CURRENT_SC),
1527 scsi_get_resid(CURRENT_SC),
1528 scsi_bufflen(CURRENT_SC));
1529#if defined(AHA152X_STAT) 1404#if defined(AHA152X_STAT)
1530 HOSTDATA(shpnt)->disconnections++; 1405 HOSTDATA(shpnt)->disconnections++;
1531#endif 1406#endif
@@ -1553,13 +1428,6 @@ static void busfree_run(struct Scsi_Host *shpnt)
1553 struct scsi_cmnd *cmd = HOSTDATA(shpnt)->done_SC; 1428 struct scsi_cmnd *cmd = HOSTDATA(shpnt)->done_SC;
1554 struct aha152x_scdata *sc = SCDATA(cmd); 1429 struct aha152x_scdata *sc = SCDATA(cmd);
1555 1430
1556#if 0
1557 if(HOSTDATA(shpnt)->debug & debug_eh) {
1558 printk(ERR_LEAD "received sense: ", CMDINFO(DONE_SC));
1559 scsi_print_sense("bh", DONE_SC);
1560 }
1561#endif
1562
1563 scsi_eh_restore_cmnd(cmd, &sc->ses); 1431 scsi_eh_restore_cmnd(cmd, &sc->ses);
1564 1432
1565 cmd->SCp.Status = SAM_STAT_CHECK_CONDITION; 1433 cmd->SCp.Status = SAM_STAT_CHECK_CONDITION;
@@ -1571,17 +1439,11 @@ static void busfree_run(struct Scsi_Host *shpnt)
1571#if defined(AHA152X_STAT) 1439#if defined(AHA152X_STAT)
1572 HOSTDATA(shpnt)->busfree_with_check_condition++; 1440 HOSTDATA(shpnt)->busfree_with_check_condition++;
1573#endif 1441#endif
1574#if 0
1575 DPRINTK(debug_eh, ERR_LEAD "CHECK CONDITION found\n", CMDINFO(DONE_SC));
1576#endif
1577 1442
1578 if(!(DONE_SC->SCp.phase & not_issued)) { 1443 if(!(DONE_SC->SCp.phase & not_issued)) {
1579 struct aha152x_scdata *sc; 1444 struct aha152x_scdata *sc;
1580 Scsi_Cmnd *ptr = DONE_SC; 1445 Scsi_Cmnd *ptr = DONE_SC;
1581 DONE_SC=NULL; 1446 DONE_SC=NULL;
1582#if 0
1583 DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr));
1584#endif
1585 1447
1586 sc = SCDATA(ptr); 1448 sc = SCDATA(ptr);
1587 /* It was allocated in aha152x_internal_queue? */ 1449 /* It was allocated in aha152x_internal_queue? */
@@ -1591,19 +1453,10 @@ static void busfree_run(struct Scsi_Host *shpnt)
1591 DO_UNLOCK(flags); 1453 DO_UNLOCK(flags);
1592 aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done); 1454 aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done);
1593 DO_LOCK(flags); 1455 DO_LOCK(flags);
1594#if 0
1595 } else {
1596 DPRINTK(debug_eh, ERR_LEAD "command not issued - CHECK CONDITION ignored\n", CMDINFO(DONE_SC));
1597#endif
1598 } 1456 }
1599 } 1457 }
1600 1458
1601 if(DONE_SC && DONE_SC->scsi_done) { 1459 if(DONE_SC && DONE_SC->scsi_done) {
1602#if defined(AHA152X_DEBUG)
1603 int hostno=DONE_SC->device->host->host_no;
1604 int id=DONE_SC->device->id & 0xf;
1605 int lun=((u8)DONE_SC->device->lun) & 0x7;
1606#endif
1607 Scsi_Cmnd *ptr = DONE_SC; 1460 Scsi_Cmnd *ptr = DONE_SC;
1608 DONE_SC=NULL; 1461 DONE_SC=NULL;
1609 1462
@@ -1618,9 +1471,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
1618 } 1471 }
1619 1472
1620 DO_UNLOCK(flags); 1473 DO_UNLOCK(flags);
1621 DPRINTK(debug_done, DEBUG_LEAD "calling scsi_done(%p)\n", hostno, id, lun, ptr); 1474 ptr->scsi_done(ptr);
1622 ptr->scsi_done(ptr);
1623 DPRINTK(debug_done, DEBUG_LEAD "scsi_done(%p) returned\n", hostno, id, lun, ptr);
1624 DO_LOCK(flags); 1475 DO_LOCK(flags);
1625 } 1476 }
1626 1477
@@ -1640,9 +1491,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
1640#if defined(AHA152X_STAT) 1491#if defined(AHA152X_STAT)
1641 action++; 1492 action++;
1642#endif 1493#endif
1643 CURRENT_SC->SCp.phase |= selecting; 1494 CURRENT_SC->SCp.phase |= selecting;
1644
1645 DPRINTK(debug_selection, DEBUG_LEAD "selecting target\n", CMDINFO(CURRENT_SC));
1646 1495
1647 /* clear selection timeout */ 1496 /* clear selection timeout */
1648 SETPORT(SSTAT1, SELTO); 1497 SETPORT(SSTAT1, SELTO);
@@ -1674,18 +1523,19 @@ static void seldo_run(struct Scsi_Host *shpnt)
1674 SETPORT(SSTAT1, CLRBUSFREE); 1523 SETPORT(SSTAT1, CLRBUSFREE);
1675 SETPORT(SSTAT1, CLRPHASECHG); 1524 SETPORT(SSTAT1, CLRPHASECHG);
1676 1525
1677 CURRENT_SC->SCp.phase &= ~(selecting|not_issued); 1526 CURRENT_SC->SCp.phase &= ~(selecting|not_issued);
1678 1527
1679 SETPORT(SCSISEQ, 0); 1528 SETPORT(SCSISEQ, 0);
1680 1529
1681 if (TESTLO(SSTAT0, SELDO)) { 1530 if (TESTLO(SSTAT0, SELDO)) {
1682 printk(ERR_LEAD "aha152x: passing bus free condition\n", CMDINFO(CURRENT_SC)); 1531 scmd_printk(KERN_ERR, CURRENT_SC,
1532 "aha152x: passing bus free condition\n");
1683 done(shpnt, DID_NO_CONNECT << 16); 1533 done(shpnt, DID_NO_CONNECT << 16);
1684 return; 1534 return;
1685 } 1535 }
1686 1536
1687 SETPORT(SSTAT0, CLRSELDO); 1537 SETPORT(SSTAT0, CLRSELDO);
1688 1538
1689 ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun)); 1539 ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun));
1690 1540
1691 if (CURRENT_SC->SCp.phase & aborting) { 1541 if (CURRENT_SC->SCp.phase & aborting) {
@@ -1693,7 +1543,7 @@ static void seldo_run(struct Scsi_Host *shpnt)
1693 } else if (CURRENT_SC->SCp.phase & resetting) { 1543 } else if (CURRENT_SC->SCp.phase & resetting) {
1694 ADDMSGO(BUS_DEVICE_RESET); 1544 ADDMSGO(BUS_DEVICE_RESET);
1695 } else if (SYNCNEG==0 && SYNCHRONOUS) { 1545 } else if (SYNCNEG==0 && SYNCHRONOUS) {
1696 CURRENT_SC->SCp.phase |= syncneg; 1546 CURRENT_SC->SCp.phase |= syncneg;
1697 MSGOLEN += spi_populate_sync_msg(&MSGO(MSGOLEN), 50, 8); 1547 MSGOLEN += spi_populate_sync_msg(&MSGO(MSGOLEN), 50, 8);
1698 SYNCNEG=1; /* negotiation in progress */ 1548 SYNCNEG=1; /* negotiation in progress */
1699 } 1549 }
@@ -1708,29 +1558,21 @@ static void seldo_run(struct Scsi_Host *shpnt)
1708 */ 1558 */
1709static void selto_run(struct Scsi_Host *shpnt) 1559static void selto_run(struct Scsi_Host *shpnt)
1710{ 1560{
1711 SETPORT(SCSISEQ, 0); 1561 SETPORT(SCSISEQ, 0);
1712 SETPORT(SSTAT1, CLRSELTIMO); 1562 SETPORT(SSTAT1, CLRSELTIMO);
1713 1563
1714 DPRINTK(debug_selection, DEBUG_LEAD "selection timeout\n", CMDINFO(CURRENT_SC)); 1564 if (!CURRENT_SC)
1715
1716 if(!CURRENT_SC) {
1717 DPRINTK(debug_selection, DEBUG_LEAD "!CURRENT_SC\n", CMDINFO(CURRENT_SC));
1718 return; 1565 return;
1719 }
1720 1566
1721 CURRENT_SC->SCp.phase &= ~selecting; 1567 CURRENT_SC->SCp.phase &= ~selecting;
1722 1568
1723 if (CURRENT_SC->SCp.phase & aborted) { 1569 if (CURRENT_SC->SCp.phase & aborted)
1724 DPRINTK(debug_selection, DEBUG_LEAD "aborted\n", CMDINFO(CURRENT_SC));
1725 done(shpnt, DID_ABORT << 16); 1570 done(shpnt, DID_ABORT << 16);
1726 } else if (TESTLO(SSTAT0, SELINGO)) { 1571 else if (TESTLO(SSTAT0, SELINGO))
1727 DPRINTK(debug_selection, DEBUG_LEAD "arbitration not won\n", CMDINFO(CURRENT_SC));
1728 done(shpnt, DID_BUS_BUSY << 16); 1572 done(shpnt, DID_BUS_BUSY << 16);
1729 } else { 1573 else
1730 /* ARBITRATION won, but SELECTION failed */ 1574 /* ARBITRATION won, but SELECTION failed */
1731 DPRINTK(debug_selection, DEBUG_LEAD "selection failed\n", CMDINFO(CURRENT_SC));
1732 done(shpnt, DID_NO_CONNECT << 16); 1575 done(shpnt, DID_NO_CONNECT << 16);
1733 }
1734} 1576}
1735 1577
1736/* 1578/*
@@ -1753,9 +1595,8 @@ static void seldi_run(struct Scsi_Host *shpnt)
1753 1595
1754 if(CURRENT_SC) { 1596 if(CURRENT_SC) {
1755 if(!(CURRENT_SC->SCp.phase & not_issued)) 1597 if(!(CURRENT_SC->SCp.phase & not_issued))
1756 printk(ERR_LEAD "command should not have been issued yet\n", CMDINFO(CURRENT_SC)); 1598 scmd_printk(KERN_ERR, CURRENT_SC,
1757 1599 "command should not have been issued yet\n");
1758 DPRINTK(debug_selection, ERR_LEAD "command requeued - reselection\n", CMDINFO(CURRENT_SC));
1759 1600
1760 DO_LOCK(flags); 1601 DO_LOCK(flags);
1761 append_SC(&ISSUE_SC, CURRENT_SC); 1602 append_SC(&ISSUE_SC, CURRENT_SC);
@@ -1764,17 +1605,16 @@ static void seldi_run(struct Scsi_Host *shpnt)
1764 CURRENT_SC = NULL; 1605 CURRENT_SC = NULL;
1765 } 1606 }
1766 1607
1767 if(!DISCONNECTED_SC) { 1608 if (!DISCONNECTED_SC)
1768 DPRINTK(debug_selection, DEBUG_LEAD "unexpected SELDI ", CMDINFO(CURRENT_SC));
1769 return; 1609 return;
1770 }
1771 1610
1772 RECONN_TARGET=-1; 1611 RECONN_TARGET=-1;
1773 1612
1774 selid = GETPORT(SELID) & ~(1 << shpnt->this_id); 1613 selid = GETPORT(SELID) & ~(1 << shpnt->this_id);
1775 1614
1776 if (selid==0) { 1615 if (selid==0) {
1777 printk("aha152x%d: target id unknown (%02x)\n", HOSTNO, selid); 1616 shost_printk(KERN_INFO, shpnt,
1617 "target id unknown (%02x)\n", selid);
1778 return; 1618 return;
1779 } 1619 }
1780 1620
@@ -1782,8 +1622,8 @@ static void seldi_run(struct Scsi_Host *shpnt)
1782 ; 1622 ;
1783 1623
1784 if(selid & ~(1 << target)) { 1624 if(selid & ~(1 << target)) {
1785 printk("aha152x%d: multiple targets reconnected (%02x)\n", 1625 shost_printk(KERN_INFO, shpnt,
1786 HOSTNO, selid); 1626 "multiple targets reconnected (%02x)\n", selid);
1787 } 1627 }
1788 1628
1789 1629
@@ -1793,7 +1633,6 @@ static void seldi_run(struct Scsi_Host *shpnt)
1793 SETRATE(HOSTDATA(shpnt)->syncrate[target]); 1633 SETRATE(HOSTDATA(shpnt)->syncrate[target]);
1794 1634
1795 RECONN_TARGET=target; 1635 RECONN_TARGET=target;
1796 DPRINTK(debug_selection, DEBUG_LEAD "target %d reselected (%02x).\n", CMDINFO(CURRENT_SC), target, selid);
1797} 1636}
1798 1637
1799/* 1638/*
@@ -1817,31 +1656,24 @@ static void msgi_run(struct Scsi_Host *shpnt)
1817 if(sstat1 & (PHASECHG|PHASEMIS|BUSFREE) || !(sstat1 & REQINIT)) 1656 if(sstat1 & (PHASECHG|PHASEMIS|BUSFREE) || !(sstat1 & REQINIT))
1818 return; 1657 return;
1819 1658
1820 if(TESTLO(SSTAT0,SPIORDY)) { 1659 if (TESTLO(SSTAT0, SPIORDY))
1821 DPRINTK(debug_msgi, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC));
1822 return; 1660 return;
1823 }
1824 1661
1825 ADDMSGI(GETPORT(SCSIDAT)); 1662 ADDMSGI(GETPORT(SCSIDAT));
1826 1663
1827#if defined(AHA152X_DEBUG)
1828 if (HOSTDATA(shpnt)->debug & debug_msgi) {
1829 printk(INFO_LEAD "inbound message %02x ", CMDINFO(CURRENT_SC), MSGI(0));
1830 spi_print_msg(&MSGI(0));
1831 printk("\n");
1832 }
1833#endif
1834
1835 if(!CURRENT_SC) { 1664 if(!CURRENT_SC) {
1836 if(LASTSTATE!=seldi) { 1665 if(LASTSTATE!=seldi) {
1837 printk(KERN_ERR "aha152x%d: message in w/o current command not after reselection\n", HOSTNO); 1666 shost_printk(KERN_ERR, shpnt,
1667 "message in w/o current command"
1668 " not after reselection\n");
1838 } 1669 }
1839 1670
1840 /* 1671 /*
1841 * Handle reselection 1672 * Handle reselection
1842 */ 1673 */
1843 if(!(MSGI(0) & IDENTIFY_BASE)) { 1674 if(!(MSGI(0) & IDENTIFY_BASE)) {
1844 printk(KERN_ERR "aha152x%d: target didn't identify after reselection\n", HOSTNO); 1675 shost_printk(KERN_ERR, shpnt,
1676 "target didn't identify after reselection\n");
1845 continue; 1677 continue;
1846 } 1678 }
1847 1679
@@ -1849,12 +1681,13 @@ static void msgi_run(struct Scsi_Host *shpnt)
1849 1681
1850 if (!CURRENT_SC) { 1682 if (!CURRENT_SC) {
1851 show_queues(shpnt); 1683 show_queues(shpnt);
1852 printk(KERN_ERR "aha152x%d: no disconnected command for target %d/%d\n", HOSTNO, RECONN_TARGET, MSGI(0) & 0x3f); 1684 shost_printk(KERN_ERR, shpnt,
1685 "no disconnected command"
1686 " for target %d/%d\n",
1687 RECONN_TARGET, MSGI(0) & 0x3f);
1853 continue; 1688 continue;
1854 } 1689 }
1855 1690
1856 DPRINTK(debug_msgi, DEBUG_LEAD "target reconnected\n", CMDINFO(CURRENT_SC));
1857
1858 CURRENT_SC->SCp.Message = MSGI(0); 1691 CURRENT_SC->SCp.Message = MSGI(0);
1859 CURRENT_SC->SCp.phase &= ~disconnected; 1692 CURRENT_SC->SCp.phase &= ~disconnected;
1860 1693
@@ -1862,31 +1695,32 @@ static void msgi_run(struct Scsi_Host *shpnt)
1862 1695
1863 /* next message if any */ 1696 /* next message if any */
1864 continue; 1697 continue;
1865 } 1698 }
1866 1699
1867 CURRENT_SC->SCp.Message = MSGI(0); 1700 CURRENT_SC->SCp.Message = MSGI(0);
1868 1701
1869 switch (MSGI(0)) { 1702 switch (MSGI(0)) {
1870 case DISCONNECT: 1703 case DISCONNECT:
1871 if (!RECONNECT) 1704 if (!RECONNECT)
1872 printk(WARN_LEAD "target was not allowed to disconnect\n", CMDINFO(CURRENT_SC)); 1705 scmd_printk(KERN_WARNING, CURRENT_SC,
1706 "target was not allowed to disconnect\n");
1873 1707
1874 CURRENT_SC->SCp.phase |= disconnected; 1708 CURRENT_SC->SCp.phase |= disconnected;
1875 break; 1709 break;
1876 1710
1877 case COMMAND_COMPLETE: 1711 case COMMAND_COMPLETE:
1878 if(CURRENT_SC->SCp.phase & completed)
1879 DPRINTK(debug_msgi, DEBUG_LEAD "again COMMAND COMPLETE\n", CMDINFO(CURRENT_SC));
1880
1881 CURRENT_SC->SCp.phase |= completed; 1712 CURRENT_SC->SCp.phase |= completed;
1882 break; 1713 break;
1883 1714
1884 case MESSAGE_REJECT: 1715 case MESSAGE_REJECT:
1885 if (SYNCNEG==1) { 1716 if (SYNCNEG==1) {
1886 printk(INFO_LEAD "Synchronous Data Transfer Request was rejected\n", CMDINFO(CURRENT_SC)); 1717 scmd_printk(KERN_INFO, CURRENT_SC,
1718 "Synchronous Data Transfer Request"
1719 " was rejected\n");
1887 SYNCNEG=2; /* negotiation completed */ 1720 SYNCNEG=2; /* negotiation completed */
1888 } else 1721 } else
1889 printk(INFO_LEAD "inbound message (MESSAGE REJECT)\n", CMDINFO(CURRENT_SC)); 1722 scmd_printk(KERN_INFO, CURRENT_SC,
1723 "inbound message (MESSAGE REJECT)\n");
1890 break; 1724 break;
1891 1725
1892 case SAVE_POINTERS: 1726 case SAVE_POINTERS:
@@ -1907,7 +1741,8 @@ static void msgi_run(struct Scsi_Host *shpnt)
1907 long ticks; 1741 long ticks;
1908 1742
1909 if (MSGI(1) != 3) { 1743 if (MSGI(1) != 3) {
1910 printk(ERR_LEAD "SDTR message length!=3\n", CMDINFO(CURRENT_SC)); 1744 scmd_printk(KERN_ERR, CURRENT_SC,
1745 "SDTR message length!=3\n");
1911 break; 1746 break;
1912 } 1747 }
1913 1748
@@ -1924,10 +1759,12 @@ static void msgi_run(struct Scsi_Host *shpnt)
1924 /* negotiation in progress */ 1759 /* negotiation in progress */
1925 if (ticks > 9 || MSGI(4) < 1 || MSGI(4) > 8) { 1760 if (ticks > 9 || MSGI(4) < 1 || MSGI(4) > 8) {
1926 ADDMSGO(MESSAGE_REJECT); 1761 ADDMSGO(MESSAGE_REJECT);
1927 printk(INFO_LEAD "received Synchronous Data Transfer Request invalid - rejected\n", CMDINFO(CURRENT_SC)); 1762 scmd_printk(KERN_INFO,
1763 CURRENT_SC,
1764 "received Synchronous Data Transfer Request invalid - rejected\n");
1928 break; 1765 break;
1929 } 1766 }
1930 1767
1931 SYNCRATE |= ((ticks - 2) << 4) + MSGI(4); 1768 SYNCRATE |= ((ticks - 2) << 4) + MSGI(4);
1932 } else if (ticks <= 9 && MSGI(4) >= 1) { 1769 } else if (ticks <= 9 && MSGI(4) >= 1) {
1933 ADDMSGO(EXTENDED_MESSAGE); 1770 ADDMSGO(EXTENDED_MESSAGE);
@@ -1947,11 +1784,14 @@ static void msgi_run(struct Scsi_Host *shpnt)
1947 SYNCRATE |= ((ticks - 2) << 4) + MSGI(4); 1784 SYNCRATE |= ((ticks - 2) << 4) + MSGI(4);
1948 } else { 1785 } else {
1949 /* requested SDTR is too slow, do it asynchronously */ 1786 /* requested SDTR is too slow, do it asynchronously */
1950 printk(INFO_LEAD "Synchronous Data Transfer Request too slow - Rejecting\n", CMDINFO(CURRENT_SC)); 1787 scmd_printk(KERN_INFO,
1788 CURRENT_SC,
1789 "Synchronous Data Transfer Request too slow - Rejecting\n");
1951 ADDMSGO(MESSAGE_REJECT); 1790 ADDMSGO(MESSAGE_REJECT);
1952 } 1791 }
1953 1792
1954 SYNCNEG=2; /* negotiation completed */ 1793 /* negotiation completed */
1794 SYNCNEG=2;
1955 SETRATE(SYNCRATE); 1795 SETRATE(SYNCRATE);
1956 } 1796 }
1957 break; 1797 break;
@@ -1985,12 +1825,12 @@ static void msgi_run(struct Scsi_Host *shpnt)
1985static void msgi_end(struct Scsi_Host *shpnt) 1825static void msgi_end(struct Scsi_Host *shpnt)
1986{ 1826{
1987 if(MSGILEN>0) 1827 if(MSGILEN>0)
1988 printk(WARN_LEAD "target left before message completed (%d)\n", CMDINFO(CURRENT_SC), MSGILEN); 1828 scmd_printk(KERN_WARNING, CURRENT_SC,
1829 "target left before message completed (%d)\n",
1830 MSGILEN);
1989 1831
1990 if (MSGOLEN > 0 && !(GETPORT(SSTAT1) & BUSFREE)) { 1832 if (MSGOLEN > 0 && !(GETPORT(SSTAT1) & BUSFREE))
1991 DPRINTK(debug_msgi, DEBUG_LEAD "msgo pending\n", CMDINFO(CURRENT_SC));
1992 SETPORT(SCSISIG, P_MSGI | SIG_ATNO); 1833 SETPORT(SCSISIG, P_MSGI | SIG_ATNO);
1993 }
1994} 1834}
1995 1835
1996/* 1836/*
@@ -2003,21 +1843,12 @@ static void msgo_init(struct Scsi_Host *shpnt)
2003 if((CURRENT_SC->SCp.phase & syncneg) && SYNCNEG==2 && SYNCRATE==0) { 1843 if((CURRENT_SC->SCp.phase & syncneg) && SYNCNEG==2 && SYNCRATE==0) {
2004 ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun)); 1844 ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun));
2005 } else { 1845 } else {
2006 printk(INFO_LEAD "unexpected MESSAGE OUT phase; rejecting\n", CMDINFO(CURRENT_SC)); 1846 scmd_printk(KERN_INFO, CURRENT_SC,
1847 "unexpected MESSAGE OUT phase; rejecting\n");
2007 ADDMSGO(MESSAGE_REJECT); 1848 ADDMSGO(MESSAGE_REJECT);
2008 } 1849 }
2009 } 1850 }
2010 1851
2011#if defined(AHA152X_DEBUG)
2012 if(HOSTDATA(shpnt)->debug & debug_msgo) {
2013 int i;
2014
2015 printk(DEBUG_LEAD "messages( ", CMDINFO(CURRENT_SC));
2016 for (i=0; i<MSGOLEN; i+=spi_print_msg(&MSGO(i)), printk(" "))
2017 ;
2018 printk(")\n");
2019 }
2020#endif
2021} 1852}
2022 1853
2023/* 1854/*
@@ -2026,16 +1857,9 @@ static void msgo_init(struct Scsi_Host *shpnt)
2026 */ 1857 */
2027static void msgo_run(struct Scsi_Host *shpnt) 1858static void msgo_run(struct Scsi_Host *shpnt)
2028{ 1859{
2029 if(MSGO_I==MSGOLEN)
2030 DPRINTK(debug_msgo, DEBUG_LEAD "messages all sent (%d/%d)\n", CMDINFO(CURRENT_SC), MSGO_I, MSGOLEN);
2031
2032 while(MSGO_I<MSGOLEN) { 1860 while(MSGO_I<MSGOLEN) {
2033 DPRINTK(debug_msgo, DEBUG_LEAD "message byte %02x (%d/%d)\n", CMDINFO(CURRENT_SC), MSGO(MSGO_I), MSGO_I, MSGOLEN); 1861 if (TESTLO(SSTAT0, SPIORDY))
2034
2035 if(TESTLO(SSTAT0, SPIORDY)) {
2036 DPRINTK(debug_msgo, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC));
2037 return; 1862 return;
2038 }
2039 1863
2040 if (MSGO_I==MSGOLEN-1) { 1864 if (MSGO_I==MSGOLEN-1) {
2041 /* Leave MESSAGE OUT after transfer */ 1865 /* Leave MESSAGE OUT after transfer */
@@ -2059,36 +1883,33 @@ static void msgo_run(struct Scsi_Host *shpnt)
2059static void msgo_end(struct Scsi_Host *shpnt) 1883static void msgo_end(struct Scsi_Host *shpnt)
2060{ 1884{
2061 if(MSGO_I<MSGOLEN) { 1885 if(MSGO_I<MSGOLEN) {
2062 printk(ERR_LEAD "message sent incompletely (%d/%d)\n", CMDINFO(CURRENT_SC), MSGO_I, MSGOLEN); 1886 scmd_printk(KERN_ERR, CURRENT_SC,
1887 "message sent incompletely (%d/%d)\n",
1888 MSGO_I, MSGOLEN);
2063 if(SYNCNEG==1) { 1889 if(SYNCNEG==1) {
2064 printk(INFO_LEAD "Synchronous Data Transfer Request was rejected\n", CMDINFO(CURRENT_SC)); 1890 scmd_printk(KERN_INFO, CURRENT_SC,
1891 "Synchronous Data Transfer Request was rejected\n");
2065 SYNCNEG=2; 1892 SYNCNEG=2;
2066 } 1893 }
2067 } 1894 }
2068 1895
2069 MSGO_I = 0; 1896 MSGO_I = 0;
2070 MSGOLEN = 0; 1897 MSGOLEN = 0;
2071} 1898}
2072 1899
2073/* 1900/*
2074 * command phase 1901 * command phase
2075 * 1902 *
2076 */ 1903 */
2077static void cmd_init(struct Scsi_Host *shpnt) 1904static void cmd_init(struct Scsi_Host *shpnt)
2078{ 1905{
2079 if (CURRENT_SC->SCp.sent_command) { 1906 if (CURRENT_SC->SCp.sent_command) {
2080 printk(ERR_LEAD "command already sent\n", CMDINFO(CURRENT_SC)); 1907 scmd_printk(KERN_ERR, CURRENT_SC,
1908 "command already sent\n");
2081 done(shpnt, DID_ERROR << 16); 1909 done(shpnt, DID_ERROR << 16);
2082 return; 1910 return;
2083 } 1911 }
2084 1912
2085#if defined(AHA152X_DEBUG)
2086 if (HOSTDATA(shpnt)->debug & debug_cmd) {
2087 printk(DEBUG_LEAD "cmd_init: ", CMDINFO(CURRENT_SC));
2088 __scsi_print_command(CURRENT_SC->cmnd);
2089 }
2090#endif
2091
2092 CMD_I=0; 1913 CMD_I=0;
2093} 1914}
2094 1915
@@ -2098,18 +1919,9 @@ static void cmd_init(struct Scsi_Host *shpnt)
2098 */ 1919 */
2099static void cmd_run(struct Scsi_Host *shpnt) 1920static void cmd_run(struct Scsi_Host *shpnt)
2100{ 1921{
2101 if(CMD_I==CURRENT_SC->cmd_len) {
2102 DPRINTK(debug_cmd, DEBUG_LEAD "command already completely sent (%d/%d)", CMDINFO(CURRENT_SC), CMD_I, CURRENT_SC->cmd_len);
2103 disp_ports(shpnt);
2104 }
2105
2106 while(CMD_I<CURRENT_SC->cmd_len) { 1922 while(CMD_I<CURRENT_SC->cmd_len) {
2107 DPRINTK(debug_cmd, DEBUG_LEAD "command byte %02x (%d/%d)\n", CMDINFO(CURRENT_SC), CURRENT_SC->cmnd[CMD_I], CMD_I, CURRENT_SC->cmd_len); 1923 if (TESTLO(SSTAT0, SPIORDY))
2108
2109 if(TESTLO(SSTAT0, SPIORDY)) {
2110 DPRINTK(debug_cmd, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC));
2111 return; 1924 return;
2112 }
2113 1925
2114 SETPORT(SCSIDAT, CURRENT_SC->cmnd[CMD_I++]); 1926 SETPORT(SCSIDAT, CURRENT_SC->cmnd[CMD_I++]);
2115 } 1927 }
@@ -2118,7 +1930,9 @@ static void cmd_run(struct Scsi_Host *shpnt)
2118static void cmd_end(struct Scsi_Host *shpnt) 1930static void cmd_end(struct Scsi_Host *shpnt)
2119{ 1931{
2120 if(CMD_I<CURRENT_SC->cmd_len) 1932 if(CMD_I<CURRENT_SC->cmd_len)
2121 printk(ERR_LEAD "command sent incompletely (%d/%d)\n", CMDINFO(CURRENT_SC), CMD_I, CURRENT_SC->cmd_len); 1933 scmd_printk(KERN_ERR, CURRENT_SC,
1934 "command sent incompletely (%d/%d)\n",
1935 CMD_I, CURRENT_SC->cmd_len);
2122 else 1936 else
2123 CURRENT_SC->SCp.sent_command++; 1937 CURRENT_SC->SCp.sent_command++;
2124} 1938}
@@ -2129,20 +1943,11 @@ static void cmd_end(struct Scsi_Host *shpnt)
2129 */ 1943 */
2130static void status_run(struct Scsi_Host *shpnt) 1944static void status_run(struct Scsi_Host *shpnt)
2131{ 1945{
2132 if(TESTLO(SSTAT0,SPIORDY)) { 1946 if (TESTLO(SSTAT0, SPIORDY))
2133 DPRINTK(debug_status, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC));
2134 return; 1947 return;
2135 }
2136 1948
2137 CURRENT_SC->SCp.Status = GETPORT(SCSIDAT); 1949 CURRENT_SC->SCp.Status = GETPORT(SCSIDAT);
2138 1950
2139#if defined(AHA152X_DEBUG)
2140 if (HOSTDATA(shpnt)->debug & debug_status) {
2141 printk(DEBUG_LEAD "inbound status %02x ", CMDINFO(CURRENT_SC), CURRENT_SC->SCp.Status);
2142 scsi_print_status(CURRENT_SC->SCp.Status);
2143 printk("\n");
2144 }
2145#endif
2146} 1951}
2147 1952
2148/* 1953/*
@@ -2161,10 +1966,6 @@ static void datai_init(struct Scsi_Host *shpnt)
2161 SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE); 1966 SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE);
2162 1967
2163 DATA_LEN=0; 1968 DATA_LEN=0;
2164 DPRINTK(debug_datai,
2165 DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n",
2166 CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
2167 scsi_get_resid(CURRENT_SC));
2168} 1969}
2169 1970
2170static void datai_run(struct Scsi_Host *shpnt) 1971static void datai_run(struct Scsi_Host *shpnt)
@@ -2186,8 +1987,7 @@ static void datai_run(struct Scsi_Host *shpnt)
2186 barrier(); 1987 barrier();
2187 1988
2188 if(TESTLO(DMASTAT, DFIFOFULL|INTSTAT)) { 1989 if(TESTLO(DMASTAT, DFIFOFULL|INTSTAT)) {
2189 printk(ERR_LEAD "datai timeout", CMDINFO(CURRENT_SC)); 1990 scmd_printk(KERN_ERR, CURRENT_SC, "datai timeout\n");
2190 disp_ports(shpnt);
2191 break; 1991 break;
2192 } 1992 }
2193 1993
@@ -2199,8 +1999,8 @@ static void datai_run(struct Scsi_Host *shpnt)
2199 barrier(); 1999 barrier();
2200 2000
2201 if(TESTLO(SSTAT2, SEMPTY)) { 2001 if(TESTLO(SSTAT2, SEMPTY)) {
2202 printk(ERR_LEAD "datai sempty timeout", CMDINFO(CURRENT_SC)); 2002 scmd_printk(KERN_ERR, CURRENT_SC,
2203 disp_ports(shpnt); 2003 "datai sempty timeout");
2204 break; 2004 break;
2205 } 2005 }
2206 2006
@@ -2209,48 +2009,49 @@ static void datai_run(struct Scsi_Host *shpnt)
2209 2009
2210 if(CURRENT_SC->SCp.this_residual>0) { 2010 if(CURRENT_SC->SCp.this_residual>0) {
2211 while(fifodata>0 && CURRENT_SC->SCp.this_residual>0) { 2011 while(fifodata>0 && CURRENT_SC->SCp.this_residual>0) {
2212 data_count = fifodata>CURRENT_SC->SCp.this_residual ? 2012 data_count = fifodata > CURRENT_SC->SCp.this_residual ?
2213 CURRENT_SC->SCp.this_residual : 2013 CURRENT_SC->SCp.this_residual :
2214 fifodata; 2014 fifodata;
2215 fifodata -= data_count; 2015 fifodata -= data_count;
2216 2016
2217 if(data_count & 1) { 2017 if (data_count & 1) {
2218 DPRINTK(debug_datai, DEBUG_LEAD "8bit\n", CMDINFO(CURRENT_SC)); 2018 SETPORT(DMACNTRL0, ENDMA|_8BIT);
2219 SETPORT(DMACNTRL0, ENDMA|_8BIT); 2019 *CURRENT_SC->SCp.ptr++ = GETPORT(DATAPORT);
2220 *CURRENT_SC->SCp.ptr++ = GETPORT(DATAPORT); 2020 CURRENT_SC->SCp.this_residual--;
2221 CURRENT_SC->SCp.this_residual--; 2021 DATA_LEN++;
2222 DATA_LEN++; 2022 SETPORT(DMACNTRL0, ENDMA);
2223 SETPORT(DMACNTRL0, ENDMA); 2023 }
2224 } 2024
2225 2025 if (data_count > 1) {
2226 if(data_count > 1) { 2026 data_count >>= 1;
2227 DPRINTK(debug_datai, DEBUG_LEAD "16bit(%d)\n", CMDINFO(CURRENT_SC), data_count); 2027 insw(DATAPORT, CURRENT_SC->SCp.ptr, data_count);
2228 data_count >>= 1; 2028 CURRENT_SC->SCp.ptr += 2 * data_count;
2229 insw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); 2029 CURRENT_SC->SCp.this_residual -= 2 * data_count;
2230 CURRENT_SC->SCp.ptr += 2 * data_count; 2030 DATA_LEN += 2 * data_count;
2231 CURRENT_SC->SCp.this_residual -= 2 * data_count; 2031 }
2232 DATA_LEN += 2 * data_count; 2032
2233 } 2033 if (CURRENT_SC->SCp.this_residual == 0 &&
2234 2034 CURRENT_SC->SCp.buffers_residual > 0) {
2235 if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { 2035 /* advance to next buffer */
2236 /* advance to next buffer */ 2036 CURRENT_SC->SCp.buffers_residual--;
2237 CURRENT_SC->SCp.buffers_residual--; 2037 CURRENT_SC->SCp.buffer++;
2238 CURRENT_SC->SCp.buffer++; 2038 CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer);
2239 CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer); 2039 CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length;
2240 CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length; 2040 }
2241 } 2041 }
2242 } 2042 } else if (fifodata > 0) {
2243 } else if(fifodata>0) { 2043 scmd_printk(KERN_ERR, CURRENT_SC,
2244 printk(ERR_LEAD "no buffers left for %d(%d) bytes (data overrun!?)\n", CMDINFO(CURRENT_SC), fifodata, GETPORT(FIFOSTAT)); 2044 "no buffers left for %d(%d) bytes"
2245 SETPORT(DMACNTRL0, ENDMA|_8BIT); 2045 " (data overrun!?)\n",
2046 fifodata, GETPORT(FIFOSTAT));
2047 SETPORT(DMACNTRL0, ENDMA|_8BIT);
2246 while(fifodata>0) { 2048 while(fifodata>0) {
2247 int data; 2049 int data;
2248 data=GETPORT(DATAPORT); 2050 data=GETPORT(DATAPORT);
2249 DPRINTK(debug_datai, DEBUG_LEAD "data=%02x\n", CMDINFO(CURRENT_SC), data);
2250 fifodata--; 2051 fifodata--;
2251 DATA_LEN++; 2052 DATA_LEN++;
2252 } 2053 }
2253 SETPORT(DMACNTRL0, ENDMA|_8BIT); 2054 SETPORT(DMACNTRL0, ENDMA|_8BIT);
2254 } 2055 }
2255 } 2056 }
2256 2057
@@ -2258,19 +2059,20 @@ static void datai_run(struct Scsi_Host *shpnt)
2258 TESTLO(DMASTAT, DFIFOEMP) || 2059 TESTLO(DMASTAT, DFIFOEMP) ||
2259 TESTLO(SSTAT2, SEMPTY) || 2060 TESTLO(SSTAT2, SEMPTY) ||
2260 GETPORT(FIFOSTAT)>0) { 2061 GETPORT(FIFOSTAT)>0) {
2261 /* 2062 /*
2262 * something went wrong, if there's something left in the fifos 2063 * something went wrong, if there's something left in the fifos
2263 * or the phase didn't change 2064 * or the phase didn't change
2264 */ 2065 */
2265 printk(ERR_LEAD "fifos should be empty and phase should have changed\n", CMDINFO(CURRENT_SC)); 2066 scmd_printk(KERN_ERR, CURRENT_SC,
2266 disp_ports(shpnt); 2067 "fifos should be empty and phase should have changed\n");
2267 } 2068 }
2268 2069
2269 if(DATA_LEN!=GETSTCNT()) { 2070 if(DATA_LEN!=GETSTCNT()) {
2270 printk(ERR_LEAD 2071 scmd_printk(KERN_ERR, CURRENT_SC,
2271 "manual transfer count differs from automatic (count=%d;stcnt=%d;diff=%d;fifostat=%d)", 2072 "manual transfer count differs from automatic "
2272 CMDINFO(CURRENT_SC), DATA_LEN, GETSTCNT(), GETSTCNT()-DATA_LEN, GETPORT(FIFOSTAT)); 2073 "(count=%d;stcnt=%d;diff=%d;fifostat=%d)",
2273 disp_ports(shpnt); 2074 DATA_LEN, GETSTCNT(), GETSTCNT()-DATA_LEN,
2075 GETPORT(FIFOSTAT));
2274 mdelay(10000); 2076 mdelay(10000);
2275 } 2077 }
2276} 2078}
@@ -2279,11 +2081,6 @@ static void datai_end(struct Scsi_Host *shpnt)
2279{ 2081{
2280 CMD_INC_RESID(CURRENT_SC, -GETSTCNT()); 2082 CMD_INC_RESID(CURRENT_SC, -GETSTCNT());
2281 2083
2282 DPRINTK(debug_datai,
2283 DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n",
2284 CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
2285 scsi_get_resid(CURRENT_SC), GETSTCNT());
2286
2287 SETPORT(SXFRCTL0, CH1|CLRSTCNT); 2084 SETPORT(SXFRCTL0, CH1|CLRSTCNT);
2288 SETPORT(DMACNTRL0, 0); 2085 SETPORT(DMACNTRL0, 0);
2289} 2086}
@@ -2304,11 +2101,6 @@ static void datao_init(struct Scsi_Host *shpnt)
2304 SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE ); 2101 SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE );
2305 2102
2306 DATA_LEN = scsi_get_resid(CURRENT_SC); 2103 DATA_LEN = scsi_get_resid(CURRENT_SC);
2307
2308 DPRINTK(debug_datao,
2309 DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n",
2310 CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
2311 scsi_get_resid(CURRENT_SC));
2312} 2104}
2313 2105
2314static void datao_run(struct Scsi_Host *shpnt) 2106static void datao_run(struct Scsi_Host *shpnt)
@@ -2323,8 +2115,9 @@ static void datao_run(struct Scsi_Host *shpnt)
2323 data_count=CURRENT_SC->SCp.this_residual; 2115 data_count=CURRENT_SC->SCp.this_residual;
2324 2116
2325 if(TESTLO(DMASTAT, DFIFOEMP)) { 2117 if(TESTLO(DMASTAT, DFIFOEMP)) {
2326 printk(ERR_LEAD "datao fifo not empty (%d)", CMDINFO(CURRENT_SC), GETPORT(FIFOSTAT)); 2118 scmd_printk(KERN_ERR, CURRENT_SC,
2327 disp_ports(shpnt); 2119 "datao fifo not empty (%d)",
2120 GETPORT(FIFOSTAT));
2328 break; 2121 break;
2329 } 2122 }
2330 2123
@@ -2342,7 +2135,7 @@ static void datao_run(struct Scsi_Host *shpnt)
2342 CURRENT_SC->SCp.ptr += 2 * data_count; 2135 CURRENT_SC->SCp.ptr += 2 * data_count;
2343 CURRENT_SC->SCp.this_residual -= 2 * data_count; 2136 CURRENT_SC->SCp.this_residual -= 2 * data_count;
2344 CMD_INC_RESID(CURRENT_SC, -2 * data_count); 2137 CMD_INC_RESID(CURRENT_SC, -2 * data_count);
2345 } 2138 }
2346 2139
2347 if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { 2140 if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) {
2348 /* advance to next buffer */ 2141 /* advance to next buffer */
@@ -2357,8 +2150,7 @@ static void datao_run(struct Scsi_Host *shpnt)
2357 barrier(); 2150 barrier();
2358 2151
2359 if(TESTLO(DMASTAT, DFIFOEMP|INTSTAT)) { 2152 if(TESTLO(DMASTAT, DFIFOEMP|INTSTAT)) {
2360 printk(ERR_LEAD "dataout timeout", CMDINFO(CURRENT_SC)); 2153 scmd_printk(KERN_ERR, CURRENT_SC, "dataout timeout\n");
2361 disp_ports(shpnt);
2362 break; 2154 break;
2363 } 2155 }
2364 } 2156 }
@@ -2368,35 +2160,23 @@ static void datao_end(struct Scsi_Host *shpnt)
2368{ 2160{
2369 if(TESTLO(DMASTAT, DFIFOEMP)) { 2161 if(TESTLO(DMASTAT, DFIFOEMP)) {
2370 int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - 2162 int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) -
2371 GETSTCNT(); 2163 GETSTCNT();
2372
2373 DPRINTK(debug_datao, DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n",
2374 CMDINFO(CURRENT_SC),
2375 data_count,
2376 DATA_LEN - scsi_get_resid(CURRENT_SC),
2377 GETSTCNT());
2378 2164
2379 CMD_INC_RESID(CURRENT_SC, data_count); 2165 CMD_INC_RESID(CURRENT_SC, data_count);
2380 2166
2381 data_count -= CURRENT_SC->SCp.ptr - 2167 data_count -= CURRENT_SC->SCp.ptr -
2382 SG_ADDRESS(CURRENT_SC->SCp.buffer); 2168 SG_ADDRESS(CURRENT_SC->SCp.buffer);
2383 while(data_count>0) { 2169 while(data_count>0) {
2384 CURRENT_SC->SCp.buffer--; 2170 CURRENT_SC->SCp.buffer--;
2385 CURRENT_SC->SCp.buffers_residual++; 2171 CURRENT_SC->SCp.buffers_residual++;
2386 data_count -= CURRENT_SC->SCp.buffer->length; 2172 data_count -= CURRENT_SC->SCp.buffer->length;
2387 } 2173 }
2388 CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - 2174 CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) -
2389 data_count; 2175 data_count;
2390 CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + 2176 CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length +
2391 data_count; 2177 data_count;
2392 } 2178 }
2393 2179
2394 DPRINTK(debug_datao, DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n",
2395 CMDINFO(CURRENT_SC),
2396 scsi_bufflen(CURRENT_SC),
2397 scsi_get_resid(CURRENT_SC),
2398 GETSTCNT());
2399
2400 SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); 2180 SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT);
2401 SETPORT(SXFRCTL0, CH1); 2181 SETPORT(SXFRCTL0, CH1);
2402 2182
@@ -2420,7 +2200,7 @@ static int update_state(struct Scsi_Host *shpnt)
2420 STATE=rsti; 2200 STATE=rsti;
2421 SETPORT(SCSISEQ,0); 2201 SETPORT(SCSISEQ,0);
2422 SETPORT(SSTAT1,SCSIRSTI); 2202 SETPORT(SSTAT1,SCSIRSTI);
2423 } else if(stat0 & SELDI && PREVSTATE==busfree) { 2203 } else if (stat0 & SELDI && PREVSTATE == busfree) {
2424 STATE=seldi; 2204 STATE=seldi;
2425 } else if(stat0 & SELDO && CURRENT_SC && (CURRENT_SC->SCp.phase & selecting)) { 2205 } else if(stat0 & SELDO && CURRENT_SC && (CURRENT_SC->SCp.phase & selecting)) {
2426 STATE=seldo; 2206 STATE=seldo;
@@ -2445,8 +2225,7 @@ static int update_state(struct Scsi_Host *shpnt)
2445 } 2225 }
2446 2226
2447 if((stat0 & SELDI) && STATE!=seldi && !dataphase) { 2227 if((stat0 & SELDI) && STATE!=seldi && !dataphase) {
2448 printk(INFO_LEAD "reselection missed?", CMDINFO(CURRENT_SC)); 2228 scmd_printk(KERN_INFO, CURRENT_SC, "reselection missed?");
2449 disp_ports(shpnt);
2450 } 2229 }
2451 2230
2452 if(STATE!=PREVSTATE) { 2231 if(STATE!=PREVSTATE) {
@@ -2464,7 +2243,7 @@ static int update_state(struct Scsi_Host *shpnt)
2464 */ 2243 */
2465static void parerr_run(struct Scsi_Host *shpnt) 2244static void parerr_run(struct Scsi_Host *shpnt)
2466{ 2245{
2467 printk(ERR_LEAD "parity error\n", CMDINFO(CURRENT_SC)); 2246 scmd_printk(KERN_ERR, CURRENT_SC, "parity error\n");
2468 done(shpnt, DID_PARITY << 16); 2247 done(shpnt, DID_PARITY << 16);
2469} 2248}
2470 2249
@@ -2476,8 +2255,8 @@ static void rsti_run(struct Scsi_Host *shpnt)
2476{ 2255{
2477 Scsi_Cmnd *ptr; 2256 Scsi_Cmnd *ptr;
2478 2257
2479 printk(KERN_NOTICE "aha152x%d: scsi reset in\n", HOSTNO); 2258 shost_printk(KERN_NOTICE, shpnt, "scsi reset in\n");
2480 2259
2481 ptr=DISCONNECTED_SC; 2260 ptr=DISCONNECTED_SC;
2482 while(ptr) { 2261 while(ptr) {
2483 Scsi_Cmnd *next = SCNEXT(ptr); 2262 Scsi_Cmnd *next = SCNEXT(ptr);
@@ -2539,8 +2318,6 @@ static void is_complete(struct Scsi_Host *shpnt)
2539 2318
2540 dataphase=update_state(shpnt); 2319 dataphase=update_state(shpnt);
2541 2320
2542 DPRINTK(debug_phases, LEAD "start %s %s(%s)\n", CMDINFO(CURRENT_SC), states[STATE].name, states[PREVSTATE].name, states[LASTSTATE].name);
2543
2544 /* 2321 /*
2545 * end previous state 2322 * end previous state
2546 * 2323 *
@@ -2567,9 +2344,9 @@ static void is_complete(struct Scsi_Host *shpnt)
2567 if(dataphase) { 2344 if(dataphase) {
2568 SETPORT(SSTAT0, REQINIT); 2345 SETPORT(SSTAT0, REQINIT);
2569 SETPORT(SCSISIG, GETPORT(SCSISIG) & P_MASK); 2346 SETPORT(SCSISIG, GETPORT(SCSISIG) & P_MASK);
2570 SETPORT(SSTAT1, PHASECHG); 2347 SETPORT(SSTAT1, PHASECHG);
2571 } 2348 }
2572 2349
2573 /* 2350 /*
2574 * enable SPIO mode if previous didn't use it 2351 * enable SPIO mode if previous didn't use it
2575 * and this one does 2352 * and this one does
@@ -2581,14 +2358,14 @@ static void is_complete(struct Scsi_Host *shpnt)
2581 if(CURRENT_SC) 2358 if(CURRENT_SC)
2582 CURRENT_SC->SCp.phase |= spiordy; 2359 CURRENT_SC->SCp.phase |= spiordy;
2583 } 2360 }
2584 2361
2585 /* 2362 /*
2586 * initialize for new state 2363 * initialize for new state
2587 * 2364 *
2588 */ 2365 */
2589 if(PREVSTATE!=STATE && states[STATE].init) 2366 if(PREVSTATE!=STATE && states[STATE].init)
2590 states[STATE].init(shpnt); 2367 states[STATE].init(shpnt);
2591 2368
2592 /* 2369 /*
2593 * handle current state 2370 * handle current state
2594 * 2371 *
@@ -2596,8 +2373,9 @@ static void is_complete(struct Scsi_Host *shpnt)
2596 if(states[STATE].run) 2373 if(states[STATE].run)
2597 states[STATE].run(shpnt); 2374 states[STATE].run(shpnt);
2598 else 2375 else
2599 printk(ERR_LEAD "unexpected state (%x)\n", CMDINFO(CURRENT_SC), STATE); 2376 scmd_printk(KERN_ERR, CURRENT_SC,
2600 2377 "unexpected state (%x)\n", STATE);
2378
2601 /* 2379 /*
2602 * setup controller to interrupt on 2380 * setup controller to interrupt on
2603 * the next expected condition and 2381 * the next expected condition and
@@ -2613,7 +2391,6 @@ static void is_complete(struct Scsi_Host *shpnt)
2613 HOSTDATA(shpnt)->time[STATE] += jiffies-start; 2391 HOSTDATA(shpnt)->time[STATE] += jiffies-start;
2614#endif 2392#endif
2615 2393
2616 DPRINTK(debug_phases, LEAD "end %s %s(%s)\n", CMDINFO(CURRENT_SC), states[STATE].name, states[PREVSTATE].name, states[LASTSTATE].name);
2617 } while(pending); 2394 } while(pending);
2618 2395
2619 /* 2396 /*
@@ -2626,289 +2403,42 @@ static void is_complete(struct Scsi_Host *shpnt)
2626} 2403}
2627 2404
2628 2405
2629/* 2406/*
2630 * Dump the current driver status and panic 2407 * Dump the current driver status and panic
2631 */ 2408 */
2632static void aha152x_error(struct Scsi_Host *shpnt, char *msg) 2409static void aha152x_error(struct Scsi_Host *shpnt, char *msg)
2633{ 2410{
2634 printk(KERN_EMERG "\naha152x%d: %s\n", HOSTNO, msg); 2411 shost_printk(KERN_EMERG, shpnt, "%s\n", msg);
2635 show_queues(shpnt); 2412 show_queues(shpnt);
2636 panic("aha152x panic\n"); 2413 panic("aha152x panic\n");
2637} 2414}
2638 2415
2639/* 2416/*
2640 * Display registers of AIC-6260
2641 */
2642static void disp_ports(struct Scsi_Host *shpnt)
2643{
2644#if defined(AHA152X_DEBUG)
2645 int s;
2646
2647 printk("\n%s: %s(%s) ",
2648 CURRENT_SC ? "busy" : "waiting",
2649 states[STATE].name,
2650 states[PREVSTATE].name);
2651
2652 s = GETPORT(SCSISEQ);
2653 printk("SCSISEQ( ");
2654 if (s & TEMODEO)
2655 printk("TARGET MODE ");
2656 if (s & ENSELO)
2657 printk("SELO ");
2658 if (s & ENSELI)
2659 printk("SELI ");
2660 if (s & ENRESELI)
2661 printk("RESELI ");
2662 if (s & ENAUTOATNO)
2663 printk("AUTOATNO ");
2664 if (s & ENAUTOATNI)
2665 printk("AUTOATNI ");
2666 if (s & ENAUTOATNP)
2667 printk("AUTOATNP ");
2668 if (s & SCSIRSTO)
2669 printk("SCSIRSTO ");
2670 printk(");");
2671
2672 printk(" SCSISIG(");
2673 s = GETPORT(SCSISIG);
2674 switch (s & P_MASK) {
2675 case P_DATAO:
2676 printk("DATA OUT");
2677 break;
2678 case P_DATAI:
2679 printk("DATA IN");
2680 break;
2681 case P_CMD:
2682 printk("COMMAND");
2683 break;
2684 case P_STATUS:
2685 printk("STATUS");
2686 break;
2687 case P_MSGO:
2688 printk("MESSAGE OUT");
2689 break;
2690 case P_MSGI:
2691 printk("MESSAGE IN");
2692 break;
2693 default:
2694 printk("*invalid*");
2695 break;
2696 }
2697
2698 printk("); ");
2699
2700 printk("INTSTAT (%s); ", TESTHI(DMASTAT, INTSTAT) ? "hi" : "lo");
2701
2702 printk("SSTAT( ");
2703 s = GETPORT(SSTAT0);
2704 if (s & TARGET)
2705 printk("TARGET ");
2706 if (s & SELDO)
2707 printk("SELDO ");
2708 if (s & SELDI)
2709 printk("SELDI ");
2710 if (s & SELINGO)
2711 printk("SELINGO ");
2712 if (s & SWRAP)
2713 printk("SWRAP ");
2714 if (s & SDONE)
2715 printk("SDONE ");
2716 if (s & SPIORDY)
2717 printk("SPIORDY ");
2718 if (s & DMADONE)
2719 printk("DMADONE ");
2720
2721 s = GETPORT(SSTAT1);
2722 if (s & SELTO)
2723 printk("SELTO ");
2724 if (s & ATNTARG)
2725 printk("ATNTARG ");
2726 if (s & SCSIRSTI)
2727 printk("SCSIRSTI ");
2728 if (s & PHASEMIS)
2729 printk("PHASEMIS ");
2730 if (s & BUSFREE)
2731 printk("BUSFREE ");
2732 if (s & SCSIPERR)
2733 printk("SCSIPERR ");
2734 if (s & PHASECHG)
2735 printk("PHASECHG ");
2736 if (s & REQINIT)
2737 printk("REQINIT ");
2738 printk("); ");
2739
2740
2741 printk("SSTAT( ");
2742
2743 s = GETPORT(SSTAT0) & GETPORT(SIMODE0);
2744
2745 if (s & TARGET)
2746 printk("TARGET ");
2747 if (s & SELDO)
2748 printk("SELDO ");
2749 if (s & SELDI)
2750 printk("SELDI ");
2751 if (s & SELINGO)
2752 printk("SELINGO ");
2753 if (s & SWRAP)
2754 printk("SWRAP ");
2755 if (s & SDONE)
2756 printk("SDONE ");
2757 if (s & SPIORDY)
2758 printk("SPIORDY ");
2759 if (s & DMADONE)
2760 printk("DMADONE ");
2761
2762 s = GETPORT(SSTAT1) & GETPORT(SIMODE1);
2763
2764 if (s & SELTO)
2765 printk("SELTO ");
2766 if (s & ATNTARG)
2767 printk("ATNTARG ");
2768 if (s & SCSIRSTI)
2769 printk("SCSIRSTI ");
2770 if (s & PHASEMIS)
2771 printk("PHASEMIS ");
2772 if (s & BUSFREE)
2773 printk("BUSFREE ");
2774 if (s & SCSIPERR)
2775 printk("SCSIPERR ");
2776 if (s & PHASECHG)
2777 printk("PHASECHG ");
2778 if (s & REQINIT)
2779 printk("REQINIT ");
2780 printk("); ");
2781
2782 printk("SXFRCTL0( ");
2783
2784 s = GETPORT(SXFRCTL0);
2785 if (s & SCSIEN)
2786 printk("SCSIEN ");
2787 if (s & DMAEN)
2788 printk("DMAEN ");
2789 if (s & CH1)
2790 printk("CH1 ");
2791 if (s & CLRSTCNT)
2792 printk("CLRSTCNT ");
2793 if (s & SPIOEN)
2794 printk("SPIOEN ");
2795 if (s & CLRCH1)
2796 printk("CLRCH1 ");
2797 printk("); ");
2798
2799 printk("SIGNAL( ");
2800
2801 s = GETPORT(SCSISIG);
2802 if (s & SIG_ATNI)
2803 printk("ATNI ");
2804 if (s & SIG_SELI)
2805 printk("SELI ");
2806 if (s & SIG_BSYI)
2807 printk("BSYI ");
2808 if (s & SIG_REQI)
2809 printk("REQI ");
2810 if (s & SIG_ACKI)
2811 printk("ACKI ");
2812 printk("); ");
2813
2814 printk("SELID (%02x), ", GETPORT(SELID));
2815
2816 printk("STCNT (%d), ", GETSTCNT());
2817
2818 printk("SSTAT2( ");
2819
2820 s = GETPORT(SSTAT2);
2821 if (s & SOFFSET)
2822 printk("SOFFSET ");
2823 if (s & SEMPTY)
2824 printk("SEMPTY ");
2825 if (s & SFULL)
2826 printk("SFULL ");
2827 printk("); SFCNT (%d); ", s & (SFULL | SFCNT));
2828
2829 s = GETPORT(SSTAT3);
2830 printk("SCSICNT (%d), OFFCNT(%d), ", (s & 0xf0) >> 4, s & 0x0f);
2831
2832 printk("SSTAT4( ");
2833 s = GETPORT(SSTAT4);
2834 if (s & SYNCERR)
2835 printk("SYNCERR ");
2836 if (s & FWERR)
2837 printk("FWERR ");
2838 if (s & FRERR)
2839 printk("FRERR ");
2840 printk("); ");
2841
2842 printk("DMACNTRL0( ");
2843 s = GETPORT(DMACNTRL0);
2844 printk("%s ", s & _8BIT ? "8BIT" : "16BIT");
2845 printk("%s ", s & DMA ? "DMA" : "PIO");
2846 printk("%s ", s & WRITE_READ ? "WRITE" : "READ");
2847 if (s & ENDMA)
2848 printk("ENDMA ");
2849 if (s & INTEN)
2850 printk("INTEN ");
2851 if (s & RSTFIFO)
2852 printk("RSTFIFO ");
2853 if (s & SWINT)
2854 printk("SWINT ");
2855 printk("); ");
2856
2857 printk("DMASTAT( ");
2858 s = GETPORT(DMASTAT);
2859 if (s & ATDONE)
2860 printk("ATDONE ");
2861 if (s & WORDRDY)
2862 printk("WORDRDY ");
2863 if (s & DFIFOFULL)
2864 printk("DFIFOFULL ");
2865 if (s & DFIFOEMP)
2866 printk("DFIFOEMP ");
2867 printk(")\n");
2868#endif
2869}
2870
2871/*
2872 * display enabled interrupts 2417 * display enabled interrupts
2873 */ 2418 */
2874static void disp_enintr(struct Scsi_Host *shpnt) 2419static void disp_enintr(struct Scsi_Host *shpnt)
2875{ 2420{
2876 int s; 2421 int s0, s1;
2877 2422
2878 printk(KERN_DEBUG "enabled interrupts ( "); 2423 s0 = GETPORT(SIMODE0);
2879 2424 s1 = GETPORT(SIMODE1);
2880 s = GETPORT(SIMODE0); 2425
2881 if (s & ENSELDO) 2426 shost_printk(KERN_DEBUG, shpnt,
2882 printk("ENSELDO "); 2427 "enabled interrupts (%s%s%s%s%s%s%s%s%s%s%s%s%s%s)\n",
2883 if (s & ENSELDI) 2428 (s0 & ENSELDO) ? "ENSELDO " : "",
2884 printk("ENSELDI "); 2429 (s0 & ENSELDI) ? "ENSELDI " : "",
2885 if (s & ENSELINGO) 2430 (s0 & ENSELINGO) ? "ENSELINGO " : "",
2886 printk("ENSELINGO "); 2431 (s0 & ENSWRAP) ? "ENSWRAP " : "",
2887 if (s & ENSWRAP) 2432 (s0 & ENSDONE) ? "ENSDONE " : "",
2888 printk("ENSWRAP "); 2433 (s0 & ENSPIORDY) ? "ENSPIORDY " : "",
2889 if (s & ENSDONE) 2434 (s0 & ENDMADONE) ? "ENDMADONE " : "",
2890 printk("ENSDONE "); 2435 (s1 & ENSELTIMO) ? "ENSELTIMO " : "",
2891 if (s & ENSPIORDY) 2436 (s1 & ENATNTARG) ? "ENATNTARG " : "",
2892 printk("ENSPIORDY "); 2437 (s1 & ENPHASEMIS) ? "ENPHASEMIS " : "",
2893 if (s & ENDMADONE) 2438 (s1 & ENBUSFREE) ? "ENBUSFREE " : "",
2894 printk("ENDMADONE "); 2439 (s1 & ENSCSIPERR) ? "ENSCSIPERR " : "",
2895 2440 (s1 & ENPHASECHG) ? "ENPHASECHG " : "",
2896 s = GETPORT(SIMODE1); 2441 (s1 & ENREQINIT) ? "ENREQINIT " : "");
2897 if (s & ENSELTIMO)
2898 printk("ENSELTIMO ");
2899 if (s & ENATNTARG)
2900 printk("ENATNTARG ");
2901 if (s & ENPHASEMIS)
2902 printk("ENPHASEMIS ");
2903 if (s & ENBUSFREE)
2904 printk("ENBUSFREE ");
2905 if (s & ENSCSIPERR)
2906 printk("ENSCSIPERR ");
2907 if (s & ENPHASECHG)
2908 printk("ENPHASECHG ");
2909 if (s & ENREQINIT)
2910 printk("ENREQINIT ");
2911 printk(")\n");
2912} 2442}
2913 2443
2914/* 2444/*
@@ -2916,36 +2446,21 @@ static void disp_enintr(struct Scsi_Host *shpnt)
2916 */ 2446 */
2917static void show_command(Scsi_Cmnd *ptr) 2447static void show_command(Scsi_Cmnd *ptr)
2918{ 2448{
2919 scmd_printk(KERN_DEBUG, ptr, "%p: cmnd=(", ptr); 2449 scsi_print_command(ptr);
2920 2450 scmd_printk(KERN_DEBUG, ptr,
2921 __scsi_print_command(ptr->cmnd); 2451 "request_bufflen=%d; resid=%d; "
2922 2452 "phase |%s%s%s%s%s%s%s%s%s; next=0x%p",
2923 printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |", 2453 scsi_bufflen(ptr), scsi_get_resid(ptr),
2924 scsi_bufflen(ptr), scsi_get_resid(ptr)); 2454 (ptr->SCp.phase & not_issued) ? "not issued|" : "",
2925 2455 (ptr->SCp.phase & selecting) ? "selecting|" : "",
2926 if (ptr->SCp.phase & not_issued) 2456 (ptr->SCp.phase & identified) ? "identified|" : "",
2927 printk("not issued|"); 2457 (ptr->SCp.phase & disconnected) ? "disconnected|" : "",
2928 if (ptr->SCp.phase & selecting) 2458 (ptr->SCp.phase & completed) ? "completed|" : "",
2929 printk("selecting|"); 2459 (ptr->SCp.phase & spiordy) ? "spiordy|" : "",
2930 if (ptr->SCp.phase & identified) 2460 (ptr->SCp.phase & syncneg) ? "syncneg|" : "",
2931 printk("identified|"); 2461 (ptr->SCp.phase & aborted) ? "aborted|" : "",
2932 if (ptr->SCp.phase & disconnected) 2462 (ptr->SCp.phase & resetted) ? "resetted|" : "",
2933 printk("disconnected|"); 2463 (SCDATA(ptr)) ? SCNEXT(ptr) : NULL);
2934 if (ptr->SCp.phase & completed)
2935 printk("completed|");
2936 if (ptr->SCp.phase & spiordy)
2937 printk("spiordy|");
2938 if (ptr->SCp.phase & syncneg)
2939 printk("syncneg|");
2940 if (ptr->SCp.phase & aborted)
2941 printk("aborted|");
2942 if (ptr->SCp.phase & resetted)
2943 printk("resetted|");
2944 if( SCDATA(ptr) ) {
2945 printk("; next=0x%p\n", SCNEXT(ptr));
2946 } else {
2947 printk("; next=(host scribble NULL)\n");
2948 }
2949} 2464}
2950 2465
2951/* 2466/*
@@ -2972,7 +2487,6 @@ static void show_queues(struct Scsi_Host *shpnt)
2972 for (ptr = DISCONNECTED_SC; ptr; ptr = SCDATA(ptr) ? SCNEXT(ptr) : NULL) 2487 for (ptr = DISCONNECTED_SC; ptr; ptr = SCDATA(ptr) ? SCNEXT(ptr) : NULL)
2973 show_command(ptr); 2488 show_command(ptr);
2974 2489
2975 disp_ports(shpnt);
2976 disp_enintr(shpnt); 2490 disp_enintr(shpnt);
2977} 2491}
2978 2492
@@ -3276,15 +2790,6 @@ static int aha152x_set_info(struct Scsi_Host *shpnt, char *buffer, int length)
3276 if(!shpnt || !buffer || length<8 || strncmp("aha152x ", buffer, 8)!=0) 2790 if(!shpnt || !buffer || length<8 || strncmp("aha152x ", buffer, 8)!=0)
3277 return -EINVAL; 2791 return -EINVAL;
3278 2792
3279#if defined(AHA152X_DEBUG)
3280 if(length>14 && strncmp("debug ", buffer+8, 6)==0) {
3281 int debug = HOSTDATA(shpnt)->debug;
3282
3283 HOSTDATA(shpnt)->debug = simple_strtoul(buffer+14, NULL, 0);
3284
3285 printk(KERN_INFO "aha152x%d: debugging options set to 0x%04x (were 0x%04x)\n", HOSTNO, HOSTDATA(shpnt)->debug, debug);
3286 } else
3287#endif
3288#if defined(AHA152X_STAT) 2793#if defined(AHA152X_STAT)
3289 if(length>13 && strncmp("reset", buffer+8, 5)==0) { 2794 if(length>13 && strncmp("reset", buffer+8, 5)==0) {
3290 int i; 2795 int i;
@@ -3302,7 +2807,7 @@ static int aha152x_set_info(struct Scsi_Host *shpnt, char *buffer, int length)
3302 HOSTDATA(shpnt)->time[i]=0; 2807 HOSTDATA(shpnt)->time[i]=0;
3303 } 2808 }
3304 2809
3305 printk(KERN_INFO "aha152x%d: stats reseted.\n", HOSTNO); 2810 shost_printk(KERN_INFO, shpnt, "aha152x: stats reset.\n");
3306 2811
3307 } else 2812 } else
3308#endif 2813#endif
@@ -3343,29 +2848,6 @@ static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt)
3343 (((HOSTDATA(shpnt)->syncrate[i] & 0x70) >> 4) + 2) * 50, 2848 (((HOSTDATA(shpnt)->syncrate[i] & 0x70) >> 4) + 2) * 50,
3344 HOSTDATA(shpnt)->syncrate[i] & 0x0f); 2849 HOSTDATA(shpnt)->syncrate[i] & 0x0f);
3345 } 2850 }
3346#if defined(AHA152X_DEBUG)
3347#define PDEBUG(flags,txt) \
3348 if(HOSTDATA(shpnt)->debug & flags) SPRINTF("(%s) ", txt);
3349
3350 SPRINTF("enabled debugging options: ");
3351
3352 PDEBUG(debug_procinfo, "procinfo");
3353 PDEBUG(debug_queue, "queue");
3354 PDEBUG(debug_intr, "interrupt");
3355 PDEBUG(debug_selection, "selection");
3356 PDEBUG(debug_msgo, "message out");
3357 PDEBUG(debug_msgi, "message in");
3358 PDEBUG(debug_status, "status");
3359 PDEBUG(debug_cmd, "command");
3360 PDEBUG(debug_datai, "data in");
3361 PDEBUG(debug_datao, "data out");
3362 PDEBUG(debug_eh, "eh");
3363 PDEBUG(debug_locking, "locks");
3364 PDEBUG(debug_phases, "phases");
3365
3366 SPRINTF("\n");
3367#endif
3368
3369 SPRINTF("\nqueue status:\n"); 2851 SPRINTF("\nqueue status:\n");
3370 DO_LOCK(flags); 2852 DO_LOCK(flags);
3371 if (ISSUE_SC) { 2853 if (ISSUE_SC) {
@@ -3393,8 +2875,8 @@ static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt)
3393 2875
3394#if defined(AHA152X_STAT) 2876#if defined(AHA152X_STAT)
3395 SPRINTF("statistics:\n" 2877 SPRINTF("statistics:\n"
3396 "total commands: %d\n" 2878 "total commands: %d\n"
3397 "disconnections: %d\n" 2879 "disconnections: %d\n"
3398 "busfree with check condition: %d\n" 2880 "busfree with check condition: %d\n"
3399 "busfree without old command: %d\n" 2881 "busfree without old command: %d\n"
3400 "busfree without new command: %d\n" 2882 "busfree without new command: %d\n"
@@ -3413,7 +2895,7 @@ static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt)
3413 HOSTDATA(shpnt)->busfree_without_any_action); 2895 HOSTDATA(shpnt)->busfree_without_any_action);
3414 for(i=0; i<maxstate; i++) { 2896 for(i=0; i<maxstate; i++) {
3415 SPRINTF("%-10s %-12d %-12d %-12ld\n", 2897 SPRINTF("%-10s %-12d %-12d %-12ld\n",
3416 states[i].name, 2898 states[i].name,
3417 HOSTDATA(shpnt)->count_trans[i], 2899 HOSTDATA(shpnt)->count_trans[i],
3418 HOSTDATA(shpnt)->count[i], 2900 HOSTDATA(shpnt)->count[i],
3419 HOSTDATA(shpnt)->time[i]); 2901 HOSTDATA(shpnt)->time[i]);
@@ -3671,25 +3153,19 @@ static int __init aha152x_init(void)
3671 setup[setup_count].synchronous = aha152x[5]; 3153 setup[setup_count].synchronous = aha152x[5];
3672 setup[setup_count].delay = aha152x[6]; 3154 setup[setup_count].delay = aha152x[6];
3673 setup[setup_count].ext_trans = aha152x[7]; 3155 setup[setup_count].ext_trans = aha152x[7];
3674#if defined(AHA152X_DEBUG) 3156 } else if (io[0] != 0 || irq[0] != 0) {
3675 setup[setup_count].debug = aha152x[8];
3676#endif
3677 } else if(io[0]!=0 || irq[0]!=0) {
3678 if(io[0]!=0) setup[setup_count].io_port = io[0]; 3157 if(io[0]!=0) setup[setup_count].io_port = io[0];
3679 if(irq[0]!=0) setup[setup_count].irq = irq[0]; 3158 if(irq[0]!=0) setup[setup_count].irq = irq[0];
3680 3159
3681 setup[setup_count].scsiid = scsiid[0]; 3160 setup[setup_count].scsiid = scsiid[0];
3682 setup[setup_count].reconnect = reconnect[0]; 3161 setup[setup_count].reconnect = reconnect[0];
3683 setup[setup_count].parity = parity[0]; 3162 setup[setup_count].parity = parity[0];
3684 setup[setup_count].synchronous = sync[0]; 3163 setup[setup_count].synchronous = sync[0];
3685 setup[setup_count].delay = delay[0]; 3164 setup[setup_count].delay = delay[0];
3686 setup[setup_count].ext_trans = exttrans[0]; 3165 setup[setup_count].ext_trans = exttrans[0];
3687#if defined(AHA152X_DEBUG)
3688 setup[setup_count].debug = debug[0];
3689#endif
3690 } 3166 }
3691 3167
3692 if (checksetup(&setup[setup_count])) 3168 if (checksetup(&setup[setup_count]))
3693 setup_count++; 3169 setup_count++;
3694 else 3170 else
3695 printk(KERN_ERR "aha152x: invalid module params io=0x%x, irq=%d,scsiid=%d,reconnect=%d,parity=%d,sync=%d,delay=%d,exttrans=%d\n", 3171 printk(KERN_ERR "aha152x: invalid module params io=0x%x, irq=%d,scsiid=%d,reconnect=%d,parity=%d,sync=%d,delay=%d,exttrans=%d\n",
@@ -3714,22 +3190,16 @@ static int __init aha152x_init(void)
3714 setup[setup_count].synchronous = aha152x1[5]; 3190 setup[setup_count].synchronous = aha152x1[5];
3715 setup[setup_count].delay = aha152x1[6]; 3191 setup[setup_count].delay = aha152x1[6];
3716 setup[setup_count].ext_trans = aha152x1[7]; 3192 setup[setup_count].ext_trans = aha152x1[7];
3717#if defined(AHA152X_DEBUG) 3193 } else if (io[1] != 0 || irq[1] != 0) {
3718 setup[setup_count].debug = aha152x1[8];
3719#endif
3720 } else if(io[1]!=0 || irq[1]!=0) {
3721 if(io[1]!=0) setup[setup_count].io_port = io[1]; 3194 if(io[1]!=0) setup[setup_count].io_port = io[1];
3722 if(irq[1]!=0) setup[setup_count].irq = irq[1]; 3195 if(irq[1]!=0) setup[setup_count].irq = irq[1];
3723 3196
3724 setup[setup_count].scsiid = scsiid[1]; 3197 setup[setup_count].scsiid = scsiid[1];
3725 setup[setup_count].reconnect = reconnect[1]; 3198 setup[setup_count].reconnect = reconnect[1];
3726 setup[setup_count].parity = parity[1]; 3199 setup[setup_count].parity = parity[1];
3727 setup[setup_count].synchronous = sync[1]; 3200 setup[setup_count].synchronous = sync[1];
3728 setup[setup_count].delay = delay[1]; 3201 setup[setup_count].delay = delay[1];
3729 setup[setup_count].ext_trans = exttrans[1]; 3202 setup[setup_count].ext_trans = exttrans[1];
3730#if defined(AHA152X_DEBUG)
3731 setup[setup_count].debug = debug[1];
3732#endif
3733 } 3203 }
3734 if (checksetup(&setup[setup_count])) 3204 if (checksetup(&setup[setup_count]))
3735 setup_count++; 3205 setup_count++;
@@ -3776,9 +3246,6 @@ static int __init aha152x_init(void)
3776 setup[setup_count].synchronous = 1; 3246 setup[setup_count].synchronous = 1;
3777 setup[setup_count].delay = DELAY_DEFAULT; 3247 setup[setup_count].delay = DELAY_DEFAULT;
3778 setup[setup_count].ext_trans = 0; 3248 setup[setup_count].ext_trans = 0;
3779#if defined(AHA152X_DEBUG)
3780 setup[setup_count].debug = DEBUG_DEFAULT;
3781#endif
3782#if defined(__ISAPNP__) 3249#if defined(__ISAPNP__)
3783 pnpdev[setup_count] = dev; 3250 pnpdev[setup_count] = dev;
3784#endif 3251#endif
@@ -3847,9 +3314,6 @@ static int __init aha152x_init(void)
3847 setup[setup_count].synchronous = conf.cf_syncneg; 3314 setup[setup_count].synchronous = conf.cf_syncneg;
3848 setup[setup_count].delay = DELAY_DEFAULT; 3315 setup[setup_count].delay = DELAY_DEFAULT;
3849 setup[setup_count].ext_trans = 0; 3316 setup[setup_count].ext_trans = 0;
3850#if defined(AHA152X_DEBUG)
3851 setup[setup_count].debug = DEBUG_DEFAULT;
3852#endif
3853 setup_count++; 3317 setup_count++;
3854 3318
3855 } 3319 }
@@ -3903,11 +3367,8 @@ module_exit(aha152x_exit);
3903#if !defined(MODULE) 3367#if !defined(MODULE)
3904static int __init aha152x_setup(char *str) 3368static int __init aha152x_setup(char *str)
3905{ 3369{
3906#if defined(AHA152X_DEBUG)
3907 int ints[11];
3908#else
3909 int ints[10]; 3370 int ints[10];
3910#endif 3371
3911 get_options(str, ARRAY_SIZE(ints), ints); 3372 get_options(str, ARRAY_SIZE(ints), ints);
3912 3373
3913 if(setup_count>=ARRAY_SIZE(setup)) { 3374 if(setup_count>=ARRAY_SIZE(setup)) {
@@ -3924,16 +3385,9 @@ static int __init aha152x_setup(char *str)
3924 setup[setup_count].synchronous = ints[0] >= 6 ? ints[6] : 1; 3385 setup[setup_count].synchronous = ints[0] >= 6 ? ints[6] : 1;
3925 setup[setup_count].delay = ints[0] >= 7 ? ints[7] : DELAY_DEFAULT; 3386 setup[setup_count].delay = ints[0] >= 7 ? ints[7] : DELAY_DEFAULT;
3926 setup[setup_count].ext_trans = ints[0] >= 8 ? ints[8] : 0; 3387 setup[setup_count].ext_trans = ints[0] >= 8 ? ints[8] : 0;
3927#if defined(AHA152X_DEBUG)
3928 setup[setup_count].debug = ints[0] >= 9 ? ints[9] : DEBUG_DEFAULT;
3929 if (ints[0] > 9) {
3930 printk(KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>"
3931 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>[,<DEBUG>]]]]]]]]\n");
3932#else
3933 if (ints[0] > 8) { /*}*/ 3388 if (ints[0] > 8) { /*}*/
3934 printk(KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>" 3389 printk(KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>"
3935 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n"); 3390 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n");
3936#endif
3937 } else { 3391 } else {
3938 setup_count++; 3392 setup_count++;
3939 return 0; 3393 return 0;