Lines Matching refs:ms

183 static void dlog(struct mesh_state *ms, char *fmt, int a);
184 static void dumplog(struct mesh_state *ms, int tgt);
185 static void dumpslog(struct mesh_state *ms);
188 static inline void dlog(struct mesh_state *ms, char *fmt, int a) in dlog() argument
190 static inline void dumplog(struct mesh_state *ms, int tgt) in dumplog() argument
192 static inline void dumpslog(struct mesh_state *ms) in dumpslog() argument
224 static void do_abort(struct mesh_state *ms);
225 static void set_mesh_power(struct mesh_state *ms, int state);
246 struct mesh_state *ms, **prev_statep; in mesh_detect() local
311 ms = (struct mesh_state *) mesh_host->hostdata; in mesh_detect()
312 if (ms == 0) in mesh_detect()
314 memset(ms, 0, sizeof(*ms)); in mesh_detect()
315 ms->host = mesh_host; in mesh_detect()
316 ms->ofnode = mesh; in mesh_detect()
317 ms->pdev = pdev; in mesh_detect()
318 ms->mesh = (volatile struct mesh_regs *) in mesh_detect()
320 ms->dma = (volatile struct dbdma_regs *) in mesh_detect()
322 ms->meshintr = mesh->intrs[0].line; in mesh_detect()
323 ms->dmaintr = mesh->intrs[1].line; in mesh_detect()
331 ms->dma_cmds = (struct dbdma_cmd *) DBDMA_ALIGN(dma_cmd_space); in mesh_detect()
332 memset(ms->dma_cmds, 0, (mesh_host->sg_tablesize + 1) in mesh_detect()
334 ms->dma_cmd_space = dma_cmd_space; in mesh_detect()
336 ms->current_req = 0; in mesh_detect()
338 ms->tgts[tgt].sdtr_state = do_sdtr; in mesh_detect()
339 ms->tgts[tgt].sync_params = ASYNC_PARAMS; in mesh_detect()
340 ms->tgts[tgt].current_req = 0; in mesh_detect()
342 *prev_statep = ms; in mesh_detect()
343 prev_statep = &ms->next; in mesh_detect()
347 ms->clk_freq = *cfp; in mesh_detect()
350 ms->clk_freq = 50000000; in mesh_detect()
354 minper = 1000000000 / (ms->clk_freq / 5); /* ns */ in mesh_detect()
358 set_mesh_power(ms, 1); in mesh_detect()
360 mesh_init(ms); in mesh_detect()
362 if (request_irq(ms->meshintr, do_mesh_interrupt, 0, "MESH", ms)) { in mesh_detect()
363 printk(KERN_ERR "MESH: can't get irq %d\n", ms->meshintr); in mesh_detect()
385 struct mesh_state *ms = (struct mesh_state *) host->hostdata; in mesh_release() local
387 if (ms == 0) in mesh_release()
389 if (ms->mesh) in mesh_release()
390 iounmap((void *) ms->mesh); in mesh_release()
391 if (ms->dma) in mesh_release()
392 iounmap((void *) ms->dma); in mesh_release()
393 kfree(ms->dma_cmd_space); in mesh_release()
394 free_irq(ms->meshintr, ms); in mesh_release()
395 pmac_call_feature(PMAC_FTR_MESH_ENABLE, ms->ofnode, 0, 0); in mesh_release()
400 set_mesh_power(struct mesh_state *ms, int state) in set_mesh_power() argument
405 pmac_call_feature(PMAC_FTR_MESH_ENABLE, ms->ofnode, 0, 1); in set_mesh_power()
408 pmac_call_feature(PMAC_FTR_MESH_ENABLE, ms->ofnode, 0, 0); in set_mesh_power()
420 struct mesh_state *ms; in mesh_notify_sleep() local
432 for (ms = all_meshes; ms != 0; ms = ms->next) { in mesh_notify_sleep()
435 scsi_block_requests(ms->host); in mesh_notify_sleep()
437 while(ms->phase != idle) { in mesh_notify_sleep()
443 ms->phase = sleeping; in mesh_notify_sleep()
445 disable_irq(ms->meshintr); in mesh_notify_sleep()
446 set_mesh_power(ms, 0); in mesh_notify_sleep()
450 for (ms = all_meshes; ms != 0; ms = ms->next) { in mesh_notify_sleep()
453 set_mesh_power(ms, 1); in mesh_notify_sleep()
454 mesh_init(ms); in mesh_notify_sleep()
456 mesh_start(ms); in mesh_notify_sleep()
458 enable_irq(ms->meshintr); in mesh_notify_sleep()
459 scsi_unblock_requests(ms->host); in mesh_notify_sleep()
474 struct mesh_state *ms; in mesh_queue() local
479 ms = (struct mesh_state *) cmd->host->hostdata; in mesh_queue()
481 if (ms->request_q == NULL) in mesh_queue()
482 ms->request_q = cmd; in mesh_queue()
484 ms->request_qtail->host_scribble = (void *) cmd; in mesh_queue()
485 ms->request_qtail = cmd; in mesh_queue()
487 if (ms->phase == idle) in mesh_queue()
488 mesh_start(ms); in mesh_queue()
500 struct mesh_state *ms = (struct mesh_state *) cmd->host->hostdata; in mesh_abort() local
503 mesh_dump_regs(ms); in mesh_abort()
504 dumplog(ms, cmd->target); in mesh_abort()
505 dumpslog(ms); in mesh_abort()
510 mesh_dump_regs(struct mesh_state *ms) in mesh_dump_regs() argument
512 volatile struct mesh_regs *mr = ms->mesh; in mesh_dump_regs()
513 volatile struct dbdma_regs *md = ms->dma; in mesh_dump_regs()
518 ms, mr, md); in mesh_dump_regs()
530 ms->phase, ms->msgphase, ms->conn_tgt, ms->data_ptr); in mesh_dump_regs()
532 ms->dma_started, ms->dma_count, ms->n_msgout); in mesh_dump_regs()
534 tp = &ms->tgts[t]; in mesh_dump_regs()
551 struct mesh_state *ms = (struct mesh_state *) cmd->host->hostdata; in mesh_host_reset() local
552 volatile struct mesh_regs *mr = ms->mesh; in mesh_host_reset()
553 volatile struct dbdma_regs *md = ms->dma; in mesh_host_reset()
564 out_8(&mr->source_id, ms->host->this_id); in mesh_host_reset()
574 handle_reset(ms); in mesh_host_reset()
587 struct mesh_state *ms; in mesh_notify_reboot() local
592 for (ms = all_meshes; ms != 0; ms = ms->next) { in mesh_notify_reboot()
593 mr = ms->mesh; in mesh_notify_reboot()
610 mesh_init(struct mesh_state *ms) in mesh_init() argument
612 volatile struct mesh_regs *mr = ms->mesh; in mesh_init()
613 volatile struct dbdma_regs *md = ms->dma; in mesh_init()
624 out_8(&mr->source_id, ms->host->this_id); in mesh_init()
648 ms->phase = idle; in mesh_init()
649 ms->msgphase = msg_none; in mesh_init()
657 mesh_start(struct mesh_state *ms) in mesh_start() argument
661 if (ms->phase != idle || ms->current_req != NULL) { in mesh_start()
663 ms->phase, ms); in mesh_start()
667 while (ms->phase == idle) { in mesh_start()
669 for (cmd = ms->request_q; ; cmd = (Scsi_Cmnd *) cmd->host_scribble) { in mesh_start()
672 if (ms->tgts[cmd->target].current_req == NULL) in mesh_start()
678 ms->request_q = next; in mesh_start()
682 ms->request_qtail = prev; in mesh_start()
684 mesh_start_cmd(ms, cmd); in mesh_start()
689 mesh_start_cmd(struct mesh_state *ms, Scsi_Cmnd *cmd) in mesh_start_cmd() argument
691 volatile struct mesh_regs *mr = ms->mesh; in mesh_start_cmd()
694 ms->current_req = cmd; in mesh_start_cmd()
695 ms->tgts[cmd->target].data_goes_out = data_goes_out(cmd); in mesh_start_cmd()
696 ms->tgts[cmd->target].current_req = cmd; in mesh_start_cmd()
709 if (ms->dma_started) in mesh_start_cmd()
712 ms->phase = arbitrating; in mesh_start_cmd()
713 ms->msgphase = msg_none; in mesh_start_cmd()
714 ms->data_ptr = 0; in mesh_start_cmd()
715 ms->dma_started = 0; in mesh_start_cmd()
716 ms->n_msgout = 0; in mesh_start_cmd()
717 ms->last_n_msgout = 0; in mesh_start_cmd()
718 ms->expect_reply = 0; in mesh_start_cmd()
719 ms->conn_tgt = cmd->target; in mesh_start_cmd()
720 ms->tgts[cmd->target].saved_ptr = 0; in mesh_start_cmd()
721 ms->stat = DID_OK; in mesh_start_cmd()
722 ms->aborting = 0; in mesh_start_cmd()
724 ms->tgts[cmd->target].n_log = 0; in mesh_start_cmd()
725 dlog(ms, "start cmd=%x", (int) cmd); in mesh_start_cmd()
729 dlog(ms, "about to arb, intr/exc/err/fc=%.8x", in mesh_start_cmd()
740 dlog(ms, "busy b4 arb, intr/exc/err/fc=%.8x", in mesh_start_cmd()
747 dlog(ms, "intr b4 arb, intr/exc/err/fc=%.8x", in mesh_start_cmd()
750 mesh_interrupt(0, (void *)ms, 0); in mesh_start_cmd()
751 if (ms->phase != arbitrating) in mesh_start_cmd()
758 ms->stat = DID_BUS_BUSY; in mesh_start_cmd()
759 ms->phase = idle; in mesh_start_cmd()
760 mesh_done(ms, 0); in mesh_start_cmd()
785 dlog(ms, "intr after disresel, intr/exc/err/fc=%.8x", in mesh_start_cmd()
788 mesh_interrupt(0, (void *)ms, 0); in mesh_start_cmd()
789 if (ms->phase != arbitrating) in mesh_start_cmd()
791 dlog(ms, "after intr after disresel, intr/exc/err/fc=%.8x", in mesh_start_cmd()
803 dlog(ms, "after arb, intr/exc/err/fc=%.8x", in mesh_start_cmd()
808 dlog(ms, "resel? after arb, intr/exc/err/fc=%.8x", in mesh_start_cmd()
817 dlog(ms, "tried reset after arb, intr/exc/err/fc=%.8x", in mesh_start_cmd()
836 add_sdtr_msg(struct mesh_state *ms) in add_sdtr_msg() argument
838 int i = ms->n_msgout; in add_sdtr_msg()
840 ms->msgout[i] = EXTENDED_MESSAGE; in add_sdtr_msg()
841 ms->msgout[i+1] = 3; in add_sdtr_msg()
842 ms->msgout[i+2] = EXTENDED_SDTR; in add_sdtr_msg()
843 ms->msgout[i+3] = mesh_sync_period/4; in add_sdtr_msg()
844 ms->msgout[i+4] = (ALLOW_SYNC(ms->conn_tgt)? mesh_sync_offset: 0); in add_sdtr_msg()
845 ms->n_msgout = i + 5; in add_sdtr_msg()
849 set_sdtr(struct mesh_state *ms, int period, int offset) in set_sdtr() argument
851 struct mesh_target *tp = &ms->tgts[ms->conn_tgt]; in set_sdtr()
852 volatile struct mesh_regs *mr = ms->mesh; in set_sdtr()
860 ms->conn_tgt); in set_sdtr()
869 v = (ms->clk_freq / 5000) * period; in set_sdtr()
874 tr = (ms->clk_freq + 250000) / 500000; in set_sdtr()
880 tr = ((ms->clk_freq / (v + 2)) + 199999) / 200000; in set_sdtr()
887 ms->conn_tgt, tr/10, tr%10); in set_sdtr()
891 start_phase(struct mesh_state *ms) in start_phase() argument
894 volatile struct mesh_regs *mr = ms->mesh; in start_phase()
895 volatile struct dbdma_regs *md = ms->dma; in start_phase()
896 Scsi_Cmnd *cmd = ms->current_req; in start_phase()
897 struct mesh_target *tp = &ms->tgts[ms->conn_tgt]; in start_phase()
899 dlog(ms, "start_phase nmo/exc/fc/seq = %.8x", in start_phase()
900 MKWORD(ms->n_msgout, mr->exception, mr->fifo_count, mr->sequence)); in start_phase()
902 seq = use_active_neg + (ms->n_msgout? SEQ_ATN: 0); in start_phase()
903 switch (ms->msgphase) { in start_phase()
911 ms->n_msgin = 0; in start_phase()
920 if (ms->n_msgout <= 0) { in start_phase()
922 ms->n_msgout); in start_phase()
923 mesh_dump_regs(ms); in start_phase()
924 ms->msgphase = msg_none; in start_phase()
927 if (ALLOW_DEBUG(ms->conn_tgt)) { in start_phase()
929 ms->n_msgout); in start_phase()
930 for (i = 0; i < ms->n_msgout; ++i) in start_phase()
931 printk(" %x", ms->msgout[i]); in start_phase()
934 dlog(ms, "msgout msg=%.8x", MKWORD(ms->n_msgout, ms->msgout[0], in start_phase()
935 ms->msgout[1], ms->msgout[2])); in start_phase()
944 dlog(ms, "bus0 was %.2x explictly asserting ATN", mr->bus_status0); in start_phase()
950 dlog(ms,"hace: after explicit ATN bus0=%.2x",mr->bus_status0); in start_phase()
952 if (ms->n_msgout == 1) { in start_phase()
959 cmd_complete(ms); in start_phase()
961 out_8(&mr->count_lo, ms->n_msgout - 1); in start_phase()
963 for (i = 0; i < ms->n_msgout - 1; ++i) in start_phase()
964 out_8(&mr->fifo, ms->msgout[i]); in start_phase()
970 ms->msgphase); in start_phase()
973 switch (ms->phase) { in start_phase()
975 out_8(&mr->dest_id, ms->conn_tgt); in start_phase()
995 if (!ms->dma_started) { in start_phase()
996 set_dma_cmds(ms, cmd); in start_phase()
997 out_le32(&md->cmdptr, virt_to_phys(ms->dma_cmds)); in start_phase()
999 ms->dma_started = 1; in start_phase()
1001 nb = ms->dma_count; in start_phase()
1004 ms->dma_count -= nb; in start_phase()
1005 ms->data_ptr += nb; in start_phase()
1020 dlog(ms, "enbresel intr/exc/err/fc=%.8x", in start_phase()
1027 ms->phase); in start_phase()
1028 dumpslog(ms); in start_phase()
1034 get_msgin(struct mesh_state *ms) in get_msgin() argument
1036 volatile struct mesh_regs *mr = ms->mesh; in get_msgin()
1041 i = ms->n_msgin; in get_msgin()
1042 ms->n_msgin = i + n; in get_msgin()
1044 ms->msgin[i++] = in_8(&mr->fifo); in get_msgin()
1049 msgin_length(struct mesh_state *ms) in msgin_length() argument
1054 if (ms->n_msgin > 0) { in msgin_length()
1055 b = ms->msgin[0]; in msgin_length()
1058 n = ms->n_msgin < 2? 2: ms->msgin[1] + 2; in msgin_length()
1068 cmd_complete(struct mesh_state *ms) in cmd_complete() argument
1070 volatile struct mesh_regs *mr = ms->mesh; in cmd_complete()
1071 Scsi_Cmnd *cmd = ms->current_req; in cmd_complete()
1072 struct mesh_target *tp = &ms->tgts[ms->conn_tgt]; in cmd_complete()
1075 dlog(ms, "cmd_complete fc=%x", mr->fifo_count); in cmd_complete()
1076 seq = use_active_neg + (ms->n_msgout? SEQ_ATN: 0); in cmd_complete()
1077 switch (ms->msgphase) { in cmd_complete()
1080 ms->n_msgin = 0; in cmd_complete()
1081 ms->msgphase = msg_in; in cmd_complete()
1086 get_msgin(ms); in cmd_complete()
1087 n = msgin_length(ms); in cmd_complete()
1088 if (ms->n_msgin < n) { in cmd_complete()
1089 out_8(&mr->count_lo, n - ms->n_msgin); in cmd_complete()
1092 ms->msgphase = msg_none; in cmd_complete()
1093 handle_msgin(ms); in cmd_complete()
1094 start_phase(ms); in cmd_complete()
1122 dlog(ms, "last_mbyte err/exc/fc/cl=%.8x", in cmd_complete()
1127 ms->last_n_msgout = ms->n_msgout; in cmd_complete()
1128 ms->n_msgout = 0; in cmd_complete()
1132 handle_error(ms); in cmd_complete()
1141 handle_exception(ms); in cmd_complete()
1147 out_8(&mr->fifo, ms->msgout[ms->n_msgout-1]); in cmd_complete()
1148 ms->msgphase = msg_out_last; in cmd_complete()
1151 ms->msgphase = msg_out_xxx; in cmd_complete()
1156 ms->last_n_msgout = ms->n_msgout; in cmd_complete()
1157 ms->n_msgout = 0; in cmd_complete()
1158 ms->msgphase = ms->expect_reply? msg_in: msg_none; in cmd_complete()
1159 start_phase(ms); in cmd_complete()
1163 switch (ms->phase) { in cmd_complete()
1166 dumpslog(ms); in cmd_complete()
1169 dlog(ms, "Selecting phase at command completion",0); in cmd_complete()
1170 ms->msgout[0] = IDENTIFY(ALLOW_RESEL(ms->conn_tgt), in cmd_complete()
1172 ms->n_msgout = 1; in cmd_complete()
1173 ms->expect_reply = 0; in cmd_complete()
1174 if (ms->aborting) { in cmd_complete()
1175 ms->msgout[0] = ABORT; in cmd_complete()
1176 ms->n_msgout++; in cmd_complete()
1179 add_sdtr_msg(ms); in cmd_complete()
1180 ms->expect_reply = 1; in cmd_complete()
1183 ms->msgphase = msg_out; in cmd_complete()
1194 dlog(ms, "impatient for req", ms->n_msgout); in cmd_complete()
1195 ms->msgphase = msg_none; in cmd_complete()
1202 if (ms->dma_count != 0) { in cmd_complete()
1203 start_phase(ms); in cmd_complete()
1219 halt_dma(ms); in cmd_complete()
1228 ms->msgphase = msg_in; in cmd_complete()
1231 mesh_done(ms, 1); in cmd_complete()
1234 ms->current_req = 0; in cmd_complete()
1235 ms->phase = idle; in cmd_complete()
1236 mesh_start(ms); in cmd_complete()
1241 ++ms->phase; in cmd_complete()
1242 start_phase(ms); in cmd_complete()
1247 static void phase_mismatch(struct mesh_state *ms) in phase_mismatch() argument
1249 volatile struct mesh_regs *mr = ms->mesh; in phase_mismatch()
1252 dlog(ms, "phasemm ch/cl/seq/fc=%.8x", in phase_mismatch()
1255 if (ms->msgphase == msg_out_xxx && phase == BP_MSGOUT) { in phase_mismatch()
1260 out_8(&mr->fifo, ms->msgout[ms->n_msgout-1]); in phase_mismatch()
1261 ms->msgphase = msg_out_last; in phase_mismatch()
1265 if (ms->msgphase == msg_in) { in phase_mismatch()
1266 get_msgin(ms); in phase_mismatch()
1267 if (ms->n_msgin) in phase_mismatch()
1268 handle_msgin(ms); in phase_mismatch()
1271 if (ms->dma_started) in phase_mismatch()
1272 halt_dma(ms); in phase_mismatch()
1278 ms->msgphase = msg_none; in phase_mismatch()
1281 ms->tgts[ms->conn_tgt].data_goes_out = 0; in phase_mismatch()
1282 ms->phase = dataing; in phase_mismatch()
1285 ms->tgts[ms->conn_tgt].data_goes_out = 1; in phase_mismatch()
1286 ms->phase = dataing; in phase_mismatch()
1289 ms->phase = commanding; in phase_mismatch()
1292 ms->phase = statusing; in phase_mismatch()
1295 ms->msgphase = msg_in; in phase_mismatch()
1296 ms->n_msgin = 0; in phase_mismatch()
1299 ms->msgphase = msg_out; in phase_mismatch()
1300 if (ms->n_msgout == 0) { in phase_mismatch()
1301 if (ms->aborting) { in phase_mismatch()
1302 do_abort(ms); in phase_mismatch()
1304 if (ms->last_n_msgout == 0) { in phase_mismatch()
1307 ms->msgout[0] = NOP; in phase_mismatch()
1308 ms->last_n_msgout = 1; in phase_mismatch()
1310 ms->n_msgout = ms->last_n_msgout; in phase_mismatch()
1316 ms->stat = DID_ERROR; in phase_mismatch()
1317 mesh_done(ms, 1); in phase_mismatch()
1321 start_phase(ms); in phase_mismatch()
1325 reselected(struct mesh_state *ms) in reselected() argument
1327 volatile struct mesh_regs *mr = ms->mesh; in reselected()
1332 switch (ms->phase) { in reselected()
1336 if ((cmd = ms->current_req) != NULL) { in reselected()
1338 cmd->host_scribble = (void *) ms->request_q; in reselected()
1339 if (ms->request_q == NULL) in reselected()
1340 ms->request_qtail = cmd; in reselected()
1341 ms->request_q = cmd; in reselected()
1342 tp = &ms->tgts[cmd->target]; in reselected()
1347 ms->phase = reselecting; in reselected()
1348 mesh_done(ms, 0); in reselected()
1354 ms->msgphase, ms->phase, ms->conn_tgt); in reselected()
1355 dumplog(ms, ms->conn_tgt); in reselected()
1356 dumpslog(ms); in reselected()
1359 if (ms->dma_started) { in reselected()
1361 halt_dma(ms); in reselected()
1363 ms->current_req = NULL; in reselected()
1364 ms->phase = dataing; in reselected()
1365 ms->msgphase = msg_in; in reselected()
1366 ms->n_msgout = 0; in reselected()
1367 ms->last_n_msgout = 0; in reselected()
1368 prev = ms->conn_tgt; in reselected()
1380 dlog(ms, "extra resel err/exc/fc = %.6x", in reselected()
1394 ms->conn_tgt = ms->host->this_id; in reselected()
1400 dlog(ms, "reseldata %x", b); in reselected()
1403 if ((b & (1 << t)) != 0 && t != ms->host->this_id) in reselected()
1405 if (b != (1 << t) + (1 << ms->host->this_id)) { in reselected()
1407 ms->conn_tgt = ms->host->this_id; in reselected()
1415 ms->conn_tgt = t; in reselected()
1416 tp = &ms->tgts[t]; in reselected()
1423 ms->current_req = tp->current_req; in reselected()
1428 ms->data_ptr = tp->saved_ptr; in reselected()
1429 dlog(ms, "resel prev tgt=%d", prev); in reselected()
1430 dlog(ms, "resel err/exc=%.4x", MKWORD(0, 0, mr->error, mr->exception)); in reselected()
1431 start_phase(ms); in reselected()
1435 dumplog(ms, ms->conn_tgt); in reselected()
1436 dumpslog(ms); in reselected()
1437 ms->data_ptr = 0; in reselected()
1438 ms->aborting = 1; in reselected()
1439 start_phase(ms); in reselected()
1442 static void do_abort(struct mesh_state *ms) in do_abort() argument
1444 ms->msgout[0] = ABORT; in do_abort()
1445 ms->n_msgout = 1; in do_abort()
1446 ms->aborting = 1; in do_abort()
1447 ms->stat = DID_ABORT; in do_abort()
1448 dlog(ms, "abort", 0); in do_abort()
1452 handle_reset(struct mesh_state *ms) in handle_reset() argument
1457 volatile struct mesh_regs *mr = ms->mesh; in handle_reset()
1460 tp = &ms->tgts[tgt]; in handle_reset()
1464 mesh_completed(ms, cmd); in handle_reset()
1466 ms->tgts[tgt].sdtr_state = do_sdtr; in handle_reset()
1467 ms->tgts[tgt].sync_params = ASYNC_PARAMS; in handle_reset()
1469 ms->current_req = NULL; in handle_reset()
1470 while ((cmd = ms->request_q) != NULL) { in handle_reset()
1471 ms->request_q = (Scsi_Cmnd *) cmd->host_scribble; in handle_reset()
1473 mesh_completed(ms, cmd); in handle_reset()
1475 ms->phase = idle; in handle_reset()
1476 ms->msgphase = msg_none; in handle_reset()
1494 static void handle_error(struct mesh_state *ms) in handle_error() argument
1497 volatile struct mesh_regs *mr = ms->mesh; in handle_error()
1502 dlog(ms, "error err/exc/fc/cl=%.8x", in handle_error()
1511 handle_reset(ms); in handle_error()
1518 reselected(ms); in handle_error()
1521 if (!ms->aborting) { in handle_error()
1523 ms->conn_tgt); in handle_error()
1524 dumplog(ms, ms->conn_tgt); in handle_error()
1525 dumpslog(ms); in handle_error()
1528 ms->stat = DID_ABORT; in handle_error()
1529 mesh_done(ms, 1); in handle_error()
1533 if (ms->msgphase == msg_in) { in handle_error()
1535 ms->conn_tgt); in handle_error()
1536 ms->msgout[0] = MSG_PARITY_ERROR; in handle_error()
1537 ms->n_msgout = 1; in handle_error()
1538 ms->msgphase = msg_in_bad; in handle_error()
1539 cmd_complete(ms); in handle_error()
1542 if (ms->stat == DID_OK) { in handle_error()
1544 ms->conn_tgt); in handle_error()
1545 ms->stat = DID_PARITY; in handle_error()
1549 cmd_complete(ms); in handle_error()
1562 reselected(ms); in handle_error()
1568 phase_mismatch(ms); in handle_error()
1576 mesh_dump_regs(ms); in handle_error()
1577 dumplog(ms, ms->conn_tgt); in handle_error()
1578 if (ms->phase > selecting && (mr->bus_status1 & BS1_BSY)) { in handle_error()
1580 do_abort(ms); in handle_error()
1581 phase_mismatch(ms); in handle_error()
1584 ms->stat = DID_ERROR; in handle_error()
1585 mesh_done(ms, 1); in handle_error()
1588 static void handle_exception(struct mesh_state *ms) in handle_exception() argument
1591 volatile struct mesh_regs *mr = ms->mesh; in handle_exception()
1598 reselected(ms); in handle_exception()
1601 ms->stat = DID_BUS_BUSY; in handle_exception()
1602 mesh_done(ms, 1); in handle_exception()
1605 ms->stat = DID_BAD_TARGET; in handle_exception()
1606 mesh_done(ms, 1); in handle_exception()
1610 phase_mismatch(ms); in handle_exception()
1613 mesh_dump_regs(ms); in handle_exception()
1614 dumplog(ms, ms->conn_tgt); in handle_exception()
1615 do_abort(ms); in handle_exception()
1616 phase_mismatch(ms); in handle_exception()
1623 struct mesh_state *ms = (struct mesh_state *) dev_id; in mesh_interrupt() local
1624 volatile struct mesh_regs *mr = ms->mesh; in mesh_interrupt()
1628 if (ALLOW_DEBUG(ms->conn_tgt)) in mesh_interrupt()
1632 ms->phase, ms->msgphase); in mesh_interrupt()
1635 dlog(ms, "interrupt intr/err/exc/seq=%.8x", in mesh_interrupt()
1638 handle_error(ms); in mesh_interrupt()
1640 handle_exception(ms); in mesh_interrupt()
1643 cmd_complete(ms); in mesh_interrupt()
1649 handle_msgin(struct mesh_state *ms) in handle_msgin() argument
1652 Scsi_Cmnd *cmd = ms->current_req; in handle_msgin()
1653 struct mesh_target *tp = &ms->tgts[ms->conn_tgt]; in handle_msgin()
1655 if (ms->n_msgin == 0) in handle_msgin()
1657 code = ms->msgin[0]; in handle_msgin()
1658 if (ALLOW_DEBUG(ms->conn_tgt)) { in handle_msgin()
1659 printk(KERN_DEBUG "got %d message bytes:", ms->n_msgin); in handle_msgin()
1660 for (i = 0; i < ms->n_msgin; ++i) in handle_msgin()
1661 printk(" %x", ms->msgin[i]); in handle_msgin()
1664 dlog(ms, "msgin msg=%.8x", in handle_msgin()
1665 MKWORD(ms->n_msgin, code, ms->msgin[1], ms->msgin[2])); in handle_msgin()
1667 ms->expect_reply = 0; in handle_msgin()
1668 ms->n_msgout = 0; in handle_msgin()
1669 if (ms->n_msgin < msgin_length(ms)) in handle_msgin()
1677 switch (ms->msgin[2]) { in handle_msgin()
1679 ms->data_ptr += (ms->msgin[3] << 24) + ms->msgin[6] in handle_msgin()
1680 + (ms->msgin[4] << 16) + (ms->msgin[5] << 8); in handle_msgin()
1685 add_sdtr_msg(ms); in handle_msgin()
1688 if (ms->msgout[3] < ms->msgin[3]) in handle_msgin()
1689 ms->msgout[3] = ms->msgin[3]; in handle_msgin()
1690 if (ms->msgout[4] > ms->msgin[4]) in handle_msgin()
1691 ms->msgout[4] = ms->msgin[4]; in handle_msgin()
1692 set_sdtr(ms, ms->msgout[3], ms->msgout[4]); in handle_msgin()
1693 ms->msgphase = msg_out; in handle_msgin()
1695 set_sdtr(ms, ms->msgin[3], ms->msgin[4]); in handle_msgin()
1703 tp->saved_ptr = ms->data_ptr; in handle_msgin()
1706 ms->data_ptr = tp->saved_ptr; in handle_msgin()
1709 ms->phase = disconnecting; in handle_msgin()
1715 set_sdtr(ms, 0, 0); in handle_msgin()
1722 do_abort(ms); in handle_msgin()
1723 ms->msgphase = msg_out; in handle_msgin()
1728 ms->conn_tgt); in handle_msgin()
1738 ms->conn_tgt); in handle_msgin()
1739 for (i = 0; i < ms->n_msgin; ++i) in handle_msgin()
1740 printk(" %x", ms->msgin[i]); in handle_msgin()
1742 ms->msgout[0] = MESSAGE_REJECT; in handle_msgin()
1743 ms->n_msgout = 1; in handle_msgin()
1744 ms->msgphase = msg_out; in handle_msgin()
1748 mesh_done(struct mesh_state *ms, int start_next) in mesh_done() argument
1751 struct mesh_target *tp = &ms->tgts[ms->conn_tgt]; in mesh_done()
1753 cmd = ms->current_req; in mesh_done()
1754 ms->current_req = 0; in mesh_done()
1757 cmd->result = (ms->stat << 16) + cmd->SCp.Status; in mesh_done()
1758 if (ms->stat == DID_OK) in mesh_done()
1762 cmd->result, ms->data_ptr, cmd->request_bufflen); in mesh_done()
1770 cmd->SCp.this_residual -= ms->data_ptr; in mesh_done()
1771 mesh_completed(ms, cmd); in mesh_done()
1774 out_8(&ms->mesh->sequence, SEQ_ENBRESEL); in mesh_done()
1776 ms->phase = idle; in mesh_done()
1777 mesh_start(ms); in mesh_done()
1782 mesh_completed(struct mesh_state *ms, Scsi_Cmnd *cmd) in mesh_completed() argument
1791 set_dma_cmds(struct mesh_state *ms, Scsi_Cmnd *cmd) in set_dma_cmds() argument
1797 dma_cmd = ms->tgts[ms->conn_tgt].data_goes_out? in set_dma_cmds()
1799 dcmds = ms->dma_cmds; in set_dma_cmds()
1807 off = ms->data_ptr; in set_dma_cmds()
1808 nseg = pci_map_sg(ms->pdev, scl, cmd->use_sg, in set_dma_cmds()
1829 } else if (ms->data_ptr < cmd->request_bufflen) { in set_dma_cmds()
1830 dtot = cmd->request_bufflen - ms->data_ptr; in set_dma_cmds()
1836 virt_to_phys(cmd->request_buffer) + ms->data_ptr); in set_dma_cmds()
1856 ms->dma_count = dtot; in set_dma_cmds()
1860 halt_dma(struct mesh_state *ms) in halt_dma() argument
1862 volatile struct dbdma_regs *md = ms->dma; in halt_dma()
1863 volatile struct mesh_regs *mr = ms->mesh; in halt_dma()
1864 Scsi_Cmnd *cmd = ms->current_req; in halt_dma()
1867 if (!ms->tgts[ms->conn_tgt].data_goes_out) { in halt_dma()
1878 dlog(ms, "halt_dma fc/count=%.6x", in halt_dma()
1880 if (ms->tgts[ms->conn_tgt].data_goes_out) in halt_dma()
1884 ms->data_ptr -= nb; in halt_dma()
1885 dlog(ms, "data_ptr %x", ms->data_ptr); in halt_dma()
1886 if (ms->data_ptr < 0) { in halt_dma()
1888 ms->data_ptr, nb, ms); in halt_dma()
1889 ms->data_ptr = 0; in halt_dma()
1891 dumplog(ms, ms->conn_tgt); in halt_dma()
1892 dumpslog(ms); in halt_dma()
1895 ms->data_ptr > cmd->request_bufflen) { in halt_dma()
1898 ms->conn_tgt, ms->data_ptr, cmd->request_bufflen, in halt_dma()
1899 ms->tgts[ms->conn_tgt].data_goes_out); in halt_dma()
1904 pci_unmap_sg(ms->pdev, sg, cmd->use_sg, in halt_dma()
1907 ms->dma_started = 0; in halt_dma()
1969 static void dlog(struct mesh_state *ms, char *fmt, int a) in dlog() argument
1971 struct mesh_target *tp = &ms->tgts[ms->conn_tgt]; in dlog()
1975 slp = &ms->log[ms->log_ix]; in dlog()
1978 tlp->phase = (ms->msgphase << 4) + ms->phase; in dlog()
1979 tlp->bs0 = ms->mesh->bus_status0; in dlog()
1980 tlp->bs1 = ms->mesh->bus_status1; in dlog()
1981 tlp->tgt = ms->conn_tgt; in dlog()
1988 if (++ms->log_ix >= N_DBG_SLOG) in dlog()
1989 ms->log_ix = 0; in dlog()
1990 if (ms->n_log < N_DBG_SLOG) in dlog()
1991 ++ms->n_log; in dlog()
1994 static void dumplog(struct mesh_state *ms, int t) in dumplog() argument
1996 struct mesh_target *tp = &ms->tgts[t]; in dumplog()
2020 static void dumpslog(struct mesh_state *ms) in dumpslog() argument
2025 if (ms->n_log == 0) in dumpslog()
2027 i = ms->log_ix - ms->n_log; in dumpslog()
2030 ms->n_log = 0; in dumpslog()
2032 lp = &ms->log[i]; in dumpslog()
2042 } while (i != ms->log_ix); in dumpslog()