Lines Matching refs:ahd

98 static void		ahd_handle_transmission_error(struct ahd_softc *ahd);
99 static void ahd_handle_lqiphase_error(struct ahd_softc *ahd,
101 static int ahd_handle_pkt_busfree(struct ahd_softc *ahd,
103 static int ahd_handle_nonpkt_busfree(struct ahd_softc *ahd);
104 static void ahd_handle_proto_violation(struct ahd_softc *ahd);
105 static void ahd_force_renegotiation(struct ahd_softc *ahd,
109 ahd_alloc_tstate(struct ahd_softc *ahd,
112 static void ahd_free_tstate(struct ahd_softc *ahd,
115 static void ahd_devlimited_syncrate(struct ahd_softc *ahd,
120 static void ahd_update_neg_table(struct ahd_softc *ahd,
123 static void ahd_update_pending_scbs(struct ahd_softc *ahd);
124 static void ahd_fetch_devinfo(struct ahd_softc *ahd,
126 static void ahd_scb_devinfo(struct ahd_softc *ahd,
129 static void ahd_setup_initiator_msgout(struct ahd_softc *ahd,
132 static void ahd_build_transfer_msg(struct ahd_softc *ahd,
134 static void ahd_construct_sdtr(struct ahd_softc *ahd,
137 static void ahd_construct_wdtr(struct ahd_softc *ahd,
140 static void ahd_construct_ppr(struct ahd_softc *ahd,
144 static void ahd_clear_msg_state(struct ahd_softc *ahd);
145 static void ahd_handle_message_phase(struct ahd_softc *ahd);
151 static int ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type,
153 static int ahd_parse_msg(struct ahd_softc *ahd,
155 static int ahd_handle_msg_reject(struct ahd_softc *ahd,
157 static void ahd_handle_ign_wide_residue(struct ahd_softc *ahd,
159 static void ahd_reinitialize_dataptrs(struct ahd_softc *ahd);
160 static void ahd_handle_devreset(struct ahd_softc *ahd,
165 static void ahd_setup_target_msgin(struct ahd_softc *ahd,
170 static u_int ahd_sglist_size(struct ahd_softc *ahd);
171 static u_int ahd_sglist_allocsize(struct ahd_softc *ahd);
174 static void ahd_initialize_hscbs(struct ahd_softc *ahd);
175 static int ahd_init_scbdata(struct ahd_softc *ahd);
176 static void ahd_fini_scbdata(struct ahd_softc *ahd);
177 static void ahd_setup_iocell_workaround(struct ahd_softc *ahd);
178 static void ahd_iocell_first_selection(struct ahd_softc *ahd);
179 static void ahd_add_col_list(struct ahd_softc *ahd,
181 static void ahd_rem_col_list(struct ahd_softc *ahd,
183 static void ahd_chip_init(struct ahd_softc *ahd);
184 static void ahd_qinfifo_requeue(struct ahd_softc *ahd,
187 static int ahd_qinfifo_count(struct ahd_softc *ahd);
188 static int ahd_search_scb_list(struct ahd_softc *ahd, int target,
194 static void ahd_stitch_tid_list(struct ahd_softc *ahd,
197 static void ahd_add_scb_to_free_list(struct ahd_softc *ahd,
199 static u_int ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
201 static void ahd_reset_current_bus(struct ahd_softc *ahd);
204 static void ahd_dumpseq(struct ahd_softc *ahd);
206 static void ahd_loadseq(struct ahd_softc *ahd);
207 static int ahd_check_patch(struct ahd_softc *ahd,
210 static u_int ahd_resolve_seqaddr(struct ahd_softc *ahd,
212 static void ahd_download_instr(struct ahd_softc *ahd,
214 static int ahd_probe_stack_size(struct ahd_softc *ahd);
215 static int ahd_scb_active_in_fifo(struct ahd_softc *ahd,
217 static void ahd_run_data_fifo(struct ahd_softc *ahd,
221 static void ahd_queue_lstate_event(struct ahd_softc *ahd,
226 static void ahd_update_scsiid(struct ahd_softc *ahd,
228 static int ahd_handle_target_cmd(struct ahd_softc *ahd,
232 static int ahd_abort_scbs(struct ahd_softc *ahd, int target,
235 static void ahd_alloc_scbs(struct ahd_softc *ahd);
236 static void ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl,
238 static void ahd_calc_residual(struct ahd_softc *ahd,
240 static void ahd_clear_critical_section(struct ahd_softc *ahd);
241 static void ahd_clear_intstat(struct ahd_softc *ahd);
242 static void ahd_enable_coalescing(struct ahd_softc *ahd,
244 static u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
245 static void ahd_freeze_devq(struct ahd_softc *ahd,
247 static void ahd_handle_scb_status(struct ahd_softc *ahd,
251 static void ahd_update_coalescing_values(struct ahd_softc *ahd,
256 static int ahd_wait_seeprom(struct ahd_softc *ahd);
257 static int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
261 static void ahd_reset_cmds_pending(struct ahd_softc *ahd);
264 static void ahd_run_qoutfifo(struct ahd_softc *ahd);
266 static void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
268 static void ahd_handle_hwerrint(struct ahd_softc *ahd);
269 static void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
270 static void ahd_handle_scsiint(struct ahd_softc *ahd,
275 ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst) in ahd_set_modes() argument
277 if (ahd->src_mode == src && ahd->dst_mode == dst) in ahd_set_modes()
280 if (ahd->src_mode == AHD_MODE_UNKNOWN in ahd_set_modes()
281 || ahd->dst_mode == AHD_MODE_UNKNOWN) in ahd_set_modes()
284 printk("%s: Setting mode 0x%x\n", ahd_name(ahd), in ahd_set_modes()
285 ahd_build_mode_state(ahd, src, dst)); in ahd_set_modes()
287 ahd_outb(ahd, MODE_PTR, ahd_build_mode_state(ahd, src, dst)); in ahd_set_modes()
288 ahd->src_mode = src; in ahd_set_modes()
289 ahd->dst_mode = dst; in ahd_set_modes()
293 ahd_update_modes(struct ahd_softc *ahd) in ahd_update_modes() argument
299 mode_ptr = ahd_inb(ahd, MODE_PTR); in ahd_update_modes()
304 ahd_extract_mode_state(ahd, mode_ptr, &src, &dst); in ahd_update_modes()
305 ahd_known_modes(ahd, src, dst); in ahd_update_modes()
309 ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode, in ahd_assert_modes() argument
313 if ((srcmode & AHD_MK_MSK(ahd->src_mode)) == 0 in ahd_assert_modes()
314 || (dstmode & AHD_MK_MSK(ahd->dst_mode)) == 0) { in ahd_assert_modes()
316 ahd_name(ahd), file, line); in ahd_assert_modes()
321 #define AHD_ASSERT_MODES(ahd, source, dest) \ argument
322 ahd_assert_modes(ahd, source, dest, __FILE__, __LINE__);
325 ahd_save_modes(struct ahd_softc *ahd) in ahd_save_modes() argument
327 if (ahd->src_mode == AHD_MODE_UNKNOWN in ahd_save_modes()
328 || ahd->dst_mode == AHD_MODE_UNKNOWN) in ahd_save_modes()
329 ahd_update_modes(ahd); in ahd_save_modes()
331 return (ahd_build_mode_state(ahd, ahd->src_mode, ahd->dst_mode)); in ahd_save_modes()
335 ahd_restore_modes(struct ahd_softc *ahd, ahd_mode_state state) in ahd_restore_modes() argument
340 ahd_extract_mode_state(ahd, state, &src, &dst); in ahd_restore_modes()
341 ahd_set_modes(ahd, src, dst); in ahd_restore_modes()
349 ahd_is_paused(struct ahd_softc *ahd) in ahd_is_paused() argument
351 return ((ahd_inb(ahd, HCNTRL) & PAUSE) != 0); in ahd_is_paused()
362 ahd_pause(struct ahd_softc *ahd) in ahd_pause() argument
364 ahd_outb(ahd, HCNTRL, ahd->pause); in ahd_pause()
370 while (ahd_is_paused(ahd) == 0) in ahd_pause()
385 ahd_unpause(struct ahd_softc *ahd) in ahd_unpause() argument
391 if (ahd->saved_src_mode != AHD_MODE_UNKNOWN in ahd_unpause()
392 && ahd->saved_dst_mode != AHD_MODE_UNKNOWN) { in ahd_unpause()
393 if ((ahd->flags & AHD_UPDATE_PEND_CMDS) != 0) in ahd_unpause()
394 ahd_reset_cmds_pending(ahd); in ahd_unpause()
395 ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode); in ahd_unpause()
398 if ((ahd_inb(ahd, INTSTAT) & ~CMDCMPLT) == 0) in ahd_unpause()
399 ahd_outb(ahd, HCNTRL, ahd->unpause); in ahd_unpause()
401 ahd_known_modes(ahd, AHD_MODE_UNKNOWN, AHD_MODE_UNKNOWN); in ahd_unpause()
406 ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb, in ahd_sg_setup() argument
411 && (ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_sg_setup()
430 ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb) in ahd_setup_scb_common() argument
451 ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_setup_data_scb() argument
456 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_setup_data_scb()
470 if ((ahd->flags & AHD_39BIT_ADDRESSING) != 0) { in ahd_setup_data_scb()
488 ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_setup_noxfer_scb() argument
497 ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr) in ahd_sg_bus_to_virt() argument
502 sg_offset = sg_busaddr - (scb->sg_list_busaddr - ahd_sg_size(ahd)); in ahd_sg_bus_to_virt()
507 ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg) in ahd_sg_virt_to_bus() argument
513 - ahd_sg_size(ahd); in ahd_sg_virt_to_bus()
519 ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op) in ahd_sync_scb() argument
521 ahd_dmamap_sync(ahd, ahd->scb_data.hscb_dmat, in ahd_sync_scb()
528 ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op) in ahd_sync_sglist() argument
533 ahd_dmamap_sync(ahd, ahd->scb_data.sg_dmat, in ahd_sync_sglist()
535 /*offset*/scb->sg_list_busaddr - ahd_sg_size(ahd), in ahd_sync_sglist()
536 /*len*/ahd_sg_size(ahd) * scb->sg_count, op); in ahd_sync_sglist()
540 ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op) in ahd_sync_sense() argument
542 ahd_dmamap_sync(ahd, ahd->scb_data.sense_dmat, in ahd_sync_sense()
550 ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index) in ahd_targetcmd_offset() argument
552 return (((uint8_t *)&ahd->targetcmds[index]) in ahd_targetcmd_offset()
553 - (uint8_t *)ahd->qoutfifo); in ahd_targetcmd_offset()
563 ahd_fetch_transinfo(struct ahd_softc *ahd, char channel, u_int our_id, in ahd_fetch_transinfo() argument
574 *tstate = ahd->enabled_targets[our_id]; in ahd_fetch_transinfo()
579 ahd_inw(struct ahd_softc *ahd, u_int port) in ahd_inw() argument
586 uint16_t r = ahd_inb(ahd, port+1) << 8; in ahd_inw()
587 return r | ahd_inb(ahd, port); in ahd_inw()
591 ahd_outw(struct ahd_softc *ahd, u_int port, u_int value) in ahd_outw() argument
597 ahd_outb(ahd, port, value & 0xFF); in ahd_outw()
598 ahd_outb(ahd, port+1, (value >> 8) & 0xFF); in ahd_outw()
602 ahd_inl(struct ahd_softc *ahd, u_int port) in ahd_inl() argument
604 return ((ahd_inb(ahd, port)) in ahd_inl()
605 | (ahd_inb(ahd, port+1) << 8) in ahd_inl()
606 | (ahd_inb(ahd, port+2) << 16) in ahd_inl()
607 | (ahd_inb(ahd, port+3) << 24)); in ahd_inl()
611 ahd_outl(struct ahd_softc *ahd, u_int port, uint32_t value) in ahd_outl() argument
613 ahd_outb(ahd, port, (value) & 0xFF); in ahd_outl()
614 ahd_outb(ahd, port+1, ((value) >> 8) & 0xFF); in ahd_outl()
615 ahd_outb(ahd, port+2, ((value) >> 16) & 0xFF); in ahd_outl()
616 ahd_outb(ahd, port+3, ((value) >> 24) & 0xFF); in ahd_outl()
620 ahd_inq(struct ahd_softc *ahd, u_int port) in ahd_inq() argument
622 return ((ahd_inb(ahd, port)) in ahd_inq()
623 | (ahd_inb(ahd, port+1) << 8) in ahd_inq()
624 | (ahd_inb(ahd, port+2) << 16) in ahd_inq()
625 | (ahd_inb(ahd, port+3) << 24) in ahd_inq()
626 | (((uint64_t)ahd_inb(ahd, port+4)) << 32) in ahd_inq()
627 | (((uint64_t)ahd_inb(ahd, port+5)) << 40) in ahd_inq()
628 | (((uint64_t)ahd_inb(ahd, port+6)) << 48) in ahd_inq()
629 | (((uint64_t)ahd_inb(ahd, port+7)) << 56)); in ahd_inq()
633 ahd_outq(struct ahd_softc *ahd, u_int port, uint64_t value) in ahd_outq() argument
635 ahd_outb(ahd, port, value & 0xFF); in ahd_outq()
636 ahd_outb(ahd, port+1, (value >> 8) & 0xFF); in ahd_outq()
637 ahd_outb(ahd, port+2, (value >> 16) & 0xFF); in ahd_outq()
638 ahd_outb(ahd, port+3, (value >> 24) & 0xFF); in ahd_outq()
639 ahd_outb(ahd, port+4, (value >> 32) & 0xFF); in ahd_outq()
640 ahd_outb(ahd, port+5, (value >> 40) & 0xFF); in ahd_outq()
641 ahd_outb(ahd, port+6, (value >> 48) & 0xFF); in ahd_outq()
642 ahd_outb(ahd, port+7, (value >> 56) & 0xFF); in ahd_outq()
646 ahd_get_scbptr(struct ahd_softc *ahd) in ahd_get_scbptr() argument
648 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_get_scbptr()
650 return (ahd_inb(ahd, SCBPTR) | (ahd_inb(ahd, SCBPTR + 1) << 8)); in ahd_get_scbptr()
654 ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr) in ahd_set_scbptr() argument
656 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_set_scbptr()
658 ahd_outb(ahd, SCBPTR, scbptr & 0xFF); in ahd_set_scbptr()
659 ahd_outb(ahd, SCBPTR+1, (scbptr >> 8) & 0xFF); in ahd_set_scbptr()
664 ahd_get_hnscb_qoff(struct ahd_softc *ahd)
666 return (ahd_inw_atomic(ahd, HNSCB_QOFF));
671 ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_hnscb_qoff() argument
673 ahd_outw_atomic(ahd, HNSCB_QOFF, value); in ahd_set_hnscb_qoff()
678 ahd_get_hescb_qoff(struct ahd_softc *ahd)
680 return (ahd_inb(ahd, HESCB_QOFF));
685 ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_hescb_qoff() argument
687 ahd_outb(ahd, HESCB_QOFF, value); in ahd_set_hescb_qoff()
691 ahd_get_snscb_qoff(struct ahd_softc *ahd) in ahd_get_snscb_qoff() argument
695 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_get_snscb_qoff()
696 oldvalue = ahd_inw(ahd, SNSCB_QOFF); in ahd_get_snscb_qoff()
697 ahd_outw(ahd, SNSCB_QOFF, oldvalue); in ahd_get_snscb_qoff()
702 ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_snscb_qoff() argument
704 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_set_snscb_qoff()
705 ahd_outw(ahd, SNSCB_QOFF, value); in ahd_set_snscb_qoff()
710 ahd_get_sescb_qoff(struct ahd_softc *ahd)
712 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
713 return (ahd_inb(ahd, SESCB_QOFF));
718 ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_sescb_qoff() argument
720 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_set_sescb_qoff()
721 ahd_outb(ahd, SESCB_QOFF, value); in ahd_set_sescb_qoff()
726 ahd_get_sdscb_qoff(struct ahd_softc *ahd)
728 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
729 return (ahd_inb(ahd, SDSCB_QOFF) | (ahd_inb(ahd, SDSCB_QOFF + 1) << 8));
734 ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_sdscb_qoff() argument
736 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_set_sdscb_qoff()
737 ahd_outb(ahd, SDSCB_QOFF, value & 0xFF); in ahd_set_sdscb_qoff()
738 ahd_outb(ahd, SDSCB_QOFF+1, (value >> 8) & 0xFF); in ahd_set_sdscb_qoff()
742 ahd_inb_scbram(struct ahd_softc *ahd, u_int offset) in ahd_inb_scbram() argument
760 value = ahd_inb(ahd, offset); in ahd_inb_scbram()
761 if ((ahd->bugs & AHD_PCIX_SCBRAM_RD_BUG) != 0) in ahd_inb_scbram()
762 ahd_inb(ahd, MODE_PTR); in ahd_inb_scbram()
767 ahd_inw_scbram(struct ahd_softc *ahd, u_int offset) in ahd_inw_scbram() argument
769 return (ahd_inb_scbram(ahd, offset) in ahd_inw_scbram()
770 | (ahd_inb_scbram(ahd, offset+1) << 8)); in ahd_inw_scbram()
774 ahd_inl_scbram(struct ahd_softc *ahd, u_int offset) in ahd_inl_scbram() argument
776 return (ahd_inw_scbram(ahd, offset) in ahd_inl_scbram()
777 | (ahd_inw_scbram(ahd, offset+2) << 16)); in ahd_inl_scbram()
781 ahd_inq_scbram(struct ahd_softc *ahd, u_int offset) in ahd_inq_scbram() argument
783 return (ahd_inl_scbram(ahd, offset) in ahd_inq_scbram()
784 | ((uint64_t)ahd_inl_scbram(ahd, offset+4)) << 32); in ahd_inq_scbram()
788 ahd_lookup_scb(struct ahd_softc *ahd, u_int tag) in ahd_lookup_scb() argument
794 scb = ahd->scb_data.scbindex[tag]; in ahd_lookup_scb()
796 ahd_sync_scb(ahd, scb, in ahd_lookup_scb()
802 ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb) in ahd_swap_with_next_hscb() argument
820 q_hscb = ahd->next_queued_hscb; in ahd_swap_with_next_hscb()
821 q_hscb_map = ahd->next_queued_hscb_map; in ahd_swap_with_next_hscb()
828 ahd->next_queued_hscb = scb->hscb; in ahd_swap_with_next_hscb()
829 ahd->next_queued_hscb_map = scb->hscb_map; in ahd_swap_with_next_hscb()
834 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb; in ahd_swap_with_next_hscb()
841 ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_queue_scb() argument
843 ahd_swap_with_next_hscb(ahd, scb); in ahd_queue_scb()
852 ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb); in ahd_queue_scb()
853 ahd->qinfifonext++; in ahd_queue_scb()
856 ahd_setup_data_scb(ahd, scb); in ahd_queue_scb()
858 ahd_setup_noxfer_scb(ahd, scb); in ahd_queue_scb()
859 ahd_setup_scb_common(ahd, scb); in ahd_queue_scb()
865 ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahd_queue_scb()
873 ahd_name(ahd), in ahd_queue_scb()
882 ahd_set_hnscb_qoff(ahd, ahd->qinfifonext); in ahd_queue_scb()
887 ahd_sync_qoutfifo(struct ahd_softc *ahd, int op) in ahd_sync_qoutfifo() argument
889 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap, in ahd_sync_qoutfifo()
895 ahd_sync_tqinfifo(struct ahd_softc *ahd, int op) in ahd_sync_tqinfifo() argument
898 if ((ahd->flags & AHD_TARGETROLE) != 0) { in ahd_sync_tqinfifo()
899 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, in ahd_sync_tqinfifo()
900 ahd->shared_data_map.dmamap, in ahd_sync_tqinfifo()
901 ahd_targetcmd_offset(ahd, 0), in ahd_sync_tqinfifo()
915 ahd_check_cmdcmpltqueues(struct ahd_softc *ahd) in ahd_check_cmdcmpltqueues() argument
920 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap, in ahd_check_cmdcmpltqueues()
921 /*offset*/ahd->qoutfifonext * sizeof(*ahd->qoutfifo), in ahd_check_cmdcmpltqueues()
922 /*len*/sizeof(*ahd->qoutfifo), BUS_DMASYNC_POSTREAD); in ahd_check_cmdcmpltqueues()
923 if (ahd->qoutfifo[ahd->qoutfifonext].valid_tag in ahd_check_cmdcmpltqueues()
924 == ahd->qoutfifonext_valid_tag) in ahd_check_cmdcmpltqueues()
927 if ((ahd->flags & AHD_TARGETROLE) != 0 in ahd_check_cmdcmpltqueues()
928 && (ahd->flags & AHD_TQINFIFO_BLOCKED) == 0) { in ahd_check_cmdcmpltqueues()
929 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, in ahd_check_cmdcmpltqueues()
930 ahd->shared_data_map.dmamap, in ahd_check_cmdcmpltqueues()
931 ahd_targetcmd_offset(ahd, ahd->tqinfifofnext), in ahd_check_cmdcmpltqueues()
934 if (ahd->targetcmds[ahd->tqinfifonext].cmd_valid != 0) in ahd_check_cmdcmpltqueues()
945 ahd_intr(struct ahd_softc *ahd) in ahd_intr() argument
949 if ((ahd->pause & INTEN) == 0) { in ahd_intr()
965 if ((ahd->flags & AHD_ALL_INTERRUPTS) == 0 in ahd_intr()
966 && (ahd_check_cmdcmpltqueues(ahd) != 0)) in ahd_intr()
969 intstat = ahd_inb(ahd, INTSTAT); in ahd_intr()
975 ahd_outb(ahd, CLRINT, CLRCMDINT); in ahd_intr()
985 if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) { in ahd_intr()
986 if (ahd_is_paused(ahd)) { in ahd_intr()
992 if (ahd_inb(ahd, SEQINTCODE) != NO_SEQINT) in ahd_intr()
996 ahd_flush_device_writes(ahd); in ahd_intr()
998 ahd_run_qoutfifo(ahd); in ahd_intr()
999 ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]++; in ahd_intr()
1000 ahd->cmdcmplt_total++; in ahd_intr()
1002 if ((ahd->flags & AHD_TARGETROLE) != 0) in ahd_intr()
1003 ahd_run_tqinfifo(ahd, /*paused*/FALSE); in ahd_intr()
1011 if (intstat == 0xFF && (ahd->features & AHD_REMOVABLE) != 0) { in ahd_intr()
1014 ahd_handle_hwerrint(ahd); in ahd_intr()
1016 ahd->bus_intr(ahd); in ahd_intr()
1020 ahd_handle_seqint(ahd, intstat); in ahd_intr()
1023 ahd_handle_scsiint(ahd, intstat); in ahd_intr()
1030 ahd_assert_atn(struct ahd_softc *ahd) in ahd_assert_atn() argument
1032 ahd_outb(ahd, SCSISIGO, ATNO); in ahd_assert_atn()
1042 ahd_currently_packetized(struct ahd_softc *ahd) in ahd_currently_packetized() argument
1047 saved_modes = ahd_save_modes(ahd); in ahd_currently_packetized()
1048 if ((ahd->bugs & AHD_PKTIZED_STATUS_BUG) != 0) { in ahd_currently_packetized()
1054 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_currently_packetized()
1055 packetized = ahd_inb(ahd, LQISTATE) != 0; in ahd_currently_packetized()
1057 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_currently_packetized()
1058 packetized = ahd_inb(ahd, LQISTAT2) & PACKETIZED; in ahd_currently_packetized()
1060 ahd_restore_modes(ahd, saved_modes); in ahd_currently_packetized()
1065 ahd_set_active_fifo(struct ahd_softc *ahd) in ahd_set_active_fifo() argument
1069 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_set_active_fifo()
1070 active_fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO; in ahd_set_active_fifo()
1074 ahd_set_modes(ahd, active_fifo, active_fifo); in ahd_set_active_fifo()
1082 ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl) in ahd_unbusy_tcl() argument
1084 ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL); in ahd_unbusy_tcl()
1092 ahd_update_residual(struct ahd_softc *ahd, struct scb *scb) in ahd_update_residual() argument
1098 ahd_calc_residual(ahd, scb); in ahd_update_residual()
1102 ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_complete_scb() argument
1108 ahd_handle_scb_status(ahd, scb); in ahd_complete_scb()
1110 ahd_done(ahd, scb); in ahd_complete_scb()
1119 ahd_restart(struct ahd_softc *ahd) in ahd_restart() argument
1122 ahd_pause(ahd); in ahd_restart()
1124 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_restart()
1127 ahd_clear_msg_state(ahd); in ahd_restart()
1128 ahd_outb(ahd, SCSISIGO, 0); /* De-assert BSY */ in ahd_restart()
1129 ahd_outb(ahd, MSG_OUT, NOP); /* No message to send */ in ahd_restart()
1130 ahd_outb(ahd, SXFRCTL1, ahd_inb(ahd, SXFRCTL1) & ~BITBUCKET); in ahd_restart()
1131 ahd_outb(ahd, SEQINTCTL, 0); in ahd_restart()
1132 ahd_outb(ahd, LASTPHASE, P_BUSFREE); in ahd_restart()
1133 ahd_outb(ahd, SEQ_FLAGS, 0); in ahd_restart()
1134 ahd_outb(ahd, SAVED_SCSIID, 0xFF); in ahd_restart()
1135 ahd_outb(ahd, SAVED_LUN, 0xFF); in ahd_restart()
1144 ahd_outb(ahd, TQINPOS, ahd->tqinfifonext); in ahd_restart()
1147 ahd_outb(ahd, SCSISEQ1, in ahd_restart()
1148 ahd_inb(ahd, SCSISEQ_TEMPLATE) & (ENSELI|ENRSELI|ENAUTOATNP)); in ahd_restart()
1149 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_restart()
1156 ahd_outb(ahd, CLRINT, CLRSEQINT); in ahd_restart()
1158 ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET); in ahd_restart()
1159 ahd_unpause(ahd); in ahd_restart()
1163 ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo) in ahd_clear_fifo() argument
1169 printk("%s: Clearing FIFO %d\n", ahd_name(ahd), fifo); in ahd_clear_fifo()
1171 saved_modes = ahd_save_modes(ahd); in ahd_clear_fifo()
1172 ahd_set_modes(ahd, fifo, fifo); in ahd_clear_fifo()
1173 ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT); in ahd_clear_fifo()
1174 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) in ahd_clear_fifo()
1175 ahd_outb(ahd, CCSGCTL, CCSGRESET); in ahd_clear_fifo()
1176 ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR); in ahd_clear_fifo()
1177 ahd_outb(ahd, SG_STATE, 0); in ahd_clear_fifo()
1178 ahd_restore_modes(ahd, saved_modes); in ahd_clear_fifo()
1187 ahd_flush_qoutfifo(struct ahd_softc *ahd) in ahd_flush_qoutfifo() argument
1196 saved_modes = ahd_save_modes(ahd); in ahd_flush_qoutfifo()
1201 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_flush_qoutfifo()
1202 saved_scbptr = ahd_get_scbptr(ahd); in ahd_flush_qoutfifo()
1203 while ((ahd_inb(ahd, LQISTAT2) & LQIGSAVAIL) != 0) { in ahd_flush_qoutfifo()
1207 scbid = ahd_inw(ahd, GSFIFO); in ahd_flush_qoutfifo()
1208 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1211 ahd_name(ahd), scbid); in ahd_flush_qoutfifo()
1224 ahd_set_modes(ahd, fifo_mode, fifo_mode); in ahd_flush_qoutfifo()
1226 if (ahd_scb_active_in_fifo(ahd, scb) == 0) in ahd_flush_qoutfifo()
1229 ahd_run_data_fifo(ahd, scb); in ahd_flush_qoutfifo()
1248 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_flush_qoutfifo()
1249 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1250 if ((ahd_inb_scbram(ahd, SCB_SGPTR) & SG_LIST_NULL) == 0 in ahd_flush_qoutfifo()
1251 && ((ahd_inb_scbram(ahd, SCB_SGPTR) & SG_FULL_RESID) != 0 in ahd_flush_qoutfifo()
1252 || (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR) in ahd_flush_qoutfifo()
1262 ahd_outb(ahd, SCB_SCSI_STATUS, 0); in ahd_flush_qoutfifo()
1263 ahd_outb(ahd, SCB_SGPTR, in ahd_flush_qoutfifo()
1264 ahd_inb_scbram(ahd, SCB_SGPTR) in ahd_flush_qoutfifo()
1266 ahd_outw(ahd, SCB_TAG, scbid); in ahd_flush_qoutfifo()
1267 ahd_outw(ahd, SCB_NEXT_COMPLETE, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1268 comp_head = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD); in ahd_flush_qoutfifo()
1270 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, scbid); in ahd_flush_qoutfifo()
1271 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid); in ahd_flush_qoutfifo()
1275 tail = ahd_inw(ahd, COMPLETE_DMA_SCB_TAIL); in ahd_flush_qoutfifo()
1276 ahd_set_scbptr(ahd, tail); in ahd_flush_qoutfifo()
1277 ahd_outw(ahd, SCB_NEXT_COMPLETE, scbid); in ahd_flush_qoutfifo()
1278 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid); in ahd_flush_qoutfifo()
1279 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1282 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1284 ahd_set_scbptr(ahd, saved_scbptr); in ahd_flush_qoutfifo()
1289 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_flush_qoutfifo()
1295 while (((ccscbctl = ahd_inb(ahd, CCSCBCTL)) & (CCARREN|CCSCBEN)) != 0) { in ahd_flush_qoutfifo()
1312 ahd_outb(ahd, CCSCBCTL, ccscbctl & ~(CCARREN|CCSCBEN)); in ahd_flush_qoutfifo()
1318 ahd_run_qoutfifo(ahd); in ahd_flush_qoutfifo()
1320 saved_scbptr = ahd_get_scbptr(ahd); in ahd_flush_qoutfifo()
1325 scbid = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD); in ahd_flush_qoutfifo()
1330 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1331 next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_flush_qoutfifo()
1332 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1335 "SCB %d invalid\n", ahd_name(ahd), scbid); in ahd_flush_qoutfifo()
1340 *hscb_ptr++ = ahd_inb_scbram(ahd, SCB_BASE + i); in ahd_flush_qoutfifo()
1342 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1345 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1346 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1348 scbid = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD); in ahd_flush_qoutfifo()
1351 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1352 next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_flush_qoutfifo()
1353 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1356 ahd_name(ahd), scbid); in ahd_flush_qoutfifo()
1360 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1363 ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1365 scbid = ahd_inw(ahd, COMPLETE_SCB_HEAD); in ahd_flush_qoutfifo()
1368 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1369 next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_flush_qoutfifo()
1370 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1373 ahd_name(ahd), scbid); in ahd_flush_qoutfifo()
1377 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1380 ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1385 ahd_set_scbptr(ahd, saved_scbptr); in ahd_flush_qoutfifo()
1386 ahd_restore_modes(ahd, saved_modes); in ahd_flush_qoutfifo()
1387 ahd->flags |= AHD_UPDATE_PEND_CMDS; in ahd_flush_qoutfifo()
1395 ahd_scb_active_in_fifo(struct ahd_softc *ahd, struct scb *scb) in ahd_scb_active_in_fifo() argument
1404 if (ahd_get_scbptr(ahd) != SCB_GET_TAG(scb) in ahd_scb_active_in_fifo()
1405 || ((ahd_inb(ahd, LONGJMP_ADDR+1) & INVALID_ADDR) != 0 in ahd_scb_active_in_fifo()
1406 && (ahd_inb(ahd, SEQINTSRC) & (CFG4DATA|SAVEPTRS)) == 0)) in ahd_scb_active_in_fifo()
1424 ahd_run_data_fifo(struct ahd_softc *ahd, struct scb *scb) in ahd_run_data_fifo() argument
1428 seqintsrc = ahd_inb(ahd, SEQINTSRC); in ahd_run_data_fifo()
1436 sgptr = ahd_inl_scbram(ahd, SCB_SGPTR) & ~SG_FULL_RESID; in ahd_run_data_fifo()
1437 ahd_outb(ahd, SCB_SGPTR, sgptr); in ahd_run_data_fifo()
1442 datacnt = ahd_inl_scbram(ahd, SCB_DATACNT); in ahd_run_data_fifo()
1445 ahd_outb(ahd, SG_STATE, 0); in ahd_run_data_fifo()
1447 ahd_outb(ahd, SG_STATE, LOADING_NEEDED); in ahd_run_data_fifo()
1448 ahd_outq(ahd, HADDR, ahd_inq_scbram(ahd, SCB_DATAPTR)); in ahd_run_data_fifo()
1449 ahd_outl(ahd, HCNT, datacnt & AHD_SG_LEN_MASK); in ahd_run_data_fifo()
1450 ahd_outb(ahd, SG_CACHE_PRE, sgptr); in ahd_run_data_fifo()
1451 ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN); in ahd_run_data_fifo()
1456 ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, datacnt >> 24); in ahd_run_data_fifo()
1457 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr & SG_PTR_MASK); in ahd_run_data_fifo()
1462 ahd_outb(ahd, SCB_FIFO_USE_COUNT, in ahd_run_data_fifo()
1463 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) + 1); in ahd_run_data_fifo()
1468 ahd_outw(ahd, LONGJMP_ADDR, 0); in ahd_run_data_fifo()
1474 ahd_outb(ahd, CLRSEQINTSRC, CLRCFG4DATA); in ahd_run_data_fifo()
1479 if ((ahd_inb(ahd, LONGJMP_ADDR+1)&INVALID_ADDR) != 0) { in ahd_run_data_fifo()
1492 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) in ahd_run_data_fifo()
1493 ahd_outb(ahd, CCSGCTL, 0); in ahd_run_data_fifo()
1494 ahd_outb(ahd, SG_STATE, 0); in ahd_run_data_fifo()
1500 ahd_outb(ahd, DFCNTRL, ahd_inb(ahd, DFCNTRL) | FIFOFLUSH); in ahd_run_data_fifo()
1505 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_run_data_fifo()
1506 resid = ahd_inl(ahd, SHCNT); in ahd_run_data_fifo()
1507 resid |= ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT+3) << 24; in ahd_run_data_fifo()
1508 ahd_outl(ahd, SCB_RESIDUAL_DATACNT, resid); in ahd_run_data_fifo()
1509 if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG) == 0) { in ahd_run_data_fifo()
1517 if ((ahd_inb(ahd, SG_CACHE_SHADOW) & 0x80) != 0 in ahd_run_data_fifo()
1521 sgptr |= ahd_inb(ahd, SG_CACHE_SHADOW) in ahd_run_data_fifo()
1523 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr); in ahd_run_data_fifo()
1524 ahd_outb(ahd, SCB_RESIDUAL_DATACNT + 3, 0); in ahd_run_data_fifo()
1526 ahd_outb(ahd, SCB_RESIDUAL_SGPTR, in ahd_run_data_fifo()
1532 ahd_outq(ahd, SCB_DATAPTR, ahd_inq(ahd, SHADDR)); in ahd_run_data_fifo()
1533 ahd_outl(ahd, SCB_DATACNT, resid); in ahd_run_data_fifo()
1534 ahd_outl(ahd, SCB_SGPTR, sgptr); in ahd_run_data_fifo()
1535 ahd_outb(ahd, CLRSEQINTSRC, CLRSAVEPTRS); in ahd_run_data_fifo()
1536 ahd_outb(ahd, SEQIMODE, in ahd_run_data_fifo()
1537 ahd_inb(ahd, SEQIMODE) | ENSAVEPTRS); in ahd_run_data_fifo()
1542 if ((ahd_inb(ahd, DFCNTRL) & DIRECTION) != 0) in ahd_run_data_fifo()
1544 } else if ((ahd_inb(ahd, SG_STATE) & LOADING_NEEDED) != 0) { in ahd_run_data_fifo()
1555 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) { in ahd_run_data_fifo()
1556 ahd_outb(ahd, CCSGCTL, 0); in ahd_run_data_fifo()
1557 ahd_outb(ahd, SG_STATE, LOADING_NEEDED); in ahd_run_data_fifo()
1566 if ((ahd_inb(ahd, DFSTATUS) & PRELOAD_AVAIL) != 0 in ahd_run_data_fifo()
1567 && (ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0) { in ahd_run_data_fifo()
1573 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_run_data_fifo()
1575 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_run_data_fifo()
1578 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_run_data_fifo()
1585 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_run_data_fifo()
1596 ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, data_len >> 24); in ahd_run_data_fifo()
1597 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr); in ahd_run_data_fifo()
1604 ahd_outb(ahd, SG_STATE, 0); in ahd_run_data_fifo()
1606 ahd_outq(ahd, HADDR, data_addr); in ahd_run_data_fifo()
1607 ahd_outl(ahd, HCNT, data_len & AHD_SG_LEN_MASK); in ahd_run_data_fifo()
1608 ahd_outb(ahd, SG_CACHE_PRE, sgptr & 0xFF); in ahd_run_data_fifo()
1613 dfcntrl = ahd_inb(ahd, DFCNTRL)|PRELOADEN|HDMAEN; in ahd_run_data_fifo()
1614 if ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0) { in ahd_run_data_fifo()
1622 ahd_outb(ahd, DFCNTRL, dfcntrl); in ahd_run_data_fifo()
1624 } else if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG_DONE) != 0) { in ahd_run_data_fifo()
1630 ahd_outb(ahd, SCB_SGPTR, in ahd_run_data_fifo()
1631 ahd_inb_scbram(ahd, SCB_SGPTR) | SG_LIST_NULL); in ahd_run_data_fifo()
1633 } else if ((ahd_inb(ahd, DFSTATUS) & FIFOEMP) != 0) { in ahd_run_data_fifo()
1640 ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR); in ahd_run_data_fifo()
1641 ahd_outb(ahd, SCB_FIFO_USE_COUNT, in ahd_run_data_fifo()
1642 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) - 1); in ahd_run_data_fifo()
1643 ahd_outb(ahd, DFFSXFRCTL, CLRCHN); in ahd_run_data_fifo()
1658 ahd_run_qoutfifo(struct ahd_softc *ahd) in ahd_run_qoutfifo() argument
1664 if ((ahd->flags & AHD_RUNNING_QOUTFIFO) != 0) in ahd_run_qoutfifo()
1666 ahd->flags |= AHD_RUNNING_QOUTFIFO; in ahd_run_qoutfifo()
1667 ahd_sync_qoutfifo(ahd, BUS_DMASYNC_POSTREAD); in ahd_run_qoutfifo()
1669 completion = &ahd->qoutfifo[ahd->qoutfifonext]; in ahd_run_qoutfifo()
1671 if (completion->valid_tag != ahd->qoutfifonext_valid_tag) in ahd_run_qoutfifo()
1675 scb = ahd_lookup_scb(ahd, scb_index); in ahd_run_qoutfifo()
1679 ahd_name(ahd), scb_index, in ahd_run_qoutfifo()
1680 ahd->qoutfifonext); in ahd_run_qoutfifo()
1681 ahd_dump_card_state(ahd); in ahd_run_qoutfifo()
1683 ahd_handle_scb_status(ahd, scb); in ahd_run_qoutfifo()
1685 ahd_done(ahd, scb); in ahd_run_qoutfifo()
1688 ahd->qoutfifonext = (ahd->qoutfifonext+1) & (AHD_QOUT_SIZE-1); in ahd_run_qoutfifo()
1689 if (ahd->qoutfifonext == 0) in ahd_run_qoutfifo()
1690 ahd->qoutfifonext_valid_tag ^= QOUTFIFO_ENTRY_VALID; in ahd_run_qoutfifo()
1692 ahd->flags &= ~AHD_RUNNING_QOUTFIFO; in ahd_run_qoutfifo()
1697 ahd_handle_hwerrint(struct ahd_softc *ahd) in ahd_handle_hwerrint() argument
1706 error = ahd_inb(ahd, ERROR); in ahd_handle_hwerrint()
1710 ahd_name(ahd), ahd_hard_errors[i].errmesg); in ahd_handle_hwerrint()
1713 ahd_dump_card_state(ahd); in ahd_handle_hwerrint()
1717 ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS, in ahd_handle_hwerrint()
1722 ahd_free(ahd); in ahd_handle_hwerrint()
1769 ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat) in ahd_handle_seqint() argument
1778 seqintcode = ahd_inb(ahd, SEQINTCODE); in ahd_handle_seqint()
1779 ahd_outb(ahd, CLRINT, CLRSEQINT); in ahd_handle_seqint()
1780 if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) { in ahd_handle_seqint()
1787 ahd_unpause(ahd); in ahd_handle_seqint()
1788 while (!ahd_is_paused(ahd)) in ahd_handle_seqint()
1790 ahd_outb(ahd, CLRINT, CLRSEQINT); in ahd_handle_seqint()
1792 ahd_update_modes(ahd); in ahd_handle_seqint()
1796 ahd_name(ahd), seqintcode); in ahd_handle_seqint()
1804 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_handle_seqint()
1806 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
1807 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1816 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid); in ahd_handle_seqint()
1817 ahd_outb(ahd, SAVED_LUN, scb->hscb->lun); in ahd_handle_seqint()
1818 ahd_outb(ahd, SEQ_FLAGS, 0x0); in ahd_handle_seqint()
1820 if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0 in ahd_handle_seqint()
1821 && (ahd_inb(ahd, SCSISIGO) & ATNO) != 0) { in ahd_handle_seqint()
1830 "P0 assertion\n", ahd_name(ahd)); in ahd_handle_seqint()
1835 printk("%s: Entering NONPACK\n", ahd_name(ahd)); in ahd_handle_seqint()
1842 ahd_name(ahd)); in ahd_handle_seqint()
1845 ahd_dump_card_state(ahd); in ahd_handle_seqint()
1847 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_seqint()
1854 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
1855 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1857 ahd_print_path(ahd, scb); in ahd_handle_seqint()
1859 printk("%s: ", ahd_name(ahd)); in ahd_handle_seqint()
1861 ahd_dump_card_state(ahd); in ahd_handle_seqint()
1862 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_seqint()
1870 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
1871 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1873 ahd_dump_card_state(ahd); in ahd_handle_seqint()
1877 ahd_outq(ahd, HADDR, scb->sense_busaddr); in ahd_handle_seqint()
1878 ahd_outw(ahd, HCNT, AHD_SENSE_BUFSIZE); in ahd_handle_seqint()
1879 ahd_outb(ahd, HCNT + 2, 0); in ahd_handle_seqint()
1880 ahd_outb(ahd, SG_CACHE_PRE, SG_LAST_SEG); in ahd_handle_seqint()
1881 ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN); in ahd_handle_seqint()
1888 bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK; in ahd_handle_seqint()
1890 ahd_name(ahd), bus_phase); in ahd_handle_seqint()
1900 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_seqint()
1901 printk("%s: Issued Bus Reset.\n", ahd_name(ahd)); in ahd_handle_seqint()
1920 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
1921 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1925 ahd_reset_channel(ahd, 'A', in ahd_handle_seqint()
1930 SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
1932 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_seqint()
1934 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_handle_seqint()
1936 ahd_set_syncrate(ahd, &devinfo, /*period*/0, in ahd_handle_seqint()
1940 ahd_outb(ahd, SCB_CDB_STORE, 0); in ahd_handle_seqint()
1941 ahd_outb(ahd, SCB_CDB_STORE+1, 0); in ahd_handle_seqint()
1942 ahd_outb(ahd, SCB_CDB_STORE+2, 0); in ahd_handle_seqint()
1943 ahd_outb(ahd, SCB_CDB_STORE+3, 0); in ahd_handle_seqint()
1944 ahd_outb(ahd, SCB_CDB_STORE+4, 0); in ahd_handle_seqint()
1945 ahd_outb(ahd, SCB_CDB_STORE+5, 0); in ahd_handle_seqint()
1946 ahd_outb(ahd, SCB_CDB_LEN, 6); in ahd_handle_seqint()
1949 ahd_outb(ahd, SCB_CONTROL, scb->hscb->control); in ahd_handle_seqint()
1950 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_seqint()
1951 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid); in ahd_handle_seqint()
1956 ahd_outb(ahd, SAVED_LUN, 0); in ahd_handle_seqint()
1957 ahd_outb(ahd, SEQ_FLAGS, 0); in ahd_handle_seqint()
1958 ahd_assert_atn(ahd); in ahd_handle_seqint()
1961 ahd_freeze_devq(ahd, scb); in ahd_handle_seqint()
1966 ahd_send_async(ahd, devinfo.channel, devinfo.target, in ahd_handle_seqint()
1973 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_seqint()
1974 ahd_outb(ahd, CLRLQOINT1, CLRLQOPHACHGINPKT); in ahd_handle_seqint()
1975 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) { in ahd_handle_seqint()
1976 ahd_outb(ahd, CLRLQOINT1, 0); in ahd_handle_seqint()
1980 ahd_print_path(ahd, scb); in ahd_handle_seqint()
1997 printk("%s: CFG4OVERRUN mode = %x\n", ahd_name(ahd), in ahd_handle_seqint()
1998 ahd_inb(ahd, MODE_PTR)); in ahd_handle_seqint()
2001 scb_index = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2002 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_seqint()
2008 ahd_assert_atn(ahd); in ahd_handle_seqint()
2009 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_seqint()
2010 ahd->msgout_buf[0] = ABORT_TASK; in ahd_handle_seqint()
2011 ahd->msgout_len = 1; in ahd_handle_seqint()
2012 ahd->msgout_index = 0; in ahd_handle_seqint()
2013 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_handle_seqint()
2018 ahd_outb(ahd, SCB_CONTROL, in ahd_handle_seqint()
2019 ahd_inb_scbram(ahd, SCB_CONTROL) in ahd_handle_seqint()
2026 ahd_dump_card_state(ahd); in ahd_handle_seqint()
2035 ahd_name(ahd), ahd_inb(ahd, DFCNTRL), in ahd_handle_seqint()
2036 ahd_inb(ahd, SG_CACHE_SHADOW)); in ahd_handle_seqint()
2039 ahd_reinitialize_dataptrs(ahd); in ahd_handle_seqint()
2057 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_seqint()
2058 if (ahd->msg_type == MSG_TYPE_NONE) { in ahd_handle_seqint()
2063 bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK; in ahd_handle_seqint()
2072 ahd_dump_card_state(ahd); in ahd_handle_seqint()
2073 ahd_clear_intstat(ahd); in ahd_handle_seqint()
2074 ahd_restart(ahd); in ahd_handle_seqint()
2078 scb_index = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2079 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_seqint()
2082 ahd_setup_initiator_msgout(ahd, in ahd_handle_seqint()
2086 ahd->msg_type = in ahd_handle_seqint()
2088 ahd->msgin_index = 0; in ahd_handle_seqint()
2094 ahd->msg_type = in ahd_handle_seqint()
2096 ahd->msgin_index = 0; in ahd_handle_seqint()
2098 ahd_setup_target_msgin(ahd, in ahd_handle_seqint()
2105 ahd_handle_message_phase(ahd); in ahd_handle_seqint()
2111 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_handle_seqint()
2112 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO); in ahd_handle_seqint()
2116 ahd_name(ahd), 'A', ahd_inb(ahd, SELID) >> 4); in ahd_handle_seqint()
2119 ahd_inb(ahd, SAVED_SCSIID), ahd_inb(ahd, SAVED_LUN), in ahd_handle_seqint()
2120 ahd_inw(ahd, REG0), ahd_inb(ahd, ACCUM)); in ahd_handle_seqint()
2123 ahd_inb(ahd, SEQ_FLAGS), ahd_get_scbptr(ahd), in ahd_handle_seqint()
2124 ahd_find_busy_tcl(ahd, in ahd_handle_seqint()
2125 BUILD_TCL(ahd_inb(ahd, SAVED_SCSIID), in ahd_handle_seqint()
2126 ahd_inb(ahd, SAVED_LUN))), in ahd_handle_seqint()
2127 ahd_inw(ahd, SINDEX)); in ahd_handle_seqint()
2130 ahd_inb(ahd, SELID), ahd_inb_scbram(ahd, SCB_SCSIID), in ahd_handle_seqint()
2131 ahd_inb_scbram(ahd, SCB_LUN), in ahd_handle_seqint()
2132 ahd_inb_scbram(ahd, SCB_CONTROL)); in ahd_handle_seqint()
2134 ahd_inb(ahd, SCSIBUS), ahd_inb(ahd, SCSISIGI)); in ahd_handle_seqint()
2135 printk("SXFRCTL0 == 0x%x\n", ahd_inb(ahd, SXFRCTL0)); in ahd_handle_seqint()
2136 printk("SEQCTL0 == 0x%x\n", ahd_inb(ahd, SEQCTL0)); in ahd_handle_seqint()
2137 ahd_dump_card_state(ahd); in ahd_handle_seqint()
2138 ahd->msgout_buf[0] = TARGET_RESET; in ahd_handle_seqint()
2139 ahd->msgout_len = 1; in ahd_handle_seqint()
2140 ahd->msgout_index = 0; in ahd_handle_seqint()
2141 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_handle_seqint()
2142 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_seqint()
2143 ahd_assert_atn(ahd); in ahd_handle_seqint()
2148 ahd_handle_proto_violation(ahd); in ahd_handle_seqint()
2155 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_seqint()
2156 ahd_handle_ign_wide_residue(ahd, &devinfo); in ahd_handle_seqint()
2163 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_seqint()
2166 ahd_name(ahd), 'A', in ahd_handle_seqint()
2167 SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)), in ahd_handle_seqint()
2168 lastphase, ahd_inb(ahd, SCSISIGI)); in ahd_handle_seqint()
2175 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_seqint()
2178 ahd_name(ahd), 'A', in ahd_handle_seqint()
2179 SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)), in ahd_handle_seqint()
2180 lastphase, ahd_inb(ahd, SCSISIGI)); in ahd_handle_seqint()
2181 ahd_restart(ahd); in ahd_handle_seqint()
2200 scbindex = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2201 scb = ahd_lookup_scb(ahd, scbindex); in ahd_handle_seqint()
2203 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_seqint()
2205 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2209 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2212 ahd_inb(ahd, SEQ_FLAGS) & DPHASE in ahd_handle_seqint()
2223 ahd_freeze_devq(ahd, scb); in ahd_handle_seqint()
2234 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_seqint()
2236 ahd_name(ahd), devinfo.channel, devinfo.target, in ahd_handle_seqint()
2238 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2239 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
2246 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
2247 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_seqint()
2251 ahd_outb(ahd, SCB_CONTROL, in ahd_handle_seqint()
2252 ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE); in ahd_handle_seqint()
2260 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2261 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
2267 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2281 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
2292 ahd_scb_devinfo(ahd, &devinfo, scb); in ahd_handle_seqint()
2294 ahd_handle_devreset(ahd, &devinfo, lun, in ahd_handle_seqint()
2318 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2319 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
2325 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2334 while ((ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0 in ahd_handle_seqint()
2335 && (ahd_inb(ahd, SSTAT0) & SELDO) == 0 in ahd_handle_seqint()
2336 && (ahd_inb(ahd, SSTAT1) & SELTO) == 0) in ahd_handle_seqint()
2338 ahd_outb(ahd, SCB_TASK_MANAGEMENT, 0); in ahd_handle_seqint()
2339 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
2340 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_seqint()
2351 printk("%s: Tracepoint %d\n", ahd_name(ahd), in ahd_handle_seqint()
2357 ahd_handle_hwerrint(ahd); in ahd_handle_seqint()
2360 printk("%s: Unexpected SEQINTCODE %d\n", ahd_name(ahd), in ahd_handle_seqint()
2369 ahd_unpause(ahd); in ahd_handle_seqint()
2373 ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat) in ahd_handle_scsiint() argument
2384 ahd_update_modes(ahd); in ahd_handle_scsiint()
2385 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_scsiint()
2387 status3 = ahd_inb(ahd, SSTAT3) & (NTRAMPERR|OSRAMPERR); in ahd_handle_scsiint()
2388 status0 = ahd_inb(ahd, SSTAT0) & (IOERR|OVERRUN|SELDI|SELDO); in ahd_handle_scsiint()
2389 status = ahd_inb(ahd, SSTAT1) & (SELTO|SCSIRSTI|BUSFREE|SCSIPERR); in ahd_handle_scsiint()
2390 lqistat1 = ahd_inb(ahd, LQISTAT1); in ahd_handle_scsiint()
2391 lqostat0 = ahd_inb(ahd, LQOSTAT0); in ahd_handle_scsiint()
2392 busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME; in ahd_handle_scsiint()
2397 if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) { in ahd_handle_scsiint()
2398 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI); in ahd_handle_scsiint()
2405 ahd->flags &= ~AHD_BUS_RESET_ACTIVE; in ahd_handle_scsiint()
2410 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_handle_scsiint()
2411 simode0 = ahd_inb(ahd, SIMODE0); in ahd_handle_scsiint()
2413 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_scsiint()
2415 scbid = ahd_get_scbptr(ahd); in ahd_handle_scsiint()
2416 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_scsiint()
2418 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0) in ahd_handle_scsiint()
2424 now_lvd = ahd_inb(ahd, SBLKCTL) & ENAB40; in ahd_handle_scsiint()
2426 ahd_name(ahd), now_lvd ? "LVD" : "SE"); in ahd_handle_scsiint()
2427 ahd_outb(ahd, CLRSINT0, CLRIOERR); in ahd_handle_scsiint()
2431 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_scsiint()
2432 ahd_pause(ahd); in ahd_handle_scsiint()
2433 ahd_setup_iocell_workaround(ahd); in ahd_handle_scsiint()
2434 ahd_unpause(ahd); in ahd_handle_scsiint()
2438 ahd_name(ahd)); in ahd_handle_scsiint()
2439 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_scsiint()
2442 printk("%s: Someone reset channel A\n", ahd_name(ahd)); in ahd_handle_scsiint()
2443 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE); in ahd_handle_scsiint()
2447 ahd_clear_critical_section(ahd); in ahd_handle_scsiint()
2449 ahd_handle_transmission_error(ahd); in ahd_handle_scsiint()
2452 printk("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0); in ahd_handle_scsiint()
2453 ahd_outb(ahd, CLRLQOINT0, lqostat0); in ahd_handle_scsiint()
2454 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) in ahd_handle_scsiint()
2455 ahd_outb(ahd, CLRLQOINT1, 0); in ahd_handle_scsiint()
2458 ahd_outb(ahd, SCSISEQ0, 0); in ahd_handle_scsiint()
2461 ahd_clear_critical_section(ahd); in ahd_handle_scsiint()
2464 ahd_clear_msg_state(ahd); in ahd_handle_scsiint()
2467 ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRBUSFREE|CLRSCSIPERR); in ahd_handle_scsiint()
2477 ahd_outb(ahd, CLRSINT0, CLRSELINGO); in ahd_handle_scsiint()
2479 scbid = ahd_inw(ahd, WAITING_TID_HEAD); in ahd_handle_scsiint()
2480 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_scsiint()
2484 ahd_name(ahd), scbid); in ahd_handle_scsiint()
2485 ahd_dump_card_state(ahd); in ahd_handle_scsiint()
2490 ahd_print_path(ahd, scb); in ahd_handle_scsiint()
2495 ahd_scb_devinfo(ahd, &devinfo, scb); in ahd_handle_scsiint()
2497 ahd_freeze_devq(ahd, scb); in ahd_handle_scsiint()
2505 ahd_handle_devreset(ahd, &devinfo, in ahd_handle_scsiint()
2511 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_handle_scsiint()
2512 ahd_iocell_first_selection(ahd); in ahd_handle_scsiint()
2513 ahd_unpause(ahd); in ahd_handle_scsiint()
2516 ahd_iocell_first_selection(ahd); in ahd_handle_scsiint()
2517 ahd_unpause(ahd); in ahd_handle_scsiint()
2520 ahd_name(ahd), status3); in ahd_handle_scsiint()
2521 ahd_outb(ahd, CLRSINT3, status3); in ahd_handle_scsiint()
2525 ahd_clear_critical_section(ahd); in ahd_handle_scsiint()
2527 ahd_handle_lqiphase_error(ahd, lqistat1); in ahd_handle_scsiint()
2535 ahd_outb(ahd, CLRLQIINT1, CLRLQICRCI_NLQ); in ahd_handle_scsiint()
2550 ahd_outb(ahd, SCSISEQ0, 0); in ahd_handle_scsiint()
2553 ahd_clear_critical_section(ahd); in ahd_handle_scsiint()
2560 busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME; in ahd_handle_scsiint()
2561 lqostat1 = ahd_inb(ahd, LQOSTAT1); in ahd_handle_scsiint()
2568 ahd_set_modes(ahd, mode, mode); in ahd_handle_scsiint()
2569 scbid = ahd_get_scbptr(ahd); in ahd_handle_scsiint()
2570 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_scsiint()
2574 ahd_name(ahd), scbid, mode); in ahd_handle_scsiint()
2589 && ahd_inb(ahd, LASTPHASE) == P_BUSFREE in ahd_handle_scsiint()
2590 && (ahd_inb(ahd, SSTAT0) & SELDI) == 0 in ahd_handle_scsiint()
2591 && ((ahd_inb(ahd, SSTAT0) & SELDO) == 0 in ahd_handle_scsiint()
2592 || (ahd_inb(ahd, SCSISEQ0) & ENSELO) == 0)) in ahd_handle_scsiint()
2612 if (packetized && ahd_inb(ahd, LASTPHASE) == P_BUSFREE) { in ahd_handle_scsiint()
2613 restart = ahd_handle_pkt_busfree(ahd, busfreetime); in ahd_handle_scsiint()
2616 restart = ahd_handle_nonpkt_busfree(ahd); in ahd_handle_scsiint()
2629 ahd_outb(ahd, CLRSINT1, CLRBUSFREE); in ahd_handle_scsiint()
2631 && (ahd->bugs & AHD_BUSFREEREV_BUG) != 0) in ahd_handle_scsiint()
2632 ahd_outb(ahd, SIMODE1, in ahd_handle_scsiint()
2633 ahd_inb(ahd, SIMODE1) & ~ENBUSFREE); in ahd_handle_scsiint()
2636 ahd_clear_fifo(ahd, mode); in ahd_handle_scsiint()
2638 ahd_clear_msg_state(ahd); in ahd_handle_scsiint()
2639 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_handle_scsiint()
2641 ahd_restart(ahd); in ahd_handle_scsiint()
2643 ahd_unpause(ahd); in ahd_handle_scsiint()
2647 ahd_name(ahd), status); in ahd_handle_scsiint()
2648 ahd_dump_card_state(ahd); in ahd_handle_scsiint()
2649 ahd_clear_intstat(ahd); in ahd_handle_scsiint()
2650 ahd_unpause(ahd); in ahd_handle_scsiint()
2655 ahd_handle_transmission_error(struct ahd_softc *ahd) in ahd_handle_transmission_error() argument
2668 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_transmission_error()
2669 lqistat1 = ahd_inb(ahd, LQISTAT1) & ~(LQIPHASE_LQ|LQIPHASE_NLQ); in ahd_handle_transmission_error()
2670 ahd_inb(ahd, LQISTAT2); in ahd_handle_transmission_error()
2672 && (ahd->bugs & AHD_NLQICRC_DELAYED_BUG) != 0) { in ahd_handle_transmission_error()
2675 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_handle_transmission_error()
2676 lqistate = ahd_inb(ahd, LQISTATE); in ahd_handle_transmission_error()
2682 ahd_name(ahd)); in ahd_handle_transmission_error()
2687 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_transmission_error()
2690 ahd_outb(ahd, CLRLQIINT1, lqistat1); in ahd_handle_transmission_error()
2691 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_transmission_error()
2692 curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK; in ahd_handle_transmission_error()
2693 perrdiag = ahd_inb(ahd, PERRDIAG); in ahd_handle_transmission_error()
2695 ahd_outb(ahd, CLRSINT1, CLRSCSIPERR); in ahd_handle_transmission_error()
2704 ahd_set_active_fifo(ahd); in ahd_handle_transmission_error()
2705 scbid = ahd_get_scbptr(ahd); in ahd_handle_transmission_error()
2706 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_transmission_error()
2713 printk("%s: Transmission error detected\n", ahd_name(ahd)); in ahd_handle_transmission_error()
2719 ahd_dump_card_state(ahd); in ahd_handle_transmission_error()
2726 ahd_name(ahd), lqistat1); in ahd_handle_transmission_error()
2728 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_transmission_error()
2752 ahd_outb(ahd, LQCTL2, LQIRETRY); in ahd_handle_transmission_error()
2804 "Resetting bus\n", ahd_name(ahd)); in ahd_handle_transmission_error()
2805 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_transmission_error()
2810 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_transmission_error()
2818 ahd_inb(ahd, SCSIDAT); in ahd_handle_transmission_error()
2832 ahd->send_msg_perror = msg_out; in ahd_handle_transmission_error()
2835 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_transmission_error()
2836 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_handle_transmission_error()
2837 ahd_unpause(ahd); in ahd_handle_transmission_error()
2841 ahd_handle_lqiphase_error(struct ahd_softc *ahd, u_int lqistat1) in ahd_handle_lqiphase_error() argument
2846 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_lqiphase_error()
2847 ahd_outb(ahd, CLRLQIINT1, lqistat1); in ahd_handle_lqiphase_error()
2857 ahd_set_active_fifo(ahd); in ahd_handle_lqiphase_error()
2858 if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0 in ahd_handle_lqiphase_error()
2859 && (ahd_inb(ahd, MDFFSTAT) & DLZERO) != 0) { in ahd_handle_lqiphase_error()
2862 ahd_outb(ahd, LQCTL2, LQIRETRY); in ahd_handle_lqiphase_error()
2865 ahd_outb(ahd, LQCTL2, LQIRETRY); in ahd_handle_lqiphase_error()
2868 ahd_dump_card_state(ahd); in ahd_handle_lqiphase_error()
2869 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_handle_lqiphase_error()
2870 ahd_unpause(ahd); in ahd_handle_lqiphase_error()
2873 ahd_dump_card_state(ahd); in ahd_handle_lqiphase_error()
2874 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_lqiphase_error()
2883 ahd_handle_pkt_busfree(struct ahd_softc *ahd, u_int busfreetime) in ahd_handle_pkt_busfree() argument
2887 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_handle_pkt_busfree()
2889 lqostat1 = ahd_inb(ahd, LQOSTAT1); in ahd_handle_pkt_busfree()
2913 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_pkt_busfree()
2914 scbid = ahd_inw(ahd, CURRSCB); in ahd_handle_pkt_busfree()
2915 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_pkt_busfree()
2921 ahd_outb(ahd, CLRLQOINT1, CLRLQOBUSFREE); in ahd_handle_pkt_busfree()
2922 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) in ahd_handle_pkt_busfree()
2923 ahd_outb(ahd, CLRLQOINT1, 0); in ahd_handle_pkt_busfree()
2924 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO); in ahd_handle_pkt_busfree()
2925 ahd_flush_device_writes(ahd); in ahd_handle_pkt_busfree()
2926 ahd_outb(ahd, CLRSINT0, CLRSELDO); in ahd_handle_pkt_busfree()
2934 ahd_outb(ahd, LQCTL2, ahd_inb(ahd, LQCTL2) | LQOTOIDLE); in ahd_handle_pkt_busfree()
2940 waiting_h = ahd_inw(ahd, WAITING_TID_HEAD); in ahd_handle_pkt_busfree()
2941 saved_scbptr = ahd_get_scbptr(ahd); in ahd_handle_pkt_busfree()
2944 ahd_outw(ahd, WAITING_TID_HEAD, scbid); in ahd_handle_pkt_busfree()
2945 waiting_t = ahd_inw(ahd, WAITING_TID_TAIL); in ahd_handle_pkt_busfree()
2947 ahd_outw(ahd, WAITING_TID_TAIL, scbid); in ahd_handle_pkt_busfree()
2950 ahd_set_scbptr(ahd, waiting_h); in ahd_handle_pkt_busfree()
2951 next = ahd_inw_scbram(ahd, SCB_NEXT2); in ahd_handle_pkt_busfree()
2953 ahd_set_scbptr(ahd, scbid); in ahd_handle_pkt_busfree()
2954 ahd_outw(ahd, SCB_NEXT2, next); in ahd_handle_pkt_busfree()
2956 ahd_set_scbptr(ahd, saved_scbptr); in ahd_handle_pkt_busfree()
2959 ahd_print_path(ahd, scb); in ahd_handle_pkt_busfree()
2967 ahd_freeze_devq(ahd, scb); in ahd_handle_pkt_busfree()
2971 } else if ((ahd_inb(ahd, PERRDIAG) & PARITYERR) != 0) { in ahd_handle_pkt_busfree()
2979 ahd_outb(ahd, CLRSINT1, CLRSCSIPERR|CLRBUSFREE); in ahd_handle_pkt_busfree()
2984 ahd_name(ahd)); in ahd_handle_pkt_busfree()
2989 if (ahd->src_mode != AHD_MODE_SCSI) { in ahd_handle_pkt_busfree()
2993 scbid = ahd_get_scbptr(ahd); in ahd_handle_pkt_busfree()
2994 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_pkt_busfree()
2995 ahd_print_path(ahd, scb); in ahd_handle_pkt_busfree()
2997 ahd_dump_card_state(ahd); in ahd_handle_pkt_busfree()
2998 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), 'A', in ahd_handle_pkt_busfree()
3005 printk("%s: Unexpected PKT busfree condition\n", ahd_name(ahd)); in ahd_handle_pkt_busfree()
3006 ahd_dump_card_state(ahd); in ahd_handle_pkt_busfree()
3015 ahd_handle_nonpkt_busfree(struct ahd_softc *ahd) in ahd_handle_nonpkt_busfree() argument
3033 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_nonpkt_busfree()
3034 saved_scsiid = ahd_inb(ahd, SAVED_SCSIID); in ahd_handle_nonpkt_busfree()
3035 saved_lun = ahd_inb(ahd, SAVED_LUN); in ahd_handle_nonpkt_busfree()
3036 target = SCSIID_TARGET(ahd, saved_scsiid); in ahd_handle_nonpkt_busfree()
3042 scbid = ahd_get_scbptr(ahd); in ahd_handle_nonpkt_busfree()
3043 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_nonpkt_busfree()
3045 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0) in ahd_handle_nonpkt_busfree()
3048 ppr_busfree = (ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0; in ahd_handle_nonpkt_busfree()
3053 if (ahd_sent_msg(ahd, AHDMSG_1B, ABORT_TASK, TRUE) in ahd_handle_nonpkt_busfree()
3054 || ahd_sent_msg(ahd, AHDMSG_1B, ABORT_TASK_SET, TRUE)) { in ahd_handle_nonpkt_busfree()
3059 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_nonpkt_busfree()
3065 sent_msg = ahd->msgout_buf[ahd->msgout_index - 1]; in ahd_handle_nonpkt_busfree()
3066 ahd_print_path(ahd, scb); in ahd_handle_nonpkt_busfree()
3090 found = ahd_abort_scbs(ahd, target, 'A', saved_lun, in ahd_handle_nonpkt_busfree()
3095 } else if (ahd_sent_msg(ahd, AHDMSG_1B, in ahd_handle_nonpkt_busfree()
3097 ahd_handle_devreset(ahd, &devinfo, CAM_LUN_WILDCARD, in ahd_handle_nonpkt_busfree()
3101 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_PPR, FALSE) in ahd_handle_nonpkt_busfree()
3120 tinfo = ahd_fetch_transinfo(ahd, devinfo.channel, in ahd_handle_nonpkt_busfree()
3124 ahd_set_width(ahd, &devinfo, in ahd_handle_nonpkt_busfree()
3128 ahd_set_syncrate(ahd, &devinfo, in ahd_handle_nonpkt_busfree()
3149 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3150 ahd_qinfifo_requeue_tail(ahd, scb); in ahd_handle_nonpkt_busfree()
3154 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_WDTR, FALSE) in ahd_handle_nonpkt_busfree()
3164 ahd_set_width(ahd, &devinfo, in ahd_handle_nonpkt_busfree()
3175 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3176 ahd_qinfifo_requeue_tail(ahd, scb); in ahd_handle_nonpkt_busfree()
3179 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_SDTR, FALSE) in ahd_handle_nonpkt_busfree()
3189 ahd_set_syncrate(ahd, &devinfo, in ahd_handle_nonpkt_busfree()
3201 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3202 ahd_qinfifo_requeue_tail(ahd, scb); in ahd_handle_nonpkt_busfree()
3205 } else if ((ahd->msg_flags & MSG_FLAG_EXPECT_IDE_BUSFREE) != 0 in ahd_handle_nonpkt_busfree()
3206 && ahd_sent_msg(ahd, AHDMSG_1B, in ahd_handle_nonpkt_busfree()
3214 } else if ((ahd->msg_flags & MSG_FLAG_EXPECT_QASREJ_BUSFREE) in ahd_handle_nonpkt_busfree()
3215 && ahd_sent_msg(ahd, AHDMSG_1B, in ahd_handle_nonpkt_busfree()
3233 && ((ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0)) { in ahd_handle_nonpkt_busfree()
3235 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3238 if ((ahd->msg_flags & MSG_FLAG_IU_REQ_CHANGED) != 0) { in ahd_handle_nonpkt_busfree()
3239 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_nonpkt_busfree()
3240 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_nonpkt_busfree()
3248 ahd_done(ahd, scb); in ahd_handle_nonpkt_busfree()
3263 ahd_print_path(ahd, scb); in ahd_handle_nonpkt_busfree()
3264 aborted = ahd_abort_scbs(ahd, target, 'A', in ahd_handle_nonpkt_busfree()
3273 printk("%s: ", ahd_name(ahd)); in ahd_handle_nonpkt_busfree()
3279 ahd_inw(ahd, PRGMCNT)); in ahd_handle_nonpkt_busfree()
3280 ahd_dump_card_state(ahd); in ahd_handle_nonpkt_busfree()
3282 ahd_force_renegotiation(ahd, &devinfo); in ahd_handle_nonpkt_busfree()
3289 ahd_handle_proto_violation(struct ahd_softc *ahd) in ahd_handle_proto_violation() argument
3299 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_proto_violation()
3300 scbid = ahd_get_scbptr(ahd); in ahd_handle_proto_violation()
3301 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_proto_violation()
3302 seq_flags = ahd_inb(ahd, SEQ_FLAGS); in ahd_handle_proto_violation()
3303 curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK; in ahd_handle_proto_violation()
3304 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_proto_violation()
3312 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_proto_violation()
3321 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_proto_violation()
3327 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3329 } else if ((ahd_inb_scbram(ahd, SCB_CONTROL) in ahd_handle_proto_violation()
3338 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3341 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3343 ahd_dump_card_state(ahd); in ahd_handle_proto_violation()
3355 found = ahd_reset_channel(ahd, 'A', TRUE); in ahd_handle_proto_violation()
3357 "%d SCBs aborted\n", ahd_name(ahd), 'A', found); in ahd_handle_proto_violation()
3364 ahd_outb(ahd, SCSISEQ0, in ahd_handle_proto_violation()
3365 ahd_inb(ahd, SCSISEQ0) & ~ENSELO); in ahd_handle_proto_violation()
3366 ahd_assert_atn(ahd); in ahd_handle_proto_violation()
3367 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_proto_violation()
3369 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_proto_violation()
3370 ahd->msgout_buf[0] = ABORT_TASK; in ahd_handle_proto_violation()
3371 ahd->msgout_len = 1; in ahd_handle_proto_violation()
3372 ahd->msgout_index = 0; in ahd_handle_proto_violation()
3373 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_handle_proto_violation()
3375 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3388 ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_force_renegotiation() argument
3395 ahd_print_devinfo(ahd, devinfo); in ahd_force_renegotiation()
3399 targ_info = ahd_fetch_transinfo(ahd, in ahd_force_renegotiation()
3404 ahd_update_neg_request(ahd, devinfo, tstate, in ahd_force_renegotiation()
3410 ahd_clear_critical_section(struct ahd_softc *ahd) in ahd_clear_critical_section() argument
3424 if (ahd->num_critical_sections == 0) in ahd_clear_critical_section()
3437 saved_modes = ahd_save_modes(ahd); in ahd_clear_critical_section()
3443 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_clear_critical_section()
3444 seqaddr = ahd_inw(ahd, CURADDR); in ahd_clear_critical_section()
3446 cs = ahd->critical_sections; in ahd_clear_critical_section()
3447 for (i = 0; i < ahd->num_critical_sections; i++, cs++) { in ahd_clear_critical_section()
3452 if (i == ahd->num_critical_sections) in ahd_clear_critical_section()
3458 ahd_name(ahd), ahd_name(ahd), first_instr, in ahd_clear_critical_section()
3460 ahd_dump_card_state(ahd); in ahd_clear_critical_section()
3467 printk("%s: Single stepping at 0x%x\n", ahd_name(ahd), in ahd_clear_critical_section()
3473 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_clear_critical_section()
3474 simode0 = ahd_inb(ahd, SIMODE0); in ahd_clear_critical_section()
3475 simode3 = ahd_inb(ahd, SIMODE3); in ahd_clear_critical_section()
3476 lqimode0 = ahd_inb(ahd, LQIMODE0); in ahd_clear_critical_section()
3477 lqimode1 = ahd_inb(ahd, LQIMODE1); in ahd_clear_critical_section()
3478 lqomode0 = ahd_inb(ahd, LQOMODE0); in ahd_clear_critical_section()
3479 lqomode1 = ahd_inb(ahd, LQOMODE1); in ahd_clear_critical_section()
3480 ahd_outb(ahd, SIMODE0, 0); in ahd_clear_critical_section()
3481 ahd_outb(ahd, SIMODE3, 0); in ahd_clear_critical_section()
3482 ahd_outb(ahd, LQIMODE0, 0); in ahd_clear_critical_section()
3483 ahd_outb(ahd, LQIMODE1, 0); in ahd_clear_critical_section()
3484 ahd_outb(ahd, LQOMODE0, 0); in ahd_clear_critical_section()
3485 ahd_outb(ahd, LQOMODE1, 0); in ahd_clear_critical_section()
3486 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_clear_critical_section()
3487 simode1 = ahd_inb(ahd, SIMODE1); in ahd_clear_critical_section()
3494 ahd_outb(ahd, SIMODE1, simode1 & ENBUSFREE); in ahd_clear_critical_section()
3495 ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) | STEP); in ahd_clear_critical_section()
3498 ahd_outb(ahd, CLRSINT1, CLRBUSFREE); in ahd_clear_critical_section()
3499 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_clear_critical_section()
3500 ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode); in ahd_clear_critical_section()
3501 ahd_outb(ahd, HCNTRL, ahd->unpause); in ahd_clear_critical_section()
3502 while (!ahd_is_paused(ahd)) in ahd_clear_critical_section()
3504 ahd_update_modes(ahd); in ahd_clear_critical_section()
3507 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_clear_critical_section()
3508 ahd_outb(ahd, SIMODE0, simode0); in ahd_clear_critical_section()
3509 ahd_outb(ahd, SIMODE3, simode3); in ahd_clear_critical_section()
3510 ahd_outb(ahd, LQIMODE0, lqimode0); in ahd_clear_critical_section()
3511 ahd_outb(ahd, LQIMODE1, lqimode1); in ahd_clear_critical_section()
3512 ahd_outb(ahd, LQOMODE0, lqomode0); in ahd_clear_critical_section()
3513 ahd_outb(ahd, LQOMODE1, lqomode1); in ahd_clear_critical_section()
3514 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_clear_critical_section()
3515 ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) & ~STEP); in ahd_clear_critical_section()
3516 ahd_outb(ahd, SIMODE1, simode1); in ahd_clear_critical_section()
3523 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_clear_critical_section()
3525 ahd_restore_modes(ahd, saved_modes); in ahd_clear_critical_section()
3532 ahd_clear_intstat(struct ahd_softc *ahd) in ahd_clear_intstat() argument
3534 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_clear_intstat()
3537 ahd_outb(ahd, CLRLQIINT0, CLRLQIATNQAS|CLRLQICRCT1|CLRLQICRCT2 in ahd_clear_intstat()
3539 ahd_outb(ahd, CLRLQIINT1, CLRLQIPHASE_LQ|CLRLQIPHASE_NLQ|CLRLIQABORT in ahd_clear_intstat()
3542 ahd_outb(ahd, CLRLQOINT0, CLRLQOTARGSCBPERR|CLRLQOSTOPT2|CLRLQOATNLQ in ahd_clear_intstat()
3544 ahd_outb(ahd, CLRLQOINT1, CLRLQOINITSCBPERR|CLRLQOSTOPI2|CLRLQOBADQAS in ahd_clear_intstat()
3546 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) { in ahd_clear_intstat()
3547 ahd_outb(ahd, CLRLQOINT0, 0); in ahd_clear_intstat()
3548 ahd_outb(ahd, CLRLQOINT1, 0); in ahd_clear_intstat()
3550 ahd_outb(ahd, CLRSINT3, CLRNTRAMPERR|CLROSRAMPERR); in ahd_clear_intstat()
3551 ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRATNO|CLRSCSIRSTI in ahd_clear_intstat()
3553 ahd_outb(ahd, CLRSINT0, CLRSELDO|CLRSELDI|CLRSELINGO in ahd_clear_intstat()
3555 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_clear_intstat()
3596 ahd_alloc_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel) in ahd_alloc_tstate() argument
3602 master_tstate = ahd->enabled_targets[ahd->our_id]; in ahd_alloc_tstate()
3603 if (ahd->enabled_targets[scsi_id] != NULL in ahd_alloc_tstate()
3604 && ahd->enabled_targets[scsi_id] != master_tstate) in ahd_alloc_tstate()
3606 ahd_name(ahd)); in ahd_alloc_tstate()
3628 ahd->enabled_targets[scsi_id] = tstate; in ahd_alloc_tstate()
3638 ahd_free_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel, int force) in ahd_free_tstate() argument
3646 if (scsi_id == ahd->our_id in ahd_free_tstate()
3650 tstate = ahd->enabled_targets[scsi_id]; in ahd_free_tstate()
3652 ahd->enabled_targets[scsi_id] = NULL; in ahd_free_tstate()
3663 ahd_devlimited_syncrate(struct ahd_softc *ahd, in ahd_devlimited_syncrate() argument
3670 if ((ahd_inb(ahd, SBLKCTL) & ENAB40) != 0 in ahd_devlimited_syncrate()
3671 && (ahd_inb(ahd, SSTAT2) & EXP_ACTIVE) == 0) { in ahd_devlimited_syncrate()
3702 ahd_find_syncrate(ahd, period, ppr_options, maxsync); in ahd_devlimited_syncrate()
3712 ahd_find_syncrate(struct ahd_softc *ahd, u_int *period, in ahd_find_syncrate() argument
3751 ahd_validate_offset(struct ahd_softc *ahd, in ahd_validate_offset() argument
3762 if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) in ahd_validate_offset()
3782 ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, in ahd_validate_width() argument
3787 if (ahd->features & AHD_WIDE) { in ahd_validate_width()
3812 ahd_update_neg_request(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_update_neg_request() argument
3826 if ((ahd->features & AHD_WIDE) != 0) in ahd_update_neg_request()
3855 ahd_set_syncrate(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_set_syncrate() argument
3875 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid, in ahd_set_syncrate()
3905 ahd_send_async(ahd, devinfo->channel, devinfo->target, in ahd_set_syncrate()
3913 ahd_name(ahd), devinfo->target, in ahd_set_syncrate()
3943 ahd_name(ahd), devinfo->target, in ahd_set_syncrate()
3959 ahd_pause(ahd); in ahd_set_syncrate()
3960 ahd_update_neg_table(ahd, devinfo, &tinfo->curr); in ahd_set_syncrate()
3962 ahd_unpause(ahd); in ahd_set_syncrate()
3963 if (ahd->msg_type != MSG_TYPE_NONE) { in ahd_set_syncrate()
3968 ahd_print_devinfo(ahd, devinfo); in ahd_set_syncrate()
3972 ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE in ahd_set_syncrate()
3980 ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE; in ahd_set_syncrate()
3985 update_needed += ahd_update_neg_request(ahd, devinfo, tstate, in ahd_set_syncrate()
3989 ahd_update_pending_scbs(ahd); in ahd_set_syncrate()
4001 ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_set_width() argument
4012 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid, in ahd_set_width()
4027 ahd_send_async(ahd, devinfo->channel, devinfo->target, in ahd_set_width()
4031 ahd_name(ahd), devinfo->target, in ahd_set_width()
4038 ahd_pause(ahd); in ahd_set_width()
4039 ahd_update_neg_table(ahd, devinfo, &tinfo->curr); in ahd_set_width()
4041 ahd_unpause(ahd); in ahd_set_width()
4044 update_needed += ahd_update_neg_request(ahd, devinfo, tstate, in ahd_set_width()
4047 ahd_update_pending_scbs(ahd); in ahd_set_width()
4055 ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd, in ahd_set_tags() argument
4060 ahd_platform_set_tags(ahd, sdev, devinfo, alg); in ahd_set_tags()
4061 ahd_send_async(ahd, devinfo->channel, devinfo->target, in ahd_set_tags()
4066 ahd_update_neg_table(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_update_neg_table() argument
4075 uint8_t iocell_opts[sizeof(ahd->iocell_opts)]; in ahd_update_neg_table()
4077 saved_modes = ahd_save_modes(ahd); in ahd_update_neg_table()
4078 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_update_neg_table()
4080 saved_negoaddr = ahd_inb(ahd, NEGOADDR); in ahd_update_neg_table()
4081 ahd_outb(ahd, NEGOADDR, devinfo->target); in ahd_update_neg_table()
4084 memcpy(iocell_opts, ahd->iocell_opts, sizeof(ahd->iocell_opts)); in ahd_update_neg_table()
4092 if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) { in ahd_update_neg_table()
4124 if ((ahd->features & AHD_NEW_IOCELL_OPTS) != 0 in ahd_update_neg_table()
4136 if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) { in ahd_update_neg_table()
4146 ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PRECOMP_SLEW); in ahd_update_neg_table()
4147 ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_PRECOMP_SLEW_INDEX]); in ahd_update_neg_table()
4148 ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_AMPLITUDE); in ahd_update_neg_table()
4149 ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_AMPLITUDE_INDEX]); in ahd_update_neg_table()
4151 ahd_outb(ahd, NEGPERIOD, period); in ahd_update_neg_table()
4152 ahd_outb(ahd, NEGPPROPTS, ppr_opts); in ahd_update_neg_table()
4153 ahd_outb(ahd, NEGOFFSET, offset); in ahd_update_neg_table()
4163 if (ahd->features & AHD_AIC79XXB_SLOWCRC) { in ahd_update_neg_table()
4174 ahd_outb(ahd, NEGCONOPTS, con_opts); in ahd_update_neg_table()
4175 ahd_outb(ahd, NEGOADDR, saved_negoaddr); in ahd_update_neg_table()
4176 ahd_restore_modes(ahd, saved_modes); in ahd_update_neg_table()
4186 ahd_update_pending_scbs(struct ahd_softc *ahd) in ahd_update_pending_scbs() argument
4205 LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) { in ahd_update_pending_scbs()
4209 ahd_scb_devinfo(ahd, &devinfo, pending_scb); in ahd_update_pending_scbs()
4210 ahd_fetch_transinfo(ahd, devinfo.channel, devinfo.our_scsiid, in ahd_update_pending_scbs()
4217 ahd_sync_scb(ahd, pending_scb, in ahd_update_pending_scbs()
4225 if (ahd_is_paused(ahd)) { in ahd_update_pending_scbs()
4229 ahd_pause(ahd); in ahd_update_pending_scbs()
4240 saved_modes = ahd_save_modes(ahd); in ahd_update_pending_scbs()
4241 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_update_pending_scbs()
4242 if ((ahd_inb(ahd, SCSISIGI) & BSYI) != 0 in ahd_update_pending_scbs()
4243 && (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) == 0) in ahd_update_pending_scbs()
4244 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO); in ahd_update_pending_scbs()
4245 saved_scbptr = ahd_get_scbptr(ahd); in ahd_update_pending_scbs()
4247 LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) { in ahd_update_pending_scbs()
4252 ahd_set_scbptr(ahd, scb_tag); in ahd_update_pending_scbs()
4253 control = ahd_inb_scbram(ahd, SCB_CONTROL); in ahd_update_pending_scbs()
4256 ahd_outb(ahd, SCB_CONTROL, control); in ahd_update_pending_scbs()
4258 ahd_set_scbptr(ahd, saved_scbptr); in ahd_update_pending_scbs()
4259 ahd_restore_modes(ahd, saved_modes); in ahd_update_pending_scbs()
4262 ahd_unpause(ahd); in ahd_update_pending_scbs()
4267 ahd_fetch_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_fetch_devinfo() argument
4274 saved_modes = ahd_save_modes(ahd); in ahd_fetch_devinfo()
4275 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_fetch_devinfo()
4277 if (ahd_inb(ahd, SSTAT0) & TARGET) in ahd_fetch_devinfo()
4283 && (ahd_inb(ahd, SEQ_FLAGS) & CMDPHASE_PENDING) != 0) { in ahd_fetch_devinfo()
4285 our_id = ahd_inb(ahd, TARGIDIN) & OID; in ahd_fetch_devinfo()
4287 our_id = ahd_inb(ahd, TOWNID); in ahd_fetch_devinfo()
4289 our_id = ahd_inb(ahd, IOWNID); in ahd_fetch_devinfo()
4291 saved_scsiid = ahd_inb(ahd, SAVED_SCSIID); in ahd_fetch_devinfo()
4294 SCSIID_TARGET(ahd, saved_scsiid), in ahd_fetch_devinfo()
4295 ahd_inb(ahd, SAVED_LUN), in ahd_fetch_devinfo()
4296 SCSIID_CHANNEL(ahd, saved_scsiid), in ahd_fetch_devinfo()
4298 ahd_restore_modes(ahd, saved_modes); in ahd_fetch_devinfo()
4302 ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_print_devinfo() argument
4304 printk("%s:%c:%d:%d: ", ahd_name(ahd), 'A', in ahd_print_devinfo()
4342 ahd_scb_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_scb_devinfo() argument
4352 ahd_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahd, scb), in ahd_scb_devinfo()
4353 SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahd, scb), role); in ahd_scb_devinfo()
4365 ahd_setup_initiator_msgout(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_setup_initiator_msgout() argument
4373 ahd->msgout_index = 0; in ahd_setup_initiator_msgout()
4374 ahd->msgout_len = 0; in ahd_setup_initiator_msgout()
4376 if (ahd_currently_packetized(ahd)) in ahd_setup_initiator_msgout()
4377 ahd->msg_flags |= MSG_FLAG_PACKETIZED; in ahd_setup_initiator_msgout()
4379 if (ahd->send_msg_perror in ahd_setup_initiator_msgout()
4380 && ahd_inb(ahd, MSG_OUT) == HOST_MSG) { in ahd_setup_initiator_msgout()
4381 ahd->msgout_buf[ahd->msgout_index++] = ahd->send_msg_perror; in ahd_setup_initiator_msgout()
4382 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4383 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_setup_initiator_msgout()
4391 "I_T msgin. Issuing NO-OP\n", ahd_name(ahd)); in ahd_setup_initiator_msgout()
4392 ahd->msgout_buf[ahd->msgout_index++] = NOP; in ahd_setup_initiator_msgout()
4393 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4394 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_setup_initiator_msgout()
4400 && ahd_inb(ahd, MSG_OUT) == MSG_IDENTIFYFLAG) { in ahd_setup_initiator_msgout()
4406 ahd->msgout_buf[ahd->msgout_index++] = identify_msg; in ahd_setup_initiator_msgout()
4407 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4410 ahd->msgout_buf[ahd->msgout_index++] = in ahd_setup_initiator_msgout()
4412 ahd->msgout_buf[ahd->msgout_index++] = SCB_GET_TAG(scb); in ahd_setup_initiator_msgout()
4413 ahd->msgout_len += 2; in ahd_setup_initiator_msgout()
4418 ahd->msgout_buf[ahd->msgout_index++] = TARGET_RESET; in ahd_setup_initiator_msgout()
4419 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4420 ahd_print_path(ahd, scb); in ahd_setup_initiator_msgout()
4429 ahd_outb(ahd, SCSISEQ0, 0); in ahd_setup_initiator_msgout()
4433 ahd->msgout_buf[ahd->msgout_index++] = ABORT_TASK; in ahd_setup_initiator_msgout()
4435 ahd->msgout_buf[ahd->msgout_index++] = ABORT_TASK_SET; in ahd_setup_initiator_msgout()
4437 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4438 ahd_print_path(ahd, scb); in ahd_setup_initiator_msgout()
4448 ahd_outb(ahd, SCSISEQ0, 0); in ahd_setup_initiator_msgout()
4450 ahd_build_transfer_msg(ahd, devinfo); in ahd_setup_initiator_msgout()
4458 ahd_outb(ahd, SCSISEQ0, 0); in ahd_setup_initiator_msgout()
4466 ahd_inb_scbram(ahd, SCB_CONTROL), ahd_inb(ahd, MSG_OUT), in ahd_setup_initiator_msgout()
4474 ahd_outb(ahd, SCB_CONTROL, in ahd_setup_initiator_msgout()
4475 ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE); in ahd_setup_initiator_msgout()
4477 ahd->msgout_index = 0; in ahd_setup_initiator_msgout()
4478 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_setup_initiator_msgout()
4486 ahd_build_transfer_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_build_transfer_msg() argument
4502 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid, in ahd_build_transfer_msg()
4516 ahd_devlimited_syncrate(ahd, tinfo, &period, in ahd_build_transfer_msg()
4537 if ((ahd->features & AHD_WIDE) != 0) in ahd_build_transfer_msg()
4543 ahd_print_devinfo(ahd, devinfo); in ahd_build_transfer_msg()
4562 ahd_validate_offset(ahd, tinfo, period, &offset, in ahd_build_transfer_msg()
4567 ahd_construct_ppr(ahd, devinfo, period, offset, in ahd_build_transfer_msg()
4570 ahd_construct_sdtr(ahd, devinfo, period, offset); in ahd_build_transfer_msg()
4573 ahd_construct_wdtr(ahd, devinfo, tinfo->goal.width); in ahd_build_transfer_msg()
4582 ahd_construct_sdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_construct_sdtr() argument
4587 ahd->msgout_index += spi_populate_sync_msg( in ahd_construct_sdtr()
4588 ahd->msgout_buf + ahd->msgout_index, period, offset); in ahd_construct_sdtr()
4589 ahd->msgout_len += 5; in ahd_construct_sdtr()
4592 ahd_name(ahd), devinfo->channel, devinfo->target, in ahd_construct_sdtr()
4602 ahd_construct_wdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_construct_wdtr() argument
4605 ahd->msgout_index += spi_populate_width_msg( in ahd_construct_wdtr()
4606 ahd->msgout_buf + ahd->msgout_index, bus_width); in ahd_construct_wdtr()
4607 ahd->msgout_len += 4; in ahd_construct_wdtr()
4610 ahd_name(ahd), devinfo->channel, devinfo->target, in ahd_construct_wdtr()
4620 ahd_construct_ppr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_construct_ppr() argument
4633 ahd->msgout_index += spi_populate_ppr_msg( in ahd_construct_ppr()
4634 ahd->msgout_buf + ahd->msgout_index, period, offset, in ahd_construct_ppr()
4636 ahd->msgout_len += 8; in ahd_construct_ppr()
4639 "offset %x, ppr_options %x\n", ahd_name(ahd), in ahd_construct_ppr()
4649 ahd_clear_msg_state(struct ahd_softc *ahd) in ahd_clear_msg_state() argument
4653 saved_modes = ahd_save_modes(ahd); in ahd_clear_msg_state()
4654 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_clear_msg_state()
4655 ahd->send_msg_perror = 0; in ahd_clear_msg_state()
4656 ahd->msg_flags = MSG_FLAG_NONE; in ahd_clear_msg_state()
4657 ahd->msgout_len = 0; in ahd_clear_msg_state()
4658 ahd->msgin_index = 0; in ahd_clear_msg_state()
4659 ahd->msg_type = MSG_TYPE_NONE; in ahd_clear_msg_state()
4660 if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0) { in ahd_clear_msg_state()
4665 ahd_outb(ahd, CLRSINT1, CLRATNO); in ahd_clear_msg_state()
4667 ahd_outb(ahd, MSG_OUT, NOP); in ahd_clear_msg_state()
4668 ahd_outb(ahd, SEQ_FLAGS2, in ahd_clear_msg_state()
4669 ahd_inb(ahd, SEQ_FLAGS2) & ~TARGET_MSG_PENDING); in ahd_clear_msg_state()
4670 ahd_restore_modes(ahd, saved_modes); in ahd_clear_msg_state()
4677 ahd_handle_message_phase(struct ahd_softc *ahd) in ahd_handle_message_phase() argument
4683 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_message_phase()
4685 bus_phase = ahd_inb(ahd, LASTPHASE); in ahd_handle_message_phase()
4687 if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0) { in ahd_handle_message_phase()
4689 ahd_outb(ahd, LQCTL2, LQIRETRY); in ahd_handle_message_phase()
4692 switch (ahd->msg_type) { in ahd_handle_message_phase()
4699 if (ahd->msgout_len == 0 && ahd->send_msg_perror == 0) in ahd_handle_message_phase()
4704 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_message_phase()
4724 ahd_outb(ahd, CLRSINT1, CLRATNO); in ahd_handle_message_phase()
4725 ahd->send_msg_perror = 0; in ahd_handle_message_phase()
4726 ahd->msg_type = MSG_TYPE_INITIATOR_MSGIN; in ahd_handle_message_phase()
4727 ahd->msgin_index = 0; in ahd_handle_message_phase()
4734 if (ahd->send_msg_perror) { in ahd_handle_message_phase()
4735 ahd_outb(ahd, CLRSINT1, CLRATNO); in ahd_handle_message_phase()
4736 ahd_outb(ahd, CLRSINT1, CLRREQINIT); in ahd_handle_message_phase()
4739 printk(" byte 0x%x\n", ahd->send_msg_perror); in ahd_handle_message_phase()
4747 if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0 in ahd_handle_message_phase()
4748 && ahd->send_msg_perror == INITIATOR_ERROR) in ahd_handle_message_phase()
4749 ahd->msg_flags |= MSG_FLAG_EXPECT_IDE_BUSFREE; in ahd_handle_message_phase()
4751 ahd_outb(ahd, RETURN_2, ahd->send_msg_perror); in ahd_handle_message_phase()
4752 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE); in ahd_handle_message_phase()
4756 msgdone = ahd->msgout_index == ahd->msgout_len; in ahd_handle_message_phase()
4763 ahd->msgout_index = 0; in ahd_handle_message_phase()
4764 ahd_assert_atn(ahd); in ahd_handle_message_phase()
4767 lastbyte = ahd->msgout_index == (ahd->msgout_len - 1); in ahd_handle_message_phase()
4770 ahd_outb(ahd, CLRSINT1, CLRATNO); in ahd_handle_message_phase()
4777 ahd_outb(ahd, CLRSINT1, CLRREQINIT); in ahd_handle_message_phase()
4781 ahd->msgout_buf[ahd->msgout_index]); in ahd_handle_message_phase()
4783 ahd_outb(ahd, RETURN_2, ahd->msgout_buf[ahd->msgout_index++]); in ahd_handle_message_phase()
4784 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE); in ahd_handle_message_phase()
4794 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_message_phase()
4807 ahd->msgin_index = 0; in ahd_handle_message_phase()
4809 && (ahd->send_msg_perror != 0 in ahd_handle_message_phase()
4810 || (ahd->msgout_len != 0 in ahd_handle_message_phase()
4811 && ahd->msgout_index == 0))) { in ahd_handle_message_phase()
4812 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_handle_message_phase()
4820 ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIBUS); in ahd_handle_message_phase()
4824 ahd->msgin_buf[ahd->msgin_index]); in ahd_handle_message_phase()
4827 message_done = ahd_parse_msg(ahd, &devinfo); in ahd_handle_message_phase()
4834 ahd->msgin_index = 0; in ahd_handle_message_phase()
4841 if (ahd->msgout_len != 0) { in ahd_handle_message_phase()
4844 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_message_phase()
4848 ahd_assert_atn(ahd); in ahd_handle_message_phase()
4851 ahd->msgin_index++; in ahd_handle_message_phase()
4857 ahd_outb(ahd, CLRSINT1, CLRREQINIT); in ahd_handle_message_phase()
4858 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_READ); in ahd_handle_message_phase()
4870 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG); in ahd_handle_message_phase()
4872 if (ahd->msgout_len == 0) in ahd_handle_message_phase()
4881 if ((ahd_inb(ahd, SCSISIGI) & ATNI) != 0 in ahd_handle_message_phase()
4882 && ahd->msgout_index > 0) in ahd_handle_message_phase()
4895 ahd->msg_type = MSG_TYPE_TARGET_MSGOUT; in ahd_handle_message_phase()
4896 ahd_outb(ahd, SCSISIGO, P_MESGOUT | BSYO); in ahd_handle_message_phase()
4897 ahd->msgin_index = 0; in ahd_handle_message_phase()
4899 ahd_inb(ahd, SCSIDAT); in ahd_handle_message_phase()
4900 ahd_outb(ahd, SXFRCTL0, in ahd_handle_message_phase()
4901 ahd_inb(ahd, SXFRCTL0) | SPIOEN); in ahd_handle_message_phase()
4905 msgdone = ahd->msgout_index == ahd->msgout_len; in ahd_handle_message_phase()
4907 ahd_outb(ahd, SXFRCTL0, in ahd_handle_message_phase()
4908 ahd_inb(ahd, SXFRCTL0) & ~SPIOEN); in ahd_handle_message_phase()
4916 ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) | SPIOEN); in ahd_handle_message_phase()
4917 ahd_outb(ahd, SCSIDAT, ahd->msgout_buf[ahd->msgout_index++]); in ahd_handle_message_phase()
4928 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG); in ahd_handle_message_phase()
4934 lastbyte = (ahd_inb(ahd, SCSISIGI) & ATNI) == 0; in ahd_handle_message_phase()
4941 ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) & ~SPIOEN); in ahd_handle_message_phase()
4942 ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIDAT); in ahd_handle_message_phase()
4943 msgdone = ahd_parse_msg(ahd, &devinfo); in ahd_handle_message_phase()
4954 ahd->msgin_index++; in ahd_handle_message_phase()
4961 ahd->msgin_index = 0; in ahd_handle_message_phase()
4967 if (ahd->msgout_len != 0) { in ahd_handle_message_phase()
4968 ahd_outb(ahd, SCSISIGO, P_MESGIN | BSYO); in ahd_handle_message_phase()
4969 ahd_outb(ahd, SXFRCTL0, in ahd_handle_message_phase()
4970 ahd_inb(ahd, SXFRCTL0) | SPIOEN); in ahd_handle_message_phase()
4971 ahd->msg_type = MSG_TYPE_TARGET_MSGIN; in ahd_handle_message_phase()
4972 ahd->msgin_index = 0; in ahd_handle_message_phase()
4981 ahd_outb(ahd, SXFRCTL0, in ahd_handle_message_phase()
4982 ahd_inb(ahd, SXFRCTL0) | SPIOEN); in ahd_handle_message_phase()
4992 if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0) { in ahd_handle_message_phase()
4994 ahd_name(ahd)); in ahd_handle_message_phase()
4995 ahd_clear_msg_state(ahd); in ahd_handle_message_phase()
5000 ahd_outb(ahd, LASTPHASE, P_BUSFREE); in ahd_handle_message_phase()
5001 ahd_outb(ahd, SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT); in ahd_handle_message_phase()
5002 ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET); in ahd_handle_message_phase()
5004 ahd_clear_msg_state(ahd); in ahd_handle_message_phase()
5005 ahd_outb(ahd, RETURN_1, EXIT_MSG_LOOP); in ahd_handle_message_phase()
5017 ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type, u_int msgval, int full) in ahd_sent_msg() argument
5025 while (index < ahd->msgout_len) { in ahd_sent_msg()
5026 if (ahd->msgout_buf[index] == EXTENDED_MESSAGE) { in ahd_sent_msg()
5029 end_index = index + 1 + ahd->msgout_buf[index + 1]; in ahd_sent_msg()
5030 if (ahd->msgout_buf[index+2] == msgval in ahd_sent_msg()
5034 if (ahd->msgout_index > end_index) in ahd_sent_msg()
5036 } else if (ahd->msgout_index > index) in ahd_sent_msg()
5040 } else if (ahd->msgout_buf[index] >= SIMPLE_QUEUE_TAG in ahd_sent_msg()
5041 && ahd->msgout_buf[index] <= IGNORE_WIDE_RESIDUE) { in ahd_sent_msg()
5048 && ahd->msgout_index > index in ahd_sent_msg()
5049 && (ahd->msgout_buf[index] == msgval in ahd_sent_msg()
5050 || ((ahd->msgout_buf[index] & MSG_IDENTIFYFLAG) != 0 in ahd_sent_msg()
5066 ahd_parse_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_parse_msg() argument
5077 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid, in ahd_parse_msg()
5091 switch (ahd->msgin_buf[0]) { in ahd_parse_msg()
5104 response = ahd_handle_msg_reject(ahd, devinfo); in ahd_parse_msg()
5112 if (ahd->msgin_index < 2) in ahd_parse_msg()
5114 switch (ahd->msgin_buf[2]) { in ahd_parse_msg()
5122 if (ahd->msgin_buf[1] != MSG_EXT_SDTR_LEN) { in ahd_parse_msg()
5134 if (ahd->msgin_index < (MSG_EXT_SDTR_LEN + 1)) in ahd_parse_msg()
5137 period = ahd->msgin_buf[3]; in ahd_parse_msg()
5139 saved_offset = offset = ahd->msgin_buf[4]; in ahd_parse_msg()
5140 ahd_devlimited_syncrate(ahd, tinfo, &period, in ahd_parse_msg()
5142 ahd_validate_offset(ahd, tinfo, period, &offset, in ahd_parse_msg()
5148 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5150 ahd->msgin_buf[3], saved_offset, in ahd_parse_msg()
5153 ahd_set_syncrate(ahd, devinfo, period, in ahd_parse_msg()
5163 if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_SDTR, TRUE)) { in ahd_parse_msg()
5177 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5180 ahd->msgout_index = 0; in ahd_parse_msg()
5181 ahd->msgout_len = 0; in ahd_parse_msg()
5182 ahd_construct_sdtr(ahd, devinfo, in ahd_parse_msg()
5184 ahd->msgout_index = 0; in ahd_parse_msg()
5197 if (ahd->msgin_buf[1] != MSG_EXT_WDTR_LEN) { in ahd_parse_msg()
5209 if (ahd->msgin_index < (MSG_EXT_WDTR_LEN + 1)) in ahd_parse_msg()
5212 bus_width = ahd->msgin_buf[3]; in ahd_parse_msg()
5214 ahd_validate_width(ahd, tinfo, &bus_width, in ahd_parse_msg()
5219 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5224 if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_WDTR, TRUE)) { in ahd_parse_msg()
5235 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5248 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5251 ahd->msgout_index = 0; in ahd_parse_msg()
5252 ahd->msgout_len = 0; in ahd_parse_msg()
5253 ahd_construct_wdtr(ahd, devinfo, bus_width); in ahd_parse_msg()
5254 ahd->msgout_index = 0; in ahd_parse_msg()
5267 ahd_update_neg_request(ahd, devinfo, tstate, in ahd_parse_msg()
5269 ahd_set_width(ahd, devinfo, bus_width, in ahd_parse_msg()
5277 ahd->msgout_index = 0; in ahd_parse_msg()
5278 ahd->msgout_len = 0; in ahd_parse_msg()
5279 ahd_build_transfer_msg(ahd, devinfo); in ahd_parse_msg()
5280 ahd->msgout_index = 0; in ahd_parse_msg()
5296 if (ahd->msgin_buf[1] != MSG_EXT_PPR_LEN) { in ahd_parse_msg()
5308 if (ahd->msgin_index < (MSG_EXT_PPR_LEN + 1)) in ahd_parse_msg()
5311 period = ahd->msgin_buf[3]; in ahd_parse_msg()
5312 offset = ahd->msgin_buf[5]; in ahd_parse_msg()
5313 bus_width = ahd->msgin_buf[6]; in ahd_parse_msg()
5315 ppr_options = ahd->msgin_buf[7]; in ahd_parse_msg()
5334 ahd_validate_width(ahd, tinfo, &bus_width, in ahd_parse_msg()
5336 ahd_devlimited_syncrate(ahd, tinfo, &period, in ahd_parse_msg()
5338 ahd_validate_offset(ahd, tinfo, period, &offset, in ahd_parse_msg()
5341 if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_PPR, TRUE)) { in ahd_parse_msg()
5360 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5365 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5367 ahd->msgout_index = 0; in ahd_parse_msg()
5368 ahd->msgout_len = 0; in ahd_parse_msg()
5369 ahd_construct_ppr(ahd, devinfo, period, offset, in ahd_parse_msg()
5371 ahd->msgout_index = 0; in ahd_parse_msg()
5379 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5381 saved_width, ahd->msgin_buf[3], in ahd_parse_msg()
5385 ahd_set_width(ahd, devinfo, bus_width, in ahd_parse_msg()
5388 ahd_set_syncrate(ahd, devinfo, period, in ahd_parse_msg()
5405 ahd_handle_devreset(ahd, devinfo, CAM_LUN_WILDCARD, in ahd_parse_msg()
5409 ahd_restart(ahd); in ahd_parse_msg()
5424 if (ahd->msgin_buf[0] == ABORT_TASK) in ahd_parse_msg()
5425 tag = ahd_inb(ahd, INITIATOR_TAG); in ahd_parse_msg()
5426 ahd_abort_scbs(ahd, devinfo->target, devinfo->channel, in ahd_parse_msg()
5430 tstate = ahd->enabled_targets[devinfo->our_scsiid]; in ahd_parse_msg()
5436 ahd_queue_lstate_event(ahd, lstate, in ahd_parse_msg()
5438 ahd->msgin_buf[0], in ahd_parse_msg()
5440 ahd_send_lstate_events(ahd, lstate); in ahd_parse_msg()
5443 ahd_restart(ahd); in ahd_parse_msg()
5452 ahd_name(ahd), ahd_inb(ahd, SCSISIGI)); in ahd_parse_msg()
5454 ahd->msg_flags |= MSG_FLAG_EXPECT_QASREJ_BUSFREE; in ahd_parse_msg()
5466 ahd->msgout_index = 0; in ahd_parse_msg()
5467 ahd->msgout_len = 1; in ahd_parse_msg()
5468 ahd->msgout_buf[0] = MESSAGE_REJECT; in ahd_parse_msg()
5475 ahd->msgout_len = 0; in ahd_parse_msg()
5484 ahd_handle_msg_reject(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_handle_msg_reject() argument
5499 scb_index = ahd_get_scbptr(ahd); in ahd_handle_msg_reject()
5500 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_msg_reject()
5501 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, in ahd_handle_msg_reject()
5505 last_msg = ahd_inb(ahd, LAST_MSG); in ahd_handle_msg_reject()
5507 if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_PPR, /*full*/FALSE)) { in ahd_handle_msg_reject()
5508 if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_PPR, /*full*/TRUE) in ahd_handle_msg_reject()
5518 ahd_name(ahd), devinfo->channel, in ahd_handle_msg_reject()
5533 ahd_name(ahd), devinfo->channel, in ahd_handle_msg_reject()
5540 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5541 ahd->msgout_len = 0; in ahd_handle_msg_reject()
5542 ahd_build_transfer_msg(ahd, devinfo); in ahd_handle_msg_reject()
5543 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5545 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_WDTR, /*full*/FALSE)) { in ahd_handle_msg_reject()
5549 "8bit transfers\n", ahd_name(ahd), in ahd_handle_msg_reject()
5551 ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_handle_msg_reject()
5564 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5565 ahd->msgout_len = 0; in ahd_handle_msg_reject()
5566 ahd_build_transfer_msg(ahd, devinfo); in ahd_handle_msg_reject()
5567 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5570 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, EXTENDED_SDTR, /*full*/FALSE)) { in ahd_handle_msg_reject()
5572 ahd_set_syncrate(ahd, devinfo, /*period*/0, in ahd_handle_msg_reject()
5578 ahd_name(ahd), devinfo->channel, in ahd_handle_msg_reject()
5588 "Performing non-tagged I/O\n", ahd_name(ahd), in ahd_handle_msg_reject()
5590 ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_NONE); in ahd_handle_msg_reject()
5595 ahd_name(ahd), devinfo->channel, devinfo->target, in ahd_handle_msg_reject()
5598 ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_BASIC); in ahd_handle_msg_reject()
5606 ahd_outb(ahd, SCB_CONTROL, in ahd_handle_msg_reject()
5607 ahd_inb_scbram(ahd, SCB_CONTROL) & mask); in ahd_handle_msg_reject()
5611 ahd_outb(ahd, MSG_OUT, MSG_IDENTIFYFLAG); in ahd_handle_msg_reject()
5612 ahd_assert_atn(ahd); in ahd_handle_msg_reject()
5613 ahd_busy_tcl(ahd, BUILD_TCL(scb->hscb->scsiid, devinfo->lun), in ahd_handle_msg_reject()
5621 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_msg_reject()
5622 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_msg_reject()
5626 } else if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_IDENTIFYFLAG, TRUE)) { in ahd_handle_msg_reject()
5631 ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE in ahd_handle_msg_reject()
5634 ahd_force_renegotiation(ahd, devinfo); in ahd_handle_msg_reject()
5635 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5636 ahd->msgout_len = 0; in ahd_handle_msg_reject()
5637 ahd_build_transfer_msg(ahd, devinfo); in ahd_handle_msg_reject()
5638 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5645 ahd_name(ahd), devinfo->channel, devinfo->target, in ahd_handle_msg_reject()
5655 ahd_handle_ign_wide_residue(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_handle_ign_wide_residue() argument
5660 scb_index = ahd_get_scbptr(ahd); in ahd_handle_ign_wide_residue()
5661 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_ign_wide_residue()
5666 if ((ahd_inb(ahd, SEQ_FLAGS) & DPHASE) == 0 in ahd_handle_ign_wide_residue()
5682 sgptr = ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_handle_ign_wide_residue()
5684 && (ahd_inb_scbram(ahd, SCB_TASK_ATTRIBUTE) in ahd_handle_ign_wide_residue()
5698 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_handle_ign_wide_residue()
5699 data_cnt = ahd_inl_scbram(ahd, SCB_RESIDUAL_DATACNT); in ahd_handle_ign_wide_residue()
5708 data_addr = ahd_inq(ahd, SHADDR); in ahd_handle_ign_wide_residue()
5712 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_handle_ign_wide_residue()
5715 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_handle_ign_wide_residue()
5742 sgptr = ahd_sg_virt_to_bus(ahd, scb, in ahd_handle_ign_wide_residue()
5748 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_handle_ign_wide_residue()
5775 sgptr = ahd_sg_virt_to_bus(ahd, scb, in ahd_handle_ign_wide_residue()
5785 ahd_outb(ahd, SCB_TASK_ATTRIBUTE, in ahd_handle_ign_wide_residue()
5786 ahd_inb_scbram(ahd, SCB_TASK_ATTRIBUTE) in ahd_handle_ign_wide_residue()
5789 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr); in ahd_handle_ign_wide_residue()
5790 ahd_outl(ahd, SCB_RESIDUAL_DATACNT, data_cnt); in ahd_handle_ign_wide_residue()
5805 ahd_reinitialize_dataptrs(struct ahd_softc *ahd) in ahd_reinitialize_dataptrs() argument
5815 AHD_ASSERT_MODES(ahd, AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK, in ahd_reinitialize_dataptrs()
5818 scb_index = ahd_get_scbptr(ahd); in ahd_reinitialize_dataptrs()
5819 scb = ahd_lookup_scb(ahd, scb_index); in ahd_reinitialize_dataptrs()
5825 ahd_outb(ahd, DFFSXFRCTL, CLRCHN); in ahd_reinitialize_dataptrs()
5827 while (--wait && !(ahd_inb(ahd, MDFFSTAT) & FIFOFREE)) in ahd_reinitialize_dataptrs()
5830 ahd_print_path(ahd, scb); in ahd_reinitialize_dataptrs()
5832 ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT); in ahd_reinitialize_dataptrs()
5834 saved_modes = ahd_save_modes(ahd); in ahd_reinitialize_dataptrs()
5835 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reinitialize_dataptrs()
5836 ahd_outb(ahd, DFFSTAT, in ahd_reinitialize_dataptrs()
5837 ahd_inb(ahd, DFFSTAT) in ahd_reinitialize_dataptrs()
5844 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_reinitialize_dataptrs()
5847 resid = (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 2) << 16) in ahd_reinitialize_dataptrs()
5848 | (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 1) << 8) in ahd_reinitialize_dataptrs()
5849 | ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT); in ahd_reinitialize_dataptrs()
5851 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_reinitialize_dataptrs()
5854 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_reinitialize_dataptrs()
5862 ahd_outl(ahd, HADDR + 4, dataptr >> 32); in ahd_reinitialize_dataptrs()
5866 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_reinitialize_dataptrs()
5874 ahd_outb(ahd, HADDR + 4, in ahd_reinitialize_dataptrs()
5877 ahd_outl(ahd, HADDR, dataptr); in ahd_reinitialize_dataptrs()
5878 ahd_outb(ahd, HCNT + 2, resid >> 16); in ahd_reinitialize_dataptrs()
5879 ahd_outb(ahd, HCNT + 1, resid >> 8); in ahd_reinitialize_dataptrs()
5880 ahd_outb(ahd, HCNT, resid); in ahd_reinitialize_dataptrs()
5887 ahd_handle_devreset(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_handle_devreset() argument
5896 found = ahd_abort_scbs(ahd, devinfo->target, devinfo->channel, in ahd_handle_devreset()
5905 tstate = ahd->enabled_targets[devinfo->our_scsiid]; in ahd_handle_devreset()
5924 ahd_queue_lstate_event(ahd, lstate, devinfo->our_scsiid, in ahd_handle_devreset()
5926 ahd_send_lstate_events(ahd, lstate); in ahd_handle_devreset()
5934 ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_handle_devreset()
5936 ahd_set_syncrate(ahd, devinfo, /*period*/0, /*offset*/0, in ahd_handle_devreset()
5941 ahd_send_async(ahd, devinfo->channel, devinfo->target, in ahd_handle_devreset()
5945 printk("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd), in ahd_handle_devreset()
5951 ahd_setup_target_msgin(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_setup_target_msgin() argument
5960 ahd->msgout_index = 0; in ahd_setup_target_msgin()
5961 ahd->msgout_len = 0; in ahd_setup_target_msgin()
5964 ahd_build_transfer_msg(ahd, devinfo); in ahd_setup_target_msgin()
5968 ahd->msgout_index = 0; in ahd_setup_target_msgin()
5969 ahd->msg_type = MSG_TYPE_TARGET_MSGIN; in ahd_setup_target_msgin()
5974 ahd_sglist_size(struct ahd_softc *ahd) in ahd_sglist_size() argument
5979 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) in ahd_sglist_size()
5991 ahd_sglist_allocsize(struct ahd_softc *ahd) in ahd_sglist_allocsize() argument
5999 sg_list_increment = ahd_sglist_size(ahd); in ahd_sglist_allocsize()
6038 struct ahd_softc *ahd; in ahd_alloc() local
6040 ahd = kzalloc(sizeof(*ahd), GFP_ATOMIC); in ahd_alloc()
6041 if (!ahd) { in ahd_alloc()
6047 ahd->seep_config = kmalloc(sizeof(*ahd->seep_config), GFP_ATOMIC); in ahd_alloc()
6048 if (ahd->seep_config == NULL) { in ahd_alloc()
6049 kfree(ahd); in ahd_alloc()
6053 LIST_INIT(&ahd->pending_scbs); in ahd_alloc()
6055 ahd->name = name; in ahd_alloc()
6056 ahd->unit = -1; in ahd_alloc()
6057 ahd->description = NULL; in ahd_alloc()
6058 ahd->bus_description = NULL; in ahd_alloc()
6059 ahd->channel = 'A'; in ahd_alloc()
6060 ahd->chip = AHD_NONE; in ahd_alloc()
6061 ahd->features = AHD_FENONE; in ahd_alloc()
6062 ahd->bugs = AHD_BUGNONE; in ahd_alloc()
6063 ahd->flags = AHD_SPCHK_ENB_A|AHD_RESET_BUS_A|AHD_TERM_ENB_A in ahd_alloc()
6065 timer_setup(&ahd->stat_timer, ahd_stat_timer, 0); in ahd_alloc()
6066 ahd->int_coalescing_timer = AHD_INT_COALESCING_TIMER_DEFAULT; in ahd_alloc()
6067 ahd->int_coalescing_maxcmds = AHD_INT_COALESCING_MAXCMDS_DEFAULT; in ahd_alloc()
6068 ahd->int_coalescing_mincmds = AHD_INT_COALESCING_MINCMDS_DEFAULT; in ahd_alloc()
6069 ahd->int_coalescing_threshold = AHD_INT_COALESCING_THRESHOLD_DEFAULT; in ahd_alloc()
6070 ahd->int_coalescing_stop_threshold = in ahd_alloc()
6076 ahd_name(ahd), (u_int)sizeof(struct scb), in ahd_alloc()
6080 if (ahd_platform_alloc(ahd, platform_arg) != 0) { in ahd_alloc()
6081 ahd_free(ahd); in ahd_alloc()
6082 ahd = NULL; in ahd_alloc()
6084 return (ahd); in ahd_alloc()
6088 ahd_softc_init(struct ahd_softc *ahd) in ahd_softc_init() argument
6091 ahd->unpause = 0; in ahd_softc_init()
6092 ahd->pause = PAUSE; in ahd_softc_init()
6097 ahd_set_unit(struct ahd_softc *ahd, int unit) in ahd_set_unit() argument
6099 ahd->unit = unit; in ahd_set_unit()
6103 ahd_set_name(struct ahd_softc *ahd, char *name) in ahd_set_name() argument
6105 kfree(ahd->name); in ahd_set_name()
6106 ahd->name = name; in ahd_set_name()
6110 ahd_free(struct ahd_softc *ahd) in ahd_free() argument
6114 switch (ahd->init_level) { in ahd_free()
6117 ahd_shutdown(ahd); in ahd_free()
6120 ahd_dmamap_unload(ahd, ahd->shared_data_dmat, in ahd_free()
6121 ahd->shared_data_map.dmamap); in ahd_free()
6124 ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo, in ahd_free()
6125 ahd->shared_data_map.dmamap); in ahd_free()
6126 ahd_dmamap_destroy(ahd, ahd->shared_data_dmat, in ahd_free()
6127 ahd->shared_data_map.dmamap); in ahd_free()
6130 ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat); in ahd_free()
6138 ahd_platform_free(ahd); in ahd_free()
6139 ahd_fini_scbdata(ahd); in ahd_free()
6143 tstate = ahd->enabled_targets[i]; in ahd_free()
6162 if (ahd->black_hole != NULL) { in ahd_free()
6163 xpt_free_path(ahd->black_hole->path); in ahd_free()
6164 kfree(ahd->black_hole); in ahd_free()
6167 kfree(ahd->name); in ahd_free()
6168 kfree(ahd->seep_config); in ahd_free()
6169 kfree(ahd->saved_stack); in ahd_free()
6170 kfree(ahd); in ahd_free()
6177 struct ahd_softc *ahd; in ahd_shutdown() local
6179 ahd = (struct ahd_softc *)arg; in ahd_shutdown()
6184 del_timer_sync(&ahd->stat_timer); in ahd_shutdown()
6187 ahd_reset(ahd, /*reinit*/FALSE); in ahd_shutdown()
6200 ahd_reset(struct ahd_softc *ahd, int reinit) in ahd_reset() argument
6211 ahd_pause(ahd); in ahd_reset()
6212 ahd_update_modes(ahd); in ahd_reset()
6213 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reset()
6214 sxfrctl1 = ahd_inb(ahd, SXFRCTL1); in ahd_reset()
6216 cmd = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2); in ahd_reset()
6217 if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) { in ahd_reset()
6230 ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, in ahd_reset()
6233 ahd_outb(ahd, HCNTRL, CHIPRST | ahd->pause); in ahd_reset()
6244 } while (--wait && !(ahd_inb(ahd, HCNTRL) & CHIPRSTACK)); in ahd_reset()
6248 "Trying to initialize anyway.\n", ahd_name(ahd)); in ahd_reset()
6250 ahd_outb(ahd, HCNTRL, ahd->pause); in ahd_reset()
6252 if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) { in ahd_reset()
6257 ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1, in ahd_reset()
6259 ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, in ahd_reset()
6269 ahd_known_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reset()
6270 ahd_outb(ahd, MODE_PTR, in ahd_reset()
6271 ahd_build_mode_state(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI)); in ahd_reset()
6281 ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN); in ahd_reset()
6282 ahd_outb(ahd, SXFRCTL1, sxfrctl1); in ahd_reset()
6285 ahd->features &= ~AHD_WIDE; in ahd_reset()
6286 if ((ahd_inb(ahd, SBLKCTL) & SELWIDE) != 0) in ahd_reset()
6287 ahd->features |= AHD_WIDE; in ahd_reset()
6294 ahd_chip_init(ahd); in ahd_reset()
6303 ahd_probe_scbs(struct ahd_softc *ahd) { in ahd_probe_scbs() argument
6306 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_probe_scbs()
6311 ahd_set_scbptr(ahd, i); in ahd_probe_scbs()
6312 ahd_outw(ahd, SCB_BASE, i); in ahd_probe_scbs()
6314 ahd_outb(ahd, SCB_BASE+j, 0); in ahd_probe_scbs()
6316 ahd_outb(ahd, SCB_CONTROL, MK_MESSAGE); in ahd_probe_scbs()
6317 if (ahd_inw_scbram(ahd, SCB_BASE) != i) in ahd_probe_scbs()
6319 ahd_set_scbptr(ahd, 0); in ahd_probe_scbs()
6320 if (ahd_inw_scbram(ahd, SCB_BASE) != 0) in ahd_probe_scbs()
6336 ahd_initialize_hscbs(struct ahd_softc *ahd) in ahd_initialize_hscbs() argument
6340 for (i = 0; i < ahd->scb_data.maxhscbs; i++) { in ahd_initialize_hscbs()
6341 ahd_set_scbptr(ahd, i); in ahd_initialize_hscbs()
6344 ahd_outb(ahd, SCB_CONTROL, 0); in ahd_initialize_hscbs()
6347 ahd_outw(ahd, SCB_NEXT, SCB_LIST_NULL); in ahd_initialize_hscbs()
6352 ahd_init_scbdata(struct ahd_softc *ahd) in ahd_init_scbdata() argument
6357 scb_data = &ahd->scb_data; in ahd_init_scbdata()
6367 scb_data->maxhscbs = ahd_probe_scbs(ahd); in ahd_init_scbdata()
6369 printk("%s: No SCB space found\n", ahd_name(ahd)); in ahd_init_scbdata()
6373 ahd_initialize_hscbs(ahd); in ahd_init_scbdata()
6386 if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1, in ahd_init_scbdata()
6400 if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/8, in ahd_init_scbdata()
6405 ahd_sglist_allocsize(ahd), /*nsegments*/1, in ahd_init_scbdata()
6412 printk("%s: ahd_sglist_allocsize = 0x%x\n", ahd_name(ahd), in ahd_init_scbdata()
6413 ahd_sglist_allocsize(ahd)); in ahd_init_scbdata()
6419 if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1, in ahd_init_scbdata()
6433 ahd_alloc_scbs(ahd); in ahd_init_scbdata()
6438 ahd_name(ahd)); in ahd_init_scbdata()
6453 ahd_find_scb_by_tag(struct ahd_softc *ahd, u_int tag) in ahd_find_scb_by_tag() argument
6460 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_find_scb_by_tag()
6468 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) { in ahd_find_scb_by_tag()
6482 LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) { in ahd_find_scb_by_tag()
6491 ahd_fini_scbdata(struct ahd_softc *ahd) in ahd_fini_scbdata() argument
6495 scb_data = &ahd->scb_data; in ahd_fini_scbdata()
6507 ahd_dmamap_unload(ahd, scb_data->sense_dmat, in ahd_fini_scbdata()
6509 ahd_dmamem_free(ahd, scb_data->sense_dmat, in ahd_fini_scbdata()
6513 ahd_dma_tag_destroy(ahd, scb_data->sense_dmat); in ahd_fini_scbdata()
6522 ahd_dmamap_unload(ahd, scb_data->sg_dmat, in ahd_fini_scbdata()
6524 ahd_dmamem_free(ahd, scb_data->sg_dmat, in ahd_fini_scbdata()
6528 ahd_dma_tag_destroy(ahd, scb_data->sg_dmat); in ahd_fini_scbdata()
6537 ahd_dmamap_unload(ahd, scb_data->hscb_dmat, in ahd_fini_scbdata()
6539 ahd_dmamem_free(ahd, scb_data->hscb_dmat, in ahd_fini_scbdata()
6543 ahd_dma_tag_destroy(ahd, scb_data->hscb_dmat); in ahd_fini_scbdata()
6560 ahd_setup_iocell_workaround(struct ahd_softc *ahd) in ahd_setup_iocell_workaround() argument
6564 saved_modes = ahd_save_modes(ahd); in ahd_setup_iocell_workaround()
6565 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_setup_iocell_workaround()
6566 ahd_outb(ahd, DSPDATACTL, ahd_inb(ahd, DSPDATACTL) in ahd_setup_iocell_workaround()
6568 ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) | (ENSELDO|ENSELDI)); in ahd_setup_iocell_workaround()
6571 printk("%s: Setting up iocell workaround\n", ahd_name(ahd)); in ahd_setup_iocell_workaround()
6573 ahd_restore_modes(ahd, saved_modes); in ahd_setup_iocell_workaround()
6574 ahd->flags &= ~AHD_HAD_FIRST_SEL; in ahd_setup_iocell_workaround()
6578 ahd_iocell_first_selection(struct ahd_softc *ahd) in ahd_iocell_first_selection() argument
6583 if ((ahd->flags & AHD_HAD_FIRST_SEL) != 0) in ahd_iocell_first_selection()
6585 saved_modes = ahd_save_modes(ahd); in ahd_iocell_first_selection()
6586 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_iocell_first_selection()
6587 sblkctl = ahd_inb(ahd, SBLKCTL); in ahd_iocell_first_selection()
6588 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_iocell_first_selection()
6591 printk("%s: iocell first selection\n", ahd_name(ahd)); in ahd_iocell_first_selection()
6594 ahd_outb(ahd, DSPDATACTL, in ahd_iocell_first_selection()
6595 ahd_inb(ahd, DSPDATACTL) & ~BYPASSENAB); in ahd_iocell_first_selection()
6598 printk("%s: BYPASS now disabled\n", ahd_name(ahd)); in ahd_iocell_first_selection()
6601 ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) & ~(ENSELDO|ENSELDI)); in ahd_iocell_first_selection()
6602 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_iocell_first_selection()
6603 ahd_restore_modes(ahd, saved_modes); in ahd_iocell_first_selection()
6604 ahd->flags |= AHD_HAD_FIRST_SEL; in ahd_iocell_first_selection()
6609 ahd_add_col_list(struct ahd_softc *ahd, struct scb *scb, u_int col_idx) in ahd_add_col_list() argument
6617 free_list = &ahd->scb_data.free_scb_lists[col_idx]; in ahd_add_col_list()
6618 free_tailq = &ahd->scb_data.free_scbs; in ahd_add_col_list()
6629 ahd_rem_col_list(struct ahd_softc *ahd, struct scb *scb) in ahd_rem_col_list() argument
6637 col_idx = AHD_GET_SCB_COL_IDX(ahd, scb); in ahd_rem_col_list()
6638 free_list = &ahd->scb_data.free_scb_lists[col_idx]; in ahd_rem_col_list()
6639 free_tailq = &ahd->scb_data.free_scbs; in ahd_rem_col_list()
6663 ahd_get_scb(struct ahd_softc *ahd, u_int col_idx) in ahd_get_scb() argument
6670 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) { in ahd_get_scb()
6671 if (AHD_GET_SCB_COL_IDX(ahd, scb) != col_idx) { in ahd_get_scb()
6672 ahd_rem_col_list(ahd, scb); in ahd_get_scb()
6676 if ((scb = LIST_FIRST(&ahd->scb_data.any_dev_free_scb_list)) == NULL) { in ahd_get_scb()
6680 ahd_alloc_scbs(ahd); in ahd_get_scb()
6688 ahd_add_col_list(ahd, scb->col_scb, col_idx); in ahd_get_scb()
6699 ahd_free_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_free_scb() argument
6704 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = NULL; in ahd_free_scb()
6711 LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list, in ahd_free_scb()
6720 ahd_rem_col_list(ahd, scb->col_scb); in ahd_free_scb()
6721 LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list, in ahd_free_scb()
6723 LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list, in ahd_free_scb()
6734 ahd_add_col_list(ahd, scb, in ahd_free_scb()
6735 AHD_GET_SCB_COL_IDX(ahd, scb->col_scb)); in ahd_free_scb()
6743 LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list, in ahd_free_scb()
6747 ahd_platform_scb_free(ahd, scb); in ahd_free_scb()
6751 ahd_alloc_scbs(struct ahd_softc *ahd) in ahd_alloc_scbs() argument
6767 scb_data = &ahd->scb_data; in ahd_alloc_scbs()
6786 if (ahd_dmamem_alloc(ahd, scb_data->hscb_dmat, in ahd_alloc_scbs()
6795 ahd_dmamap_load(ahd, scb_data->hscb_dmat, hscb_map->dmamap, in ahd_alloc_scbs()
6807 offset = ((ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd)) in ahd_alloc_scbs()
6808 - scb_data->sgs_left) * ahd_sglist_size(ahd); in ahd_alloc_scbs()
6819 if (ahd_dmamem_alloc(ahd, scb_data->sg_dmat, in ahd_alloc_scbs()
6828 ahd_dmamap_load(ahd, scb_data->sg_dmat, sg_map->dmamap, in ahd_alloc_scbs()
6829 sg_map->vaddr, ahd_sglist_allocsize(ahd), in ahd_alloc_scbs()
6835 ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd); in ahd_alloc_scbs()
6856 if (ahd_dmamem_alloc(ahd, scb_data->sense_dmat, in ahd_alloc_scbs()
6865 ahd_dmamap_load(ahd, scb_data->sense_dmat, sense_map->dmamap, in ahd_alloc_scbs()
6910 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) in ahd_alloc_scbs()
6915 next_scb->ahd_softc = ahd; in ahd_alloc_scbs()
6919 next_scb->col_scb = ahd_find_scb_by_tag(ahd, col_tag); in ahd_alloc_scbs()
6922 ahd_free_scb(ahd, next_scb); in ahd_alloc_scbs()
6925 segs += ahd_sglist_size(ahd); in ahd_alloc_scbs()
6926 sg_busaddr += ahd_sglist_size(ahd); in ahd_alloc_scbs()
6937 ahd_controller_info(struct ahd_softc *ahd, char *buf) in ahd_controller_info() argument
6943 len = sprintf(buf, "%s: ", ahd_chip_names[ahd->chip & AHD_CHIPID_MASK]); in ahd_controller_info()
6947 if ((ahd->features & AHD_WIDE) != 0) { in ahd_controller_info()
6953 speed, type, ahd->channel, ahd->our_id); in ahd_controller_info()
6956 sprintf(buf, "%s, %d SCBs", ahd->bus_description, in ahd_controller_info()
6957 ahd->scb_data.maxhscbs); in ahd_controller_info()
6987 ahd_init(struct ahd_softc *ahd) in ahd_init() argument
6998 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_init()
7000 ahd->stack_size = ahd_probe_stack_size(ahd); in ahd_init()
7001 ahd->saved_stack = kmalloc_array(ahd->stack_size, sizeof(uint16_t), in ahd_init()
7003 if (ahd->saved_stack == NULL) in ahd_init()
7015 ahd->flags |= AHD_SEQUENCER_DEBUG; in ahd_init()
7021 ahd->flags |= AHD_INITIATORROLE; in ahd_init()
7026 if ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) == 0) in ahd_init()
7027 ahd->features &= ~AHD_TARGETMODE; in ahd_init()
7029 ahd->init_level++; in ahd_init()
7038 driver_data_size = AHD_SCB_MAX * sizeof(*ahd->qoutfifo) in ahd_init()
7040 if ((ahd->features & AHD_TARGETMODE) != 0) in ahd_init()
7042 if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) in ahd_init()
7044 if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1, in ahd_init()
7052 /*flags*/0, &ahd->shared_data_dmat) != 0) { in ahd_init()
7056 ahd->init_level++; in ahd_init()
7059 if (ahd_dmamem_alloc(ahd, ahd->shared_data_dmat, in ahd_init()
7060 (void **)&ahd->shared_data_map.vaddr, in ahd_init()
7062 &ahd->shared_data_map.dmamap) != 0) { in ahd_init()
7066 ahd->init_level++; in ahd_init()
7069 ahd_dmamap_load(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap, in ahd_init()
7070 ahd->shared_data_map.vaddr, driver_data_size, in ahd_init()
7071 ahd_dmamap_cb, &ahd->shared_data_map.physaddr, in ahd_init()
7073 ahd->qoutfifo = (struct ahd_completion *)ahd->shared_data_map.vaddr; in ahd_init()
7074 next_vaddr = (uint8_t *)&ahd->qoutfifo[AHD_QOUT_SIZE]; in ahd_init()
7075 next_baddr = ahd->shared_data_map.physaddr in ahd_init()
7077 if ((ahd->features & AHD_TARGETMODE) != 0) { in ahd_init()
7078 ahd->targetcmds = (struct target_cmd *)next_vaddr; in ahd_init()
7083 if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) { in ahd_init()
7084 ahd->overrun_buf = next_vaddr; in ahd_init()
7096 ahd->next_queued_hscb = (struct hardware_scb *)next_vaddr; in ahd_init()
7097 ahd->next_queued_hscb_map = &ahd->shared_data_map; in ahd_init()
7098 ahd->next_queued_hscb->hscb_busaddr = ahd_htole32(next_baddr); in ahd_init()
7100 ahd->init_level++; in ahd_init()
7103 if (ahd_init_scbdata(ahd) != 0) in ahd_init()
7106 if ((ahd->flags & AHD_INITIATORROLE) == 0) in ahd_init()
7107 ahd->flags &= ~AHD_RESET_BUS_A; in ahd_init()
7113 ahd_platform_init(ahd); in ahd_init()
7116 ahd_chip_init(ahd); in ahd_init()
7118 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_init()
7120 if ((ahd->flags & AHD_CURRENT_SENSING) == 0) in ahd_init()
7127 error = ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, in ahd_init()
7130 printk("%s: current sensing timeout 1\n", ahd_name(ahd)); in ahd_init()
7135 error = ahd_read_flexport(ahd, FLXADDR_FLEXSTAT, &fstat); in ahd_init()
7138 ahd_name(ahd)); in ahd_init()
7144 ahd_name(ahd)); in ahd_init()
7149 error = ahd_read_flexport(ahd, FLXADDR_CURRENT_STAT, &current_sensing); in ahd_init()
7151 printk("%s: current sensing timeout 3\n", ahd_name(ahd)); in ahd_init()
7156 ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0); in ahd_init()
7161 ahd_name(ahd), current_sensing); in ahd_init()
7178 printk("%s: %s Channel %s\n", ahd_name(ahd), in ahd_init()
7186 ahd_name(ahd), ahd_name(ahd)); in ahd_init()
7189 ahd_restart(ahd); in ahd_init()
7190 ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US); in ahd_init()
7198 ahd_chip_init(struct ahd_softc *ahd) in ahd_chip_init() argument
7207 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_chip_init()
7211 ahd_outb(ahd, SBLKCTL, ahd_inb(ahd, SBLKCTL) & ~(DIAGLEDEN|DIAGLEDON)); in ahd_chip_init()
7216 ahd->hs_mailbox = 0; in ahd_chip_init()
7217 ahd_outb(ahd, HS_MAILBOX, 0); in ahd_chip_init()
7220 ahd_outb(ahd, IOWNID, ahd->our_id); in ahd_chip_init()
7221 ahd_outb(ahd, TOWNID, ahd->our_id); in ahd_chip_init()
7222 sxfrctl1 = (ahd->flags & AHD_TERM_ENB_A) != 0 ? STPWEN : 0; in ahd_chip_init()
7223 sxfrctl1 |= (ahd->flags & AHD_SPCHK_ENB_A) != 0 ? ENSPCHK : 0; in ahd_chip_init()
7224 if ((ahd->bugs & AHD_LONG_SETIMO_BUG) in ahd_chip_init()
7225 && (ahd->seltime != STIMESEL_MIN)) { in ahd_chip_init()
7231 sxfrctl1 |= ahd->seltime + STIMESEL_BUG_ADJ; in ahd_chip_init()
7233 sxfrctl1 |= ahd->seltime; in ahd_chip_init()
7236 ahd_outb(ahd, SXFRCTL0, DFON); in ahd_chip_init()
7237 ahd_outb(ahd, SXFRCTL1, sxfrctl1|ahd->seltime|ENSTIMER|ACTNEGEN); in ahd_chip_init()
7238 ahd_outb(ahd, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR); in ahd_chip_init()
7248 (ahd_inb(ahd, SBLKCTL) & (ENAB40|ENAB20)) == 0 && wait; in ahd_chip_init()
7253 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI); in ahd_chip_init()
7254 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_chip_init()
7258 ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i); in ahd_chip_init()
7259 ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR); in ahd_chip_init()
7260 ahd_outb(ahd, SG_STATE, 0); in ahd_chip_init()
7261 ahd_outb(ahd, CLRSEQINTSRC, 0xFF); in ahd_chip_init()
7262 ahd_outb(ahd, SEQIMODE, in ahd_chip_init()
7267 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_chip_init()
7268 ahd_outb(ahd, DSCOMMAND0, ahd_inb(ahd, DSCOMMAND0)|MPARCKEN|CACHETHEN); in ahd_chip_init()
7269 ahd_outb(ahd, DFF_THRSH, RD_DFTHRSH_75|WR_DFTHRSH_75); in ahd_chip_init()
7270 ahd_outb(ahd, SIMODE0, ENIOERR|ENOVERRUN); in ahd_chip_init()
7271 ahd_outb(ahd, SIMODE3, ENNTRAMPERR|ENOSRAMPERR); in ahd_chip_init()
7272 if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) { in ahd_chip_init()
7273 ahd_outb(ahd, OPTIONMODE, AUTOACKEN|AUTO_MSGOUT_DE); in ahd_chip_init()
7275 ahd_outb(ahd, OPTIONMODE, AUTOACKEN|BUSFREEREV|AUTO_MSGOUT_DE); in ahd_chip_init()
7277 ahd_outb(ahd, SCSCHKN, CURRFIFODEF|WIDERESEN|SHVALIDSTDIS); in ahd_chip_init()
7278 if ((ahd->chip & AHD_BUS_MASK) == AHD_PCIX) in ahd_chip_init()
7284 ahd_outb(ahd, PCIXCTL, ahd_inb(ahd, PCIXCTL) | SPLTSTADIS); in ahd_chip_init()
7286 if ((ahd->bugs & AHD_LQOOVERRUN_BUG) != 0) in ahd_chip_init()
7287 ahd_outb(ahd, LQOSCSCTL, LQONOCHKOVER); in ahd_chip_init()
7292 if ((ahd->flags & AHD_HP_BOARD) != 0) { in ahd_chip_init()
7294 ahd_outb(ahd, DSPSELECT, i); in ahd_chip_init()
7295 ahd_outb(ahd, WRTBIASCTL, WRTBIASCTL_HP_DEFAULT); in ahd_chip_init()
7299 printk("%s: WRTBIASCTL now 0x%x\n", ahd_name(ahd), in ahd_chip_init()
7303 ahd_setup_iocell_workaround(ahd); in ahd_chip_init()
7308 ahd_outb(ahd, LQIMODE1, ENLQIPHASE_LQ|ENLQIPHASE_NLQ|ENLIQABORT in ahd_chip_init()
7311 ahd_outb(ahd, LQOMODE0, ENLQOATNLQ|ENLQOATNPKT|ENLQOTCRC); in ahd_chip_init()
7320 ahd_outb(ahd, LQOMODE1, ENLQOBUSFREE); in ahd_chip_init()
7325 ahd_outw(ahd, INTVEC1_ADDR, ahd_resolve_seqaddr(ahd, LABEL_seq_isr)); in ahd_chip_init()
7326 ahd_outw(ahd, INTVEC2_ADDR, ahd_resolve_seqaddr(ahd, LABEL_timer_isr)); in ahd_chip_init()
7331 if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) { in ahd_chip_init()
7332 ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb, in ahd_chip_init()
7335 ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb, lun)); in ahd_chip_init()
7337 ahd_outb(ahd, CMDLENPTR, offsetof(struct hardware_scb, cdb_len)); in ahd_chip_init()
7338 ahd_outb(ahd, ATTRPTR, offsetof(struct hardware_scb, task_attribute)); in ahd_chip_init()
7339 ahd_outb(ahd, FLAGPTR, offsetof(struct hardware_scb, task_management)); in ahd_chip_init()
7340 ahd_outb(ahd, CMDPTR, offsetof(struct hardware_scb, in ahd_chip_init()
7342 ahd_outb(ahd, QNEXTPTR, in ahd_chip_init()
7344 ahd_outb(ahd, ABRTBITPTR, MK_MESSAGE_BIT_OFFSET); in ahd_chip_init()
7345 ahd_outb(ahd, ABRTBYTEPTR, offsetof(struct hardware_scb, control)); in ahd_chip_init()
7346 if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) { in ahd_chip_init()
7347 ahd_outb(ahd, LUNLEN, in ahd_chip_init()
7348 sizeof(ahd->next_queued_hscb->pkt_long_lun) - 1); in ahd_chip_init()
7350 ahd_outb(ahd, LUNLEN, LUNLEN_SINGLE_LEVEL_LUN); in ahd_chip_init()
7352 ahd_outb(ahd, CDBLIMIT, SCB_CDB_LEN_PTR - 1); in ahd_chip_init()
7353 ahd_outb(ahd, MAXCMD, 0xFF); in ahd_chip_init()
7354 ahd_outb(ahd, SCBAUTOPTR, in ahd_chip_init()
7358 ahd_outb(ahd, MULTARGID, 0); in ahd_chip_init()
7359 ahd_outb(ahd, MULTARGID + 1, 0); in ahd_chip_init()
7361 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_chip_init()
7363 if ((ahd->features & AHD_NEW_IOCELL_OPTS) == 0) { in ahd_chip_init()
7369 ahd_outb(ahd, NEGOADDR, target); in ahd_chip_init()
7370 ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PER_DEV0); in ahd_chip_init()
7372 ahd_outb(ahd, ANNEXDAT, 0); in ahd_chip_init()
7380 tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, in ahd_chip_init()
7382 ahd_compile_devinfo(&devinfo, ahd->our_id, in ahd_chip_init()
7385 ahd_update_neg_table(ahd, &devinfo, &tinfo->curr); in ahd_chip_init()
7388 ahd_outb(ahd, CLRSINT3, NTRAMPERR|OSRAMPERR); in ahd_chip_init()
7389 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_chip_init()
7396 if ((ahd->bugs & AHD_ABORT_LQI_BUG) == 0) in ahd_chip_init()
7397 ahd_outb(ahd, LQCTL1, ABORTPENDING); in ahd_chip_init()
7400 ahd_outb(ahd, LQCTL1, 0); in ahd_chip_init()
7403 ahd->qoutfifonext = 0; in ahd_chip_init()
7404 ahd->qoutfifonext_valid_tag = QOUTFIFO_ENTRY_VALID; in ahd_chip_init()
7405 ahd_outb(ahd, QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID); in ahd_chip_init()
7407 ahd->qoutfifo[i].valid_tag = 0; in ahd_chip_init()
7408 ahd_sync_qoutfifo(ahd, BUS_DMASYNC_PREREAD); in ahd_chip_init()
7410 ahd->qinfifonext = 0; in ahd_chip_init()
7412 ahd->qinfifo[i] = SCB_LIST_NULL; in ahd_chip_init()
7414 if ((ahd->features & AHD_TARGETMODE) != 0) { in ahd_chip_init()
7417 ahd->targetcmds[i].cmd_valid = 0; in ahd_chip_init()
7418 ahd_sync_tqinfifo(ahd, BUS_DMASYNC_PREREAD); in ahd_chip_init()
7419 ahd->tqinfifonext = 1; in ahd_chip_init()
7420 ahd_outb(ahd, KERNEL_TQINPOS, ahd->tqinfifonext - 1); in ahd_chip_init()
7421 ahd_outb(ahd, TQINPOS, ahd->tqinfifonext); in ahd_chip_init()
7425 ahd_outb(ahd, SEQ_FLAGS, 0); in ahd_chip_init()
7426 ahd_outb(ahd, SEQ_FLAGS2, 0); in ahd_chip_init()
7429 ahd_outw(ahd, WAITING_TID_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7430 ahd_outw(ahd, WAITING_TID_TAIL, SCB_LIST_NULL); in ahd_chip_init()
7431 ahd_outw(ahd, MK_MESSAGE_SCB, SCB_LIST_NULL); in ahd_chip_init()
7432 ahd_outw(ahd, MK_MESSAGE_SCSIID, 0xFF); in ahd_chip_init()
7434 ahd_outw(ahd, WAITING_SCB_TAILS + (2 * i), SCB_LIST_NULL); in ahd_chip_init()
7439 ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7440 ahd_outw(ahd, COMPLETE_SCB_DMAINPROG_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7441 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7442 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL); in ahd_chip_init()
7443 ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7448 ahd->qfreeze_cnt = 0; in ahd_chip_init()
7449 ahd_outw(ahd, QFREEZE_COUNT, 0); in ahd_chip_init()
7450 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, 0); in ahd_chip_init()
7455 busaddr = ahd->shared_data_map.physaddr; in ahd_chip_init()
7456 ahd_outl(ahd, SHARED_DATA_ADDR, busaddr); in ahd_chip_init()
7457 ahd_outl(ahd, QOUTFIFO_NEXT_ADDR, busaddr); in ahd_chip_init()
7465 if ((ahd->flags & AHD_INITIATORROLE) != 0) in ahd_chip_init()
7467 ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq_template); in ahd_chip_init()
7474 ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(target, 'A', lun)); in ahd_chip_init()
7483 ahd_outb(ahd, CMDSIZE_TABLE, 5); in ahd_chip_init()
7484 ahd_outb(ahd, CMDSIZE_TABLE + 1, 9); in ahd_chip_init()
7485 ahd_outb(ahd, CMDSIZE_TABLE + 2, 9); in ahd_chip_init()
7486 ahd_outb(ahd, CMDSIZE_TABLE + 3, 0); in ahd_chip_init()
7487 ahd_outb(ahd, CMDSIZE_TABLE + 4, 15); in ahd_chip_init()
7488 ahd_outb(ahd, CMDSIZE_TABLE + 5, 11); in ahd_chip_init()
7489 ahd_outb(ahd, CMDSIZE_TABLE + 6, 0); in ahd_chip_init()
7490 ahd_outb(ahd, CMDSIZE_TABLE + 7, 0); in ahd_chip_init()
7493 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_chip_init()
7494 ahd_outb(ahd, QOFF_CTLSTA, SCB_QSIZE_512); in ahd_chip_init()
7495 ahd->qinfifonext = 0; in ahd_chip_init()
7496 ahd_set_hnscb_qoff(ahd, ahd->qinfifonext); in ahd_chip_init()
7497 ahd_set_hescb_qoff(ahd, 0); in ahd_chip_init()
7498 ahd_set_snscb_qoff(ahd, 0); in ahd_chip_init()
7499 ahd_set_sescb_qoff(ahd, 0); in ahd_chip_init()
7500 ahd_set_sdscb_qoff(ahd, 0); in ahd_chip_init()
7505 busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr); in ahd_chip_init()
7506 ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr); in ahd_chip_init()
7511 ahd_outw(ahd, INT_COALESCING_CMDCOUNT, 0); in ahd_chip_init()
7512 ahd_outw(ahd, CMDS_PENDING, 0); in ahd_chip_init()
7513 ahd_update_coalescing_values(ahd, ahd->int_coalescing_timer, in ahd_chip_init()
7514 ahd->int_coalescing_maxcmds, in ahd_chip_init()
7515 ahd->int_coalescing_mincmds); in ahd_chip_init()
7516 ahd_enable_coalescing(ahd, FALSE); in ahd_chip_init()
7518 ahd_loadseq(ahd); in ahd_chip_init()
7519 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_chip_init()
7521 if (ahd->features & AHD_AIC79XXB_SLOWCRC) { in ahd_chip_init()
7522 u_int negodat3 = ahd_inb(ahd, NEGCONOPTS); in ahd_chip_init()
7525 ahd_outb(ahd, NEGCONOPTS, negodat3); in ahd_chip_init()
7526 negodat3 = ahd_inb(ahd, NEGCONOPTS); in ahd_chip_init()
7540 ahd_default_config(struct ahd_softc *ahd) in ahd_default_config() argument
7544 ahd->our_id = 7; in ahd_default_config()
7551 if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) { in ahd_default_config()
7553 "Failing attach\n", ahd_name(ahd)); in ahd_default_config()
7563 tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, in ahd_default_config()
7572 ahd->user_discenable |= target_mask; in ahd_default_config()
7574 ahd->user_tagenable |= target_mask; in ahd_default_config()
7587 if ((ahd->features & AHD_RTI) != 0) in ahd_default_config()
7600 ahd_compile_devinfo(&devinfo, ahd->our_id, in ahd_default_config()
7604 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_default_config()
7606 ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0, in ahd_default_config()
7617 ahd_parse_cfgdata(struct ahd_softc *ahd, struct seeprom_config *sc) in ahd_parse_cfgdata() argument
7623 ahd->our_id = sc->brtime_id & CFSCSIID; in ahd_parse_cfgdata()
7630 if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) { in ahd_parse_cfgdata()
7632 "Failing attach\n", ahd_name(ahd)); in ahd_parse_cfgdata()
7643 tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, in ahd_parse_cfgdata()
7654 ahd->user_discenable &= ~target_mask; in ahd_parse_cfgdata()
7656 ahd->user_tagenable &= ~target_mask; in ahd_parse_cfgdata()
7659 ahd->user_discenable |= target_mask; in ahd_parse_cfgdata()
7660 ahd->user_tagenable |= target_mask; in ahd_parse_cfgdata()
7688 if ((ahd->features & AHD_RTI) != 0) in ahd_parse_cfgdata()
7714 ahd_compile_devinfo(&devinfo, ahd->our_id, in ahd_parse_cfgdata()
7717 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_parse_cfgdata()
7719 ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0, in ahd_parse_cfgdata()
7724 ahd->flags &= ~AHD_SPCHK_ENB_A; in ahd_parse_cfgdata()
7726 ahd->flags |= AHD_SPCHK_ENB_A; in ahd_parse_cfgdata()
7728 ahd->flags &= ~AHD_RESET_BUS_A; in ahd_parse_cfgdata()
7730 ahd->flags |= AHD_RESET_BUS_A; in ahd_parse_cfgdata()
7732 ahd->flags &= ~AHD_EXTENDED_TRANS_A; in ahd_parse_cfgdata()
7734 ahd->flags |= AHD_EXTENDED_TRANS_A; in ahd_parse_cfgdata()
7736 ahd->flags &= ~AHD_BIOS_ENABLED; in ahd_parse_cfgdata()
7738 ahd->flags |= AHD_BIOS_ENABLED; in ahd_parse_cfgdata()
7740 ahd->flags &= ~AHD_STPWLEVEL_A; in ahd_parse_cfgdata()
7742 ahd->flags |= AHD_STPWLEVEL_A; in ahd_parse_cfgdata()
7751 ahd_parse_vpddata(struct ahd_softc *ahd, struct vpd_config *vpd) in ahd_parse_vpddata() argument
7759 ahd->flags |= AHD_BOOT_CHANNEL; in ahd_parse_vpddata()
7764 ahd_intr_enable(struct ahd_softc *ahd, int enable) in ahd_intr_enable() argument
7768 hcntrl = ahd_inb(ahd, HCNTRL); in ahd_intr_enable()
7770 ahd->pause &= ~INTEN; in ahd_intr_enable()
7771 ahd->unpause &= ~INTEN; in ahd_intr_enable()
7774 ahd->pause |= INTEN; in ahd_intr_enable()
7775 ahd->unpause |= INTEN; in ahd_intr_enable()
7777 ahd_outb(ahd, HCNTRL, hcntrl); in ahd_intr_enable()
7781 ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds, in ahd_update_coalescing_values() argument
7786 ahd->int_coalescing_timer = timer; in ahd_update_coalescing_values()
7792 ahd->int_coalescing_maxcmds = maxcmds; in ahd_update_coalescing_values()
7793 ahd_outw(ahd, INT_COALESCING_TIMER, timer / AHD_TIMER_US_PER_TICK); in ahd_update_coalescing_values()
7794 ahd_outb(ahd, INT_COALESCING_MAXCMDS, -maxcmds); in ahd_update_coalescing_values()
7795 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds); in ahd_update_coalescing_values()
7799 ahd_enable_coalescing(struct ahd_softc *ahd, int enable) in ahd_enable_coalescing() argument
7802 ahd->hs_mailbox &= ~ENINT_COALESCE; in ahd_enable_coalescing()
7804 ahd->hs_mailbox |= ENINT_COALESCE; in ahd_enable_coalescing()
7805 ahd_outb(ahd, HS_MAILBOX, ahd->hs_mailbox); in ahd_enable_coalescing()
7806 ahd_flush_device_writes(ahd); in ahd_enable_coalescing()
7807 ahd_run_qoutfifo(ahd); in ahd_enable_coalescing()
7818 ahd_pause_and_flushwork(struct ahd_softc *ahd) in ahd_pause_and_flushwork() argument
7824 ahd->flags |= AHD_ALL_INTERRUPTS; in ahd_pause_and_flushwork()
7825 ahd_pause(ahd); in ahd_pause_and_flushwork()
7831 ahd->qfreeze_cnt--; in ahd_pause_and_flushwork()
7832 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt); in ahd_pause_and_flushwork()
7833 ahd_outb(ahd, SEQ_FLAGS2, ahd_inb(ahd, SEQ_FLAGS2) | SELECTOUT_QFROZEN); in ahd_pause_and_flushwork()
7836 ahd_unpause(ahd); in ahd_pause_and_flushwork()
7843 ahd_intr(ahd); in ahd_pause_and_flushwork()
7844 ahd_pause(ahd); in ahd_pause_and_flushwork()
7845 intstat = ahd_inb(ahd, INTSTAT); in ahd_pause_and_flushwork()
7847 ahd_clear_critical_section(ahd); in ahd_pause_and_flushwork()
7848 intstat = ahd_inb(ahd, INTSTAT); in ahd_pause_and_flushwork()
7851 && (intstat != 0xFF || (ahd->features & AHD_REMOVABLE) == 0) in ahd_pause_and_flushwork()
7853 || (ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0 in ahd_pause_and_flushwork()
7854 || (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0)); in ahd_pause_and_flushwork()
7858 ahd_inb(ahd, INTSTAT)); in ahd_pause_and_flushwork()
7860 ahd->qfreeze_cnt++; in ahd_pause_and_flushwork()
7861 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt); in ahd_pause_and_flushwork()
7863 ahd_flush_qoutfifo(ahd); in ahd_pause_and_flushwork()
7865 ahd->flags &= ~AHD_ALL_INTERRUPTS; in ahd_pause_and_flushwork()
7869 ahd_suspend(struct ahd_softc *ahd) in ahd_suspend() argument
7871 ahd_pause_and_flushwork(ahd); in ahd_suspend()
7873 if (LIST_FIRST(&ahd->pending_scbs) != NULL) { in ahd_suspend()
7874 ahd_unpause(ahd); in ahd_suspend()
7877 ahd_shutdown(ahd); in ahd_suspend()
7882 ahd_resume(struct ahd_softc *ahd) in ahd_resume() argument
7884 ahd_reset(ahd, /*reinit*/TRUE); in ahd_resume()
7885 ahd_intr_enable(ahd, TRUE); in ahd_resume()
7886 ahd_restart(ahd); in ahd_resume()
7899 ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl) in ahd_index_busy_tcl() argument
7904 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_index_busy_tcl()
7905 *saved_scbid = ahd_get_scbptr(ahd); in ahd_index_busy_tcl()
7906 ahd_set_scbptr(ahd, TCL_LUN(tcl) in ahd_index_busy_tcl()
7921 ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl) in ahd_find_busy_tcl() argument
7927 scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl); in ahd_find_busy_tcl()
7928 scbid = ahd_inw_scbram(ahd, scb_offset); in ahd_find_busy_tcl()
7929 ahd_set_scbptr(ahd, saved_scbptr); in ahd_find_busy_tcl()
7934 ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid) in ahd_busy_tcl() argument
7939 scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl); in ahd_busy_tcl()
7940 ahd_outw(ahd, scb_offset, scbid); in ahd_busy_tcl()
7941 ahd_set_scbptr(ahd, saved_scbptr); in ahd_busy_tcl()
7946 ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target, in ahd_match_scb() argument
7949 int targ = SCB_GET_TARGET(ahd, scb); in ahd_match_scb()
7950 char chan = SCB_GET_CHANNEL(ahd, scb); in ahd_match_scb()
7982 ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb) in ahd_freeze_devq() argument
7988 target = SCB_GET_TARGET(ahd, scb); in ahd_freeze_devq()
7990 channel = SCB_GET_CHANNEL(ahd, scb); in ahd_freeze_devq()
7992 ahd_search_qinfifo(ahd, target, channel, lun, in ahd_freeze_devq()
7996 ahd_platform_freeze_devq(ahd, scb); in ahd_freeze_devq()
8000 ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, struct scb *scb) in ahd_qinfifo_requeue_tail() argument
8005 saved_modes = ahd_save_modes(ahd); in ahd_qinfifo_requeue_tail()
8006 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_qinfifo_requeue_tail()
8008 if (ahd_qinfifo_count(ahd) != 0) { in ahd_qinfifo_requeue_tail()
8012 prev_pos = AHD_QIN_WRAP(ahd->qinfifonext - 1); in ahd_qinfifo_requeue_tail()
8013 prev_tag = ahd->qinfifo[prev_pos]; in ahd_qinfifo_requeue_tail()
8014 prev_scb = ahd_lookup_scb(ahd, prev_tag); in ahd_qinfifo_requeue_tail()
8016 ahd_qinfifo_requeue(ahd, prev_scb, scb); in ahd_qinfifo_requeue_tail()
8017 ahd_set_hnscb_qoff(ahd, ahd->qinfifonext); in ahd_qinfifo_requeue_tail()
8018 ahd_restore_modes(ahd, saved_modes); in ahd_qinfifo_requeue_tail()
8022 ahd_qinfifo_requeue(struct ahd_softc *ahd, struct scb *prev_scb, in ahd_qinfifo_requeue() argument
8029 ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr); in ahd_qinfifo_requeue()
8032 ahd_sync_scb(ahd, prev_scb, in ahd_qinfifo_requeue()
8035 ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb); in ahd_qinfifo_requeue()
8036 ahd->qinfifonext++; in ahd_qinfifo_requeue()
8037 scb->hscb->next_hscb_busaddr = ahd->next_queued_hscb->hscb_busaddr; in ahd_qinfifo_requeue()
8038 ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahd_qinfifo_requeue()
8042 ahd_qinfifo_count(struct ahd_softc *ahd) in ahd_qinfifo_count() argument
8048 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_qinfifo_count()
8049 qinpos = ahd_get_snscb_qoff(ahd); in ahd_qinfifo_count()
8051 wrap_qinfifonext = AHD_QIN_WRAP(ahd->qinfifonext); in ahd_qinfifo_count()
8056 + ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos); in ahd_qinfifo_count()
8060 ahd_reset_cmds_pending(struct ahd_softc *ahd) in ahd_reset_cmds_pending() argument
8066 saved_modes = ahd_save_modes(ahd); in ahd_reset_cmds_pending()
8067 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_reset_cmds_pending()
8073 ahd_flush_qoutfifo(ahd); in ahd_reset_cmds_pending()
8076 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_reset_cmds_pending()
8079 ahd_outw(ahd, CMDS_PENDING, pending_cmds - ahd_qinfifo_count(ahd)); in ahd_reset_cmds_pending()
8080 ahd_restore_modes(ahd, saved_modes); in ahd_reset_cmds_pending()
8081 ahd->flags &= ~AHD_UPDATE_PEND_CMDS; in ahd_reset_cmds_pending()
8085 ahd_done_with_status(struct ahd_softc *ahd, struct scb *scb, uint32_t status) in ahd_done_with_status() argument
8096 ahd_done(ahd, scb); in ahd_done_with_status()
8100 ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel, in ahd_search_qinfifo() argument
8121 saved_modes = ahd_save_modes(ahd); in ahd_search_qinfifo()
8122 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_search_qinfifo()
8128 if ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN|CCSCBDIR)) in ahd_search_qinfifo()
8130 ahd_outb(ahd, CCSCBCTL, in ahd_search_qinfifo()
8131 ahd_inb(ahd, CCSCBCTL) & ~(CCARREN|CCSCBEN)); in ahd_search_qinfifo()
8132 while ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN)) != 0) in ahd_search_qinfifo()
8136 qintail = AHD_QIN_WRAP(ahd->qinfifonext); in ahd_search_qinfifo()
8137 qinstart = ahd_get_snscb_qoff(ahd); in ahd_search_qinfifo()
8144 qinstart, ahd->qinfifonext); in ahd_search_qinfifo()
8151 ahd->qinfifonext = qinstart; in ahd_search_qinfifo()
8152 busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr); in ahd_search_qinfifo()
8153 ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr); in ahd_search_qinfifo()
8156 scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]); in ahd_search_qinfifo()
8159 qinpos, ahd->qinfifo[qinpos]); in ahd_search_qinfifo()
8163 if (ahd_match_scb(ahd, scb, target, channel, lun, tag, role)) { in ahd_search_qinfifo()
8172 ahd_done_with_status(ahd, scb, status); in ahd_search_qinfifo()
8177 printk(" 0x%x", ahd->qinfifo[qinpos]); in ahd_search_qinfifo()
8180 ahd_qinfifo_requeue(ahd, prev_scb, scb); in ahd_search_qinfifo()
8185 ahd_qinfifo_requeue(ahd, prev_scb, scb); in ahd_search_qinfifo()
8191 ahd_set_hnscb_qoff(ahd, ahd->qinfifonext); in ahd_search_qinfifo()
8202 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_search_qinfifo()
8203 seq_flags2 = ahd_inb(ahd, SEQ_FLAGS2); in ahd_search_qinfifo()
8205 scbid = ahd_inw(ahd, MK_MESSAGE_SCB); in ahd_search_qinfifo()
8206 mk_msg_scb = ahd_lookup_scb(ahd, scbid); in ahd_search_qinfifo()
8209 savedscbptr = ahd_get_scbptr(ahd); in ahd_search_qinfifo()
8210 tid_next = ahd_inw(ahd, WAITING_TID_HEAD); in ahd_search_qinfifo()
8221 if (scbid >= ahd->scb_data.numscbs) { in ahd_search_qinfifo()
8224 ahd_name(ahd), scbid, ahd->scb_data.numscbs); in ahd_search_qinfifo()
8225 ahd_dump_card_state(ahd); in ahd_search_qinfifo()
8228 scb = ahd_lookup_scb(ahd, scbid); in ahd_search_qinfifo()
8231 ahd_name(ahd), scbid); in ahd_search_qinfifo()
8234 ahd_set_scbptr(ahd, scbid); in ahd_search_qinfifo()
8235 tid_next = ahd_inw_scbram(ahd, SCB_NEXT2); in ahd_search_qinfifo()
8236 if (ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD, in ahd_search_qinfifo()
8246 printk(" %d ( ", SCB_GET_TARGET(ahd, scb)); in ahd_search_qinfifo()
8248 found += ahd_search_scb_list(ahd, target, channel, in ahd_search_qinfifo()
8251 SCB_GET_TARGET(ahd, scb)); in ahd_search_qinfifo()
8257 && ahd_match_scb(ahd, mk_msg_scb, target, channel, in ahd_search_qinfifo()
8268 ahd_done_with_status(ahd, mk_msg_scb, status); in ahd_search_qinfifo()
8281 + (2 * SCB_GET_TARGET(ahd, mk_msg_scb)); in ahd_search_qinfifo()
8282 ahd_outw(ahd, tail_offset, tid_tail); in ahd_search_qinfifo()
8285 ahd_outb(ahd, SEQ_FLAGS2, seq_flags2); in ahd_search_qinfifo()
8286 ahd_outw(ahd, CMDS_PENDING, in ahd_search_qinfifo()
8287 ahd_inw(ahd, CMDS_PENDING)-1); in ahd_search_qinfifo()
8301 && ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD, in ahd_search_qinfifo()
8310 tid_head = ahd_inw(ahd, MK_MESSAGE_SCB); in ahd_search_qinfifo()
8312 ahd_outb(ahd, SEQ_FLAGS2, seq_flags2); in ahd_search_qinfifo()
8316 ahd_stitch_tid_list(ahd, tid_prev, tid_head, tid_next); in ahd_search_qinfifo()
8324 ahd_set_scbptr(ahd, savedscbptr); in ahd_search_qinfifo()
8325 ahd_restore_modes(ahd, saved_modes); in ahd_search_qinfifo()
8330 ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel, in ahd_search_scb_list() argument
8341 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_search_scb_list()
8347 if (scbid >= ahd->scb_data.numscbs) { in ahd_search_scb_list()
8350 ahd_name(ahd), scbid, ahd->scb_data.numscbs); in ahd_search_scb_list()
8351 ahd_dump_card_state(ahd); in ahd_search_scb_list()
8354 scb = ahd_lookup_scb(ahd, scbid); in ahd_search_scb_list()
8357 ahd_name(ahd), scbid); in ahd_search_scb_list()
8360 ahd_set_scbptr(ahd, scbid); in ahd_search_scb_list()
8362 next = ahd_inw_scbram(ahd, SCB_NEXT); in ahd_search_scb_list()
8363 if (ahd_match_scb(ahd, scb, target, channel, in ahd_search_scb_list()
8373 ahd_done_with_status(ahd, scb, status); in ahd_search_scb_list()
8376 ahd_rem_wscb(ahd, scbid, prev, next, tid); in ahd_search_scb_list()
8393 ahd_outw(ahd, CMDS_PENDING, ahd_inw(ahd, CMDS_PENDING) - found); in ahd_search_scb_list()
8398 ahd_stitch_tid_list(struct ahd_softc *ahd, u_int tid_prev, in ahd_stitch_tid_list() argument
8401 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_stitch_tid_list()
8407 ahd_outw(ahd, WAITING_TID_HEAD, tid_next); in ahd_stitch_tid_list()
8409 ahd_set_scbptr(ahd, tid_prev); in ahd_stitch_tid_list()
8410 ahd_outw(ahd, SCB_NEXT2, tid_next); in ahd_stitch_tid_list()
8413 ahd_outw(ahd, WAITING_TID_TAIL, tid_prev); in ahd_stitch_tid_list()
8418 ahd_outw(ahd, WAITING_TID_HEAD, tid_cur); in ahd_stitch_tid_list()
8420 ahd_set_scbptr(ahd, tid_prev); in ahd_stitch_tid_list()
8421 ahd_outw(ahd, SCB_NEXT2, tid_cur); in ahd_stitch_tid_list()
8423 ahd_set_scbptr(ahd, tid_cur); in ahd_stitch_tid_list()
8424 ahd_outw(ahd, SCB_NEXT2, tid_next); in ahd_stitch_tid_list()
8427 ahd_outw(ahd, WAITING_TID_TAIL, tid_cur); in ahd_stitch_tid_list()
8436 ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid, in ahd_rem_wscb() argument
8441 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_rem_wscb()
8443 ahd_set_scbptr(ahd, prev); in ahd_rem_wscb()
8444 ahd_outw(ahd, SCB_NEXT, next); in ahd_rem_wscb()
8456 && ahd_inw(ahd, tail_offset) == scbid) in ahd_rem_wscb()
8457 ahd_outw(ahd, tail_offset, prev); in ahd_rem_wscb()
8459 ahd_add_scb_to_free_list(ahd, scbid); in ahd_rem_wscb()
8469 ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid) in ahd_add_scb_to_free_list() argument
8487 ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel, in ahd_abort_scbs() argument
8500 saved_modes = ahd_save_modes(ahd); in ahd_abort_scbs()
8501 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_abort_scbs()
8503 found = ahd_search_qinfifo(ahd, target, channel, lun, SCB_LIST_NULL, in ahd_abort_scbs()
8535 scbid = ahd_find_busy_tcl(ahd, tcl); in ahd_abort_scbs()
8536 scbp = ahd_lookup_scb(ahd, scbid); in ahd_abort_scbs()
8538 || ahd_match_scb(ahd, scbp, target, channel, in ahd_abort_scbs()
8541 ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(i, 'A', j)); in ahd_abort_scbs()
8550 ahd_flush_qoutfifo(ahd); in ahd_abort_scbs()
8558 scbp_next = LIST_FIRST(&ahd->pending_scbs); in ahd_abort_scbs()
8562 if (ahd_match_scb(ahd, scbp, target, channel, lun, tag, role)) { in ahd_abort_scbs()
8572 ahd_done(ahd, scbp); in ahd_abort_scbs()
8576 ahd_restore_modes(ahd, saved_modes); in ahd_abort_scbs()
8577 ahd_platform_abort_scbs(ahd, target, channel, lun, tag, role, status); in ahd_abort_scbs()
8578 ahd->flags |= AHD_UPDATE_PEND_CMDS; in ahd_abort_scbs()
8583 ahd_reset_current_bus(struct ahd_softc *ahd) in ahd_reset_current_bus() argument
8587 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_reset_current_bus()
8588 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) & ~ENSCSIRST); in ahd_reset_current_bus()
8589 scsiseq = ahd_inb(ahd, SCSISEQ0) & ~(ENSELO|ENARBO|SCSIRSTO); in ahd_reset_current_bus()
8590 ahd_outb(ahd, SCSISEQ0, scsiseq | SCSIRSTO); in ahd_reset_current_bus()
8591 ahd_flush_device_writes(ahd); in ahd_reset_current_bus()
8594 ahd_outb(ahd, SCSISEQ0, scsiseq); in ahd_reset_current_bus()
8595 ahd_flush_device_writes(ahd); in ahd_reset_current_bus()
8597 if ((ahd->bugs & AHD_SCSIRST_BUG) != 0) { in ahd_reset_current_bus()
8604 ahd_reset(ahd, /*reinit*/TRUE); in ahd_reset_current_bus()
8605 ahd_intr_enable(ahd, /*enable*/TRUE); in ahd_reset_current_bus()
8606 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_reset_current_bus()
8609 ahd_clear_intstat(ahd); in ahd_reset_current_bus()
8613 ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset) in ahd_reset_channel() argument
8627 if (ahd->flags & AHD_BUS_RESET_ACTIVE) { in ahd_reset_channel()
8629 ahd_name(ahd)); in ahd_reset_channel()
8632 ahd->flags |= AHD_BUS_RESET_ACTIVE; in ahd_reset_channel()
8634 ahd->pending_device = NULL; in ahd_reset_channel()
8641 ahd_pause(ahd); in ahd_reset_channel()
8644 ahd_clear_critical_section(ahd); in ahd_reset_channel()
8651 ahd_run_qoutfifo(ahd); in ahd_reset_channel()
8653 if ((ahd->flags & AHD_TARGETROLE) != 0) { in ahd_reset_channel()
8654 ahd_run_tqinfifo(ahd, /*paused*/TRUE); in ahd_reset_channel()
8657 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reset_channel()
8663 ahd_outb(ahd, SCSISEQ0, 0); in ahd_reset_channel()
8664 ahd_outb(ahd, SCSISEQ1, 0); in ahd_reset_channel()
8671 next_fifo = fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO; in ahd_reset_channel()
8677 ahd_set_modes(ahd, next_fifo, next_fifo); in ahd_reset_channel()
8678 ahd_outb(ahd, DFCNTRL, in ahd_reset_channel()
8679 ahd_inb(ahd, DFCNTRL) & ~(SCSIEN|HDMAEN)); in ahd_reset_channel()
8680 while ((ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0) in ahd_reset_channel()
8685 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reset_channel()
8686 ahd_outb(ahd, DFFSTAT, next_fifo); in ahd_reset_channel()
8692 ahd_clear_msg_state(ahd); in ahd_reset_channel()
8693 ahd_outb(ahd, SIMODE1, in ahd_reset_channel()
8694 ahd_inb(ahd, SIMODE1) & ~(ENBUSFREE|ENSCSIRST)); in ahd_reset_channel()
8697 ahd_reset_current_bus(ahd); in ahd_reset_channel()
8699 ahd_clear_intstat(ahd); in ahd_reset_channel()
8705 found = ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, channel, in ahd_reset_channel()
8712 ahd_clear_fifo(ahd, 0); in ahd_reset_channel()
8713 ahd_clear_fifo(ahd, 1); in ahd_reset_channel()
8718 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI); in ahd_reset_channel()
8723 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST); in ahd_reset_channel()
8724 scsiseq = ahd_inb(ahd, SCSISEQ_TEMPLATE); in ahd_reset_channel()
8725 ahd_outb(ahd, SCSISEQ1, scsiseq & (ENSELI|ENRSELI|ENAUTOATNP)); in ahd_reset_channel()
8727 max_scsiid = (ahd->features & AHD_WIDE) ? 15 : 7; in ahd_reset_channel()
8737 tstate = ahd->enabled_targets[target]; in ahd_reset_channel()
8747 ahd_queue_lstate_event(ahd, lstate, CAM_TARGET_WILDCARD, in ahd_reset_channel()
8749 ahd_send_lstate_events(ahd, lstate); in ahd_reset_channel()
8758 if (ahd->enabled_targets[target] == NULL) in ahd_reset_channel()
8766 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_reset_channel()
8768 ahd_set_syncrate(ahd, &devinfo, /*period*/0, in ahd_reset_channel()
8775 ahd_send_async(ahd, caminfo.channel, CAM_TARGET_WILDCARD, in ahd_reset_channel()
8778 ahd_restart(ahd); in ahd_reset_channel()
8787 struct ahd_softc *ahd = from_timer(ahd, t, stat_timer); in ahd_stat_timer() local
8791 ahd_lock(ahd, &s); in ahd_stat_timer()
8793 enint_coal = ahd->hs_mailbox & ENINT_COALESCE; in ahd_stat_timer()
8794 if (ahd->cmdcmplt_total > ahd->int_coalescing_threshold) in ahd_stat_timer()
8796 else if (ahd->cmdcmplt_total < ahd->int_coalescing_stop_threshold) in ahd_stat_timer()
8799 if (enint_coal != (ahd->hs_mailbox & ENINT_COALESCE)) { in ahd_stat_timer()
8800 ahd_enable_coalescing(ahd, enint_coal); in ahd_stat_timer()
8805 ahd_name(ahd), in ahd_stat_timer()
8807 ahd->cmdcmplt_total); in ahd_stat_timer()
8811 ahd->cmdcmplt_bucket = (ahd->cmdcmplt_bucket+1) & (AHD_STAT_BUCKETS-1); in ahd_stat_timer()
8812 ahd->cmdcmplt_total -= ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]; in ahd_stat_timer()
8813 ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket] = 0; in ahd_stat_timer()
8814 ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US); in ahd_stat_timer()
8815 ahd_unlock(ahd, &s); in ahd_stat_timer()
8821 ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb) in ahd_handle_scsi_status() argument
8837 if (ahd_is_paused(ahd)) { in ahd_handle_scsi_status()
8841 ahd_pause(ahd); in ahd_handle_scsi_status()
8845 ahd_freeze_devq(ahd, scb); in ahd_handle_scsi_status()
8847 ahd->qfreeze_cnt++; in ahd_handle_scsi_status()
8848 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt); in ahd_handle_scsi_status()
8851 ahd_unpause(ahd); in ahd_handle_scsi_status()
8861 ahd_done(ahd, scb); in ahd_handle_scsi_status()
8871 ahd_sync_sense(ahd, scb, BUS_DMASYNC_POSTREAD); in ahd_handle_scsi_status()
8876 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
8886 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
8925 ahd_done(ahd, scb); in ahd_handle_scsi_status()
8939 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
8949 SCB_GET_TARGET(ahd, scb), in ahd_handle_scsi_status()
8951 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_scsi_status()
8953 targ_info = ahd_fetch_transinfo(ahd, in ahd_handle_scsi_status()
8964 ahd_update_residual(ahd, scb); in ahd_handle_scsi_status()
8967 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
8972 sg = ahd_sg_setup(ahd, scb, sg, ahd_get_sense_bufaddr(ahd, scb), in ahd_handle_scsi_status()
8973 ahd_get_sense_bufsize(ahd, scb), in ahd_handle_scsi_status()
8982 sc->length = ahd_get_sense_bufsize(ahd, scb); in ahd_handle_scsi_status()
9003 ahd_update_neg_request(ahd, &devinfo, in ahd_handle_scsi_status()
9014 ahd_setup_data_scb(ahd, scb); in ahd_handle_scsi_status()
9016 ahd_queue_scb(ahd, scb); in ahd_handle_scsi_status()
9021 ahd_name(ahd)); in ahd_handle_scsi_status()
9024 ahd_done(ahd, scb); in ahd_handle_scsi_status()
9030 ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb) in ahd_handle_scb_status() argument
9033 ahd_handle_scsi_status(ahd, scb); in ahd_handle_scb_status()
9035 ahd_calc_residual(ahd, scb); in ahd_handle_scb_status()
9036 ahd_done(ahd, scb); in ahd_handle_scb_status()
9044 ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb) in ahd_calc_residual() argument
9094 ahd_print_path(ahd, scb); in ahd_calc_residual()
9097 ahd_freeze_devq(ahd, scb); in ahd_calc_residual()
9112 sg = ahd_sg_bus_to_virt(ahd, scb, resid_sgptr & SG_PTR_MASK); in ahd_calc_residual()
9134 ahd_print_path(ahd, scb); in ahd_calc_residual()
9147 ahd_queue_lstate_event(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate, in ahd_queue_lstate_event() argument
9198 ahd_send_lstate_events(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate) in ahd_send_lstate_events() argument
9234 ahd_dumpseq(struct ahd_softc* ahd) in ahd_dumpseq() argument
9241 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM); in ahd_dumpseq()
9242 ahd_outw(ahd, PRGMCNT, 0); in ahd_dumpseq()
9246 ahd_insb(ahd, SEQRAM, ins_bytes, 4); in ahd_dumpseq()
9256 ahd_loadseq(struct ahd_softc *ahd) in ahd_loadseq() argument
9276 ahd_name(ahd)); in ahd_loadseq()
9308 sg_prefetch_align = ahd->pci_cachesize; in ahd_loadseq()
9331 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) in ahd_loadseq()
9355 (ahd->overrun_buf - (uint8_t *)ahd->qoutfifo) / 256; in ahd_loadseq()
9361 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM); in ahd_loadseq()
9362 ahd_outw(ahd, PRGMCNT, 0); in ahd_loadseq()
9365 if (ahd_check_patch(ahd, &cur_patch, i, &skip_addr) == 0) { in ahd_loadseq()
9393 ahd_download_instr(ahd, i, download_consts); in ahd_loadseq()
9397 ahd->num_critical_sections = cs_count; in ahd_loadseq()
9401 ahd->critical_sections = kmemdup(cs_table, cs_count, GFP_ATOMIC); in ahd_loadseq()
9402 if (ahd->critical_sections == NULL) in ahd_loadseq()
9405 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE); in ahd_loadseq()
9410 ahd_name(ahd), ahd->features, ahd->bugs, ahd->flags); in ahd_loadseq()
9415 ahd_check_patch(struct ahd_softc *ahd, const struct patch **start_patch, in ahd_check_patch() argument
9428 if (cur_patch->patch_func(ahd) == 0) { in ahd_check_patch()
9451 ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address) in ahd_resolve_seqaddr() argument
9464 ahd_check_patch(ahd, &cur_patch, i, &skip_addr); in ahd_resolve_seqaddr()
9480 ahd_download_instr(struct ahd_softc *ahd, u_int instrptr, uint8_t *dconsts) in ahd_download_instr() argument
9508 fmt3_ins->address = ahd_resolve_seqaddr(ahd, fmt3_ins->address); in ahd_download_instr()
9539 ahd_outsb(ahd, SEQRAM, instr.bytes, 4); in ahd_download_instr()
9549 ahd_probe_stack_size(struct ahd_softc *ahd) in ahd_probe_stack_size() argument
9564 ahd_outb(ahd, STACK, i & 0xFF); in ahd_probe_stack_size()
9565 ahd_outb(ahd, STACK, (i >> 8) & 0xFF); in ahd_probe_stack_size()
9572 stack_entry = ahd_inb(ahd, STACK) in ahd_probe_stack_size()
9573 |(ahd_inb(ahd, STACK) << 8); in ahd_probe_stack_size()
9632 ahd_dump_card_state(struct ahd_softc *ahd) in ahd_dump_card_state() argument
9643 if (ahd_is_paused(ahd)) { in ahd_dump_card_state()
9647 ahd_pause(ahd); in ahd_dump_card_state()
9649 saved_modes = ahd_save_modes(ahd); in ahd_dump_card_state()
9650 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_dump_card_state()
9653 ahd_name(ahd), in ahd_dump_card_state()
9654 ahd_inw(ahd, CURADDR), in ahd_dump_card_state()
9655 ahd_build_mode_state(ahd, ahd->saved_src_mode, in ahd_dump_card_state()
9656 ahd->saved_dst_mode)); in ahd_dump_card_state()
9660 if (ahd_check_cmdcmpltqueues(ahd)) in ahd_dump_card_state()
9667 ahd_intstat_print(ahd_inb(ahd, INTSTAT), &cur_col, 50); in ahd_dump_card_state()
9668 ahd_seloid_print(ahd_inb(ahd, SELOID), &cur_col, 50); in ahd_dump_card_state()
9669 ahd_selid_print(ahd_inb(ahd, SELID), &cur_col, 50); in ahd_dump_card_state()
9670 ahd_hs_mailbox_print(ahd_inb(ahd, LOCAL_HS_MAILBOX), &cur_col, 50); in ahd_dump_card_state()
9671 ahd_intctl_print(ahd_inb(ahd, INTCTL), &cur_col, 50); in ahd_dump_card_state()
9672 ahd_seqintstat_print(ahd_inb(ahd, SEQINTSTAT), &cur_col, 50); in ahd_dump_card_state()
9673 ahd_saved_mode_print(ahd_inb(ahd, SAVED_MODE), &cur_col, 50); in ahd_dump_card_state()
9674 ahd_dffstat_print(ahd_inb(ahd, DFFSTAT), &cur_col, 50); in ahd_dump_card_state()
9675 ahd_scsisigi_print(ahd_inb(ahd, SCSISIGI), &cur_col, 50); in ahd_dump_card_state()
9676 ahd_scsiphase_print(ahd_inb(ahd, SCSIPHASE), &cur_col, 50); in ahd_dump_card_state()
9677 ahd_scsibus_print(ahd_inb(ahd, SCSIBUS), &cur_col, 50); in ahd_dump_card_state()
9678 ahd_lastphase_print(ahd_inb(ahd, LASTPHASE), &cur_col, 50); in ahd_dump_card_state()
9679 ahd_scsiseq0_print(ahd_inb(ahd, SCSISEQ0), &cur_col, 50); in ahd_dump_card_state()
9680 ahd_scsiseq1_print(ahd_inb(ahd, SCSISEQ1), &cur_col, 50); in ahd_dump_card_state()
9681 ahd_seqctl0_print(ahd_inb(ahd, SEQCTL0), &cur_col, 50); in ahd_dump_card_state()
9682 ahd_seqintctl_print(ahd_inb(ahd, SEQINTCTL), &cur_col, 50); in ahd_dump_card_state()
9683 ahd_seq_flags_print(ahd_inb(ahd, SEQ_FLAGS), &cur_col, 50); in ahd_dump_card_state()
9684 ahd_seq_flags2_print(ahd_inb(ahd, SEQ_FLAGS2), &cur_col, 50); in ahd_dump_card_state()
9685 ahd_qfreeze_count_print(ahd_inw(ahd, QFREEZE_COUNT), &cur_col, 50); in ahd_dump_card_state()
9686 ahd_kernel_qfreeze_count_print(ahd_inw(ahd, KERNEL_QFREEZE_COUNT), in ahd_dump_card_state()
9688 ahd_mk_message_scb_print(ahd_inw(ahd, MK_MESSAGE_SCB), &cur_col, 50); in ahd_dump_card_state()
9689 ahd_mk_message_scsiid_print(ahd_inb(ahd, MK_MESSAGE_SCSIID), in ahd_dump_card_state()
9691 ahd_sstat0_print(ahd_inb(ahd, SSTAT0), &cur_col, 50); in ahd_dump_card_state()
9692 ahd_sstat1_print(ahd_inb(ahd, SSTAT1), &cur_col, 50); in ahd_dump_card_state()
9693 ahd_sstat2_print(ahd_inb(ahd, SSTAT2), &cur_col, 50); in ahd_dump_card_state()
9694 ahd_sstat3_print(ahd_inb(ahd, SSTAT3), &cur_col, 50); in ahd_dump_card_state()
9695 ahd_perrdiag_print(ahd_inb(ahd, PERRDIAG), &cur_col, 50); in ahd_dump_card_state()
9696 ahd_simode1_print(ahd_inb(ahd, SIMODE1), &cur_col, 50); in ahd_dump_card_state()
9697 ahd_lqistat0_print(ahd_inb(ahd, LQISTAT0), &cur_col, 50); in ahd_dump_card_state()
9698 ahd_lqistat1_print(ahd_inb(ahd, LQISTAT1), &cur_col, 50); in ahd_dump_card_state()
9699 ahd_lqistat2_print(ahd_inb(ahd, LQISTAT2), &cur_col, 50); in ahd_dump_card_state()
9700 ahd_lqostat0_print(ahd_inb(ahd, LQOSTAT0), &cur_col, 50); in ahd_dump_card_state()
9701 ahd_lqostat1_print(ahd_inb(ahd, LQOSTAT1), &cur_col, 50); in ahd_dump_card_state()
9702 ahd_lqostat2_print(ahd_inb(ahd, LQOSTAT2), &cur_col, 50); in ahd_dump_card_state()
9706 ahd->scb_data.numscbs, ahd_inw(ahd, CMDS_PENDING), in ahd_dump_card_state()
9707 ahd_inw(ahd, LASTSCB), ahd_inw(ahd, CURRSCB), in ahd_dump_card_state()
9708 ahd_inw(ahd, NEXTSCB)); in ahd_dump_card_state()
9711 ahd_search_qinfifo(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS, in ahd_dump_card_state()
9714 saved_scb_index = ahd_get_scbptr(ahd); in ahd_dump_card_state()
9717 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_dump_card_state()
9721 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT)); in ahd_dump_card_state()
9722 ahd_set_scbptr(ahd, SCB_GET_TAG(scb)); in ahd_dump_card_state()
9723 ahd_scb_control_print(ahd_inb_scbram(ahd, SCB_CONTROL), in ahd_dump_card_state()
9725 ahd_scb_scsiid_print(ahd_inb_scbram(ahd, SCB_SCSIID), in ahd_dump_card_state()
9732 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) { in ahd_dump_card_state()
9742 LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) { in ahd_dump_card_state()
9750 scb_index = ahd_inw(ahd, COMPLETE_SCB_DMAINPROG_HEAD); in ahd_dump_card_state()
9753 ahd_set_scbptr(ahd, scb_index); in ahd_dump_card_state()
9755 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_dump_card_state()
9760 scb_index = ahd_inw(ahd, COMPLETE_SCB_HEAD); in ahd_dump_card_state()
9763 ahd_set_scbptr(ahd, scb_index); in ahd_dump_card_state()
9765 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_dump_card_state()
9770 scb_index = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD); in ahd_dump_card_state()
9773 ahd_set_scbptr(ahd, scb_index); in ahd_dump_card_state()
9775 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_dump_card_state()
9779 scb_index = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD); in ahd_dump_card_state()
9782 ahd_set_scbptr(ahd, scb_index); in ahd_dump_card_state()
9784 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_dump_card_state()
9787 ahd_set_scbptr(ahd, saved_scb_index); in ahd_dump_card_state()
9788 dffstat = ahd_inb(ahd, DFFSTAT); in ahd_dump_card_state()
9795 ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i); in ahd_dump_card_state()
9796 fifo_scbptr = ahd_get_scbptr(ahd); in ahd_dump_card_state()
9798 ahd_name(ahd), i, in ahd_dump_card_state()
9800 ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr); in ahd_dump_card_state()
9802 ahd_seqimode_print(ahd_inb(ahd, SEQIMODE), &cur_col, 50); in ahd_dump_card_state()
9803 ahd_seqintsrc_print(ahd_inb(ahd, SEQINTSRC), &cur_col, 50); in ahd_dump_card_state()
9804 ahd_dfcntrl_print(ahd_inb(ahd, DFCNTRL), &cur_col, 50); in ahd_dump_card_state()
9805 ahd_dfstatus_print(ahd_inb(ahd, DFSTATUS), &cur_col, 50); in ahd_dump_card_state()
9806 ahd_sg_cache_shadow_print(ahd_inb(ahd, SG_CACHE_SHADOW), in ahd_dump_card_state()
9808 ahd_sg_state_print(ahd_inb(ahd, SG_STATE), &cur_col, 50); in ahd_dump_card_state()
9809 ahd_dffsxfrctl_print(ahd_inb(ahd, DFFSXFRCTL), &cur_col, 50); in ahd_dump_card_state()
9810 ahd_soffcnt_print(ahd_inb(ahd, SOFFCNT), &cur_col, 50); in ahd_dump_card_state()
9811 ahd_mdffstat_print(ahd_inb(ahd, MDFFSTAT), &cur_col, 50); in ahd_dump_card_state()
9817 ahd_inl(ahd, SHADDR+4), in ahd_dump_card_state()
9818 ahd_inl(ahd, SHADDR), in ahd_dump_card_state()
9819 (ahd_inb(ahd, SHCNT) in ahd_dump_card_state()
9820 | (ahd_inb(ahd, SHCNT + 1) << 8) in ahd_dump_card_state()
9821 | (ahd_inb(ahd, SHCNT + 2) << 16))); in ahd_dump_card_state()
9827 ahd_inl(ahd, HADDR+4), in ahd_dump_card_state()
9828 ahd_inl(ahd, HADDR), in ahd_dump_card_state()
9829 (ahd_inb(ahd, HCNT) in ahd_dump_card_state()
9830 | (ahd_inb(ahd, HCNT + 1) << 8) in ahd_dump_card_state()
9831 | (ahd_inb(ahd, HCNT + 2) << 16))); in ahd_dump_card_state()
9832 ahd_ccsgctl_print(ahd_inb(ahd, CCSGCTL), &cur_col, 50); in ahd_dump_card_state()
9835 fifo_scb = ahd_lookup_scb(ahd, fifo_scbptr); in ahd_dump_card_state()
9843 printk("0x%x ", ahd_inb(ahd, LQIN + i)); in ahd_dump_card_state()
9845 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_dump_card_state()
9847 ahd_name(ahd), ahd_inb(ahd, LQISTATE), ahd_inb(ahd, LQOSTATE), in ahd_dump_card_state()
9848 ahd_inb(ahd, OPTIONMODE)); in ahd_dump_card_state()
9850 ahd_name(ahd), ahd_inb(ahd, OS_SPACE_CNT), in ahd_dump_card_state()
9851 ahd_inb(ahd, MAXCMDCNT)); in ahd_dump_card_state()
9853 ahd_name(ahd), ahd_inb(ahd, SAVED_SCSIID), in ahd_dump_card_state()
9854 ahd_inb(ahd, SAVED_LUN)); in ahd_dump_card_state()
9855 ahd_simode0_print(ahd_inb(ahd, SIMODE0), &cur_col, 50); in ahd_dump_card_state()
9857 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_dump_card_state()
9859 ahd_ccscbctl_print(ahd_inb(ahd, CCSCBCTL), &cur_col, 50); in ahd_dump_card_state()
9861 ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode); in ahd_dump_card_state()
9863 ahd_name(ahd), ahd_inw(ahd, REG0), ahd_inw(ahd, SINDEX), in ahd_dump_card_state()
9864 ahd_inw(ahd, DINDEX)); in ahd_dump_card_state()
9866 ahd_name(ahd), ahd_get_scbptr(ahd), in ahd_dump_card_state()
9867 ahd_inw_scbram(ahd, SCB_NEXT), in ahd_dump_card_state()
9868 ahd_inw_scbram(ahd, SCB_NEXT2)); in ahd_dump_card_state()
9870 ahd_inb_scbram(ahd, SCB_CDB_STORE), in ahd_dump_card_state()
9871 ahd_inb_scbram(ahd, SCB_CDB_STORE+1), in ahd_dump_card_state()
9872 ahd_inb_scbram(ahd, SCB_CDB_STORE+2), in ahd_dump_card_state()
9873 ahd_inb_scbram(ahd, SCB_CDB_STORE+3), in ahd_dump_card_state()
9874 ahd_inb_scbram(ahd, SCB_CDB_STORE+4), in ahd_dump_card_state()
9875 ahd_inb_scbram(ahd, SCB_CDB_STORE+5)); in ahd_dump_card_state()
9877 for (i = 0; i < ahd->stack_size; i++) { in ahd_dump_card_state()
9878 ahd->saved_stack[i] = in ahd_dump_card_state()
9879 ahd_inb(ahd, STACK)|(ahd_inb(ahd, STACK) << 8); in ahd_dump_card_state()
9880 printk(" 0x%x", ahd->saved_stack[i]); in ahd_dump_card_state()
9882 for (i = ahd->stack_size-1; i >= 0; i--) { in ahd_dump_card_state()
9883 ahd_outb(ahd, STACK, ahd->saved_stack[i] & 0xFF); in ahd_dump_card_state()
9884 ahd_outb(ahd, STACK, (ahd->saved_stack[i] >> 8) & 0xFF); in ahd_dump_card_state()
9887 ahd_restore_modes(ahd, saved_modes); in ahd_dump_card_state()
9889 ahd_unpause(ahd); in ahd_dump_card_state()
9894 ahd_dump_scbs(struct ahd_softc *ahd)
9900 saved_modes = ahd_save_modes(ahd);
9901 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
9902 saved_scb_index = ahd_get_scbptr(ahd);
9904 ahd_set_scbptr(ahd, i);
9907 ahd_inb_scbram(ahd, SCB_CONTROL),
9908 ahd_inb_scbram(ahd, SCB_SCSIID),
9909 ahd_inw_scbram(ahd, SCB_NEXT),
9910 ahd_inw_scbram(ahd, SCB_NEXT2),
9911 ahd_inl_scbram(ahd, SCB_SGPTR),
9912 ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR));
9915 ahd_set_scbptr(ahd, saved_scb_index);
9916 ahd_restore_modes(ahd, saved_modes);
9928 ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf, in ahd_read_seeprom() argument
9940 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_read_seeprom()
9944 ahd_outb(ahd, SEEADR, cur_addr); in ahd_read_seeprom()
9945 ahd_outb(ahd, SEECTL, SEEOP_READ | SEESTART); in ahd_read_seeprom()
9947 error = ahd_wait_seeprom(ahd); in ahd_read_seeprom()
9954 *bytestream_ptr++ = ahd_inb(ahd, SEEDAT); in ahd_read_seeprom()
9955 *bytestream_ptr = ahd_inb(ahd, SEEDAT+1); in ahd_read_seeprom()
9960 *buf = ahd_inw(ahd, SEEDAT); in ahd_read_seeprom()
9973 ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf, in ahd_write_seeprom() argument
9981 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_write_seeprom()
9985 ahd_outb(ahd, SEEADR, SEEOP_EWEN_ADDR); in ahd_write_seeprom()
9986 ahd_outb(ahd, SEECTL, SEEOP_EWEN | SEESTART); in ahd_write_seeprom()
9987 error = ahd_wait_seeprom(ahd); in ahd_write_seeprom()
9998 ahd_outw(ahd, SEEDAT, *buf++); in ahd_write_seeprom()
9999 ahd_outb(ahd, SEEADR, cur_addr); in ahd_write_seeprom()
10000 ahd_outb(ahd, SEECTL, SEEOP_WRITE | SEESTART); in ahd_write_seeprom()
10002 retval = ahd_wait_seeprom(ahd); in ahd_write_seeprom()
10010 ahd_outb(ahd, SEEADR, SEEOP_EWDS_ADDR); in ahd_write_seeprom()
10011 ahd_outb(ahd, SEECTL, SEEOP_EWDS | SEESTART); in ahd_write_seeprom()
10012 error = ahd_wait_seeprom(ahd); in ahd_write_seeprom()
10022 ahd_wait_seeprom(struct ahd_softc *ahd) in ahd_wait_seeprom() argument
10027 while ((ahd_inb(ahd, SEESTAT) & (SEEARBACK|SEEBUSY)) != 0 && --cnt) in ahd_wait_seeprom()
10090 ahd_acquire_seeprom(struct ahd_softc *ahd) in ahd_acquire_seeprom() argument
10104 error = ahd_read_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, &seetype); in ahd_acquire_seeprom()
10113 ahd_release_seeprom(struct ahd_softc *ahd) in ahd_release_seeprom() argument
10122 ahd_wait_flexport(struct ahd_softc *ahd) in ahd_wait_flexport() argument
10126 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_wait_flexport()
10128 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt) in ahd_wait_flexport()
10137 ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value) in ahd_write_flexport() argument
10141 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_write_flexport()
10144 ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3)); in ahd_write_flexport()
10145 error = ahd_wait_flexport(ahd); in ahd_write_flexport()
10148 ahd_outb(ahd, BRDDAT, value); in ahd_write_flexport()
10149 ahd_flush_device_writes(ahd); in ahd_write_flexport()
10150 ahd_outb(ahd, BRDCTL, BRDSTB|BRDEN|(addr << 3)); in ahd_write_flexport()
10151 ahd_flush_device_writes(ahd); in ahd_write_flexport()
10152 ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3)); in ahd_write_flexport()
10153 ahd_flush_device_writes(ahd); in ahd_write_flexport()
10154 ahd_outb(ahd, BRDCTL, 0); in ahd_write_flexport()
10155 ahd_flush_device_writes(ahd); in ahd_write_flexport()
10160 ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value) in ahd_read_flexport() argument
10164 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_read_flexport()
10167 ahd_outb(ahd, BRDCTL, BRDRW|BRDEN|(addr << 3)); in ahd_read_flexport()
10168 error = ahd_wait_flexport(ahd); in ahd_read_flexport()
10171 *value = ahd_inb(ahd, BRDDAT); in ahd_read_flexport()
10172 ahd_outb(ahd, BRDCTL, 0); in ahd_read_flexport()
10173 ahd_flush_device_writes(ahd); in ahd_read_flexport()
10180 ahd_find_tmode_devs(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb, in ahd_find_tmode_devs() argument
10186 if ((ahd->features & AHD_TARGETMODE) == 0) in ahd_find_tmode_devs()
10196 *lstate = ahd->black_hole; in ahd_find_tmode_devs()
10200 max_id = (ahd->features & AHD_WIDE) ? 16 : 8; in ahd_find_tmode_devs()
10207 *tstate = ahd->enabled_targets[ccb->ccb_h.target_id]; in ahd_find_tmode_devs()
10221 ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb) in ahd_handle_en_lun() argument
10234 status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate, &lstate, in ahd_handle_en_lun()
10242 if ((ahd->features & AHD_MULTIROLE) != 0) { in ahd_handle_en_lun()
10245 our_id = ahd->our_id; in ahd_handle_en_lun()
10247 if ((ahd->features & AHD_MULTI_TID) != 0 in ahd_handle_en_lun()
10248 && (ahd->flags & AHD_INITIATORROLE) != 0) { in ahd_handle_en_lun()
10257 } else if ((ahd->flags & AHD_INITIATORROLE) != 0 in ahd_handle_en_lun()
10258 || ahd->enabled_luns > 0) { in ahd_handle_en_lun()
10280 if ((ahd->flags & AHD_TARGETROLE) == 0 in ahd_handle_en_lun()
10285 ahd_lock(ahd, &s); in ahd_handle_en_lun()
10286 if (LIST_FIRST(&ahd->pending_scbs) != NULL) { in ahd_handle_en_lun()
10288 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10291 ahd->flags |= AHD_TARGETROLE; in ahd_handle_en_lun()
10292 if ((ahd->features & AHD_MULTIROLE) == 0) in ahd_handle_en_lun()
10293 ahd->flags &= ~AHD_INITIATORROLE; in ahd_handle_en_lun()
10294 ahd_pause(ahd); in ahd_handle_en_lun()
10295 ahd_loadseq(ahd); in ahd_handle_en_lun()
10296 ahd_restart(ahd); in ahd_handle_en_lun()
10297 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10302 channel = SIM_CHANNEL(ahd, sim); in ahd_handle_en_lun()
10334 tstate = ahd_alloc_tstate(ahd, target, channel); in ahd_handle_en_lun()
10362 ahd_lock(ahd, &s); in ahd_handle_en_lun()
10363 ahd_pause(ahd); in ahd_handle_en_lun()
10366 ahd->enabled_luns++; in ahd_handle_en_lun()
10368 if ((ahd->features & AHD_MULTI_TID) != 0) { in ahd_handle_en_lun()
10371 targid_mask = ahd_inw(ahd, TARGID); in ahd_handle_en_lun()
10373 ahd_outw(ahd, TARGID, targid_mask); in ahd_handle_en_lun()
10374 ahd_update_scsiid(ahd, targid_mask); in ahd_handle_en_lun()
10379 channel = SIM_CHANNEL(ahd, sim); in ahd_handle_en_lun()
10380 our_id = SIM_SCSI_ID(ahd, sim); in ahd_handle_en_lun()
10391 sblkctl = ahd_inb(ahd, SBLKCTL); in ahd_handle_en_lun()
10394 if ((ahd->features & AHD_TWIN) == 0) in ahd_handle_en_lun()
10397 ahd->our_id = target; in ahd_handle_en_lun()
10400 ahd_outb(ahd, SBLKCTL, in ahd_handle_en_lun()
10403 ahd_outb(ahd, SCSIID, target); in ahd_handle_en_lun()
10406 ahd_outb(ahd, SBLKCTL, sblkctl); in ahd_handle_en_lun()
10410 ahd->black_hole = lstate; in ahd_handle_en_lun()
10412 if (ahd->black_hole != NULL && ahd->enabled_luns > 0) { in ahd_handle_en_lun()
10413 scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE); in ahd_handle_en_lun()
10415 ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1); in ahd_handle_en_lun()
10416 scsiseq1 = ahd_inb(ahd, SCSISEQ1); in ahd_handle_en_lun()
10418 ahd_outb(ahd, SCSISEQ1, scsiseq1); in ahd_handle_en_lun()
10420 ahd_unpause(ahd); in ahd_handle_en_lun()
10421 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10434 ahd_lock(ahd, &s); in ahd_handle_en_lun()
10437 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_handle_en_lun()
10445 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10461 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10470 ahd_pause(ahd); in ahd_handle_en_lun()
10474 ahd->enabled_luns--; in ahd_handle_en_lun()
10482 ahd_free_tstate(ahd, target, channel, in ahd_handle_en_lun()
10484 if (ahd->features & AHD_MULTI_TID) { in ahd_handle_en_lun()
10487 targid_mask = ahd_inw(ahd, TARGID); in ahd_handle_en_lun()
10489 ahd_outw(ahd, TARGID, targid_mask); in ahd_handle_en_lun()
10490 ahd_update_scsiid(ahd, targid_mask); in ahd_handle_en_lun()
10495 ahd->black_hole = NULL; in ahd_handle_en_lun()
10503 if (ahd->enabled_luns == 0) { in ahd_handle_en_lun()
10507 scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE); in ahd_handle_en_lun()
10509 ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1); in ahd_handle_en_lun()
10510 scsiseq1 = ahd_inb(ahd, SCSISEQ1); in ahd_handle_en_lun()
10512 ahd_outb(ahd, SCSISEQ1, scsiseq1); in ahd_handle_en_lun()
10514 if ((ahd->features & AHD_MULTIROLE) == 0) { in ahd_handle_en_lun()
10516 ahd->flags &= ~AHD_TARGETROLE; in ahd_handle_en_lun()
10517 ahd->flags |= AHD_INITIATORROLE; in ahd_handle_en_lun()
10518 ahd_pause(ahd); in ahd_handle_en_lun()
10519 ahd_loadseq(ahd); in ahd_handle_en_lun()
10520 ahd_restart(ahd); in ahd_handle_en_lun()
10527 ahd_unpause(ahd); in ahd_handle_en_lun()
10528 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10534 ahd_update_scsiid(struct ahd_softc *ahd, u_int targid_mask) in ahd_update_scsiid() argument
10540 if ((ahd->features & AHD_MULTI_TID) == 0) in ahd_update_scsiid()
10549 if ((ahd->features & AHD_ULTRA2) != 0) in ahd_update_scsiid()
10550 scsiid = ahd_inb(ahd, SCSIID_ULTRA2); in ahd_update_scsiid()
10552 scsiid = ahd_inb(ahd, SCSIID); in ahd_update_scsiid()
10560 our_id = ahd->our_id; in ahd_update_scsiid()
10566 if ((ahd->features & AHD_ULTRA2) != 0) in ahd_update_scsiid()
10567 ahd_outb(ahd, SCSIID_ULTRA2, scsiid); in ahd_update_scsiid()
10569 ahd_outb(ahd, SCSIID, scsiid); in ahd_update_scsiid()
10574 ahd_run_tqinfifo(struct ahd_softc *ahd, int paused) in ahd_run_tqinfifo() argument
10578 ahd_sync_tqinfifo(ahd, BUS_DMASYNC_POSTREAD); in ahd_run_tqinfifo()
10579 while ((cmd = &ahd->targetcmds[ahd->tqinfifonext])->cmd_valid != 0) { in ahd_run_tqinfifo()
10585 if (ahd_handle_target_cmd(ahd, cmd) != 0) in ahd_run_tqinfifo()
10589 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, in ahd_run_tqinfifo()
10590 ahd->shared_data_map.dmamap, in ahd_run_tqinfifo()
10591 ahd_targetcmd_offset(ahd, ahd->tqinfifonext), in ahd_run_tqinfifo()
10594 ahd->tqinfifonext++; in ahd_run_tqinfifo()
10600 if ((ahd->tqinfifonext & (HOST_TQINPOS - 1)) == 1) { in ahd_run_tqinfifo()
10603 hs_mailbox = ahd_inb(ahd, HS_MAILBOX); in ahd_run_tqinfifo()
10605 hs_mailbox |= ahd->tqinfifonext & HOST_TQINPOS; in ahd_run_tqinfifo()
10606 ahd_outb(ahd, HS_MAILBOX, hs_mailbox); in ahd_run_tqinfifo()
10612 ahd_handle_target_cmd(struct ahd_softc *ahd, struct target_cmd *cmd) in ahd_handle_target_cmd() argument
10622 initiator = SCSIID_TARGET(ahd, cmd->scsiid); in ahd_handle_target_cmd()
10627 tstate = ahd->enabled_targets[target]; in ahd_handle_target_cmd()
10636 lstate = ahd->black_hole; in ahd_handle_target_cmd()
10640 ahd->flags |= AHD_TQINFIFO_BLOCKED; in ahd_handle_target_cmd()
10646 ahd->flags &= ~AHD_TQINFIFO_BLOCKED; in ahd_handle_target_cmd()
10651 lstate == ahd->black_hole ? "(Black Holed)" : ""); in ahd_handle_target_cmd()
10655 if (lstate == ahd->black_hole) { in ahd_handle_target_cmd()
10714 initiator, target, lun, ahd->pending_device); in ahd_handle_target_cmd()
10716 ahd->pending_device = lstate; in ahd_handle_target_cmd()