Lines Matching refs:ahd
106 static void ahd_handle_transmission_error(struct ahd_softc *ahd);
107 static void ahd_handle_lqiphase_error(struct ahd_softc *ahd,
109 static int ahd_handle_pkt_busfree(struct ahd_softc *ahd,
111 static int ahd_handle_nonpkt_busfree(struct ahd_softc *ahd);
112 static void ahd_handle_proto_violation(struct ahd_softc *ahd);
113 static void ahd_force_renegotiation(struct ahd_softc *ahd,
117 ahd_alloc_tstate(struct ahd_softc *ahd,
120 static void ahd_free_tstate(struct ahd_softc *ahd,
123 static void ahd_devlimited_syncrate(struct ahd_softc *ahd,
128 static void ahd_update_neg_table(struct ahd_softc *ahd,
131 static void ahd_update_pending_scbs(struct ahd_softc *ahd);
132 static void ahd_fetch_devinfo(struct ahd_softc *ahd,
134 static void ahd_scb_devinfo(struct ahd_softc *ahd,
137 static void ahd_setup_initiator_msgout(struct ahd_softc *ahd,
140 static void ahd_build_transfer_msg(struct ahd_softc *ahd,
142 static void ahd_construct_sdtr(struct ahd_softc *ahd,
145 static void ahd_construct_wdtr(struct ahd_softc *ahd,
148 static void ahd_construct_ppr(struct ahd_softc *ahd,
152 static void ahd_clear_msg_state(struct ahd_softc *ahd);
153 static void ahd_handle_message_phase(struct ahd_softc *ahd);
159 static int ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type,
161 static int ahd_parse_msg(struct ahd_softc *ahd,
163 static int ahd_handle_msg_reject(struct ahd_softc *ahd,
165 static void ahd_handle_ign_wide_residue(struct ahd_softc *ahd,
167 static void ahd_reinitialize_dataptrs(struct ahd_softc *ahd);
168 static void ahd_handle_devreset(struct ahd_softc *ahd,
173 static void ahd_setup_target_msgin(struct ahd_softc *ahd,
178 static u_int ahd_sglist_size(struct ahd_softc *ahd);
179 static u_int ahd_sglist_allocsize(struct ahd_softc *ahd);
182 static void ahd_initialize_hscbs(struct ahd_softc *ahd);
183 static int ahd_init_scbdata(struct ahd_softc *ahd);
184 static void ahd_fini_scbdata(struct ahd_softc *ahd);
185 static void ahd_setup_iocell_workaround(struct ahd_softc *ahd);
186 static void ahd_iocell_first_selection(struct ahd_softc *ahd);
187 static void ahd_add_col_list(struct ahd_softc *ahd,
189 static void ahd_rem_col_list(struct ahd_softc *ahd,
191 static void ahd_chip_init(struct ahd_softc *ahd);
192 static void ahd_qinfifo_requeue(struct ahd_softc *ahd,
195 static int ahd_qinfifo_count(struct ahd_softc *ahd);
196 static int ahd_search_scb_list(struct ahd_softc *ahd, int target,
202 static void ahd_stitch_tid_list(struct ahd_softc *ahd,
205 static void ahd_add_scb_to_free_list(struct ahd_softc *ahd,
207 static u_int ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
209 static void ahd_reset_current_bus(struct ahd_softc *ahd);
212 static void ahd_dumpseq(struct ahd_softc *ahd);
214 static void ahd_loadseq(struct ahd_softc *ahd);
215 static int ahd_check_patch(struct ahd_softc *ahd,
218 static u_int ahd_resolve_seqaddr(struct ahd_softc *ahd,
220 static void ahd_download_instr(struct ahd_softc *ahd,
222 static int ahd_probe_stack_size(struct ahd_softc *ahd);
223 static int ahd_scb_active_in_fifo(struct ahd_softc *ahd,
225 static void ahd_run_data_fifo(struct ahd_softc *ahd,
229 static void ahd_queue_lstate_event(struct ahd_softc *ahd,
234 static void ahd_update_scsiid(struct ahd_softc *ahd,
236 static int ahd_handle_target_cmd(struct ahd_softc *ahd,
240 static int ahd_abort_scbs(struct ahd_softc *ahd, int target,
243 static void ahd_alloc_scbs(struct ahd_softc *ahd);
244 static void ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl,
246 static void ahd_calc_residual(struct ahd_softc *ahd,
248 static void ahd_clear_critical_section(struct ahd_softc *ahd);
249 static void ahd_clear_intstat(struct ahd_softc *ahd);
250 static void ahd_enable_coalescing(struct ahd_softc *ahd,
252 static u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
253 static void ahd_freeze_devq(struct ahd_softc *ahd,
255 static void ahd_handle_scb_status(struct ahd_softc *ahd,
259 static void ahd_update_coalescing_values(struct ahd_softc *ahd,
264 static int ahd_wait_seeprom(struct ahd_softc *ahd);
265 static int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
269 static void ahd_reset_cmds_pending(struct ahd_softc *ahd);
272 static void ahd_run_qoutfifo(struct ahd_softc *ahd);
274 static void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
276 static void ahd_handle_hwerrint(struct ahd_softc *ahd);
277 static void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
278 static void ahd_handle_scsiint(struct ahd_softc *ahd,
283 ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst) in ahd_set_modes() argument
285 if (ahd->src_mode == src && ahd->dst_mode == dst) in ahd_set_modes()
288 if (ahd->src_mode == AHD_MODE_UNKNOWN in ahd_set_modes()
289 || ahd->dst_mode == AHD_MODE_UNKNOWN) in ahd_set_modes()
292 printk("%s: Setting mode 0x%x\n", ahd_name(ahd), in ahd_set_modes()
293 ahd_build_mode_state(ahd, src, dst)); in ahd_set_modes()
295 ahd_outb(ahd, MODE_PTR, ahd_build_mode_state(ahd, src, dst)); in ahd_set_modes()
296 ahd->src_mode = src; in ahd_set_modes()
297 ahd->dst_mode = dst; in ahd_set_modes()
301 ahd_update_modes(struct ahd_softc *ahd) in ahd_update_modes() argument
307 mode_ptr = ahd_inb(ahd, MODE_PTR); in ahd_update_modes()
312 ahd_extract_mode_state(ahd, mode_ptr, &src, &dst); in ahd_update_modes()
313 ahd_known_modes(ahd, src, dst); in ahd_update_modes()
317 ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode, in ahd_assert_modes() argument
321 if ((srcmode & AHD_MK_MSK(ahd->src_mode)) == 0 in ahd_assert_modes()
322 || (dstmode & AHD_MK_MSK(ahd->dst_mode)) == 0) { in ahd_assert_modes()
324 ahd_name(ahd), file, line); in ahd_assert_modes()
329 #define AHD_ASSERT_MODES(ahd, source, dest) \ argument
330 ahd_assert_modes(ahd, source, dest, __FILE__, __LINE__);
333 ahd_save_modes(struct ahd_softc *ahd) in ahd_save_modes() argument
335 if (ahd->src_mode == AHD_MODE_UNKNOWN in ahd_save_modes()
336 || ahd->dst_mode == AHD_MODE_UNKNOWN) in ahd_save_modes()
337 ahd_update_modes(ahd); in ahd_save_modes()
339 return (ahd_build_mode_state(ahd, ahd->src_mode, ahd->dst_mode)); in ahd_save_modes()
343 ahd_restore_modes(struct ahd_softc *ahd, ahd_mode_state state) in ahd_restore_modes() argument
348 ahd_extract_mode_state(ahd, state, &src, &dst); in ahd_restore_modes()
349 ahd_set_modes(ahd, src, dst); in ahd_restore_modes()
357 ahd_is_paused(struct ahd_softc *ahd) in ahd_is_paused() argument
359 return ((ahd_inb(ahd, HCNTRL) & PAUSE) != 0); in ahd_is_paused()
370 ahd_pause(struct ahd_softc *ahd) in ahd_pause() argument
372 ahd_outb(ahd, HCNTRL, ahd->pause); in ahd_pause()
378 while (ahd_is_paused(ahd) == 0) in ahd_pause()
393 ahd_unpause(struct ahd_softc *ahd) in ahd_unpause() argument
399 if (ahd->saved_src_mode != AHD_MODE_UNKNOWN in ahd_unpause()
400 && ahd->saved_dst_mode != AHD_MODE_UNKNOWN) { in ahd_unpause()
401 if ((ahd->flags & AHD_UPDATE_PEND_CMDS) != 0) in ahd_unpause()
402 ahd_reset_cmds_pending(ahd); in ahd_unpause()
403 ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode); in ahd_unpause()
406 if ((ahd_inb(ahd, INTSTAT) & ~CMDCMPLT) == 0) in ahd_unpause()
407 ahd_outb(ahd, HCNTRL, ahd->unpause); in ahd_unpause()
409 ahd_known_modes(ahd, AHD_MODE_UNKNOWN, AHD_MODE_UNKNOWN); in ahd_unpause()
414 ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb, in ahd_sg_setup() argument
419 && (ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_sg_setup()
438 ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb) in ahd_setup_scb_common() argument
459 ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_setup_data_scb() argument
464 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_setup_data_scb()
478 if ((ahd->flags & AHD_39BIT_ADDRESSING) != 0) { in ahd_setup_data_scb()
496 ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_setup_noxfer_scb() argument
505 ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr) in ahd_sg_bus_to_virt() argument
510 sg_offset = sg_busaddr - (scb->sg_list_busaddr - ahd_sg_size(ahd)); in ahd_sg_bus_to_virt()
515 ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg) in ahd_sg_virt_to_bus() argument
521 - ahd_sg_size(ahd); in ahd_sg_virt_to_bus()
527 ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op) in ahd_sync_scb() argument
529 ahd_dmamap_sync(ahd, ahd->scb_data.hscb_dmat, in ahd_sync_scb()
536 ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op) in ahd_sync_sglist() argument
541 ahd_dmamap_sync(ahd, ahd->scb_data.sg_dmat, in ahd_sync_sglist()
543 /*offset*/scb->sg_list_busaddr - ahd_sg_size(ahd), in ahd_sync_sglist()
544 /*len*/ahd_sg_size(ahd) * scb->sg_count, op); in ahd_sync_sglist()
548 ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op) in ahd_sync_sense() argument
550 ahd_dmamap_sync(ahd, ahd->scb_data.sense_dmat, in ahd_sync_sense()
558 ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index) in ahd_targetcmd_offset() argument
560 return (((uint8_t *)&ahd->targetcmds[index]) in ahd_targetcmd_offset()
561 - (uint8_t *)ahd->qoutfifo); in ahd_targetcmd_offset()
571 ahd_fetch_transinfo(struct ahd_softc *ahd, char channel, u_int our_id, in ahd_fetch_transinfo() argument
582 *tstate = ahd->enabled_targets[our_id]; in ahd_fetch_transinfo()
587 ahd_inw(struct ahd_softc *ahd, u_int port) in ahd_inw() argument
594 uint16_t r = ahd_inb(ahd, port+1) << 8; in ahd_inw()
595 return r | ahd_inb(ahd, port); in ahd_inw()
599 ahd_outw(struct ahd_softc *ahd, u_int port, u_int value) in ahd_outw() argument
605 ahd_outb(ahd, port, value & 0xFF); in ahd_outw()
606 ahd_outb(ahd, port+1, (value >> 8) & 0xFF); in ahd_outw()
610 ahd_inl(struct ahd_softc *ahd, u_int port) in ahd_inl() argument
612 return ((ahd_inb(ahd, port)) in ahd_inl()
613 | (ahd_inb(ahd, port+1) << 8) in ahd_inl()
614 | (ahd_inb(ahd, port+2) << 16) in ahd_inl()
615 | (ahd_inb(ahd, port+3) << 24)); in ahd_inl()
619 ahd_outl(struct ahd_softc *ahd, u_int port, uint32_t value) in ahd_outl() argument
621 ahd_outb(ahd, port, (value) & 0xFF); in ahd_outl()
622 ahd_outb(ahd, port+1, ((value) >> 8) & 0xFF); in ahd_outl()
623 ahd_outb(ahd, port+2, ((value) >> 16) & 0xFF); in ahd_outl()
624 ahd_outb(ahd, port+3, ((value) >> 24) & 0xFF); in ahd_outl()
628 ahd_inq(struct ahd_softc *ahd, u_int port) in ahd_inq() argument
630 return ((ahd_inb(ahd, port)) in ahd_inq()
631 | (ahd_inb(ahd, port+1) << 8) in ahd_inq()
632 | (ahd_inb(ahd, port+2) << 16) in ahd_inq()
633 | (ahd_inb(ahd, port+3) << 24) in ahd_inq()
634 | (((uint64_t)ahd_inb(ahd, port+4)) << 32) in ahd_inq()
635 | (((uint64_t)ahd_inb(ahd, port+5)) << 40) in ahd_inq()
636 | (((uint64_t)ahd_inb(ahd, port+6)) << 48) in ahd_inq()
637 | (((uint64_t)ahd_inb(ahd, port+7)) << 56)); in ahd_inq()
641 ahd_outq(struct ahd_softc *ahd, u_int port, uint64_t value) in ahd_outq() argument
643 ahd_outb(ahd, port, value & 0xFF); in ahd_outq()
644 ahd_outb(ahd, port+1, (value >> 8) & 0xFF); in ahd_outq()
645 ahd_outb(ahd, port+2, (value >> 16) & 0xFF); in ahd_outq()
646 ahd_outb(ahd, port+3, (value >> 24) & 0xFF); in ahd_outq()
647 ahd_outb(ahd, port+4, (value >> 32) & 0xFF); in ahd_outq()
648 ahd_outb(ahd, port+5, (value >> 40) & 0xFF); in ahd_outq()
649 ahd_outb(ahd, port+6, (value >> 48) & 0xFF); in ahd_outq()
650 ahd_outb(ahd, port+7, (value >> 56) & 0xFF); in ahd_outq()
654 ahd_get_scbptr(struct ahd_softc *ahd) in ahd_get_scbptr() argument
656 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_get_scbptr()
658 return (ahd_inb(ahd, SCBPTR) | (ahd_inb(ahd, SCBPTR + 1) << 8)); in ahd_get_scbptr()
662 ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr) in ahd_set_scbptr() argument
664 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_set_scbptr()
666 ahd_outb(ahd, SCBPTR, scbptr & 0xFF); in ahd_set_scbptr()
667 ahd_outb(ahd, SCBPTR+1, (scbptr >> 8) & 0xFF); in ahd_set_scbptr()
672 ahd_get_hnscb_qoff(struct ahd_softc *ahd)
674 return (ahd_inw_atomic(ahd, HNSCB_QOFF));
679 ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_hnscb_qoff() argument
681 ahd_outw_atomic(ahd, HNSCB_QOFF, value); in ahd_set_hnscb_qoff()
686 ahd_get_hescb_qoff(struct ahd_softc *ahd)
688 return (ahd_inb(ahd, HESCB_QOFF));
693 ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_hescb_qoff() argument
695 ahd_outb(ahd, HESCB_QOFF, value); in ahd_set_hescb_qoff()
699 ahd_get_snscb_qoff(struct ahd_softc *ahd) in ahd_get_snscb_qoff() argument
703 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_get_snscb_qoff()
704 oldvalue = ahd_inw(ahd, SNSCB_QOFF); in ahd_get_snscb_qoff()
705 ahd_outw(ahd, SNSCB_QOFF, oldvalue); in ahd_get_snscb_qoff()
710 ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_snscb_qoff() argument
712 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_set_snscb_qoff()
713 ahd_outw(ahd, SNSCB_QOFF, value); in ahd_set_snscb_qoff()
718 ahd_get_sescb_qoff(struct ahd_softc *ahd)
720 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
721 return (ahd_inb(ahd, SESCB_QOFF));
726 ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_sescb_qoff() argument
728 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_set_sescb_qoff()
729 ahd_outb(ahd, SESCB_QOFF, value); in ahd_set_sescb_qoff()
734 ahd_get_sdscb_qoff(struct ahd_softc *ahd)
736 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
737 return (ahd_inb(ahd, SDSCB_QOFF) | (ahd_inb(ahd, SDSCB_QOFF + 1) << 8));
742 ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value) in ahd_set_sdscb_qoff() argument
744 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_set_sdscb_qoff()
745 ahd_outb(ahd, SDSCB_QOFF, value & 0xFF); in ahd_set_sdscb_qoff()
746 ahd_outb(ahd, SDSCB_QOFF+1, (value >> 8) & 0xFF); in ahd_set_sdscb_qoff()
750 ahd_inb_scbram(struct ahd_softc *ahd, u_int offset) in ahd_inb_scbram() argument
768 value = ahd_inb(ahd, offset); in ahd_inb_scbram()
769 if ((ahd->bugs & AHD_PCIX_SCBRAM_RD_BUG) != 0) in ahd_inb_scbram()
770 ahd_inb(ahd, MODE_PTR); in ahd_inb_scbram()
775 ahd_inw_scbram(struct ahd_softc *ahd, u_int offset) in ahd_inw_scbram() argument
777 return (ahd_inb_scbram(ahd, offset) in ahd_inw_scbram()
778 | (ahd_inb_scbram(ahd, offset+1) << 8)); in ahd_inw_scbram()
782 ahd_inl_scbram(struct ahd_softc *ahd, u_int offset) in ahd_inl_scbram() argument
784 return (ahd_inw_scbram(ahd, offset) in ahd_inl_scbram()
785 | (ahd_inw_scbram(ahd, offset+2) << 16)); in ahd_inl_scbram()
789 ahd_inq_scbram(struct ahd_softc *ahd, u_int offset) in ahd_inq_scbram() argument
791 return (ahd_inl_scbram(ahd, offset) in ahd_inq_scbram()
792 | ((uint64_t)ahd_inl_scbram(ahd, offset+4)) << 32); in ahd_inq_scbram()
796 ahd_lookup_scb(struct ahd_softc *ahd, u_int tag) in ahd_lookup_scb() argument
802 scb = ahd->scb_data.scbindex[tag]; in ahd_lookup_scb()
804 ahd_sync_scb(ahd, scb, in ahd_lookup_scb()
810 ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb) in ahd_swap_with_next_hscb() argument
828 q_hscb = ahd->next_queued_hscb; in ahd_swap_with_next_hscb()
829 q_hscb_map = ahd->next_queued_hscb_map; in ahd_swap_with_next_hscb()
836 ahd->next_queued_hscb = scb->hscb; in ahd_swap_with_next_hscb()
837 ahd->next_queued_hscb_map = scb->hscb_map; in ahd_swap_with_next_hscb()
842 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb; in ahd_swap_with_next_hscb()
849 ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_queue_scb() argument
851 ahd_swap_with_next_hscb(ahd, scb); in ahd_queue_scb()
860 ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb); in ahd_queue_scb()
861 ahd->qinfifonext++; in ahd_queue_scb()
864 ahd_setup_data_scb(ahd, scb); in ahd_queue_scb()
866 ahd_setup_noxfer_scb(ahd, scb); in ahd_queue_scb()
867 ahd_setup_scb_common(ahd, scb); in ahd_queue_scb()
873 ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahd_queue_scb()
881 ahd_name(ahd), in ahd_queue_scb()
890 ahd_set_hnscb_qoff(ahd, ahd->qinfifonext); in ahd_queue_scb()
895 ahd_sync_qoutfifo(struct ahd_softc *ahd, int op) in ahd_sync_qoutfifo() argument
897 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap, in ahd_sync_qoutfifo()
903 ahd_sync_tqinfifo(struct ahd_softc *ahd, int op) in ahd_sync_tqinfifo() argument
906 if ((ahd->flags & AHD_TARGETROLE) != 0) { in ahd_sync_tqinfifo()
907 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, in ahd_sync_tqinfifo()
908 ahd->shared_data_map.dmamap, in ahd_sync_tqinfifo()
909 ahd_targetcmd_offset(ahd, 0), in ahd_sync_tqinfifo()
923 ahd_check_cmdcmpltqueues(struct ahd_softc *ahd) in ahd_check_cmdcmpltqueues() argument
928 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap, in ahd_check_cmdcmpltqueues()
929 /*offset*/ahd->qoutfifonext * sizeof(*ahd->qoutfifo), in ahd_check_cmdcmpltqueues()
930 /*len*/sizeof(*ahd->qoutfifo), BUS_DMASYNC_POSTREAD); in ahd_check_cmdcmpltqueues()
931 if (ahd->qoutfifo[ahd->qoutfifonext].valid_tag in ahd_check_cmdcmpltqueues()
932 == ahd->qoutfifonext_valid_tag) in ahd_check_cmdcmpltqueues()
935 if ((ahd->flags & AHD_TARGETROLE) != 0 in ahd_check_cmdcmpltqueues()
936 && (ahd->flags & AHD_TQINFIFO_BLOCKED) == 0) { in ahd_check_cmdcmpltqueues()
937 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, in ahd_check_cmdcmpltqueues()
938 ahd->shared_data_map.dmamap, in ahd_check_cmdcmpltqueues()
939 ahd_targetcmd_offset(ahd, ahd->tqinfifofnext), in ahd_check_cmdcmpltqueues()
942 if (ahd->targetcmds[ahd->tqinfifonext].cmd_valid != 0) in ahd_check_cmdcmpltqueues()
953 ahd_intr(struct ahd_softc *ahd) in ahd_intr() argument
957 if ((ahd->pause & INTEN) == 0) { in ahd_intr()
973 if ((ahd->flags & AHD_ALL_INTERRUPTS) == 0 in ahd_intr()
974 && (ahd_check_cmdcmpltqueues(ahd) != 0)) in ahd_intr()
977 intstat = ahd_inb(ahd, INTSTAT); in ahd_intr()
983 ahd_outb(ahd, CLRINT, CLRCMDINT); in ahd_intr()
993 if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) { in ahd_intr()
994 if (ahd_is_paused(ahd)) { in ahd_intr()
1000 if (ahd_inb(ahd, SEQINTCODE) != NO_SEQINT) in ahd_intr()
1004 ahd_flush_device_writes(ahd); in ahd_intr()
1006 ahd_run_qoutfifo(ahd); in ahd_intr()
1007 ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]++; in ahd_intr()
1008 ahd->cmdcmplt_total++; in ahd_intr()
1010 if ((ahd->flags & AHD_TARGETROLE) != 0) in ahd_intr()
1011 ahd_run_tqinfifo(ahd, /*paused*/FALSE); in ahd_intr()
1019 if (intstat == 0xFF && (ahd->features & AHD_REMOVABLE) != 0) { in ahd_intr()
1022 ahd_handle_hwerrint(ahd); in ahd_intr()
1024 ahd->bus_intr(ahd); in ahd_intr()
1028 ahd_handle_seqint(ahd, intstat); in ahd_intr()
1031 ahd_handle_scsiint(ahd, intstat); in ahd_intr()
1038 ahd_assert_atn(struct ahd_softc *ahd) in ahd_assert_atn() argument
1040 ahd_outb(ahd, SCSISIGO, ATNO); in ahd_assert_atn()
1050 ahd_currently_packetized(struct ahd_softc *ahd) in ahd_currently_packetized() argument
1055 saved_modes = ahd_save_modes(ahd); in ahd_currently_packetized()
1056 if ((ahd->bugs & AHD_PKTIZED_STATUS_BUG) != 0) { in ahd_currently_packetized()
1062 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_currently_packetized()
1063 packetized = ahd_inb(ahd, LQISTATE) != 0; in ahd_currently_packetized()
1065 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_currently_packetized()
1066 packetized = ahd_inb(ahd, LQISTAT2) & PACKETIZED; in ahd_currently_packetized()
1068 ahd_restore_modes(ahd, saved_modes); in ahd_currently_packetized()
1073 ahd_set_active_fifo(struct ahd_softc *ahd) in ahd_set_active_fifo() argument
1077 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_set_active_fifo()
1078 active_fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO; in ahd_set_active_fifo()
1082 ahd_set_modes(ahd, active_fifo, active_fifo); in ahd_set_active_fifo()
1090 ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl) in ahd_unbusy_tcl() argument
1092 ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL); in ahd_unbusy_tcl()
1100 ahd_update_residual(struct ahd_softc *ahd, struct scb *scb) in ahd_update_residual() argument
1106 ahd_calc_residual(ahd, scb); in ahd_update_residual()
1110 ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_complete_scb() argument
1116 ahd_handle_scb_status(ahd, scb); in ahd_complete_scb()
1118 ahd_done(ahd, scb); in ahd_complete_scb()
1127 ahd_restart(struct ahd_softc *ahd) in ahd_restart() argument
1130 ahd_pause(ahd); in ahd_restart()
1132 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_restart()
1135 ahd_clear_msg_state(ahd); in ahd_restart()
1136 ahd_outb(ahd, SCSISIGO, 0); /* De-assert BSY */ in ahd_restart()
1137 ahd_outb(ahd, MSG_OUT, MSG_NOOP); /* No message to send */ in ahd_restart()
1138 ahd_outb(ahd, SXFRCTL1, ahd_inb(ahd, SXFRCTL1) & ~BITBUCKET); in ahd_restart()
1139 ahd_outb(ahd, SEQINTCTL, 0); in ahd_restart()
1140 ahd_outb(ahd, LASTPHASE, P_BUSFREE); in ahd_restart()
1141 ahd_outb(ahd, SEQ_FLAGS, 0); in ahd_restart()
1142 ahd_outb(ahd, SAVED_SCSIID, 0xFF); in ahd_restart()
1143 ahd_outb(ahd, SAVED_LUN, 0xFF); in ahd_restart()
1152 ahd_outb(ahd, TQINPOS, ahd->tqinfifonext); in ahd_restart()
1155 ahd_outb(ahd, SCSISEQ1, in ahd_restart()
1156 ahd_inb(ahd, SCSISEQ_TEMPLATE) & (ENSELI|ENRSELI|ENAUTOATNP)); in ahd_restart()
1157 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_restart()
1164 ahd_outb(ahd, CLRINT, CLRSEQINT); in ahd_restart()
1166 ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET); in ahd_restart()
1167 ahd_unpause(ahd); in ahd_restart()
1171 ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo) in ahd_clear_fifo() argument
1177 printk("%s: Clearing FIFO %d\n", ahd_name(ahd), fifo); in ahd_clear_fifo()
1179 saved_modes = ahd_save_modes(ahd); in ahd_clear_fifo()
1180 ahd_set_modes(ahd, fifo, fifo); in ahd_clear_fifo()
1181 ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT); in ahd_clear_fifo()
1182 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) in ahd_clear_fifo()
1183 ahd_outb(ahd, CCSGCTL, CCSGRESET); in ahd_clear_fifo()
1184 ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR); in ahd_clear_fifo()
1185 ahd_outb(ahd, SG_STATE, 0); in ahd_clear_fifo()
1186 ahd_restore_modes(ahd, saved_modes); in ahd_clear_fifo()
1195 ahd_flush_qoutfifo(struct ahd_softc *ahd) in ahd_flush_qoutfifo() argument
1204 saved_modes = ahd_save_modes(ahd); in ahd_flush_qoutfifo()
1209 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_flush_qoutfifo()
1210 saved_scbptr = ahd_get_scbptr(ahd); in ahd_flush_qoutfifo()
1211 while ((ahd_inb(ahd, LQISTAT2) & LQIGSAVAIL) != 0) { in ahd_flush_qoutfifo()
1215 scbid = ahd_inw(ahd, GSFIFO); in ahd_flush_qoutfifo()
1216 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1219 ahd_name(ahd), scbid); in ahd_flush_qoutfifo()
1232 ahd_set_modes(ahd, fifo_mode, fifo_mode); in ahd_flush_qoutfifo()
1234 if (ahd_scb_active_in_fifo(ahd, scb) == 0) in ahd_flush_qoutfifo()
1237 ahd_run_data_fifo(ahd, scb); in ahd_flush_qoutfifo()
1256 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_flush_qoutfifo()
1257 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1258 if ((ahd_inb_scbram(ahd, SCB_SGPTR) & SG_LIST_NULL) == 0 in ahd_flush_qoutfifo()
1259 && ((ahd_inb_scbram(ahd, SCB_SGPTR) & SG_FULL_RESID) != 0 in ahd_flush_qoutfifo()
1260 || (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR) in ahd_flush_qoutfifo()
1270 ahd_outb(ahd, SCB_SCSI_STATUS, 0); in ahd_flush_qoutfifo()
1271 ahd_outb(ahd, SCB_SGPTR, in ahd_flush_qoutfifo()
1272 ahd_inb_scbram(ahd, SCB_SGPTR) in ahd_flush_qoutfifo()
1274 ahd_outw(ahd, SCB_TAG, scbid); in ahd_flush_qoutfifo()
1275 ahd_outw(ahd, SCB_NEXT_COMPLETE, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1276 comp_head = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD); in ahd_flush_qoutfifo()
1278 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, scbid); in ahd_flush_qoutfifo()
1279 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid); in ahd_flush_qoutfifo()
1283 tail = ahd_inw(ahd, COMPLETE_DMA_SCB_TAIL); in ahd_flush_qoutfifo()
1284 ahd_set_scbptr(ahd, tail); in ahd_flush_qoutfifo()
1285 ahd_outw(ahd, SCB_NEXT_COMPLETE, scbid); in ahd_flush_qoutfifo()
1286 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid); in ahd_flush_qoutfifo()
1287 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1290 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1292 ahd_set_scbptr(ahd, saved_scbptr); in ahd_flush_qoutfifo()
1297 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_flush_qoutfifo()
1303 while (((ccscbctl = ahd_inb(ahd, CCSCBCTL)) & (CCARREN|CCSCBEN)) != 0) { in ahd_flush_qoutfifo()
1320 ahd_outb(ahd, CCSCBCTL, ccscbctl & ~(CCARREN|CCSCBEN)); in ahd_flush_qoutfifo()
1326 ahd_run_qoutfifo(ahd); in ahd_flush_qoutfifo()
1328 saved_scbptr = ahd_get_scbptr(ahd); in ahd_flush_qoutfifo()
1333 scbid = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD); in ahd_flush_qoutfifo()
1338 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1339 next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_flush_qoutfifo()
1340 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1343 "SCB %d invalid\n", ahd_name(ahd), scbid); in ahd_flush_qoutfifo()
1348 *hscb_ptr++ = ahd_inb_scbram(ahd, SCB_BASE + i); in ahd_flush_qoutfifo()
1350 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1353 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1354 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1356 scbid = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD); in ahd_flush_qoutfifo()
1359 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1360 next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_flush_qoutfifo()
1361 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1364 ahd_name(ahd), scbid); in ahd_flush_qoutfifo()
1368 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1371 ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1373 scbid = ahd_inw(ahd, COMPLETE_SCB_HEAD); in ahd_flush_qoutfifo()
1376 ahd_set_scbptr(ahd, scbid); in ahd_flush_qoutfifo()
1377 next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_flush_qoutfifo()
1378 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1381 ahd_name(ahd), scbid); in ahd_flush_qoutfifo()
1385 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1388 ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL); in ahd_flush_qoutfifo()
1393 ahd_set_scbptr(ahd, saved_scbptr); in ahd_flush_qoutfifo()
1394 ahd_restore_modes(ahd, saved_modes); in ahd_flush_qoutfifo()
1395 ahd->flags |= AHD_UPDATE_PEND_CMDS; in ahd_flush_qoutfifo()
1403 ahd_scb_active_in_fifo(struct ahd_softc *ahd, struct scb *scb) in ahd_scb_active_in_fifo() argument
1412 if (ahd_get_scbptr(ahd) != SCB_GET_TAG(scb) in ahd_scb_active_in_fifo()
1413 || ((ahd_inb(ahd, LONGJMP_ADDR+1) & INVALID_ADDR) != 0 in ahd_scb_active_in_fifo()
1414 && (ahd_inb(ahd, SEQINTSRC) & (CFG4DATA|SAVEPTRS)) == 0)) in ahd_scb_active_in_fifo()
1432 ahd_run_data_fifo(struct ahd_softc *ahd, struct scb *scb) in ahd_run_data_fifo() argument
1436 seqintsrc = ahd_inb(ahd, SEQINTSRC); in ahd_run_data_fifo()
1444 sgptr = ahd_inl_scbram(ahd, SCB_SGPTR) & ~SG_FULL_RESID; in ahd_run_data_fifo()
1445 ahd_outb(ahd, SCB_SGPTR, sgptr); in ahd_run_data_fifo()
1450 datacnt = ahd_inl_scbram(ahd, SCB_DATACNT); in ahd_run_data_fifo()
1453 ahd_outb(ahd, SG_STATE, 0); in ahd_run_data_fifo()
1455 ahd_outb(ahd, SG_STATE, LOADING_NEEDED); in ahd_run_data_fifo()
1456 ahd_outq(ahd, HADDR, ahd_inq_scbram(ahd, SCB_DATAPTR)); in ahd_run_data_fifo()
1457 ahd_outl(ahd, HCNT, datacnt & AHD_SG_LEN_MASK); in ahd_run_data_fifo()
1458 ahd_outb(ahd, SG_CACHE_PRE, sgptr); in ahd_run_data_fifo()
1459 ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN); in ahd_run_data_fifo()
1464 ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, datacnt >> 24); in ahd_run_data_fifo()
1465 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr & SG_PTR_MASK); in ahd_run_data_fifo()
1470 ahd_outb(ahd, SCB_FIFO_USE_COUNT, in ahd_run_data_fifo()
1471 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) + 1); in ahd_run_data_fifo()
1476 ahd_outw(ahd, LONGJMP_ADDR, 0); in ahd_run_data_fifo()
1482 ahd_outb(ahd, CLRSEQINTSRC, CLRCFG4DATA); in ahd_run_data_fifo()
1487 if ((ahd_inb(ahd, LONGJMP_ADDR+1)&INVALID_ADDR) != 0) { in ahd_run_data_fifo()
1500 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) in ahd_run_data_fifo()
1501 ahd_outb(ahd, CCSGCTL, 0); in ahd_run_data_fifo()
1502 ahd_outb(ahd, SG_STATE, 0); in ahd_run_data_fifo()
1508 ahd_outb(ahd, DFCNTRL, ahd_inb(ahd, DFCNTRL) | FIFOFLUSH); in ahd_run_data_fifo()
1513 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_run_data_fifo()
1514 resid = ahd_inl(ahd, SHCNT); in ahd_run_data_fifo()
1515 resid |= ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT+3) << 24; in ahd_run_data_fifo()
1516 ahd_outl(ahd, SCB_RESIDUAL_DATACNT, resid); in ahd_run_data_fifo()
1517 if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG) == 0) { in ahd_run_data_fifo()
1525 if ((ahd_inb(ahd, SG_CACHE_SHADOW) & 0x80) != 0 in ahd_run_data_fifo()
1529 sgptr |= ahd_inb(ahd, SG_CACHE_SHADOW) in ahd_run_data_fifo()
1531 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr); in ahd_run_data_fifo()
1532 ahd_outb(ahd, SCB_RESIDUAL_DATACNT + 3, 0); in ahd_run_data_fifo()
1534 ahd_outb(ahd, SCB_RESIDUAL_SGPTR, in ahd_run_data_fifo()
1540 ahd_outq(ahd, SCB_DATAPTR, ahd_inq(ahd, SHADDR)); in ahd_run_data_fifo()
1541 ahd_outl(ahd, SCB_DATACNT, resid); in ahd_run_data_fifo()
1542 ahd_outl(ahd, SCB_SGPTR, sgptr); in ahd_run_data_fifo()
1543 ahd_outb(ahd, CLRSEQINTSRC, CLRSAVEPTRS); in ahd_run_data_fifo()
1544 ahd_outb(ahd, SEQIMODE, in ahd_run_data_fifo()
1545 ahd_inb(ahd, SEQIMODE) | ENSAVEPTRS); in ahd_run_data_fifo()
1550 if ((ahd_inb(ahd, DFCNTRL) & DIRECTION) != 0) in ahd_run_data_fifo()
1552 } else if ((ahd_inb(ahd, SG_STATE) & LOADING_NEEDED) != 0) { in ahd_run_data_fifo()
1563 if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) { in ahd_run_data_fifo()
1564 ahd_outb(ahd, CCSGCTL, 0); in ahd_run_data_fifo()
1565 ahd_outb(ahd, SG_STATE, LOADING_NEEDED); in ahd_run_data_fifo()
1574 if ((ahd_inb(ahd, DFSTATUS) & PRELOAD_AVAIL) != 0 in ahd_run_data_fifo()
1575 && (ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0) { in ahd_run_data_fifo()
1581 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_run_data_fifo()
1583 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_run_data_fifo()
1586 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_run_data_fifo()
1593 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_run_data_fifo()
1604 ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, data_len >> 24); in ahd_run_data_fifo()
1605 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr); in ahd_run_data_fifo()
1612 ahd_outb(ahd, SG_STATE, 0); in ahd_run_data_fifo()
1614 ahd_outq(ahd, HADDR, data_addr); in ahd_run_data_fifo()
1615 ahd_outl(ahd, HCNT, data_len & AHD_SG_LEN_MASK); in ahd_run_data_fifo()
1616 ahd_outb(ahd, SG_CACHE_PRE, sgptr & 0xFF); in ahd_run_data_fifo()
1621 dfcntrl = ahd_inb(ahd, DFCNTRL)|PRELOADEN|HDMAEN; in ahd_run_data_fifo()
1622 if ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0) { in ahd_run_data_fifo()
1630 ahd_outb(ahd, DFCNTRL, dfcntrl); in ahd_run_data_fifo()
1632 } else if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG_DONE) != 0) { in ahd_run_data_fifo()
1638 ahd_outb(ahd, SCB_SGPTR, in ahd_run_data_fifo()
1639 ahd_inb_scbram(ahd, SCB_SGPTR) | SG_LIST_NULL); in ahd_run_data_fifo()
1641 } else if ((ahd_inb(ahd, DFSTATUS) & FIFOEMP) != 0) { in ahd_run_data_fifo()
1648 ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR); in ahd_run_data_fifo()
1649 ahd_outb(ahd, SCB_FIFO_USE_COUNT, in ahd_run_data_fifo()
1650 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) - 1); in ahd_run_data_fifo()
1651 ahd_outb(ahd, DFFSXFRCTL, CLRCHN); in ahd_run_data_fifo()
1666 ahd_run_qoutfifo(struct ahd_softc *ahd) in ahd_run_qoutfifo() argument
1672 if ((ahd->flags & AHD_RUNNING_QOUTFIFO) != 0) in ahd_run_qoutfifo()
1674 ahd->flags |= AHD_RUNNING_QOUTFIFO; in ahd_run_qoutfifo()
1675 ahd_sync_qoutfifo(ahd, BUS_DMASYNC_POSTREAD); in ahd_run_qoutfifo()
1677 completion = &ahd->qoutfifo[ahd->qoutfifonext]; in ahd_run_qoutfifo()
1679 if (completion->valid_tag != ahd->qoutfifonext_valid_tag) in ahd_run_qoutfifo()
1683 scb = ahd_lookup_scb(ahd, scb_index); in ahd_run_qoutfifo()
1687 ahd_name(ahd), scb_index, in ahd_run_qoutfifo()
1688 ahd->qoutfifonext); in ahd_run_qoutfifo()
1689 ahd_dump_card_state(ahd); in ahd_run_qoutfifo()
1691 ahd_handle_scb_status(ahd, scb); in ahd_run_qoutfifo()
1693 ahd_done(ahd, scb); in ahd_run_qoutfifo()
1696 ahd->qoutfifonext = (ahd->qoutfifonext+1) & (AHD_QOUT_SIZE-1); in ahd_run_qoutfifo()
1697 if (ahd->qoutfifonext == 0) in ahd_run_qoutfifo()
1698 ahd->qoutfifonext_valid_tag ^= QOUTFIFO_ENTRY_VALID; in ahd_run_qoutfifo()
1700 ahd->flags &= ~AHD_RUNNING_QOUTFIFO; in ahd_run_qoutfifo()
1705 ahd_handle_hwerrint(struct ahd_softc *ahd) in ahd_handle_hwerrint() argument
1714 error = ahd_inb(ahd, ERROR); in ahd_handle_hwerrint()
1718 ahd_name(ahd), ahd_hard_errors[i].errmesg); in ahd_handle_hwerrint()
1721 ahd_dump_card_state(ahd); in ahd_handle_hwerrint()
1725 ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS, in ahd_handle_hwerrint()
1730 ahd_free(ahd); in ahd_handle_hwerrint()
1779 ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat) in ahd_handle_seqint() argument
1788 seqintcode = ahd_inb(ahd, SEQINTCODE); in ahd_handle_seqint()
1789 ahd_outb(ahd, CLRINT, CLRSEQINT); in ahd_handle_seqint()
1790 if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) { in ahd_handle_seqint()
1797 ahd_unpause(ahd); in ahd_handle_seqint()
1798 while (!ahd_is_paused(ahd)) in ahd_handle_seqint()
1800 ahd_outb(ahd, CLRINT, CLRSEQINT); in ahd_handle_seqint()
1802 ahd_update_modes(ahd); in ahd_handle_seqint()
1806 ahd_name(ahd), seqintcode); in ahd_handle_seqint()
1814 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_handle_seqint()
1816 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
1817 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1826 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid); in ahd_handle_seqint()
1827 ahd_outb(ahd, SAVED_LUN, scb->hscb->lun); in ahd_handle_seqint()
1828 ahd_outb(ahd, SEQ_FLAGS, 0x0); in ahd_handle_seqint()
1830 if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0 in ahd_handle_seqint()
1831 && (ahd_inb(ahd, SCSISIGO) & ATNO) != 0) { in ahd_handle_seqint()
1840 "P0 assertion\n", ahd_name(ahd)); in ahd_handle_seqint()
1845 printk("%s: Entering NONPACK\n", ahd_name(ahd)); in ahd_handle_seqint()
1852 ahd_name(ahd)); in ahd_handle_seqint()
1855 ahd_dump_card_state(ahd); in ahd_handle_seqint()
1857 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_seqint()
1864 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
1865 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1867 ahd_print_path(ahd, scb); in ahd_handle_seqint()
1869 printk("%s: ", ahd_name(ahd)); in ahd_handle_seqint()
1871 ahd_dump_card_state(ahd); in ahd_handle_seqint()
1872 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_seqint()
1880 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
1881 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1883 ahd_dump_card_state(ahd); in ahd_handle_seqint()
1887 ahd_outq(ahd, HADDR, scb->sense_busaddr); in ahd_handle_seqint()
1888 ahd_outw(ahd, HCNT, AHD_SENSE_BUFSIZE); in ahd_handle_seqint()
1889 ahd_outb(ahd, HCNT + 2, 0); in ahd_handle_seqint()
1890 ahd_outb(ahd, SG_CACHE_PRE, SG_LAST_SEG); in ahd_handle_seqint()
1891 ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN); in ahd_handle_seqint()
1898 bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK; in ahd_handle_seqint()
1900 ahd_name(ahd), bus_phase); in ahd_handle_seqint()
1910 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_seqint()
1911 printk("%s: Issued Bus Reset.\n", ahd_name(ahd)); in ahd_handle_seqint()
1933 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
1934 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1938 ahd_reset_channel(ahd, 'A', in ahd_handle_seqint()
1943 SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
1945 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_seqint()
1947 targ_info = ahd_fetch_transinfo(ahd, in ahd_handle_seqint()
1953 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_handle_seqint()
1955 ahd_set_syncrate(ahd, &devinfo, /*period*/0, in ahd_handle_seqint()
1959 ahd_outb(ahd, SCB_CDB_STORE, 0); in ahd_handle_seqint()
1960 ahd_outb(ahd, SCB_CDB_STORE+1, 0); in ahd_handle_seqint()
1961 ahd_outb(ahd, SCB_CDB_STORE+2, 0); in ahd_handle_seqint()
1962 ahd_outb(ahd, SCB_CDB_STORE+3, 0); in ahd_handle_seqint()
1963 ahd_outb(ahd, SCB_CDB_STORE+4, 0); in ahd_handle_seqint()
1964 ahd_outb(ahd, SCB_CDB_STORE+5, 0); in ahd_handle_seqint()
1965 ahd_outb(ahd, SCB_CDB_LEN, 6); in ahd_handle_seqint()
1968 ahd_outb(ahd, SCB_CONTROL, scb->hscb->control); in ahd_handle_seqint()
1969 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_seqint()
1970 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid); in ahd_handle_seqint()
1975 ahd_outb(ahd, SAVED_LUN, 0); in ahd_handle_seqint()
1976 ahd_outb(ahd, SEQ_FLAGS, 0); in ahd_handle_seqint()
1977 ahd_assert_atn(ahd); in ahd_handle_seqint()
1980 ahd_freeze_devq(ahd, scb); in ahd_handle_seqint()
1985 ahd_send_async(ahd, devinfo.channel, devinfo.target, in ahd_handle_seqint()
1992 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_seqint()
1993 ahd_outb(ahd, CLRLQOINT1, CLRLQOPHACHGINPKT); in ahd_handle_seqint()
1994 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) { in ahd_handle_seqint()
1995 ahd_outb(ahd, CLRLQOINT1, 0); in ahd_handle_seqint()
1999 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2016 printk("%s: CFG4OVERRUN mode = %x\n", ahd_name(ahd), in ahd_handle_seqint()
2017 ahd_inb(ahd, MODE_PTR)); in ahd_handle_seqint()
2020 scb_index = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2021 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_seqint()
2027 ahd_assert_atn(ahd); in ahd_handle_seqint()
2028 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_seqint()
2029 ahd->msgout_buf[0] = MSG_ABORT_TASK; in ahd_handle_seqint()
2030 ahd->msgout_len = 1; in ahd_handle_seqint()
2031 ahd->msgout_index = 0; in ahd_handle_seqint()
2032 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_handle_seqint()
2037 ahd_outb(ahd, SCB_CONTROL, in ahd_handle_seqint()
2038 ahd_inb_scbram(ahd, SCB_CONTROL) in ahd_handle_seqint()
2045 ahd_dump_card_state(ahd); in ahd_handle_seqint()
2054 ahd_name(ahd), ahd_inb(ahd, DFCNTRL), in ahd_handle_seqint()
2055 ahd_inb(ahd, SG_CACHE_SHADOW)); in ahd_handle_seqint()
2058 ahd_reinitialize_dataptrs(ahd); in ahd_handle_seqint()
2076 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_seqint()
2077 if (ahd->msg_type == MSG_TYPE_NONE) { in ahd_handle_seqint()
2082 bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK; in ahd_handle_seqint()
2091 ahd_dump_card_state(ahd); in ahd_handle_seqint()
2092 ahd_clear_intstat(ahd); in ahd_handle_seqint()
2093 ahd_restart(ahd); in ahd_handle_seqint()
2097 scb_index = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2098 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_seqint()
2101 ahd_setup_initiator_msgout(ahd, in ahd_handle_seqint()
2105 ahd->msg_type = in ahd_handle_seqint()
2107 ahd->msgin_index = 0; in ahd_handle_seqint()
2113 ahd->msg_type = in ahd_handle_seqint()
2115 ahd->msgin_index = 0; in ahd_handle_seqint()
2118 ahd_setup_target_msgin(ahd, in ahd_handle_seqint()
2125 ahd_handle_message_phase(ahd); in ahd_handle_seqint()
2131 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_handle_seqint()
2132 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO); in ahd_handle_seqint()
2136 ahd_name(ahd), 'A', ahd_inb(ahd, SELID) >> 4); in ahd_handle_seqint()
2139 ahd_inb(ahd, SAVED_SCSIID), ahd_inb(ahd, SAVED_LUN), in ahd_handle_seqint()
2140 ahd_inw(ahd, REG0), ahd_inb(ahd, ACCUM)); in ahd_handle_seqint()
2143 ahd_inb(ahd, SEQ_FLAGS), ahd_get_scbptr(ahd), in ahd_handle_seqint()
2144 ahd_find_busy_tcl(ahd, in ahd_handle_seqint()
2145 BUILD_TCL(ahd_inb(ahd, SAVED_SCSIID), in ahd_handle_seqint()
2146 ahd_inb(ahd, SAVED_LUN))), in ahd_handle_seqint()
2147 ahd_inw(ahd, SINDEX)); in ahd_handle_seqint()
2150 ahd_inb(ahd, SELID), ahd_inb_scbram(ahd, SCB_SCSIID), in ahd_handle_seqint()
2151 ahd_inb_scbram(ahd, SCB_LUN), in ahd_handle_seqint()
2152 ahd_inb_scbram(ahd, SCB_CONTROL)); in ahd_handle_seqint()
2154 ahd_inb(ahd, SCSIBUS), ahd_inb(ahd, SCSISIGI)); in ahd_handle_seqint()
2155 printk("SXFRCTL0 == 0x%x\n", ahd_inb(ahd, SXFRCTL0)); in ahd_handle_seqint()
2156 printk("SEQCTL0 == 0x%x\n", ahd_inb(ahd, SEQCTL0)); in ahd_handle_seqint()
2157 ahd_dump_card_state(ahd); in ahd_handle_seqint()
2158 ahd->msgout_buf[0] = MSG_BUS_DEV_RESET; in ahd_handle_seqint()
2159 ahd->msgout_len = 1; in ahd_handle_seqint()
2160 ahd->msgout_index = 0; in ahd_handle_seqint()
2161 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_handle_seqint()
2162 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_seqint()
2163 ahd_assert_atn(ahd); in ahd_handle_seqint()
2168 ahd_handle_proto_violation(ahd); in ahd_handle_seqint()
2175 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_seqint()
2176 ahd_handle_ign_wide_residue(ahd, &devinfo); in ahd_handle_seqint()
2183 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_seqint()
2186 ahd_name(ahd), 'A', in ahd_handle_seqint()
2187 SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)), in ahd_handle_seqint()
2188 lastphase, ahd_inb(ahd, SCSISIGI)); in ahd_handle_seqint()
2195 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_seqint()
2198 ahd_name(ahd), 'A', in ahd_handle_seqint()
2199 SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)), in ahd_handle_seqint()
2200 lastphase, ahd_inb(ahd, SCSISIGI)); in ahd_handle_seqint()
2201 ahd_restart(ahd); in ahd_handle_seqint()
2220 scbindex = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2221 scb = ahd_lookup_scb(ahd, scbindex); in ahd_handle_seqint()
2223 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_seqint()
2225 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2229 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2232 ahd_inb(ahd, SEQ_FLAGS) & DPHASE in ahd_handle_seqint()
2243 ahd_freeze_devq(ahd, scb); in ahd_handle_seqint()
2254 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_seqint()
2256 ahd_name(ahd), devinfo.channel, devinfo.target, in ahd_handle_seqint()
2258 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2259 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
2266 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
2267 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_seqint()
2271 ahd_outb(ahd, SCB_CONTROL, in ahd_handle_seqint()
2272 ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE); in ahd_handle_seqint()
2280 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2281 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
2287 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2300 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
2310 ahd_scb_devinfo(ahd, &devinfo, scb); in ahd_handle_seqint()
2312 ahd_handle_devreset(ahd, &devinfo, lun, in ahd_handle_seqint()
2336 scbid = ahd_get_scbptr(ahd); in ahd_handle_seqint()
2337 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
2343 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2352 while ((ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0 in ahd_handle_seqint()
2353 && (ahd_inb(ahd, SSTAT0) & SELDO) == 0 in ahd_handle_seqint()
2354 && (ahd_inb(ahd, SSTAT1) & SELTO) == 0) in ahd_handle_seqint()
2356 ahd_outb(ahd, SCB_TASK_MANAGEMENT, 0); in ahd_handle_seqint()
2357 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
2358 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_seqint()
2369 printk("%s: Tracepoint %d\n", ahd_name(ahd), in ahd_handle_seqint()
2375 ahd_handle_hwerrint(ahd); in ahd_handle_seqint()
2378 printk("%s: Unexpected SEQINTCODE %d\n", ahd_name(ahd), in ahd_handle_seqint()
2387 ahd_unpause(ahd); in ahd_handle_seqint()
2391 ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat) in ahd_handle_scsiint() argument
2402 ahd_update_modes(ahd); in ahd_handle_scsiint()
2403 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_scsiint()
2405 status3 = ahd_inb(ahd, SSTAT3) & (NTRAMPERR|OSRAMPERR); in ahd_handle_scsiint()
2406 status0 = ahd_inb(ahd, SSTAT0) & (IOERR|OVERRUN|SELDI|SELDO); in ahd_handle_scsiint()
2407 status = ahd_inb(ahd, SSTAT1) & (SELTO|SCSIRSTI|BUSFREE|SCSIPERR); in ahd_handle_scsiint()
2408 lqistat1 = ahd_inb(ahd, LQISTAT1); in ahd_handle_scsiint()
2409 lqostat0 = ahd_inb(ahd, LQOSTAT0); in ahd_handle_scsiint()
2410 busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME; in ahd_handle_scsiint()
2415 if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) { in ahd_handle_scsiint()
2416 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI); in ahd_handle_scsiint()
2423 ahd->flags &= ~AHD_BUS_RESET_ACTIVE; in ahd_handle_scsiint()
2428 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_handle_scsiint()
2429 simode0 = ahd_inb(ahd, SIMODE0); in ahd_handle_scsiint()
2431 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_scsiint()
2433 scbid = ahd_get_scbptr(ahd); in ahd_handle_scsiint()
2434 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_scsiint()
2436 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0) in ahd_handle_scsiint()
2442 now_lvd = ahd_inb(ahd, SBLKCTL) & ENAB40; in ahd_handle_scsiint()
2444 ahd_name(ahd), now_lvd ? "LVD" : "SE"); in ahd_handle_scsiint()
2445 ahd_outb(ahd, CLRSINT0, CLRIOERR); in ahd_handle_scsiint()
2449 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_scsiint()
2450 ahd_pause(ahd); in ahd_handle_scsiint()
2451 ahd_setup_iocell_workaround(ahd); in ahd_handle_scsiint()
2452 ahd_unpause(ahd); in ahd_handle_scsiint()
2456 ahd_name(ahd)); in ahd_handle_scsiint()
2457 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_scsiint()
2460 printk("%s: Someone reset channel A\n", ahd_name(ahd)); in ahd_handle_scsiint()
2461 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE); in ahd_handle_scsiint()
2465 ahd_clear_critical_section(ahd); in ahd_handle_scsiint()
2467 ahd_handle_transmission_error(ahd); in ahd_handle_scsiint()
2470 printk("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0); in ahd_handle_scsiint()
2471 ahd_outb(ahd, CLRLQOINT0, lqostat0); in ahd_handle_scsiint()
2472 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) in ahd_handle_scsiint()
2473 ahd_outb(ahd, CLRLQOINT1, 0); in ahd_handle_scsiint()
2476 ahd_outb(ahd, SCSISEQ0, 0); in ahd_handle_scsiint()
2479 ahd_clear_critical_section(ahd); in ahd_handle_scsiint()
2482 ahd_clear_msg_state(ahd); in ahd_handle_scsiint()
2485 ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRBUSFREE|CLRSCSIPERR); in ahd_handle_scsiint()
2495 ahd_outb(ahd, CLRSINT0, CLRSELINGO); in ahd_handle_scsiint()
2497 scbid = ahd_inw(ahd, WAITING_TID_HEAD); in ahd_handle_scsiint()
2498 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_scsiint()
2502 ahd_name(ahd), scbid); in ahd_handle_scsiint()
2503 ahd_dump_card_state(ahd); in ahd_handle_scsiint()
2508 ahd_print_path(ahd, scb); in ahd_handle_scsiint()
2513 ahd_scb_devinfo(ahd, &devinfo, scb); in ahd_handle_scsiint()
2515 ahd_freeze_devq(ahd, scb); in ahd_handle_scsiint()
2523 ahd_handle_devreset(ahd, &devinfo, in ahd_handle_scsiint()
2529 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_handle_scsiint()
2530 ahd_iocell_first_selection(ahd); in ahd_handle_scsiint()
2531 ahd_unpause(ahd); in ahd_handle_scsiint()
2534 ahd_iocell_first_selection(ahd); in ahd_handle_scsiint()
2535 ahd_unpause(ahd); in ahd_handle_scsiint()
2538 ahd_name(ahd), status3); in ahd_handle_scsiint()
2539 ahd_outb(ahd, CLRSINT3, status3); in ahd_handle_scsiint()
2543 ahd_clear_critical_section(ahd); in ahd_handle_scsiint()
2545 ahd_handle_lqiphase_error(ahd, lqistat1); in ahd_handle_scsiint()
2553 ahd_outb(ahd, CLRLQIINT1, CLRLQICRCI_NLQ); in ahd_handle_scsiint()
2568 ahd_outb(ahd, SCSISEQ0, 0); in ahd_handle_scsiint()
2571 ahd_clear_critical_section(ahd); in ahd_handle_scsiint()
2578 busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME; in ahd_handle_scsiint()
2579 lqostat1 = ahd_inb(ahd, LQOSTAT1); in ahd_handle_scsiint()
2586 ahd_set_modes(ahd, mode, mode); in ahd_handle_scsiint()
2587 scbid = ahd_get_scbptr(ahd); in ahd_handle_scsiint()
2588 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_scsiint()
2592 ahd_name(ahd), scbid, mode); in ahd_handle_scsiint()
2607 && ahd_inb(ahd, LASTPHASE) == P_BUSFREE in ahd_handle_scsiint()
2608 && (ahd_inb(ahd, SSTAT0) & SELDI) == 0 in ahd_handle_scsiint()
2609 && ((ahd_inb(ahd, SSTAT0) & SELDO) == 0 in ahd_handle_scsiint()
2610 || (ahd_inb(ahd, SCSISEQ0) & ENSELO) == 0)) in ahd_handle_scsiint()
2630 if (packetized && ahd_inb(ahd, LASTPHASE) == P_BUSFREE) { in ahd_handle_scsiint()
2631 restart = ahd_handle_pkt_busfree(ahd, busfreetime); in ahd_handle_scsiint()
2634 restart = ahd_handle_nonpkt_busfree(ahd); in ahd_handle_scsiint()
2647 ahd_outb(ahd, CLRSINT1, CLRBUSFREE); in ahd_handle_scsiint()
2649 && (ahd->bugs & AHD_BUSFREEREV_BUG) != 0) in ahd_handle_scsiint()
2650 ahd_outb(ahd, SIMODE1, in ahd_handle_scsiint()
2651 ahd_inb(ahd, SIMODE1) & ~ENBUSFREE); in ahd_handle_scsiint()
2654 ahd_clear_fifo(ahd, mode); in ahd_handle_scsiint()
2656 ahd_clear_msg_state(ahd); in ahd_handle_scsiint()
2657 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_handle_scsiint()
2659 ahd_restart(ahd); in ahd_handle_scsiint()
2661 ahd_unpause(ahd); in ahd_handle_scsiint()
2665 ahd_name(ahd), status); in ahd_handle_scsiint()
2666 ahd_dump_card_state(ahd); in ahd_handle_scsiint()
2667 ahd_clear_intstat(ahd); in ahd_handle_scsiint()
2668 ahd_unpause(ahd); in ahd_handle_scsiint()
2673 ahd_handle_transmission_error(struct ahd_softc *ahd) in ahd_handle_transmission_error() argument
2687 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_transmission_error()
2688 lqistat1 = ahd_inb(ahd, LQISTAT1) & ~(LQIPHASE_LQ|LQIPHASE_NLQ); in ahd_handle_transmission_error()
2689 lqistat2 = ahd_inb(ahd, LQISTAT2); in ahd_handle_transmission_error()
2691 && (ahd->bugs & AHD_NLQICRC_DELAYED_BUG) != 0) { in ahd_handle_transmission_error()
2694 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_handle_transmission_error()
2695 lqistate = ahd_inb(ahd, LQISTATE); in ahd_handle_transmission_error()
2701 ahd_name(ahd)); in ahd_handle_transmission_error()
2706 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_transmission_error()
2709 ahd_outb(ahd, CLRLQIINT1, lqistat1); in ahd_handle_transmission_error()
2710 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_transmission_error()
2711 curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK; in ahd_handle_transmission_error()
2712 perrdiag = ahd_inb(ahd, PERRDIAG); in ahd_handle_transmission_error()
2714 ahd_outb(ahd, CLRSINT1, CLRSCSIPERR); in ahd_handle_transmission_error()
2723 ahd_set_active_fifo(ahd); in ahd_handle_transmission_error()
2724 scbid = ahd_get_scbptr(ahd); in ahd_handle_transmission_error()
2725 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_transmission_error()
2732 printk("%s: Transmission error detected\n", ahd_name(ahd)); in ahd_handle_transmission_error()
2738 ahd_dump_card_state(ahd); in ahd_handle_transmission_error()
2745 ahd_name(ahd), lqistat1); in ahd_handle_transmission_error()
2747 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_transmission_error()
2771 ahd_outb(ahd, LQCTL2, LQIRETRY); in ahd_handle_transmission_error()
2823 "Resetting bus\n", ahd_name(ahd)); in ahd_handle_transmission_error()
2824 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_transmission_error()
2829 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_transmission_error()
2837 ahd_inb(ahd, SCSIDAT); in ahd_handle_transmission_error()
2851 ahd->send_msg_perror = msg_out; in ahd_handle_transmission_error()
2854 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_transmission_error()
2855 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_handle_transmission_error()
2856 ahd_unpause(ahd); in ahd_handle_transmission_error()
2860 ahd_handle_lqiphase_error(struct ahd_softc *ahd, u_int lqistat1) in ahd_handle_lqiphase_error() argument
2865 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_lqiphase_error()
2866 ahd_outb(ahd, CLRLQIINT1, lqistat1); in ahd_handle_lqiphase_error()
2876 ahd_set_active_fifo(ahd); in ahd_handle_lqiphase_error()
2877 if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0 in ahd_handle_lqiphase_error()
2878 && (ahd_inb(ahd, MDFFSTAT) & DLZERO) != 0) { in ahd_handle_lqiphase_error()
2881 ahd_outb(ahd, LQCTL2, LQIRETRY); in ahd_handle_lqiphase_error()
2884 ahd_outb(ahd, LQCTL2, LQIRETRY); in ahd_handle_lqiphase_error()
2887 ahd_dump_card_state(ahd); in ahd_handle_lqiphase_error()
2888 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_handle_lqiphase_error()
2889 ahd_unpause(ahd); in ahd_handle_lqiphase_error()
2892 ahd_dump_card_state(ahd); in ahd_handle_lqiphase_error()
2893 ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); in ahd_handle_lqiphase_error()
2902 ahd_handle_pkt_busfree(struct ahd_softc *ahd, u_int busfreetime) in ahd_handle_pkt_busfree() argument
2906 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_handle_pkt_busfree()
2908 lqostat1 = ahd_inb(ahd, LQOSTAT1); in ahd_handle_pkt_busfree()
2932 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_handle_pkt_busfree()
2933 scbid = ahd_inw(ahd, CURRSCB); in ahd_handle_pkt_busfree()
2934 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_pkt_busfree()
2940 ahd_outb(ahd, CLRLQOINT1, CLRLQOBUSFREE); in ahd_handle_pkt_busfree()
2941 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) in ahd_handle_pkt_busfree()
2942 ahd_outb(ahd, CLRLQOINT1, 0); in ahd_handle_pkt_busfree()
2943 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO); in ahd_handle_pkt_busfree()
2944 ahd_flush_device_writes(ahd); in ahd_handle_pkt_busfree()
2945 ahd_outb(ahd, CLRSINT0, CLRSELDO); in ahd_handle_pkt_busfree()
2953 ahd_outb(ahd, LQCTL2, ahd_inb(ahd, LQCTL2) | LQOTOIDLE); in ahd_handle_pkt_busfree()
2959 waiting_h = ahd_inw(ahd, WAITING_TID_HEAD); in ahd_handle_pkt_busfree()
2960 saved_scbptr = ahd_get_scbptr(ahd); in ahd_handle_pkt_busfree()
2963 ahd_outw(ahd, WAITING_TID_HEAD, scbid); in ahd_handle_pkt_busfree()
2964 waiting_t = ahd_inw(ahd, WAITING_TID_TAIL); in ahd_handle_pkt_busfree()
2966 ahd_outw(ahd, WAITING_TID_TAIL, scbid); in ahd_handle_pkt_busfree()
2969 ahd_set_scbptr(ahd, waiting_h); in ahd_handle_pkt_busfree()
2970 next = ahd_inw_scbram(ahd, SCB_NEXT2); in ahd_handle_pkt_busfree()
2972 ahd_set_scbptr(ahd, scbid); in ahd_handle_pkt_busfree()
2973 ahd_outw(ahd, SCB_NEXT2, next); in ahd_handle_pkt_busfree()
2975 ahd_set_scbptr(ahd, saved_scbptr); in ahd_handle_pkt_busfree()
2978 ahd_print_path(ahd, scb); in ahd_handle_pkt_busfree()
2986 ahd_freeze_devq(ahd, scb); in ahd_handle_pkt_busfree()
2990 } else if ((ahd_inb(ahd, PERRDIAG) & PARITYERR) != 0) { in ahd_handle_pkt_busfree()
2998 ahd_outb(ahd, CLRSINT1, CLRSCSIPERR|CLRBUSFREE); in ahd_handle_pkt_busfree()
3003 ahd_name(ahd)); in ahd_handle_pkt_busfree()
3008 if (ahd->src_mode != AHD_MODE_SCSI) { in ahd_handle_pkt_busfree()
3012 scbid = ahd_get_scbptr(ahd); in ahd_handle_pkt_busfree()
3013 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_pkt_busfree()
3014 ahd_print_path(ahd, scb); in ahd_handle_pkt_busfree()
3016 ahd_dump_card_state(ahd); in ahd_handle_pkt_busfree()
3017 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), 'A', in ahd_handle_pkt_busfree()
3024 printk("%s: Unexpected PKT busfree condition\n", ahd_name(ahd)); in ahd_handle_pkt_busfree()
3025 ahd_dump_card_state(ahd); in ahd_handle_pkt_busfree()
3034 ahd_handle_nonpkt_busfree(struct ahd_softc *ahd) in ahd_handle_nonpkt_busfree() argument
3052 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_nonpkt_busfree()
3053 saved_scsiid = ahd_inb(ahd, SAVED_SCSIID); in ahd_handle_nonpkt_busfree()
3054 saved_lun = ahd_inb(ahd, SAVED_LUN); in ahd_handle_nonpkt_busfree()
3055 target = SCSIID_TARGET(ahd, saved_scsiid); in ahd_handle_nonpkt_busfree()
3061 scbid = ahd_get_scbptr(ahd); in ahd_handle_nonpkt_busfree()
3062 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_nonpkt_busfree()
3064 && (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0) in ahd_handle_nonpkt_busfree()
3067 ppr_busfree = (ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0; in ahd_handle_nonpkt_busfree()
3072 if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT_TAG, TRUE) in ahd_handle_nonpkt_busfree()
3073 || ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT, TRUE)) { in ahd_handle_nonpkt_busfree()
3078 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_nonpkt_busfree()
3084 sent_msg = ahd->msgout_buf[ahd->msgout_index - 1]; in ahd_handle_nonpkt_busfree()
3085 ahd_print_path(ahd, scb); in ahd_handle_nonpkt_busfree()
3109 found = ahd_abort_scbs(ahd, target, 'A', saved_lun, in ahd_handle_nonpkt_busfree()
3114 } else if (ahd_sent_msg(ahd, AHDMSG_1B, in ahd_handle_nonpkt_busfree()
3124 && ahd_match_scb(ahd, scb, target, 'A', in ahd_handle_nonpkt_busfree()
3129 ahd_handle_devreset(ahd, &devinfo, CAM_LUN_WILDCARD, in ahd_handle_nonpkt_busfree()
3133 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, FALSE) in ahd_handle_nonpkt_busfree()
3152 tinfo = ahd_fetch_transinfo(ahd, devinfo.channel, in ahd_handle_nonpkt_busfree()
3156 ahd_set_width(ahd, &devinfo, in ahd_handle_nonpkt_busfree()
3160 ahd_set_syncrate(ahd, &devinfo, in ahd_handle_nonpkt_busfree()
3181 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3182 ahd_qinfifo_requeue_tail(ahd, scb); in ahd_handle_nonpkt_busfree()
3186 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, FALSE) in ahd_handle_nonpkt_busfree()
3196 ahd_set_width(ahd, &devinfo, in ahd_handle_nonpkt_busfree()
3207 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3208 ahd_qinfifo_requeue_tail(ahd, scb); in ahd_handle_nonpkt_busfree()
3211 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, FALSE) in ahd_handle_nonpkt_busfree()
3221 ahd_set_syncrate(ahd, &devinfo, in ahd_handle_nonpkt_busfree()
3233 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3234 ahd_qinfifo_requeue_tail(ahd, scb); in ahd_handle_nonpkt_busfree()
3237 } else if ((ahd->msg_flags & MSG_FLAG_EXPECT_IDE_BUSFREE) != 0 in ahd_handle_nonpkt_busfree()
3238 && ahd_sent_msg(ahd, AHDMSG_1B, in ahd_handle_nonpkt_busfree()
3246 } else if ((ahd->msg_flags & MSG_FLAG_EXPECT_QASREJ_BUSFREE) in ahd_handle_nonpkt_busfree()
3247 && ahd_sent_msg(ahd, AHDMSG_1B, in ahd_handle_nonpkt_busfree()
3265 && ((ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0)) { in ahd_handle_nonpkt_busfree()
3267 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3270 if ((ahd->msg_flags & MSG_FLAG_IU_REQ_CHANGED) != 0) { in ahd_handle_nonpkt_busfree()
3271 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_nonpkt_busfree()
3272 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_nonpkt_busfree()
3280 ahd_done(ahd, scb); in ahd_handle_nonpkt_busfree()
3295 ahd_print_path(ahd, scb); in ahd_handle_nonpkt_busfree()
3296 aborted = ahd_abort_scbs(ahd, target, 'A', in ahd_handle_nonpkt_busfree()
3305 printk("%s: ", ahd_name(ahd)); in ahd_handle_nonpkt_busfree()
3311 ahd_inw(ahd, PRGMCNT)); in ahd_handle_nonpkt_busfree()
3312 ahd_dump_card_state(ahd); in ahd_handle_nonpkt_busfree()
3314 ahd_force_renegotiation(ahd, &devinfo); in ahd_handle_nonpkt_busfree()
3321 ahd_handle_proto_violation(struct ahd_softc *ahd) in ahd_handle_proto_violation() argument
3331 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_proto_violation()
3332 scbid = ahd_get_scbptr(ahd); in ahd_handle_proto_violation()
3333 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_proto_violation()
3334 seq_flags = ahd_inb(ahd, SEQ_FLAGS); in ahd_handle_proto_violation()
3335 curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK; in ahd_handle_proto_violation()
3336 lastphase = ahd_inb(ahd, LASTPHASE); in ahd_handle_proto_violation()
3344 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_proto_violation()
3353 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_proto_violation()
3359 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3361 } else if ((ahd_inb_scbram(ahd, SCB_CONTROL) in ahd_handle_proto_violation()
3370 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3373 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3375 ahd_dump_card_state(ahd); in ahd_handle_proto_violation()
3387 found = ahd_reset_channel(ahd, 'A', TRUE); in ahd_handle_proto_violation()
3389 "%d SCBs aborted\n", ahd_name(ahd), 'A', found); in ahd_handle_proto_violation()
3396 ahd_outb(ahd, SCSISEQ0, in ahd_handle_proto_violation()
3397 ahd_inb(ahd, SCSISEQ0) & ~ENSELO); in ahd_handle_proto_violation()
3398 ahd_assert_atn(ahd); in ahd_handle_proto_violation()
3399 ahd_outb(ahd, MSG_OUT, HOST_MSG); in ahd_handle_proto_violation()
3401 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_proto_violation()
3402 ahd->msgout_buf[0] = MSG_ABORT_TASK; in ahd_handle_proto_violation()
3403 ahd->msgout_len = 1; in ahd_handle_proto_violation()
3404 ahd->msgout_index = 0; in ahd_handle_proto_violation()
3405 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_handle_proto_violation()
3407 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3420 ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_force_renegotiation() argument
3427 ahd_print_devinfo(ahd, devinfo); in ahd_force_renegotiation()
3431 targ_info = ahd_fetch_transinfo(ahd, in ahd_force_renegotiation()
3436 ahd_update_neg_request(ahd, devinfo, tstate, in ahd_force_renegotiation()
3442 ahd_clear_critical_section(struct ahd_softc *ahd) in ahd_clear_critical_section() argument
3456 if (ahd->num_critical_sections == 0) in ahd_clear_critical_section()
3469 saved_modes = ahd_save_modes(ahd); in ahd_clear_critical_section()
3475 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_clear_critical_section()
3476 seqaddr = ahd_inw(ahd, CURADDR); in ahd_clear_critical_section()
3478 cs = ahd->critical_sections; in ahd_clear_critical_section()
3479 for (i = 0; i < ahd->num_critical_sections; i++, cs++) { in ahd_clear_critical_section()
3485 if (i == ahd->num_critical_sections) in ahd_clear_critical_section()
3491 ahd_name(ahd), ahd_name(ahd), first_instr, in ahd_clear_critical_section()
3493 ahd_dump_card_state(ahd); in ahd_clear_critical_section()
3500 printk("%s: Single stepping at 0x%x\n", ahd_name(ahd), in ahd_clear_critical_section()
3506 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_clear_critical_section()
3507 simode0 = ahd_inb(ahd, SIMODE0); in ahd_clear_critical_section()
3508 simode3 = ahd_inb(ahd, SIMODE3); in ahd_clear_critical_section()
3509 lqimode0 = ahd_inb(ahd, LQIMODE0); in ahd_clear_critical_section()
3510 lqimode1 = ahd_inb(ahd, LQIMODE1); in ahd_clear_critical_section()
3511 lqomode0 = ahd_inb(ahd, LQOMODE0); in ahd_clear_critical_section()
3512 lqomode1 = ahd_inb(ahd, LQOMODE1); in ahd_clear_critical_section()
3513 ahd_outb(ahd, SIMODE0, 0); in ahd_clear_critical_section()
3514 ahd_outb(ahd, SIMODE3, 0); in ahd_clear_critical_section()
3515 ahd_outb(ahd, LQIMODE0, 0); in ahd_clear_critical_section()
3516 ahd_outb(ahd, LQIMODE1, 0); in ahd_clear_critical_section()
3517 ahd_outb(ahd, LQOMODE0, 0); in ahd_clear_critical_section()
3518 ahd_outb(ahd, LQOMODE1, 0); in ahd_clear_critical_section()
3519 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_clear_critical_section()
3520 simode1 = ahd_inb(ahd, SIMODE1); in ahd_clear_critical_section()
3527 ahd_outb(ahd, SIMODE1, simode1 & ENBUSFREE); in ahd_clear_critical_section()
3528 ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) | STEP); in ahd_clear_critical_section()
3531 ahd_outb(ahd, CLRSINT1, CLRBUSFREE); in ahd_clear_critical_section()
3532 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_clear_critical_section()
3533 ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode); in ahd_clear_critical_section()
3534 ahd_outb(ahd, HCNTRL, ahd->unpause); in ahd_clear_critical_section()
3535 while (!ahd_is_paused(ahd)) in ahd_clear_critical_section()
3537 ahd_update_modes(ahd); in ahd_clear_critical_section()
3540 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_clear_critical_section()
3541 ahd_outb(ahd, SIMODE0, simode0); in ahd_clear_critical_section()
3542 ahd_outb(ahd, SIMODE3, simode3); in ahd_clear_critical_section()
3543 ahd_outb(ahd, LQIMODE0, lqimode0); in ahd_clear_critical_section()
3544 ahd_outb(ahd, LQIMODE1, lqimode1); in ahd_clear_critical_section()
3545 ahd_outb(ahd, LQOMODE0, lqomode0); in ahd_clear_critical_section()
3546 ahd_outb(ahd, LQOMODE1, lqomode1); in ahd_clear_critical_section()
3547 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_clear_critical_section()
3548 ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) & ~STEP); in ahd_clear_critical_section()
3549 ahd_outb(ahd, SIMODE1, simode1); in ahd_clear_critical_section()
3556 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_clear_critical_section()
3558 ahd_restore_modes(ahd, saved_modes); in ahd_clear_critical_section()
3565 ahd_clear_intstat(struct ahd_softc *ahd) in ahd_clear_intstat() argument
3567 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_clear_intstat()
3570 ahd_outb(ahd, CLRLQIINT0, CLRLQIATNQAS|CLRLQICRCT1|CLRLQICRCT2 in ahd_clear_intstat()
3572 ahd_outb(ahd, CLRLQIINT1, CLRLQIPHASE_LQ|CLRLQIPHASE_NLQ|CLRLIQABORT in ahd_clear_intstat()
3575 ahd_outb(ahd, CLRLQOINT0, CLRLQOTARGSCBPERR|CLRLQOSTOPT2|CLRLQOATNLQ in ahd_clear_intstat()
3577 ahd_outb(ahd, CLRLQOINT1, CLRLQOINITSCBPERR|CLRLQOSTOPI2|CLRLQOBADQAS in ahd_clear_intstat()
3579 if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) { in ahd_clear_intstat()
3580 ahd_outb(ahd, CLRLQOINT0, 0); in ahd_clear_intstat()
3581 ahd_outb(ahd, CLRLQOINT1, 0); in ahd_clear_intstat()
3583 ahd_outb(ahd, CLRSINT3, CLRNTRAMPERR|CLROSRAMPERR); in ahd_clear_intstat()
3584 ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRATNO|CLRSCSIRSTI in ahd_clear_intstat()
3586 ahd_outb(ahd, CLRSINT0, CLRSELDO|CLRSELDI|CLRSELINGO in ahd_clear_intstat()
3588 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_clear_intstat()
3629 ahd_alloc_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel) in ahd_alloc_tstate() argument
3635 master_tstate = ahd->enabled_targets[ahd->our_id]; in ahd_alloc_tstate()
3636 if (ahd->enabled_targets[scsi_id] != NULL in ahd_alloc_tstate()
3637 && ahd->enabled_targets[scsi_id] != master_tstate) in ahd_alloc_tstate()
3639 ahd_name(ahd)); in ahd_alloc_tstate()
3661 ahd->enabled_targets[scsi_id] = tstate; in ahd_alloc_tstate()
3671 ahd_free_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel, int force) in ahd_free_tstate() argument
3679 if (scsi_id == ahd->our_id in ahd_free_tstate()
3683 tstate = ahd->enabled_targets[scsi_id]; in ahd_free_tstate()
3686 ahd->enabled_targets[scsi_id] = NULL; in ahd_free_tstate()
3697 ahd_devlimited_syncrate(struct ahd_softc *ahd, in ahd_devlimited_syncrate() argument
3704 if ((ahd_inb(ahd, SBLKCTL) & ENAB40) != 0 in ahd_devlimited_syncrate()
3705 && (ahd_inb(ahd, SSTAT2) & EXP_ACTIVE) == 0) { in ahd_devlimited_syncrate()
3736 ahd_find_syncrate(ahd, period, ppr_options, maxsync); in ahd_devlimited_syncrate()
3746 ahd_find_syncrate(struct ahd_softc *ahd, u_int *period, in ahd_find_syncrate() argument
3785 ahd_validate_offset(struct ahd_softc *ahd, in ahd_validate_offset() argument
3796 if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) in ahd_validate_offset()
3816 ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, in ahd_validate_width() argument
3821 if (ahd->features & AHD_WIDE) { in ahd_validate_width()
3846 ahd_update_neg_request(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_update_neg_request() argument
3860 if ((ahd->features & AHD_WIDE) != 0) in ahd_update_neg_request()
3889 ahd_set_syncrate(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_set_syncrate() argument
3909 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid, in ahd_set_syncrate()
3939 ahd_send_async(ahd, devinfo->channel, devinfo->target, in ahd_set_syncrate()
3947 ahd_name(ahd), devinfo->target, in ahd_set_syncrate()
3977 ahd_name(ahd), devinfo->target, in ahd_set_syncrate()
3993 ahd_pause(ahd); in ahd_set_syncrate()
3994 ahd_update_neg_table(ahd, devinfo, &tinfo->curr); in ahd_set_syncrate()
3996 ahd_unpause(ahd); in ahd_set_syncrate()
3997 if (ahd->msg_type != MSG_TYPE_NONE) { in ahd_set_syncrate()
4002 ahd_print_devinfo(ahd, devinfo); in ahd_set_syncrate()
4006 ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE in ahd_set_syncrate()
4014 ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE; in ahd_set_syncrate()
4019 update_needed += ahd_update_neg_request(ahd, devinfo, tstate, in ahd_set_syncrate()
4023 ahd_update_pending_scbs(ahd); in ahd_set_syncrate()
4035 ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_set_width() argument
4046 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid, in ahd_set_width()
4061 ahd_send_async(ahd, devinfo->channel, devinfo->target, in ahd_set_width()
4065 ahd_name(ahd), devinfo->target, in ahd_set_width()
4072 ahd_pause(ahd); in ahd_set_width()
4073 ahd_update_neg_table(ahd, devinfo, &tinfo->curr); in ahd_set_width()
4075 ahd_unpause(ahd); in ahd_set_width()
4078 update_needed += ahd_update_neg_request(ahd, devinfo, tstate, in ahd_set_width()
4081 ahd_update_pending_scbs(ahd); in ahd_set_width()
4089 ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd, in ahd_set_tags() argument
4094 ahd_platform_set_tags(ahd, sdev, devinfo, alg); in ahd_set_tags()
4095 ahd_send_async(ahd, devinfo->channel, devinfo->target, in ahd_set_tags()
4100 ahd_update_neg_table(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_update_neg_table() argument
4109 uint8_t iocell_opts[sizeof(ahd->iocell_opts)]; in ahd_update_neg_table()
4111 saved_modes = ahd_save_modes(ahd); in ahd_update_neg_table()
4112 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_update_neg_table()
4114 saved_negoaddr = ahd_inb(ahd, NEGOADDR); in ahd_update_neg_table()
4115 ahd_outb(ahd, NEGOADDR, devinfo->target); in ahd_update_neg_table()
4118 memcpy(iocell_opts, ahd->iocell_opts, sizeof(ahd->iocell_opts)); in ahd_update_neg_table()
4126 if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) { in ahd_update_neg_table()
4158 if ((ahd->features & AHD_NEW_IOCELL_OPTS) != 0 in ahd_update_neg_table()
4170 if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) { in ahd_update_neg_table()
4180 ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PRECOMP_SLEW); in ahd_update_neg_table()
4181 ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_PRECOMP_SLEW_INDEX]); in ahd_update_neg_table()
4182 ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_AMPLITUDE); in ahd_update_neg_table()
4183 ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_AMPLITUDE_INDEX]); in ahd_update_neg_table()
4185 ahd_outb(ahd, NEGPERIOD, period); in ahd_update_neg_table()
4186 ahd_outb(ahd, NEGPPROPTS, ppr_opts); in ahd_update_neg_table()
4187 ahd_outb(ahd, NEGOFFSET, offset); in ahd_update_neg_table()
4197 if (ahd->features & AHD_AIC79XXB_SLOWCRC) { in ahd_update_neg_table()
4208 ahd_outb(ahd, NEGCONOPTS, con_opts); in ahd_update_neg_table()
4209 ahd_outb(ahd, NEGOADDR, saved_negoaddr); in ahd_update_neg_table()
4210 ahd_restore_modes(ahd, saved_modes); in ahd_update_neg_table()
4220 ahd_update_pending_scbs(struct ahd_softc *ahd) in ahd_update_pending_scbs() argument
4239 LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) { in ahd_update_pending_scbs()
4244 ahd_scb_devinfo(ahd, &devinfo, pending_scb); in ahd_update_pending_scbs()
4245 tinfo = ahd_fetch_transinfo(ahd, devinfo.channel, in ahd_update_pending_scbs()
4253 ahd_sync_scb(ahd, pending_scb, in ahd_update_pending_scbs()
4261 if (ahd_is_paused(ahd)) { in ahd_update_pending_scbs()
4265 ahd_pause(ahd); in ahd_update_pending_scbs()
4276 saved_modes = ahd_save_modes(ahd); in ahd_update_pending_scbs()
4277 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_update_pending_scbs()
4278 if ((ahd_inb(ahd, SCSISIGI) & BSYI) != 0 in ahd_update_pending_scbs()
4279 && (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) == 0) in ahd_update_pending_scbs()
4280 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO); in ahd_update_pending_scbs()
4281 saved_scbptr = ahd_get_scbptr(ahd); in ahd_update_pending_scbs()
4283 LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) { in ahd_update_pending_scbs()
4288 ahd_set_scbptr(ahd, scb_tag); in ahd_update_pending_scbs()
4289 control = ahd_inb_scbram(ahd, SCB_CONTROL); in ahd_update_pending_scbs()
4292 ahd_outb(ahd, SCB_CONTROL, control); in ahd_update_pending_scbs()
4294 ahd_set_scbptr(ahd, saved_scbptr); in ahd_update_pending_scbs()
4295 ahd_restore_modes(ahd, saved_modes); in ahd_update_pending_scbs()
4298 ahd_unpause(ahd); in ahd_update_pending_scbs()
4303 ahd_fetch_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_fetch_devinfo() argument
4310 saved_modes = ahd_save_modes(ahd); in ahd_fetch_devinfo()
4311 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_fetch_devinfo()
4313 if (ahd_inb(ahd, SSTAT0) & TARGET) in ahd_fetch_devinfo()
4319 && (ahd_inb(ahd, SEQ_FLAGS) & CMDPHASE_PENDING) != 0) { in ahd_fetch_devinfo()
4321 our_id = ahd_inb(ahd, TARGIDIN) & OID; in ahd_fetch_devinfo()
4323 our_id = ahd_inb(ahd, TOWNID); in ahd_fetch_devinfo()
4325 our_id = ahd_inb(ahd, IOWNID); in ahd_fetch_devinfo()
4327 saved_scsiid = ahd_inb(ahd, SAVED_SCSIID); in ahd_fetch_devinfo()
4330 SCSIID_TARGET(ahd, saved_scsiid), in ahd_fetch_devinfo()
4331 ahd_inb(ahd, SAVED_LUN), in ahd_fetch_devinfo()
4332 SCSIID_CHANNEL(ahd, saved_scsiid), in ahd_fetch_devinfo()
4334 ahd_restore_modes(ahd, saved_modes); in ahd_fetch_devinfo()
4338 ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_print_devinfo() argument
4340 printk("%s:%c:%d:%d: ", ahd_name(ahd), 'A', in ahd_print_devinfo()
4378 ahd_scb_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_scb_devinfo() argument
4388 ahd_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahd, scb), in ahd_scb_devinfo()
4389 SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahd, scb), role); in ahd_scb_devinfo()
4401 ahd_setup_initiator_msgout(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_setup_initiator_msgout() argument
4409 ahd->msgout_index = 0; in ahd_setup_initiator_msgout()
4410 ahd->msgout_len = 0; in ahd_setup_initiator_msgout()
4412 if (ahd_currently_packetized(ahd)) in ahd_setup_initiator_msgout()
4413 ahd->msg_flags |= MSG_FLAG_PACKETIZED; in ahd_setup_initiator_msgout()
4415 if (ahd->send_msg_perror in ahd_setup_initiator_msgout()
4416 && ahd_inb(ahd, MSG_OUT) == HOST_MSG) { in ahd_setup_initiator_msgout()
4417 ahd->msgout_buf[ahd->msgout_index++] = ahd->send_msg_perror; in ahd_setup_initiator_msgout()
4418 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4419 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_setup_initiator_msgout()
4427 "I_T msgin. Issuing NO-OP\n", ahd_name(ahd)); in ahd_setup_initiator_msgout()
4428 ahd->msgout_buf[ahd->msgout_index++] = MSG_NOOP; in ahd_setup_initiator_msgout()
4429 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4430 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_setup_initiator_msgout()
4436 && ahd_inb(ahd, MSG_OUT) == MSG_IDENTIFYFLAG) { in ahd_setup_initiator_msgout()
4442 ahd->msgout_buf[ahd->msgout_index++] = identify_msg; in ahd_setup_initiator_msgout()
4443 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4446 ahd->msgout_buf[ahd->msgout_index++] = in ahd_setup_initiator_msgout()
4448 ahd->msgout_buf[ahd->msgout_index++] = SCB_GET_TAG(scb); in ahd_setup_initiator_msgout()
4449 ahd->msgout_len += 2; in ahd_setup_initiator_msgout()
4454 ahd->msgout_buf[ahd->msgout_index++] = MSG_BUS_DEV_RESET; in ahd_setup_initiator_msgout()
4455 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4456 ahd_print_path(ahd, scb); in ahd_setup_initiator_msgout()
4465 ahd_outb(ahd, SCSISEQ0, 0); in ahd_setup_initiator_msgout()
4469 ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT_TAG; in ahd_setup_initiator_msgout()
4471 ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT; in ahd_setup_initiator_msgout()
4473 ahd->msgout_len++; in ahd_setup_initiator_msgout()
4474 ahd_print_path(ahd, scb); in ahd_setup_initiator_msgout()
4484 ahd_outb(ahd, SCSISEQ0, 0); in ahd_setup_initiator_msgout()
4486 ahd_build_transfer_msg(ahd, devinfo); in ahd_setup_initiator_msgout()
4494 ahd_outb(ahd, SCSISEQ0, 0); in ahd_setup_initiator_msgout()
4502 ahd_inb_scbram(ahd, SCB_CONTROL), ahd_inb(ahd, MSG_OUT), in ahd_setup_initiator_msgout()
4510 ahd_outb(ahd, SCB_CONTROL, in ahd_setup_initiator_msgout()
4511 ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE); in ahd_setup_initiator_msgout()
4513 ahd->msgout_index = 0; in ahd_setup_initiator_msgout()
4514 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_setup_initiator_msgout()
4522 ahd_build_transfer_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_build_transfer_msg() argument
4538 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid, in ahd_build_transfer_msg()
4552 ahd_devlimited_syncrate(ahd, tinfo, &period, in ahd_build_transfer_msg()
4573 if ((ahd->features & AHD_WIDE) != 0) in ahd_build_transfer_msg()
4579 ahd_print_devinfo(ahd, devinfo); in ahd_build_transfer_msg()
4598 ahd_validate_offset(ahd, tinfo, period, &offset, in ahd_build_transfer_msg()
4603 ahd_construct_ppr(ahd, devinfo, period, offset, in ahd_build_transfer_msg()
4606 ahd_construct_sdtr(ahd, devinfo, period, offset); in ahd_build_transfer_msg()
4609 ahd_construct_wdtr(ahd, devinfo, tinfo->goal.width); in ahd_build_transfer_msg()
4618 ahd_construct_sdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_construct_sdtr() argument
4623 ahd->msgout_index += spi_populate_sync_msg( in ahd_construct_sdtr()
4624 ahd->msgout_buf + ahd->msgout_index, period, offset); in ahd_construct_sdtr()
4625 ahd->msgout_len += 5; in ahd_construct_sdtr()
4628 ahd_name(ahd), devinfo->channel, devinfo->target, in ahd_construct_sdtr()
4638 ahd_construct_wdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_construct_wdtr() argument
4641 ahd->msgout_index += spi_populate_width_msg( in ahd_construct_wdtr()
4642 ahd->msgout_buf + ahd->msgout_index, bus_width); in ahd_construct_wdtr()
4643 ahd->msgout_len += 4; in ahd_construct_wdtr()
4646 ahd_name(ahd), devinfo->channel, devinfo->target, in ahd_construct_wdtr()
4656 ahd_construct_ppr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_construct_ppr() argument
4669 ahd->msgout_index += spi_populate_ppr_msg( in ahd_construct_ppr()
4670 ahd->msgout_buf + ahd->msgout_index, period, offset, in ahd_construct_ppr()
4672 ahd->msgout_len += 8; in ahd_construct_ppr()
4675 "offset %x, ppr_options %x\n", ahd_name(ahd), in ahd_construct_ppr()
4685 ahd_clear_msg_state(struct ahd_softc *ahd) in ahd_clear_msg_state() argument
4689 saved_modes = ahd_save_modes(ahd); in ahd_clear_msg_state()
4690 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_clear_msg_state()
4691 ahd->send_msg_perror = 0; in ahd_clear_msg_state()
4692 ahd->msg_flags = MSG_FLAG_NONE; in ahd_clear_msg_state()
4693 ahd->msgout_len = 0; in ahd_clear_msg_state()
4694 ahd->msgin_index = 0; in ahd_clear_msg_state()
4695 ahd->msg_type = MSG_TYPE_NONE; in ahd_clear_msg_state()
4696 if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0) { in ahd_clear_msg_state()
4701 ahd_outb(ahd, CLRSINT1, CLRATNO); in ahd_clear_msg_state()
4703 ahd_outb(ahd, MSG_OUT, MSG_NOOP); in ahd_clear_msg_state()
4704 ahd_outb(ahd, SEQ_FLAGS2, in ahd_clear_msg_state()
4705 ahd_inb(ahd, SEQ_FLAGS2) & ~TARGET_MSG_PENDING); in ahd_clear_msg_state()
4706 ahd_restore_modes(ahd, saved_modes); in ahd_clear_msg_state()
4713 ahd_handle_message_phase(struct ahd_softc *ahd) in ahd_handle_message_phase() argument
4719 ahd_fetch_devinfo(ahd, &devinfo); in ahd_handle_message_phase()
4721 bus_phase = ahd_inb(ahd, LASTPHASE); in ahd_handle_message_phase()
4723 if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0) { in ahd_handle_message_phase()
4725 ahd_outb(ahd, LQCTL2, LQIRETRY); in ahd_handle_message_phase()
4728 switch (ahd->msg_type) { in ahd_handle_message_phase()
4735 if (ahd->msgout_len == 0 && ahd->send_msg_perror == 0) in ahd_handle_message_phase()
4740 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_message_phase()
4760 ahd_outb(ahd, CLRSINT1, CLRATNO); in ahd_handle_message_phase()
4761 ahd->send_msg_perror = 0; in ahd_handle_message_phase()
4762 ahd->msg_type = MSG_TYPE_INITIATOR_MSGIN; in ahd_handle_message_phase()
4763 ahd->msgin_index = 0; in ahd_handle_message_phase()
4770 if (ahd->send_msg_perror) { in ahd_handle_message_phase()
4771 ahd_outb(ahd, CLRSINT1, CLRATNO); in ahd_handle_message_phase()
4772 ahd_outb(ahd, CLRSINT1, CLRREQINIT); in ahd_handle_message_phase()
4775 printk(" byte 0x%x\n", ahd->send_msg_perror); in ahd_handle_message_phase()
4783 if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0 in ahd_handle_message_phase()
4784 && ahd->send_msg_perror == MSG_INITIATOR_DET_ERR) in ahd_handle_message_phase()
4785 ahd->msg_flags |= MSG_FLAG_EXPECT_IDE_BUSFREE; in ahd_handle_message_phase()
4787 ahd_outb(ahd, RETURN_2, ahd->send_msg_perror); in ahd_handle_message_phase()
4788 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE); in ahd_handle_message_phase()
4792 msgdone = ahd->msgout_index == ahd->msgout_len; in ahd_handle_message_phase()
4799 ahd->msgout_index = 0; in ahd_handle_message_phase()
4800 ahd_assert_atn(ahd); in ahd_handle_message_phase()
4803 lastbyte = ahd->msgout_index == (ahd->msgout_len - 1); in ahd_handle_message_phase()
4806 ahd_outb(ahd, CLRSINT1, CLRATNO); in ahd_handle_message_phase()
4813 ahd_outb(ahd, CLRSINT1, CLRREQINIT); in ahd_handle_message_phase()
4817 ahd->msgout_buf[ahd->msgout_index]); in ahd_handle_message_phase()
4819 ahd_outb(ahd, RETURN_2, ahd->msgout_buf[ahd->msgout_index++]); in ahd_handle_message_phase()
4820 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE); in ahd_handle_message_phase()
4830 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_message_phase()
4843 ahd->msgin_index = 0; in ahd_handle_message_phase()
4845 && (ahd->send_msg_perror != 0 in ahd_handle_message_phase()
4846 || (ahd->msgout_len != 0 in ahd_handle_message_phase()
4847 && ahd->msgout_index == 0))) { in ahd_handle_message_phase()
4848 ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahd_handle_message_phase()
4856 ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIBUS); in ahd_handle_message_phase()
4860 ahd->msgin_buf[ahd->msgin_index]); in ahd_handle_message_phase()
4863 message_done = ahd_parse_msg(ahd, &devinfo); in ahd_handle_message_phase()
4870 ahd->msgin_index = 0; in ahd_handle_message_phase()
4877 if (ahd->msgout_len != 0) { in ahd_handle_message_phase()
4880 ahd_print_devinfo(ahd, &devinfo); in ahd_handle_message_phase()
4884 ahd_assert_atn(ahd); in ahd_handle_message_phase()
4887 ahd->msgin_index++; in ahd_handle_message_phase()
4893 ahd_outb(ahd, CLRSINT1, CLRREQINIT); in ahd_handle_message_phase()
4894 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_READ); in ahd_handle_message_phase()
4906 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG); in ahd_handle_message_phase()
4908 if (ahd->msgout_len == 0) in ahd_handle_message_phase()
4917 if ((ahd_inb(ahd, SCSISIGI) & ATNI) != 0 in ahd_handle_message_phase()
4918 && ahd->msgout_index > 0) in ahd_handle_message_phase()
4931 ahd->msg_type = MSG_TYPE_TARGET_MSGOUT; in ahd_handle_message_phase()
4932 ahd_outb(ahd, SCSISIGO, P_MESGOUT | BSYO); in ahd_handle_message_phase()
4933 ahd->msgin_index = 0; in ahd_handle_message_phase()
4935 ahd_inb(ahd, SCSIDAT); in ahd_handle_message_phase()
4936 ahd_outb(ahd, SXFRCTL0, in ahd_handle_message_phase()
4937 ahd_inb(ahd, SXFRCTL0) | SPIOEN); in ahd_handle_message_phase()
4941 msgdone = ahd->msgout_index == ahd->msgout_len; in ahd_handle_message_phase()
4943 ahd_outb(ahd, SXFRCTL0, in ahd_handle_message_phase()
4944 ahd_inb(ahd, SXFRCTL0) & ~SPIOEN); in ahd_handle_message_phase()
4952 ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) | SPIOEN); in ahd_handle_message_phase()
4953 ahd_outb(ahd, SCSIDAT, ahd->msgout_buf[ahd->msgout_index++]); in ahd_handle_message_phase()
4964 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG); in ahd_handle_message_phase()
4970 lastbyte = (ahd_inb(ahd, SCSISIGI) & ATNI) == 0; in ahd_handle_message_phase()
4977 ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) & ~SPIOEN); in ahd_handle_message_phase()
4978 ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIDAT); in ahd_handle_message_phase()
4979 msgdone = ahd_parse_msg(ahd, &devinfo); in ahd_handle_message_phase()
4990 ahd->msgin_index++; in ahd_handle_message_phase()
4997 ahd->msgin_index = 0; in ahd_handle_message_phase()
5003 if (ahd->msgout_len != 0) { in ahd_handle_message_phase()
5004 ahd_outb(ahd, SCSISIGO, P_MESGIN | BSYO); in ahd_handle_message_phase()
5005 ahd_outb(ahd, SXFRCTL0, in ahd_handle_message_phase()
5006 ahd_inb(ahd, SXFRCTL0) | SPIOEN); in ahd_handle_message_phase()
5007 ahd->msg_type = MSG_TYPE_TARGET_MSGIN; in ahd_handle_message_phase()
5008 ahd->msgin_index = 0; in ahd_handle_message_phase()
5017 ahd_outb(ahd, SXFRCTL0, in ahd_handle_message_phase()
5018 ahd_inb(ahd, SXFRCTL0) | SPIOEN); in ahd_handle_message_phase()
5028 if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0) { in ahd_handle_message_phase()
5030 ahd_name(ahd)); in ahd_handle_message_phase()
5031 ahd_clear_msg_state(ahd); in ahd_handle_message_phase()
5036 ahd_outb(ahd, LASTPHASE, P_BUSFREE); in ahd_handle_message_phase()
5037 ahd_outb(ahd, SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT); in ahd_handle_message_phase()
5038 ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET); in ahd_handle_message_phase()
5040 ahd_clear_msg_state(ahd); in ahd_handle_message_phase()
5041 ahd_outb(ahd, RETURN_1, EXIT_MSG_LOOP); in ahd_handle_message_phase()
5053 ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type, u_int msgval, int full) in ahd_sent_msg() argument
5061 while (index < ahd->msgout_len) { in ahd_sent_msg()
5062 if (ahd->msgout_buf[index] == MSG_EXTENDED) { in ahd_sent_msg()
5065 end_index = index + 1 + ahd->msgout_buf[index + 1]; in ahd_sent_msg()
5066 if (ahd->msgout_buf[index+2] == msgval in ahd_sent_msg()
5070 if (ahd->msgout_index > end_index) in ahd_sent_msg()
5072 } else if (ahd->msgout_index > index) in ahd_sent_msg()
5076 } else if (ahd->msgout_buf[index] >= MSG_SIMPLE_TASK in ahd_sent_msg()
5077 && ahd->msgout_buf[index] <= MSG_IGN_WIDE_RESIDUE) { in ahd_sent_msg()
5084 && ahd->msgout_index > index in ahd_sent_msg()
5085 && (ahd->msgout_buf[index] == msgval in ahd_sent_msg()
5086 || ((ahd->msgout_buf[index] & MSG_IDENTIFYFLAG) != 0 in ahd_sent_msg()
5102 ahd_parse_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_parse_msg() argument
5113 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid, in ahd_parse_msg()
5127 switch (ahd->msgin_buf[0]) { in ahd_parse_msg()
5140 response = ahd_handle_msg_reject(ahd, devinfo); in ahd_parse_msg()
5148 if (ahd->msgin_index < 2) in ahd_parse_msg()
5150 switch (ahd->msgin_buf[2]) { in ahd_parse_msg()
5158 if (ahd->msgin_buf[1] != MSG_EXT_SDTR_LEN) { in ahd_parse_msg()
5170 if (ahd->msgin_index < (MSG_EXT_SDTR_LEN + 1)) in ahd_parse_msg()
5173 period = ahd->msgin_buf[3]; in ahd_parse_msg()
5175 saved_offset = offset = ahd->msgin_buf[4]; in ahd_parse_msg()
5176 ahd_devlimited_syncrate(ahd, tinfo, &period, in ahd_parse_msg()
5178 ahd_validate_offset(ahd, tinfo, period, &offset, in ahd_parse_msg()
5184 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5186 ahd->msgin_buf[3], saved_offset, in ahd_parse_msg()
5189 ahd_set_syncrate(ahd, devinfo, period, in ahd_parse_msg()
5199 if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, TRUE)) { in ahd_parse_msg()
5213 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5216 ahd->msgout_index = 0; in ahd_parse_msg()
5217 ahd->msgout_len = 0; in ahd_parse_msg()
5218 ahd_construct_sdtr(ahd, devinfo, in ahd_parse_msg()
5220 ahd->msgout_index = 0; in ahd_parse_msg()
5233 if (ahd->msgin_buf[1] != MSG_EXT_WDTR_LEN) { in ahd_parse_msg()
5245 if (ahd->msgin_index < (MSG_EXT_WDTR_LEN + 1)) in ahd_parse_msg()
5248 bus_width = ahd->msgin_buf[3]; in ahd_parse_msg()
5250 ahd_validate_width(ahd, tinfo, &bus_width, in ahd_parse_msg()
5255 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5260 if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, TRUE)) { in ahd_parse_msg()
5271 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5284 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5287 ahd->msgout_index = 0; in ahd_parse_msg()
5288 ahd->msgout_len = 0; in ahd_parse_msg()
5289 ahd_construct_wdtr(ahd, devinfo, bus_width); in ahd_parse_msg()
5290 ahd->msgout_index = 0; in ahd_parse_msg()
5303 ahd_update_neg_request(ahd, devinfo, tstate, in ahd_parse_msg()
5305 ahd_set_width(ahd, devinfo, bus_width, in ahd_parse_msg()
5313 ahd->msgout_index = 0; in ahd_parse_msg()
5314 ahd->msgout_len = 0; in ahd_parse_msg()
5315 ahd_build_transfer_msg(ahd, devinfo); in ahd_parse_msg()
5316 ahd->msgout_index = 0; in ahd_parse_msg()
5332 if (ahd->msgin_buf[1] != MSG_EXT_PPR_LEN) { in ahd_parse_msg()
5344 if (ahd->msgin_index < (MSG_EXT_PPR_LEN + 1)) in ahd_parse_msg()
5347 period = ahd->msgin_buf[3]; in ahd_parse_msg()
5348 offset = ahd->msgin_buf[5]; in ahd_parse_msg()
5349 bus_width = ahd->msgin_buf[6]; in ahd_parse_msg()
5351 ppr_options = ahd->msgin_buf[7]; in ahd_parse_msg()
5370 ahd_validate_width(ahd, tinfo, &bus_width, in ahd_parse_msg()
5372 ahd_devlimited_syncrate(ahd, tinfo, &period, in ahd_parse_msg()
5374 ahd_validate_offset(ahd, tinfo, period, &offset, in ahd_parse_msg()
5377 if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, TRUE)) { in ahd_parse_msg()
5396 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5401 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5403 ahd->msgout_index = 0; in ahd_parse_msg()
5404 ahd->msgout_len = 0; in ahd_parse_msg()
5405 ahd_construct_ppr(ahd, devinfo, period, offset, in ahd_parse_msg()
5407 ahd->msgout_index = 0; in ahd_parse_msg()
5415 ahd_name(ahd), devinfo->channel, in ahd_parse_msg()
5417 saved_width, ahd->msgin_buf[3], in ahd_parse_msg()
5421 ahd_set_width(ahd, devinfo, bus_width, in ahd_parse_msg()
5424 ahd_set_syncrate(ahd, devinfo, period, in ahd_parse_msg()
5441 ahd_handle_devreset(ahd, devinfo, CAM_LUN_WILDCARD, in ahd_parse_msg()
5445 ahd_restart(ahd); in ahd_parse_msg()
5460 if (ahd->msgin_buf[0] == MSG_ABORT_TAG) in ahd_parse_msg()
5461 tag = ahd_inb(ahd, INITIATOR_TAG); in ahd_parse_msg()
5462 ahd_abort_scbs(ahd, devinfo->target, devinfo->channel, in ahd_parse_msg()
5466 tstate = ahd->enabled_targets[devinfo->our_scsiid]; in ahd_parse_msg()
5472 ahd_queue_lstate_event(ahd, lstate, in ahd_parse_msg()
5474 ahd->msgin_buf[0], in ahd_parse_msg()
5476 ahd_send_lstate_events(ahd, lstate); in ahd_parse_msg()
5479 ahd_restart(ahd); in ahd_parse_msg()
5488 ahd_name(ahd), ahd_inb(ahd, SCSISIGI)); in ahd_parse_msg()
5490 ahd->msg_flags |= MSG_FLAG_EXPECT_QASREJ_BUSFREE; in ahd_parse_msg()
5502 ahd->msgout_index = 0; in ahd_parse_msg()
5503 ahd->msgout_len = 1; in ahd_parse_msg()
5504 ahd->msgout_buf[0] = MSG_MESSAGE_REJECT; in ahd_parse_msg()
5511 ahd->msgout_len = 0; in ahd_parse_msg()
5520 ahd_handle_msg_reject(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_handle_msg_reject() argument
5535 scb_index = ahd_get_scbptr(ahd); in ahd_handle_msg_reject()
5536 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_msg_reject()
5537 tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, in ahd_handle_msg_reject()
5541 last_msg = ahd_inb(ahd, LAST_MSG); in ahd_handle_msg_reject()
5543 if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/FALSE)) { in ahd_handle_msg_reject()
5544 if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/TRUE) in ahd_handle_msg_reject()
5554 ahd_name(ahd), devinfo->channel, in ahd_handle_msg_reject()
5569 ahd_name(ahd), devinfo->channel, in ahd_handle_msg_reject()
5576 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5577 ahd->msgout_len = 0; in ahd_handle_msg_reject()
5578 ahd_build_transfer_msg(ahd, devinfo); in ahd_handle_msg_reject()
5579 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5581 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, /*full*/FALSE)) { in ahd_handle_msg_reject()
5585 "8bit transfers\n", ahd_name(ahd), in ahd_handle_msg_reject()
5587 ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_handle_msg_reject()
5600 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5601 ahd->msgout_len = 0; in ahd_handle_msg_reject()
5602 ahd_build_transfer_msg(ahd, devinfo); in ahd_handle_msg_reject()
5603 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5606 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, /*full*/FALSE)) { in ahd_handle_msg_reject()
5608 ahd_set_syncrate(ahd, devinfo, /*period*/0, in ahd_handle_msg_reject()
5614 ahd_name(ahd), devinfo->channel, in ahd_handle_msg_reject()
5624 "Performing non-tagged I/O\n", ahd_name(ahd), in ahd_handle_msg_reject()
5626 ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_NONE); in ahd_handle_msg_reject()
5631 ahd_name(ahd), devinfo->channel, devinfo->target, in ahd_handle_msg_reject()
5634 ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_BASIC); in ahd_handle_msg_reject()
5642 ahd_outb(ahd, SCB_CONTROL, in ahd_handle_msg_reject()
5643 ahd_inb_scbram(ahd, SCB_CONTROL) & mask); in ahd_handle_msg_reject()
5647 ahd_outb(ahd, MSG_OUT, MSG_IDENTIFYFLAG); in ahd_handle_msg_reject()
5648 ahd_assert_atn(ahd); in ahd_handle_msg_reject()
5649 ahd_busy_tcl(ahd, BUILD_TCL(scb->hscb->scsiid, devinfo->lun), in ahd_handle_msg_reject()
5657 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_msg_reject()
5658 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_msg_reject()
5662 } else if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_IDENTIFYFLAG, TRUE)) { in ahd_handle_msg_reject()
5667 ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE in ahd_handle_msg_reject()
5670 ahd_force_renegotiation(ahd, devinfo); in ahd_handle_msg_reject()
5671 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5672 ahd->msgout_len = 0; in ahd_handle_msg_reject()
5673 ahd_build_transfer_msg(ahd, devinfo); in ahd_handle_msg_reject()
5674 ahd->msgout_index = 0; in ahd_handle_msg_reject()
5681 ahd_name(ahd), devinfo->channel, devinfo->target, in ahd_handle_msg_reject()
5691 ahd_handle_ign_wide_residue(struct ahd_softc *ahd, struct ahd_devinfo *devinfo) in ahd_handle_ign_wide_residue() argument
5696 scb_index = ahd_get_scbptr(ahd); in ahd_handle_ign_wide_residue()
5697 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_ign_wide_residue()
5702 if ((ahd_inb(ahd, SEQ_FLAGS) & DPHASE) == 0 in ahd_handle_ign_wide_residue()
5718 sgptr = ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_handle_ign_wide_residue()
5720 && (ahd_inb_scbram(ahd, SCB_TASK_ATTRIBUTE) in ahd_handle_ign_wide_residue()
5734 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_handle_ign_wide_residue()
5735 data_cnt = ahd_inl_scbram(ahd, SCB_RESIDUAL_DATACNT); in ahd_handle_ign_wide_residue()
5744 data_addr = ahd_inq(ahd, SHADDR); in ahd_handle_ign_wide_residue()
5748 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_handle_ign_wide_residue()
5751 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_handle_ign_wide_residue()
5778 sgptr = ahd_sg_virt_to_bus(ahd, scb, in ahd_handle_ign_wide_residue()
5784 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_handle_ign_wide_residue()
5811 sgptr = ahd_sg_virt_to_bus(ahd, scb, in ahd_handle_ign_wide_residue()
5821 ahd_outb(ahd, SCB_TASK_ATTRIBUTE, in ahd_handle_ign_wide_residue()
5822 ahd_inb_scbram(ahd, SCB_TASK_ATTRIBUTE) in ahd_handle_ign_wide_residue()
5825 ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr); in ahd_handle_ign_wide_residue()
5826 ahd_outl(ahd, SCB_RESIDUAL_DATACNT, data_cnt); in ahd_handle_ign_wide_residue()
5841 ahd_reinitialize_dataptrs(struct ahd_softc *ahd) in ahd_reinitialize_dataptrs() argument
5851 AHD_ASSERT_MODES(ahd, AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK, in ahd_reinitialize_dataptrs()
5854 scb_index = ahd_get_scbptr(ahd); in ahd_reinitialize_dataptrs()
5855 scb = ahd_lookup_scb(ahd, scb_index); in ahd_reinitialize_dataptrs()
5861 ahd_outb(ahd, DFFSXFRCTL, CLRCHN); in ahd_reinitialize_dataptrs()
5863 while (--wait && !(ahd_inb(ahd, MDFFSTAT) & FIFOFREE)) in ahd_reinitialize_dataptrs()
5866 ahd_print_path(ahd, scb); in ahd_reinitialize_dataptrs()
5868 ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT); in ahd_reinitialize_dataptrs()
5870 saved_modes = ahd_save_modes(ahd); in ahd_reinitialize_dataptrs()
5871 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reinitialize_dataptrs()
5872 ahd_outb(ahd, DFFSTAT, in ahd_reinitialize_dataptrs()
5873 ahd_inb(ahd, DFFSTAT) in ahd_reinitialize_dataptrs()
5880 sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR); in ahd_reinitialize_dataptrs()
5883 resid = (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 2) << 16) in ahd_reinitialize_dataptrs()
5884 | (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 1) << 8) in ahd_reinitialize_dataptrs()
5885 | ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT); in ahd_reinitialize_dataptrs()
5887 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_reinitialize_dataptrs()
5890 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_reinitialize_dataptrs()
5898 ahd_outl(ahd, HADDR + 4, dataptr >> 32); in ahd_reinitialize_dataptrs()
5902 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_reinitialize_dataptrs()
5910 ahd_outb(ahd, HADDR + 4, in ahd_reinitialize_dataptrs()
5913 ahd_outl(ahd, HADDR, dataptr); in ahd_reinitialize_dataptrs()
5914 ahd_outb(ahd, HCNT + 2, resid >> 16); in ahd_reinitialize_dataptrs()
5915 ahd_outb(ahd, HCNT + 1, resid >> 8); in ahd_reinitialize_dataptrs()
5916 ahd_outb(ahd, HCNT, resid); in ahd_reinitialize_dataptrs()
5923 ahd_handle_devreset(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_handle_devreset() argument
5932 found = ahd_abort_scbs(ahd, devinfo->target, devinfo->channel, in ahd_handle_devreset()
5941 tstate = ahd->enabled_targets[devinfo->our_scsiid]; in ahd_handle_devreset()
5960 ahd_queue_lstate_event(ahd, lstate, devinfo->our_scsiid, in ahd_handle_devreset()
5962 ahd_send_lstate_events(ahd, lstate); in ahd_handle_devreset()
5970 ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_handle_devreset()
5972 ahd_set_syncrate(ahd, devinfo, /*period*/0, /*offset*/0, in ahd_handle_devreset()
5977 ahd_send_async(ahd, devinfo->channel, devinfo->target, in ahd_handle_devreset()
5981 printk("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd), in ahd_handle_devreset()
5987 ahd_setup_target_msgin(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, in ahd_setup_target_msgin() argument
5996 ahd->msgout_index = 0; in ahd_setup_target_msgin()
5997 ahd->msgout_len = 0; in ahd_setup_target_msgin()
6000 ahd_build_transfer_msg(ahd, devinfo); in ahd_setup_target_msgin()
6004 ahd->msgout_index = 0; in ahd_setup_target_msgin()
6005 ahd->msg_type = MSG_TYPE_TARGET_MSGIN; in ahd_setup_target_msgin()
6010 ahd_sglist_size(struct ahd_softc *ahd) in ahd_sglist_size() argument
6015 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) in ahd_sglist_size()
6027 ahd_sglist_allocsize(struct ahd_softc *ahd) in ahd_sglist_allocsize() argument
6035 sg_list_increment = ahd_sglist_size(ahd); in ahd_sglist_allocsize()
6074 struct ahd_softc *ahd; in ahd_alloc() local
6077 ahd = kmalloc(sizeof(*ahd), GFP_ATOMIC); in ahd_alloc()
6078 if (!ahd) { in ahd_alloc()
6084 ahd = device_get_softc((device_t)platform_arg); in ahd_alloc()
6086 memset(ahd, 0, sizeof(*ahd)); in ahd_alloc()
6087 ahd->seep_config = kmalloc(sizeof(*ahd->seep_config), GFP_ATOMIC); in ahd_alloc()
6088 if (ahd->seep_config == NULL) { in ahd_alloc()
6090 kfree(ahd); in ahd_alloc()
6095 LIST_INIT(&ahd->pending_scbs); in ahd_alloc()
6097 ahd->name = name; in ahd_alloc()
6098 ahd->unit = -1; in ahd_alloc()
6099 ahd->description = NULL; in ahd_alloc()
6100 ahd->bus_description = NULL; in ahd_alloc()
6101 ahd->channel = 'A'; in ahd_alloc()
6102 ahd->chip = AHD_NONE; in ahd_alloc()
6103 ahd->features = AHD_FENONE; in ahd_alloc()
6104 ahd->bugs = AHD_BUGNONE; in ahd_alloc()
6105 ahd->flags = AHD_SPCHK_ENB_A|AHD_RESET_BUS_A|AHD_TERM_ENB_A in ahd_alloc()
6107 timer_setup(&ahd->stat_timer, ahd_stat_timer, 0); in ahd_alloc()
6108 ahd->int_coalescing_timer = AHD_INT_COALESCING_TIMER_DEFAULT; in ahd_alloc()
6109 ahd->int_coalescing_maxcmds = AHD_INT_COALESCING_MAXCMDS_DEFAULT; in ahd_alloc()
6110 ahd->int_coalescing_mincmds = AHD_INT_COALESCING_MINCMDS_DEFAULT; in ahd_alloc()
6111 ahd->int_coalescing_threshold = AHD_INT_COALESCING_THRESHOLD_DEFAULT; in ahd_alloc()
6112 ahd->int_coalescing_stop_threshold = in ahd_alloc()
6118 ahd_name(ahd), (u_int)sizeof(struct scb), in ahd_alloc()
6122 if (ahd_platform_alloc(ahd, platform_arg) != 0) { in ahd_alloc()
6123 ahd_free(ahd); in ahd_alloc()
6124 ahd = NULL; in ahd_alloc()
6126 return (ahd); in ahd_alloc()
6130 ahd_softc_init(struct ahd_softc *ahd) in ahd_softc_init() argument
6133 ahd->unpause = 0; in ahd_softc_init()
6134 ahd->pause = PAUSE; in ahd_softc_init()
6139 ahd_set_unit(struct ahd_softc *ahd, int unit) in ahd_set_unit() argument
6141 ahd->unit = unit; in ahd_set_unit()
6145 ahd_set_name(struct ahd_softc *ahd, char *name) in ahd_set_name() argument
6147 if (ahd->name != NULL) in ahd_set_name()
6148 kfree(ahd->name); in ahd_set_name()
6149 ahd->name = name; in ahd_set_name()
6153 ahd_free(struct ahd_softc *ahd) in ahd_free() argument
6157 switch (ahd->init_level) { in ahd_free()
6160 ahd_shutdown(ahd); in ahd_free()
6163 ahd_dmamap_unload(ahd, ahd->shared_data_dmat, in ahd_free()
6164 ahd->shared_data_map.dmamap); in ahd_free()
6167 ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo, in ahd_free()
6168 ahd->shared_data_map.dmamap); in ahd_free()
6169 ahd_dmamap_destroy(ahd, ahd->shared_data_dmat, in ahd_free()
6170 ahd->shared_data_map.dmamap); in ahd_free()
6173 ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat); in ahd_free()
6176 ahd_dma_tag_destroy(ahd, ahd->buffer_dmat); in ahd_free()
6184 ahd_dma_tag_destroy(ahd, ahd->parent_dmat); in ahd_free()
6186 ahd_platform_free(ahd); in ahd_free()
6187 ahd_fini_scbdata(ahd); in ahd_free()
6191 tstate = ahd->enabled_targets[i]; in ahd_free()
6210 if (ahd->black_hole != NULL) { in ahd_free()
6211 xpt_free_path(ahd->black_hole->path); in ahd_free()
6212 kfree(ahd->black_hole); in ahd_free()
6215 if (ahd->name != NULL) in ahd_free()
6216 kfree(ahd->name); in ahd_free()
6217 if (ahd->seep_config != NULL) in ahd_free()
6218 kfree(ahd->seep_config); in ahd_free()
6219 if (ahd->saved_stack != NULL) in ahd_free()
6220 kfree(ahd->saved_stack); in ahd_free()
6222 kfree(ahd); in ahd_free()
6230 struct ahd_softc *ahd; in ahd_shutdown() local
6232 ahd = (struct ahd_softc *)arg; in ahd_shutdown()
6237 del_timer_sync(&ahd->stat_timer); in ahd_shutdown()
6240 ahd_reset(ahd, /*reinit*/FALSE); in ahd_shutdown()
6253 ahd_reset(struct ahd_softc *ahd, int reinit) in ahd_reset() argument
6264 ahd_pause(ahd); in ahd_reset()
6265 ahd_update_modes(ahd); in ahd_reset()
6266 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reset()
6267 sxfrctl1 = ahd_inb(ahd, SXFRCTL1); in ahd_reset()
6269 cmd = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2); in ahd_reset()
6270 if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) { in ahd_reset()
6283 ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, in ahd_reset()
6286 ahd_outb(ahd, HCNTRL, CHIPRST | ahd->pause); in ahd_reset()
6297 } while (--wait && !(ahd_inb(ahd, HCNTRL) & CHIPRSTACK)); in ahd_reset()
6301 "Trying to initialize anyway.\n", ahd_name(ahd)); in ahd_reset()
6303 ahd_outb(ahd, HCNTRL, ahd->pause); in ahd_reset()
6305 if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) { in ahd_reset()
6310 ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1, in ahd_reset()
6312 ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, in ahd_reset()
6322 ahd_known_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reset()
6323 ahd_outb(ahd, MODE_PTR, in ahd_reset()
6324 ahd_build_mode_state(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI)); in ahd_reset()
6334 ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN); in ahd_reset()
6335 ahd_outb(ahd, SXFRCTL1, sxfrctl1); in ahd_reset()
6338 ahd->features &= ~AHD_WIDE; in ahd_reset()
6339 if ((ahd_inb(ahd, SBLKCTL) & SELWIDE) != 0) in ahd_reset()
6340 ahd->features |= AHD_WIDE; in ahd_reset()
6347 ahd_chip_init(ahd); in ahd_reset()
6356 ahd_probe_scbs(struct ahd_softc *ahd) { in ahd_probe_scbs() argument
6359 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), in ahd_probe_scbs()
6364 ahd_set_scbptr(ahd, i); in ahd_probe_scbs()
6365 ahd_outw(ahd, SCB_BASE, i); in ahd_probe_scbs()
6367 ahd_outb(ahd, SCB_BASE+j, 0); in ahd_probe_scbs()
6369 ahd_outb(ahd, SCB_CONTROL, MK_MESSAGE); in ahd_probe_scbs()
6370 if (ahd_inw_scbram(ahd, SCB_BASE) != i) in ahd_probe_scbs()
6372 ahd_set_scbptr(ahd, 0); in ahd_probe_scbs()
6373 if (ahd_inw_scbram(ahd, SCB_BASE) != 0) in ahd_probe_scbs()
6389 ahd_initialize_hscbs(struct ahd_softc *ahd) in ahd_initialize_hscbs() argument
6393 for (i = 0; i < ahd->scb_data.maxhscbs; i++) { in ahd_initialize_hscbs()
6394 ahd_set_scbptr(ahd, i); in ahd_initialize_hscbs()
6397 ahd_outb(ahd, SCB_CONTROL, 0); in ahd_initialize_hscbs()
6400 ahd_outw(ahd, SCB_NEXT, SCB_LIST_NULL); in ahd_initialize_hscbs()
6405 ahd_init_scbdata(struct ahd_softc *ahd) in ahd_init_scbdata() argument
6410 scb_data = &ahd->scb_data; in ahd_init_scbdata()
6420 scb_data->maxhscbs = ahd_probe_scbs(ahd); in ahd_init_scbdata()
6422 printk("%s: No SCB space found\n", ahd_name(ahd)); in ahd_init_scbdata()
6426 ahd_initialize_hscbs(ahd); in ahd_init_scbdata()
6439 if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1, in ahd_init_scbdata()
6453 if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/8, in ahd_init_scbdata()
6458 ahd_sglist_allocsize(ahd), /*nsegments*/1, in ahd_init_scbdata()
6465 printk("%s: ahd_sglist_allocsize = 0x%x\n", ahd_name(ahd), in ahd_init_scbdata()
6466 ahd_sglist_allocsize(ahd)); in ahd_init_scbdata()
6472 if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1, in ahd_init_scbdata()
6486 ahd_alloc_scbs(ahd); in ahd_init_scbdata()
6491 ahd_name(ahd)); in ahd_init_scbdata()
6506 ahd_find_scb_by_tag(struct ahd_softc *ahd, u_int tag) in ahd_find_scb_by_tag() argument
6513 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_find_scb_by_tag()
6521 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) { in ahd_find_scb_by_tag()
6535 LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) { in ahd_find_scb_by_tag()
6544 ahd_fini_scbdata(struct ahd_softc *ahd) in ahd_fini_scbdata() argument
6548 scb_data = &ahd->scb_data; in ahd_fini_scbdata()
6560 ahd_dmamap_unload(ahd, scb_data->sense_dmat, in ahd_fini_scbdata()
6562 ahd_dmamem_free(ahd, scb_data->sense_dmat, in ahd_fini_scbdata()
6566 ahd_dma_tag_destroy(ahd, scb_data->sense_dmat); in ahd_fini_scbdata()
6575 ahd_dmamap_unload(ahd, scb_data->sg_dmat, in ahd_fini_scbdata()
6577 ahd_dmamem_free(ahd, scb_data->sg_dmat, in ahd_fini_scbdata()
6581 ahd_dma_tag_destroy(ahd, scb_data->sg_dmat); in ahd_fini_scbdata()
6590 ahd_dmamap_unload(ahd, scb_data->hscb_dmat, in ahd_fini_scbdata()
6592 ahd_dmamem_free(ahd, scb_data->hscb_dmat, in ahd_fini_scbdata()
6596 ahd_dma_tag_destroy(ahd, scb_data->hscb_dmat); in ahd_fini_scbdata()
6613 ahd_setup_iocell_workaround(struct ahd_softc *ahd) in ahd_setup_iocell_workaround() argument
6617 saved_modes = ahd_save_modes(ahd); in ahd_setup_iocell_workaround()
6618 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_setup_iocell_workaround()
6619 ahd_outb(ahd, DSPDATACTL, ahd_inb(ahd, DSPDATACTL) in ahd_setup_iocell_workaround()
6621 ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) | (ENSELDO|ENSELDI)); in ahd_setup_iocell_workaround()
6624 printk("%s: Setting up iocell workaround\n", ahd_name(ahd)); in ahd_setup_iocell_workaround()
6626 ahd_restore_modes(ahd, saved_modes); in ahd_setup_iocell_workaround()
6627 ahd->flags &= ~AHD_HAD_FIRST_SEL; in ahd_setup_iocell_workaround()
6631 ahd_iocell_first_selection(struct ahd_softc *ahd) in ahd_iocell_first_selection() argument
6636 if ((ahd->flags & AHD_HAD_FIRST_SEL) != 0) in ahd_iocell_first_selection()
6638 saved_modes = ahd_save_modes(ahd); in ahd_iocell_first_selection()
6639 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_iocell_first_selection()
6640 sblkctl = ahd_inb(ahd, SBLKCTL); in ahd_iocell_first_selection()
6641 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_iocell_first_selection()
6644 printk("%s: iocell first selection\n", ahd_name(ahd)); in ahd_iocell_first_selection()
6647 ahd_outb(ahd, DSPDATACTL, in ahd_iocell_first_selection()
6648 ahd_inb(ahd, DSPDATACTL) & ~BYPASSENAB); in ahd_iocell_first_selection()
6651 printk("%s: BYPASS now disabled\n", ahd_name(ahd)); in ahd_iocell_first_selection()
6654 ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) & ~(ENSELDO|ENSELDI)); in ahd_iocell_first_selection()
6655 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_iocell_first_selection()
6656 ahd_restore_modes(ahd, saved_modes); in ahd_iocell_first_selection()
6657 ahd->flags |= AHD_HAD_FIRST_SEL; in ahd_iocell_first_selection()
6662 ahd_add_col_list(struct ahd_softc *ahd, struct scb *scb, u_int col_idx) in ahd_add_col_list() argument
6670 free_list = &ahd->scb_data.free_scb_lists[col_idx]; in ahd_add_col_list()
6671 free_tailq = &ahd->scb_data.free_scbs; in ahd_add_col_list()
6682 ahd_rem_col_list(struct ahd_softc *ahd, struct scb *scb) in ahd_rem_col_list() argument
6690 col_idx = AHD_GET_SCB_COL_IDX(ahd, scb); in ahd_rem_col_list()
6691 free_list = &ahd->scb_data.free_scb_lists[col_idx]; in ahd_rem_col_list()
6692 free_tailq = &ahd->scb_data.free_scbs; in ahd_rem_col_list()
6716 ahd_get_scb(struct ahd_softc *ahd, u_int col_idx) in ahd_get_scb() argument
6723 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) { in ahd_get_scb()
6724 if (AHD_GET_SCB_COL_IDX(ahd, scb) != col_idx) { in ahd_get_scb()
6725 ahd_rem_col_list(ahd, scb); in ahd_get_scb()
6729 if ((scb = LIST_FIRST(&ahd->scb_data.any_dev_free_scb_list)) == NULL) { in ahd_get_scb()
6733 ahd_alloc_scbs(ahd); in ahd_get_scb()
6741 ahd_add_col_list(ahd, scb->col_scb, col_idx); in ahd_get_scb()
6752 ahd_free_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_free_scb() argument
6757 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = NULL; in ahd_free_scb()
6764 LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list, in ahd_free_scb()
6773 ahd_rem_col_list(ahd, scb->col_scb); in ahd_free_scb()
6774 LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list, in ahd_free_scb()
6776 LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list, in ahd_free_scb()
6787 ahd_add_col_list(ahd, scb, in ahd_free_scb()
6788 AHD_GET_SCB_COL_IDX(ahd, scb->col_scb)); in ahd_free_scb()
6796 LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list, in ahd_free_scb()
6800 ahd_platform_scb_free(ahd, scb); in ahd_free_scb()
6804 ahd_alloc_scbs(struct ahd_softc *ahd) in ahd_alloc_scbs() argument
6820 scb_data = &ahd->scb_data; in ahd_alloc_scbs()
6839 if (ahd_dmamem_alloc(ahd, scb_data->hscb_dmat, in ahd_alloc_scbs()
6848 ahd_dmamap_load(ahd, scb_data->hscb_dmat, hscb_map->dmamap, in ahd_alloc_scbs()
6860 offset = ((ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd)) in ahd_alloc_scbs()
6861 - scb_data->sgs_left) * ahd_sglist_size(ahd); in ahd_alloc_scbs()
6872 if (ahd_dmamem_alloc(ahd, scb_data->sg_dmat, in ahd_alloc_scbs()
6881 ahd_dmamap_load(ahd, scb_data->sg_dmat, sg_map->dmamap, in ahd_alloc_scbs()
6882 sg_map->vaddr, ahd_sglist_allocsize(ahd), in ahd_alloc_scbs()
6888 ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd); in ahd_alloc_scbs()
6909 if (ahd_dmamem_alloc(ahd, scb_data->sense_dmat, in ahd_alloc_scbs()
6918 ahd_dmamap_load(ahd, scb_data->sense_dmat, sense_map->dmamap, in ahd_alloc_scbs()
6966 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) in ahd_alloc_scbs()
6971 next_scb->ahd_softc = ahd; in ahd_alloc_scbs()
6974 error = ahd_dmamap_create(ahd, ahd->buffer_dmat, /*flags*/0, in ahd_alloc_scbs()
6984 next_scb->col_scb = ahd_find_scb_by_tag(ahd, col_tag); in ahd_alloc_scbs()
6987 ahd_free_scb(ahd, next_scb); in ahd_alloc_scbs()
6990 segs += ahd_sglist_size(ahd); in ahd_alloc_scbs()
6991 sg_busaddr += ahd_sglist_size(ahd); in ahd_alloc_scbs()
7002 ahd_controller_info(struct ahd_softc *ahd, char *buf) in ahd_controller_info() argument
7008 len = sprintf(buf, "%s: ", ahd_chip_names[ahd->chip & AHD_CHIPID_MASK]); in ahd_controller_info()
7012 if ((ahd->features & AHD_WIDE) != 0) { in ahd_controller_info()
7018 speed, type, ahd->channel, ahd->our_id); in ahd_controller_info()
7021 sprintf(buf, "%s, %d SCBs", ahd->bus_description, in ahd_controller_info()
7022 ahd->scb_data.maxhscbs); in ahd_controller_info()
7052 ahd_init(struct ahd_softc *ahd) in ahd_init() argument
7063 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_init()
7065 ahd->stack_size = ahd_probe_stack_size(ahd); in ahd_init()
7066 ahd->saved_stack = kmalloc_array(ahd->stack_size, sizeof(uint16_t), in ahd_init()
7068 if (ahd->saved_stack == NULL) in ahd_init()
7080 ahd->flags |= AHD_SEQUENCER_DEBUG; in ahd_init()
7086 ahd->flags |= AHD_INITIATORROLE; in ahd_init()
7091 if ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) == 0) in ahd_init()
7092 ahd->features &= ~AHD_TARGETMODE; in ahd_init()
7096 if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1, in ahd_init()
7098 /*lowaddr*/ahd->flags & AHD_39BIT_ADDRESSING in ahd_init()
7107 &ahd->buffer_dmat) != 0) { in ahd_init()
7112 ahd->init_level++; in ahd_init()
7121 driver_data_size = AHD_SCB_MAX * sizeof(*ahd->qoutfifo) in ahd_init()
7123 if ((ahd->features & AHD_TARGETMODE) != 0) in ahd_init()
7125 if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) in ahd_init()
7127 if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1, in ahd_init()
7135 /*flags*/0, &ahd->shared_data_dmat) != 0) { in ahd_init()
7139 ahd->init_level++; in ahd_init()
7142 if (ahd_dmamem_alloc(ahd, ahd->shared_data_dmat, in ahd_init()
7143 (void **)&ahd->shared_data_map.vaddr, in ahd_init()
7145 &ahd->shared_data_map.dmamap) != 0) { in ahd_init()
7149 ahd->init_level++; in ahd_init()
7152 ahd_dmamap_load(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap, in ahd_init()
7153 ahd->shared_data_map.vaddr, driver_data_size, in ahd_init()
7154 ahd_dmamap_cb, &ahd->shared_data_map.physaddr, in ahd_init()
7156 ahd->qoutfifo = (struct ahd_completion *)ahd->shared_data_map.vaddr; in ahd_init()
7157 next_vaddr = (uint8_t *)&ahd->qoutfifo[AHD_QOUT_SIZE]; in ahd_init()
7158 next_baddr = ahd->shared_data_map.physaddr in ahd_init()
7160 if ((ahd->features & AHD_TARGETMODE) != 0) { in ahd_init()
7161 ahd->targetcmds = (struct target_cmd *)next_vaddr; in ahd_init()
7166 if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) { in ahd_init()
7167 ahd->overrun_buf = next_vaddr; in ahd_init()
7179 ahd->next_queued_hscb = (struct hardware_scb *)next_vaddr; in ahd_init()
7180 ahd->next_queued_hscb_map = &ahd->shared_data_map; in ahd_init()
7181 ahd->next_queued_hscb->hscb_busaddr = ahd_htole32(next_baddr); in ahd_init()
7183 ahd->init_level++; in ahd_init()
7186 if (ahd_init_scbdata(ahd) != 0) in ahd_init()
7189 if ((ahd->flags & AHD_INITIATORROLE) == 0) in ahd_init()
7190 ahd->flags &= ~AHD_RESET_BUS_A; in ahd_init()
7196 ahd_platform_init(ahd); in ahd_init()
7199 ahd_chip_init(ahd); in ahd_init()
7201 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_init()
7203 if ((ahd->flags & AHD_CURRENT_SENSING) == 0) in ahd_init()
7210 error = ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, in ahd_init()
7213 printk("%s: current sensing timeout 1\n", ahd_name(ahd)); in ahd_init()
7218 error = ahd_read_flexport(ahd, FLXADDR_FLEXSTAT, &fstat); in ahd_init()
7221 ahd_name(ahd)); in ahd_init()
7227 ahd_name(ahd)); in ahd_init()
7232 error = ahd_read_flexport(ahd, FLXADDR_CURRENT_STAT, ¤t_sensing); in ahd_init()
7234 printk("%s: current sensing timeout 3\n", ahd_name(ahd)); in ahd_init()
7239 ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0); in ahd_init()
7244 ahd_name(ahd), current_sensing); in ahd_init()
7260 printk("%s: %s Channel %s\n", ahd_name(ahd), in ahd_init()
7268 ahd_name(ahd), ahd_name(ahd)); in ahd_init()
7271 ahd_restart(ahd); in ahd_init()
7272 ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US); in ahd_init()
7280 ahd_chip_init(struct ahd_softc *ahd) in ahd_chip_init() argument
7289 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_chip_init()
7293 ahd_outb(ahd, SBLKCTL, ahd_inb(ahd, SBLKCTL) & ~(DIAGLEDEN|DIAGLEDON)); in ahd_chip_init()
7298 ahd->hs_mailbox = 0; in ahd_chip_init()
7299 ahd_outb(ahd, HS_MAILBOX, 0); in ahd_chip_init()
7302 ahd_outb(ahd, IOWNID, ahd->our_id); in ahd_chip_init()
7303 ahd_outb(ahd, TOWNID, ahd->our_id); in ahd_chip_init()
7304 sxfrctl1 = (ahd->flags & AHD_TERM_ENB_A) != 0 ? STPWEN : 0; in ahd_chip_init()
7305 sxfrctl1 |= (ahd->flags & AHD_SPCHK_ENB_A) != 0 ? ENSPCHK : 0; in ahd_chip_init()
7306 if ((ahd->bugs & AHD_LONG_SETIMO_BUG) in ahd_chip_init()
7307 && (ahd->seltime != STIMESEL_MIN)) { in ahd_chip_init()
7313 sxfrctl1 |= ahd->seltime + STIMESEL_BUG_ADJ; in ahd_chip_init()
7315 sxfrctl1 |= ahd->seltime; in ahd_chip_init()
7318 ahd_outb(ahd, SXFRCTL0, DFON); in ahd_chip_init()
7319 ahd_outb(ahd, SXFRCTL1, sxfrctl1|ahd->seltime|ENSTIMER|ACTNEGEN); in ahd_chip_init()
7320 ahd_outb(ahd, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR); in ahd_chip_init()
7330 (ahd_inb(ahd, SBLKCTL) & (ENAB40|ENAB20)) == 0 && wait; in ahd_chip_init()
7335 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI); in ahd_chip_init()
7336 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_chip_init()
7340 ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i); in ahd_chip_init()
7341 ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR); in ahd_chip_init()
7342 ahd_outb(ahd, SG_STATE, 0); in ahd_chip_init()
7343 ahd_outb(ahd, CLRSEQINTSRC, 0xFF); in ahd_chip_init()
7344 ahd_outb(ahd, SEQIMODE, in ahd_chip_init()
7349 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_chip_init()
7350 ahd_outb(ahd, DSCOMMAND0, ahd_inb(ahd, DSCOMMAND0)|MPARCKEN|CACHETHEN); in ahd_chip_init()
7351 ahd_outb(ahd, DFF_THRSH, RD_DFTHRSH_75|WR_DFTHRSH_75); in ahd_chip_init()
7352 ahd_outb(ahd, SIMODE0, ENIOERR|ENOVERRUN); in ahd_chip_init()
7353 ahd_outb(ahd, SIMODE3, ENNTRAMPERR|ENOSRAMPERR); in ahd_chip_init()
7354 if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) { in ahd_chip_init()
7355 ahd_outb(ahd, OPTIONMODE, AUTOACKEN|AUTO_MSGOUT_DE); in ahd_chip_init()
7357 ahd_outb(ahd, OPTIONMODE, AUTOACKEN|BUSFREEREV|AUTO_MSGOUT_DE); in ahd_chip_init()
7359 ahd_outb(ahd, SCSCHKN, CURRFIFODEF|WIDERESEN|SHVALIDSTDIS); in ahd_chip_init()
7360 if ((ahd->chip & AHD_BUS_MASK) == AHD_PCIX) in ahd_chip_init()
7366 ahd_outb(ahd, PCIXCTL, ahd_inb(ahd, PCIXCTL) | SPLTSTADIS); in ahd_chip_init()
7368 if ((ahd->bugs & AHD_LQOOVERRUN_BUG) != 0) in ahd_chip_init()
7369 ahd_outb(ahd, LQOSCSCTL, LQONOCHKOVER); in ahd_chip_init()
7374 if ((ahd->flags & AHD_HP_BOARD) != 0) { in ahd_chip_init()
7376 ahd_outb(ahd, DSPSELECT, i); in ahd_chip_init()
7377 ahd_outb(ahd, WRTBIASCTL, WRTBIASCTL_HP_DEFAULT); in ahd_chip_init()
7381 printk("%s: WRTBIASCTL now 0x%x\n", ahd_name(ahd), in ahd_chip_init()
7385 ahd_setup_iocell_workaround(ahd); in ahd_chip_init()
7390 ahd_outb(ahd, LQIMODE1, ENLQIPHASE_LQ|ENLQIPHASE_NLQ|ENLIQABORT in ahd_chip_init()
7393 ahd_outb(ahd, LQOMODE0, ENLQOATNLQ|ENLQOATNPKT|ENLQOTCRC); in ahd_chip_init()
7402 ahd_outb(ahd, LQOMODE1, ENLQOBUSFREE); in ahd_chip_init()
7407 ahd_outw(ahd, INTVEC1_ADDR, ahd_resolve_seqaddr(ahd, LABEL_seq_isr)); in ahd_chip_init()
7408 ahd_outw(ahd, INTVEC2_ADDR, ahd_resolve_seqaddr(ahd, LABEL_timer_isr)); in ahd_chip_init()
7413 if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) { in ahd_chip_init()
7414 ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb, in ahd_chip_init()
7417 ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb, lun)); in ahd_chip_init()
7419 ahd_outb(ahd, CMDLENPTR, offsetof(struct hardware_scb, cdb_len)); in ahd_chip_init()
7420 ahd_outb(ahd, ATTRPTR, offsetof(struct hardware_scb, task_attribute)); in ahd_chip_init()
7421 ahd_outb(ahd, FLAGPTR, offsetof(struct hardware_scb, task_management)); in ahd_chip_init()
7422 ahd_outb(ahd, CMDPTR, offsetof(struct hardware_scb, in ahd_chip_init()
7424 ahd_outb(ahd, QNEXTPTR, in ahd_chip_init()
7426 ahd_outb(ahd, ABRTBITPTR, MK_MESSAGE_BIT_OFFSET); in ahd_chip_init()
7427 ahd_outb(ahd, ABRTBYTEPTR, offsetof(struct hardware_scb, control)); in ahd_chip_init()
7428 if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) { in ahd_chip_init()
7429 ahd_outb(ahd, LUNLEN, in ahd_chip_init()
7430 sizeof(ahd->next_queued_hscb->pkt_long_lun) - 1); in ahd_chip_init()
7432 ahd_outb(ahd, LUNLEN, LUNLEN_SINGLE_LEVEL_LUN); in ahd_chip_init()
7434 ahd_outb(ahd, CDBLIMIT, SCB_CDB_LEN_PTR - 1); in ahd_chip_init()
7435 ahd_outb(ahd, MAXCMD, 0xFF); in ahd_chip_init()
7436 ahd_outb(ahd, SCBAUTOPTR, in ahd_chip_init()
7440 ahd_outb(ahd, MULTARGID, 0); in ahd_chip_init()
7441 ahd_outb(ahd, MULTARGID + 1, 0); in ahd_chip_init()
7443 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_chip_init()
7445 if ((ahd->features & AHD_NEW_IOCELL_OPTS) == 0) { in ahd_chip_init()
7451 ahd_outb(ahd, NEGOADDR, target); in ahd_chip_init()
7452 ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PER_DEV0); in ahd_chip_init()
7454 ahd_outb(ahd, ANNEXDAT, 0); in ahd_chip_init()
7462 tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, in ahd_chip_init()
7464 ahd_compile_devinfo(&devinfo, ahd->our_id, in ahd_chip_init()
7467 ahd_update_neg_table(ahd, &devinfo, &tinfo->curr); in ahd_chip_init()
7470 ahd_outb(ahd, CLRSINT3, NTRAMPERR|OSRAMPERR); in ahd_chip_init()
7471 ahd_outb(ahd, CLRINT, CLRSCSIINT); in ahd_chip_init()
7478 if ((ahd->bugs & AHD_ABORT_LQI_BUG) == 0) in ahd_chip_init()
7479 ahd_outb(ahd, LQCTL1, ABORTPENDING); in ahd_chip_init()
7482 ahd_outb(ahd, LQCTL1, 0); in ahd_chip_init()
7485 ahd->qoutfifonext = 0; in ahd_chip_init()
7486 ahd->qoutfifonext_valid_tag = QOUTFIFO_ENTRY_VALID; in ahd_chip_init()
7487 ahd_outb(ahd, QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID); in ahd_chip_init()
7489 ahd->qoutfifo[i].valid_tag = 0; in ahd_chip_init()
7490 ahd_sync_qoutfifo(ahd, BUS_DMASYNC_PREREAD); in ahd_chip_init()
7492 ahd->qinfifonext = 0; in ahd_chip_init()
7494 ahd->qinfifo[i] = SCB_LIST_NULL; in ahd_chip_init()
7496 if ((ahd->features & AHD_TARGETMODE) != 0) { in ahd_chip_init()
7499 ahd->targetcmds[i].cmd_valid = 0; in ahd_chip_init()
7500 ahd_sync_tqinfifo(ahd, BUS_DMASYNC_PREREAD); in ahd_chip_init()
7501 ahd->tqinfifonext = 1; in ahd_chip_init()
7502 ahd_outb(ahd, KERNEL_TQINPOS, ahd->tqinfifonext - 1); in ahd_chip_init()
7503 ahd_outb(ahd, TQINPOS, ahd->tqinfifonext); in ahd_chip_init()
7507 ahd_outb(ahd, SEQ_FLAGS, 0); in ahd_chip_init()
7508 ahd_outb(ahd, SEQ_FLAGS2, 0); in ahd_chip_init()
7511 ahd_outw(ahd, WAITING_TID_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7512 ahd_outw(ahd, WAITING_TID_TAIL, SCB_LIST_NULL); in ahd_chip_init()
7513 ahd_outw(ahd, MK_MESSAGE_SCB, SCB_LIST_NULL); in ahd_chip_init()
7514 ahd_outw(ahd, MK_MESSAGE_SCSIID, 0xFF); in ahd_chip_init()
7516 ahd_outw(ahd, WAITING_SCB_TAILS + (2 * i), SCB_LIST_NULL); in ahd_chip_init()
7521 ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7522 ahd_outw(ahd, COMPLETE_SCB_DMAINPROG_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7523 ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7524 ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL); in ahd_chip_init()
7525 ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL); in ahd_chip_init()
7530 ahd->qfreeze_cnt = 0; in ahd_chip_init()
7531 ahd_outw(ahd, QFREEZE_COUNT, 0); in ahd_chip_init()
7532 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, 0); in ahd_chip_init()
7537 busaddr = ahd->shared_data_map.physaddr; in ahd_chip_init()
7538 ahd_outl(ahd, SHARED_DATA_ADDR, busaddr); in ahd_chip_init()
7539 ahd_outl(ahd, QOUTFIFO_NEXT_ADDR, busaddr); in ahd_chip_init()
7547 if ((ahd->flags & AHD_INITIATORROLE) != 0) in ahd_chip_init()
7549 ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq_template); in ahd_chip_init()
7556 ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(target, 'A', lun)); in ahd_chip_init()
7565 ahd_outb(ahd, CMDSIZE_TABLE, 5); in ahd_chip_init()
7566 ahd_outb(ahd, CMDSIZE_TABLE + 1, 9); in ahd_chip_init()
7567 ahd_outb(ahd, CMDSIZE_TABLE + 2, 9); in ahd_chip_init()
7568 ahd_outb(ahd, CMDSIZE_TABLE + 3, 0); in ahd_chip_init()
7569 ahd_outb(ahd, CMDSIZE_TABLE + 4, 15); in ahd_chip_init()
7570 ahd_outb(ahd, CMDSIZE_TABLE + 5, 11); in ahd_chip_init()
7571 ahd_outb(ahd, CMDSIZE_TABLE + 6, 0); in ahd_chip_init()
7572 ahd_outb(ahd, CMDSIZE_TABLE + 7, 0); in ahd_chip_init()
7575 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_chip_init()
7576 ahd_outb(ahd, QOFF_CTLSTA, SCB_QSIZE_512); in ahd_chip_init()
7577 ahd->qinfifonext = 0; in ahd_chip_init()
7578 ahd_set_hnscb_qoff(ahd, ahd->qinfifonext); in ahd_chip_init()
7579 ahd_set_hescb_qoff(ahd, 0); in ahd_chip_init()
7580 ahd_set_snscb_qoff(ahd, 0); in ahd_chip_init()
7581 ahd_set_sescb_qoff(ahd, 0); in ahd_chip_init()
7582 ahd_set_sdscb_qoff(ahd, 0); in ahd_chip_init()
7587 busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr); in ahd_chip_init()
7588 ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr); in ahd_chip_init()
7593 ahd_outw(ahd, INT_COALESCING_CMDCOUNT, 0); in ahd_chip_init()
7594 ahd_outw(ahd, CMDS_PENDING, 0); in ahd_chip_init()
7595 ahd_update_coalescing_values(ahd, ahd->int_coalescing_timer, in ahd_chip_init()
7596 ahd->int_coalescing_maxcmds, in ahd_chip_init()
7597 ahd->int_coalescing_mincmds); in ahd_chip_init()
7598 ahd_enable_coalescing(ahd, FALSE); in ahd_chip_init()
7600 ahd_loadseq(ahd); in ahd_chip_init()
7601 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_chip_init()
7603 if (ahd->features & AHD_AIC79XXB_SLOWCRC) { in ahd_chip_init()
7604 u_int negodat3 = ahd_inb(ahd, NEGCONOPTS); in ahd_chip_init()
7607 ahd_outb(ahd, NEGCONOPTS, negodat3); in ahd_chip_init()
7608 negodat3 = ahd_inb(ahd, NEGCONOPTS); in ahd_chip_init()
7622 ahd_default_config(struct ahd_softc *ahd) in ahd_default_config() argument
7626 ahd->our_id = 7; in ahd_default_config()
7633 if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) { in ahd_default_config()
7635 "Failing attach\n", ahd_name(ahd)); in ahd_default_config()
7645 tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, in ahd_default_config()
7654 ahd->user_discenable |= target_mask; in ahd_default_config()
7656 ahd->user_tagenable |= target_mask; in ahd_default_config()
7669 if ((ahd->features & AHD_RTI) != 0) in ahd_default_config()
7682 ahd_compile_devinfo(&devinfo, ahd->our_id, in ahd_default_config()
7686 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_default_config()
7688 ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0, in ahd_default_config()
7699 ahd_parse_cfgdata(struct ahd_softc *ahd, struct seeprom_config *sc) in ahd_parse_cfgdata() argument
7705 ahd->our_id = sc->brtime_id & CFSCSIID; in ahd_parse_cfgdata()
7712 if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) { in ahd_parse_cfgdata()
7714 "Failing attach\n", ahd_name(ahd)); in ahd_parse_cfgdata()
7725 tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, in ahd_parse_cfgdata()
7736 ahd->user_discenable &= ~target_mask; in ahd_parse_cfgdata()
7738 ahd->user_tagenable &= ~target_mask; in ahd_parse_cfgdata()
7741 ahd->user_discenable |= target_mask; in ahd_parse_cfgdata()
7742 ahd->user_tagenable |= target_mask; in ahd_parse_cfgdata()
7770 if ((ahd->features & AHD_RTI) != 0) in ahd_parse_cfgdata()
7796 ahd_compile_devinfo(&devinfo, ahd->our_id, in ahd_parse_cfgdata()
7799 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_parse_cfgdata()
7801 ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0, in ahd_parse_cfgdata()
7806 ahd->flags &= ~AHD_SPCHK_ENB_A; in ahd_parse_cfgdata()
7808 ahd->flags |= AHD_SPCHK_ENB_A; in ahd_parse_cfgdata()
7810 ahd->flags &= ~AHD_RESET_BUS_A; in ahd_parse_cfgdata()
7812 ahd->flags |= AHD_RESET_BUS_A; in ahd_parse_cfgdata()
7814 ahd->flags &= ~AHD_EXTENDED_TRANS_A; in ahd_parse_cfgdata()
7816 ahd->flags |= AHD_EXTENDED_TRANS_A; in ahd_parse_cfgdata()
7818 ahd->flags &= ~AHD_BIOS_ENABLED; in ahd_parse_cfgdata()
7820 ahd->flags |= AHD_BIOS_ENABLED; in ahd_parse_cfgdata()
7822 ahd->flags &= ~AHD_STPWLEVEL_A; in ahd_parse_cfgdata()
7824 ahd->flags |= AHD_STPWLEVEL_A; in ahd_parse_cfgdata()
7833 ahd_parse_vpddata(struct ahd_softc *ahd, struct vpd_config *vpd) in ahd_parse_vpddata() argument
7841 ahd->flags |= AHD_BOOT_CHANNEL; in ahd_parse_vpddata()
7846 ahd_intr_enable(struct ahd_softc *ahd, int enable) in ahd_intr_enable() argument
7850 hcntrl = ahd_inb(ahd, HCNTRL); in ahd_intr_enable()
7852 ahd->pause &= ~INTEN; in ahd_intr_enable()
7853 ahd->unpause &= ~INTEN; in ahd_intr_enable()
7856 ahd->pause |= INTEN; in ahd_intr_enable()
7857 ahd->unpause |= INTEN; in ahd_intr_enable()
7859 ahd_outb(ahd, HCNTRL, hcntrl); in ahd_intr_enable()
7863 ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds, in ahd_update_coalescing_values() argument
7868 ahd->int_coalescing_timer = timer; in ahd_update_coalescing_values()
7874 ahd->int_coalescing_maxcmds = maxcmds; in ahd_update_coalescing_values()
7875 ahd_outw(ahd, INT_COALESCING_TIMER, timer / AHD_TIMER_US_PER_TICK); in ahd_update_coalescing_values()
7876 ahd_outb(ahd, INT_COALESCING_MAXCMDS, -maxcmds); in ahd_update_coalescing_values()
7877 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds); in ahd_update_coalescing_values()
7881 ahd_enable_coalescing(struct ahd_softc *ahd, int enable) in ahd_enable_coalescing() argument
7884 ahd->hs_mailbox &= ~ENINT_COALESCE; in ahd_enable_coalescing()
7886 ahd->hs_mailbox |= ENINT_COALESCE; in ahd_enable_coalescing()
7887 ahd_outb(ahd, HS_MAILBOX, ahd->hs_mailbox); in ahd_enable_coalescing()
7888 ahd_flush_device_writes(ahd); in ahd_enable_coalescing()
7889 ahd_run_qoutfifo(ahd); in ahd_enable_coalescing()
7900 ahd_pause_and_flushwork(struct ahd_softc *ahd) in ahd_pause_and_flushwork() argument
7906 ahd->flags |= AHD_ALL_INTERRUPTS; in ahd_pause_and_flushwork()
7907 ahd_pause(ahd); in ahd_pause_and_flushwork()
7913 ahd->qfreeze_cnt--; in ahd_pause_and_flushwork()
7914 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt); in ahd_pause_and_flushwork()
7915 ahd_outb(ahd, SEQ_FLAGS2, ahd_inb(ahd, SEQ_FLAGS2) | SELECTOUT_QFROZEN); in ahd_pause_and_flushwork()
7918 ahd_unpause(ahd); in ahd_pause_and_flushwork()
7925 ahd_intr(ahd); in ahd_pause_and_flushwork()
7926 ahd_pause(ahd); in ahd_pause_and_flushwork()
7927 intstat = ahd_inb(ahd, INTSTAT); in ahd_pause_and_flushwork()
7929 ahd_clear_critical_section(ahd); in ahd_pause_and_flushwork()
7930 intstat = ahd_inb(ahd, INTSTAT); in ahd_pause_and_flushwork()
7933 && (intstat != 0xFF || (ahd->features & AHD_REMOVABLE) == 0) in ahd_pause_and_flushwork()
7935 || (ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0 in ahd_pause_and_flushwork()
7936 || (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0)); in ahd_pause_and_flushwork()
7940 ahd_inb(ahd, INTSTAT)); in ahd_pause_and_flushwork()
7942 ahd->qfreeze_cnt++; in ahd_pause_and_flushwork()
7943 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt); in ahd_pause_and_flushwork()
7945 ahd_flush_qoutfifo(ahd); in ahd_pause_and_flushwork()
7947 ahd->flags &= ~AHD_ALL_INTERRUPTS; in ahd_pause_and_flushwork()
7952 ahd_suspend(struct ahd_softc *ahd) in ahd_suspend() argument
7955 ahd_pause_and_flushwork(ahd); in ahd_suspend()
7957 if (LIST_FIRST(&ahd->pending_scbs) != NULL) { in ahd_suspend()
7958 ahd_unpause(ahd); in ahd_suspend()
7961 ahd_shutdown(ahd); in ahd_suspend()
7966 ahd_resume(struct ahd_softc *ahd) in ahd_resume() argument
7969 ahd_reset(ahd, /*reinit*/TRUE); in ahd_resume()
7970 ahd_intr_enable(ahd, TRUE); in ahd_resume()
7971 ahd_restart(ahd); in ahd_resume()
7985 ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl) in ahd_index_busy_tcl() argument
7990 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_index_busy_tcl()
7991 *saved_scbid = ahd_get_scbptr(ahd); in ahd_index_busy_tcl()
7992 ahd_set_scbptr(ahd, TCL_LUN(tcl) in ahd_index_busy_tcl()
8007 ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl) in ahd_find_busy_tcl() argument
8013 scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl); in ahd_find_busy_tcl()
8014 scbid = ahd_inw_scbram(ahd, scb_offset); in ahd_find_busy_tcl()
8015 ahd_set_scbptr(ahd, saved_scbptr); in ahd_find_busy_tcl()
8020 ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid) in ahd_busy_tcl() argument
8025 scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl); in ahd_busy_tcl()
8026 ahd_outw(ahd, scb_offset, scbid); in ahd_busy_tcl()
8027 ahd_set_scbptr(ahd, saved_scbptr); in ahd_busy_tcl()
8032 ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target, in ahd_match_scb() argument
8035 int targ = SCB_GET_TARGET(ahd, scb); in ahd_match_scb()
8036 char chan = SCB_GET_CHANNEL(ahd, scb); in ahd_match_scb()
8068 ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb) in ahd_freeze_devq() argument
8074 target = SCB_GET_TARGET(ahd, scb); in ahd_freeze_devq()
8076 channel = SCB_GET_CHANNEL(ahd, scb); in ahd_freeze_devq()
8078 ahd_search_qinfifo(ahd, target, channel, lun, in ahd_freeze_devq()
8082 ahd_platform_freeze_devq(ahd, scb); in ahd_freeze_devq()
8086 ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, struct scb *scb) in ahd_qinfifo_requeue_tail() argument
8091 saved_modes = ahd_save_modes(ahd); in ahd_qinfifo_requeue_tail()
8092 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_qinfifo_requeue_tail()
8094 if (ahd_qinfifo_count(ahd) != 0) { in ahd_qinfifo_requeue_tail()
8098 prev_pos = AHD_QIN_WRAP(ahd->qinfifonext - 1); in ahd_qinfifo_requeue_tail()
8099 prev_tag = ahd->qinfifo[prev_pos]; in ahd_qinfifo_requeue_tail()
8100 prev_scb = ahd_lookup_scb(ahd, prev_tag); in ahd_qinfifo_requeue_tail()
8102 ahd_qinfifo_requeue(ahd, prev_scb, scb); in ahd_qinfifo_requeue_tail()
8103 ahd_set_hnscb_qoff(ahd, ahd->qinfifonext); in ahd_qinfifo_requeue_tail()
8104 ahd_restore_modes(ahd, saved_modes); in ahd_qinfifo_requeue_tail()
8108 ahd_qinfifo_requeue(struct ahd_softc *ahd, struct scb *prev_scb, in ahd_qinfifo_requeue() argument
8115 ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr); in ahd_qinfifo_requeue()
8118 ahd_sync_scb(ahd, prev_scb, in ahd_qinfifo_requeue()
8121 ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb); in ahd_qinfifo_requeue()
8122 ahd->qinfifonext++; in ahd_qinfifo_requeue()
8123 scb->hscb->next_hscb_busaddr = ahd->next_queued_hscb->hscb_busaddr; in ahd_qinfifo_requeue()
8124 ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahd_qinfifo_requeue()
8128 ahd_qinfifo_count(struct ahd_softc *ahd) in ahd_qinfifo_count() argument
8134 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); in ahd_qinfifo_count()
8135 qinpos = ahd_get_snscb_qoff(ahd); in ahd_qinfifo_count()
8137 wrap_qinfifonext = AHD_QIN_WRAP(ahd->qinfifonext); in ahd_qinfifo_count()
8142 + ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos); in ahd_qinfifo_count()
8146 ahd_reset_cmds_pending(struct ahd_softc *ahd) in ahd_reset_cmds_pending() argument
8152 saved_modes = ahd_save_modes(ahd); in ahd_reset_cmds_pending()
8153 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_reset_cmds_pending()
8159 ahd_flush_qoutfifo(ahd); in ahd_reset_cmds_pending()
8162 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_reset_cmds_pending()
8165 ahd_outw(ahd, CMDS_PENDING, pending_cmds - ahd_qinfifo_count(ahd)); in ahd_reset_cmds_pending()
8166 ahd_restore_modes(ahd, saved_modes); in ahd_reset_cmds_pending()
8167 ahd->flags &= ~AHD_UPDATE_PEND_CMDS; in ahd_reset_cmds_pending()
8171 ahd_done_with_status(struct ahd_softc *ahd, struct scb *scb, uint32_t status) in ahd_done_with_status() argument
8182 ahd_done(ahd, scb); in ahd_done_with_status()
8186 ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel, in ahd_search_qinfifo() argument
8207 saved_modes = ahd_save_modes(ahd); in ahd_search_qinfifo()
8208 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_search_qinfifo()
8214 if ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN|CCSCBDIR)) in ahd_search_qinfifo()
8216 ahd_outb(ahd, CCSCBCTL, in ahd_search_qinfifo()
8217 ahd_inb(ahd, CCSCBCTL) & ~(CCARREN|CCSCBEN)); in ahd_search_qinfifo()
8218 while ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN)) != 0) in ahd_search_qinfifo()
8222 qintail = AHD_QIN_WRAP(ahd->qinfifonext); in ahd_search_qinfifo()
8223 qinstart = ahd_get_snscb_qoff(ahd); in ahd_search_qinfifo()
8230 qinstart, ahd->qinfifonext); in ahd_search_qinfifo()
8237 ahd->qinfifonext = qinstart; in ahd_search_qinfifo()
8238 busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr); in ahd_search_qinfifo()
8239 ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr); in ahd_search_qinfifo()
8242 scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]); in ahd_search_qinfifo()
8245 qinpos, ahd->qinfifo[qinpos]); in ahd_search_qinfifo()
8249 if (ahd_match_scb(ahd, scb, target, channel, lun, tag, role)) { in ahd_search_qinfifo()
8258 ahd_done_with_status(ahd, scb, status); in ahd_search_qinfifo()
8263 printk(" 0x%x", ahd->qinfifo[qinpos]); in ahd_search_qinfifo()
8266 ahd_qinfifo_requeue(ahd, prev_scb, scb); in ahd_search_qinfifo()
8271 ahd_qinfifo_requeue(ahd, prev_scb, scb); in ahd_search_qinfifo()
8277 ahd_set_hnscb_qoff(ahd, ahd->qinfifonext); in ahd_search_qinfifo()
8288 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_search_qinfifo()
8289 seq_flags2 = ahd_inb(ahd, SEQ_FLAGS2); in ahd_search_qinfifo()
8291 scbid = ahd_inw(ahd, MK_MESSAGE_SCB); in ahd_search_qinfifo()
8292 mk_msg_scb = ahd_lookup_scb(ahd, scbid); in ahd_search_qinfifo()
8295 savedscbptr = ahd_get_scbptr(ahd); in ahd_search_qinfifo()
8296 tid_next = ahd_inw(ahd, WAITING_TID_HEAD); in ahd_search_qinfifo()
8307 if (scbid >= ahd->scb_data.numscbs) { in ahd_search_qinfifo()
8310 ahd_name(ahd), scbid, ahd->scb_data.numscbs); in ahd_search_qinfifo()
8311 ahd_dump_card_state(ahd); in ahd_search_qinfifo()
8314 scb = ahd_lookup_scb(ahd, scbid); in ahd_search_qinfifo()
8317 ahd_name(ahd), scbid); in ahd_search_qinfifo()
8320 ahd_set_scbptr(ahd, scbid); in ahd_search_qinfifo()
8321 tid_next = ahd_inw_scbram(ahd, SCB_NEXT2); in ahd_search_qinfifo()
8322 if (ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD, in ahd_search_qinfifo()
8332 printk(" %d ( ", SCB_GET_TARGET(ahd, scb)); in ahd_search_qinfifo()
8334 found += ahd_search_scb_list(ahd, target, channel, in ahd_search_qinfifo()
8337 SCB_GET_TARGET(ahd, scb)); in ahd_search_qinfifo()
8343 && ahd_match_scb(ahd, mk_msg_scb, target, channel, in ahd_search_qinfifo()
8354 ahd_done_with_status(ahd, mk_msg_scb, status); in ahd_search_qinfifo()
8367 + (2 * SCB_GET_TARGET(ahd, mk_msg_scb)); in ahd_search_qinfifo()
8368 ahd_outw(ahd, tail_offset, tid_tail); in ahd_search_qinfifo()
8371 ahd_outb(ahd, SEQ_FLAGS2, seq_flags2); in ahd_search_qinfifo()
8372 ahd_outw(ahd, CMDS_PENDING, in ahd_search_qinfifo()
8373 ahd_inw(ahd, CMDS_PENDING)-1); in ahd_search_qinfifo()
8387 && ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD, in ahd_search_qinfifo()
8396 tid_head = ahd_inw(ahd, MK_MESSAGE_SCB); in ahd_search_qinfifo()
8398 ahd_outb(ahd, SEQ_FLAGS2, seq_flags2); in ahd_search_qinfifo()
8402 ahd_stitch_tid_list(ahd, tid_prev, tid_head, tid_next); in ahd_search_qinfifo()
8410 ahd_set_scbptr(ahd, savedscbptr); in ahd_search_qinfifo()
8411 ahd_restore_modes(ahd, saved_modes); in ahd_search_qinfifo()
8416 ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel, in ahd_search_scb_list() argument
8427 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_search_scb_list()
8433 if (scbid >= ahd->scb_data.numscbs) { in ahd_search_scb_list()
8436 ahd_name(ahd), scbid, ahd->scb_data.numscbs); in ahd_search_scb_list()
8437 ahd_dump_card_state(ahd); in ahd_search_scb_list()
8440 scb = ahd_lookup_scb(ahd, scbid); in ahd_search_scb_list()
8443 ahd_name(ahd), scbid); in ahd_search_scb_list()
8446 ahd_set_scbptr(ahd, scbid); in ahd_search_scb_list()
8448 next = ahd_inw_scbram(ahd, SCB_NEXT); in ahd_search_scb_list()
8449 if (ahd_match_scb(ahd, scb, target, channel, in ahd_search_scb_list()
8459 ahd_done_with_status(ahd, scb, status); in ahd_search_scb_list()
8462 ahd_rem_wscb(ahd, scbid, prev, next, tid); in ahd_search_scb_list()
8478 ahd_outw(ahd, CMDS_PENDING, ahd_inw(ahd, CMDS_PENDING) - found); in ahd_search_scb_list()
8483 ahd_stitch_tid_list(struct ahd_softc *ahd, u_int tid_prev, in ahd_stitch_tid_list() argument
8486 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_stitch_tid_list()
8492 ahd_outw(ahd, WAITING_TID_HEAD, tid_next); in ahd_stitch_tid_list()
8494 ahd_set_scbptr(ahd, tid_prev); in ahd_stitch_tid_list()
8495 ahd_outw(ahd, SCB_NEXT2, tid_next); in ahd_stitch_tid_list()
8498 ahd_outw(ahd, WAITING_TID_TAIL, tid_prev); in ahd_stitch_tid_list()
8503 ahd_outw(ahd, WAITING_TID_HEAD, tid_cur); in ahd_stitch_tid_list()
8505 ahd_set_scbptr(ahd, tid_prev); in ahd_stitch_tid_list()
8506 ahd_outw(ahd, SCB_NEXT2, tid_cur); in ahd_stitch_tid_list()
8508 ahd_set_scbptr(ahd, tid_cur); in ahd_stitch_tid_list()
8509 ahd_outw(ahd, SCB_NEXT2, tid_next); in ahd_stitch_tid_list()
8512 ahd_outw(ahd, WAITING_TID_TAIL, tid_cur); in ahd_stitch_tid_list()
8521 ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid, in ahd_rem_wscb() argument
8526 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_rem_wscb()
8528 ahd_set_scbptr(ahd, prev); in ahd_rem_wscb()
8529 ahd_outw(ahd, SCB_NEXT, next); in ahd_rem_wscb()
8541 && ahd_inw(ahd, tail_offset) == scbid) in ahd_rem_wscb()
8542 ahd_outw(ahd, tail_offset, prev); in ahd_rem_wscb()
8544 ahd_add_scb_to_free_list(ahd, scbid); in ahd_rem_wscb()
8554 ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid) in ahd_add_scb_to_free_list() argument
8572 ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel, in ahd_abort_scbs() argument
8585 saved_modes = ahd_save_modes(ahd); in ahd_abort_scbs()
8586 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_abort_scbs()
8588 found = ahd_search_qinfifo(ahd, target, channel, lun, SCB_LIST_NULL, in ahd_abort_scbs()
8620 scbid = ahd_find_busy_tcl(ahd, tcl); in ahd_abort_scbs()
8621 scbp = ahd_lookup_scb(ahd, scbid); in ahd_abort_scbs()
8623 || ahd_match_scb(ahd, scbp, target, channel, in ahd_abort_scbs()
8626 ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(i, 'A', j)); in ahd_abort_scbs()
8635 ahd_flush_qoutfifo(ahd); in ahd_abort_scbs()
8643 scbp_next = LIST_FIRST(&ahd->pending_scbs); in ahd_abort_scbs()
8647 if (ahd_match_scb(ahd, scbp, target, channel, lun, tag, role)) { in ahd_abort_scbs()
8657 ahd_done(ahd, scbp); in ahd_abort_scbs()
8661 ahd_restore_modes(ahd, saved_modes); in ahd_abort_scbs()
8662 ahd_platform_abort_scbs(ahd, target, channel, lun, tag, role, status); in ahd_abort_scbs()
8663 ahd->flags |= AHD_UPDATE_PEND_CMDS; in ahd_abort_scbs()
8668 ahd_reset_current_bus(struct ahd_softc *ahd) in ahd_reset_current_bus() argument
8672 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_reset_current_bus()
8673 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) & ~ENSCSIRST); in ahd_reset_current_bus()
8674 scsiseq = ahd_inb(ahd, SCSISEQ0) & ~(ENSELO|ENARBO|SCSIRSTO); in ahd_reset_current_bus()
8675 ahd_outb(ahd, SCSISEQ0, scsiseq | SCSIRSTO); in ahd_reset_current_bus()
8676 ahd_flush_device_writes(ahd); in ahd_reset_current_bus()
8679 ahd_outb(ahd, SCSISEQ0, scsiseq); in ahd_reset_current_bus()
8680 ahd_flush_device_writes(ahd); in ahd_reset_current_bus()
8682 if ((ahd->bugs & AHD_SCSIRST_BUG) != 0) { in ahd_reset_current_bus()
8689 ahd_reset(ahd, /*reinit*/TRUE); in ahd_reset_current_bus()
8690 ahd_intr_enable(ahd, /*enable*/TRUE); in ahd_reset_current_bus()
8691 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_reset_current_bus()
8694 ahd_clear_intstat(ahd); in ahd_reset_current_bus()
8698 ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset) in ahd_reset_channel() argument
8712 if (ahd->flags & AHD_BUS_RESET_ACTIVE) { in ahd_reset_channel()
8714 ahd_name(ahd)); in ahd_reset_channel()
8717 ahd->flags |= AHD_BUS_RESET_ACTIVE; in ahd_reset_channel()
8719 ahd->pending_device = NULL; in ahd_reset_channel()
8726 ahd_pause(ahd); in ahd_reset_channel()
8729 ahd_clear_critical_section(ahd); in ahd_reset_channel()
8736 ahd_run_qoutfifo(ahd); in ahd_reset_channel()
8738 if ((ahd->flags & AHD_TARGETROLE) != 0) { in ahd_reset_channel()
8739 ahd_run_tqinfifo(ahd, /*paused*/TRUE); in ahd_reset_channel()
8742 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reset_channel()
8748 ahd_outb(ahd, SCSISEQ0, 0); in ahd_reset_channel()
8749 ahd_outb(ahd, SCSISEQ1, 0); in ahd_reset_channel()
8756 next_fifo = fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO; in ahd_reset_channel()
8762 ahd_set_modes(ahd, next_fifo, next_fifo); in ahd_reset_channel()
8763 ahd_outb(ahd, DFCNTRL, in ahd_reset_channel()
8764 ahd_inb(ahd, DFCNTRL) & ~(SCSIEN|HDMAEN)); in ahd_reset_channel()
8765 while ((ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0) in ahd_reset_channel()
8770 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_reset_channel()
8771 ahd_outb(ahd, DFFSTAT, next_fifo); in ahd_reset_channel()
8777 ahd_clear_msg_state(ahd); in ahd_reset_channel()
8778 ahd_outb(ahd, SIMODE1, in ahd_reset_channel()
8779 ahd_inb(ahd, SIMODE1) & ~(ENBUSFREE|ENSCSIRST)); in ahd_reset_channel()
8782 ahd_reset_current_bus(ahd); in ahd_reset_channel()
8784 ahd_clear_intstat(ahd); in ahd_reset_channel()
8790 found = ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, channel, in ahd_reset_channel()
8797 ahd_clear_fifo(ahd, 0); in ahd_reset_channel()
8798 ahd_clear_fifo(ahd, 1); in ahd_reset_channel()
8803 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI); in ahd_reset_channel()
8808 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST); in ahd_reset_channel()
8809 scsiseq = ahd_inb(ahd, SCSISEQ_TEMPLATE); in ahd_reset_channel()
8810 ahd_outb(ahd, SCSISEQ1, scsiseq & (ENSELI|ENRSELI|ENAUTOATNP)); in ahd_reset_channel()
8812 max_scsiid = (ahd->features & AHD_WIDE) ? 15 : 7; in ahd_reset_channel()
8822 tstate = ahd->enabled_targets[target]; in ahd_reset_channel()
8832 ahd_queue_lstate_event(ahd, lstate, CAM_TARGET_WILDCARD, in ahd_reset_channel()
8834 ahd_send_lstate_events(ahd, lstate); in ahd_reset_channel()
8843 if (ahd->enabled_targets[target] == NULL) in ahd_reset_channel()
8851 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahd_reset_channel()
8853 ahd_set_syncrate(ahd, &devinfo, /*period*/0, in ahd_reset_channel()
8860 ahd_send_async(ahd, caminfo.channel, CAM_TARGET_WILDCARD, in ahd_reset_channel()
8863 ahd_restart(ahd); in ahd_reset_channel()
8872 struct ahd_softc *ahd = from_timer(ahd, t, stat_timer); in ahd_stat_timer() local
8876 ahd_lock(ahd, &s); in ahd_stat_timer()
8878 enint_coal = ahd->hs_mailbox & ENINT_COALESCE; in ahd_stat_timer()
8879 if (ahd->cmdcmplt_total > ahd->int_coalescing_threshold) in ahd_stat_timer()
8881 else if (ahd->cmdcmplt_total < ahd->int_coalescing_stop_threshold) in ahd_stat_timer()
8884 if (enint_coal != (ahd->hs_mailbox & ENINT_COALESCE)) { in ahd_stat_timer()
8885 ahd_enable_coalescing(ahd, enint_coal); in ahd_stat_timer()
8890 ahd_name(ahd), in ahd_stat_timer()
8892 ahd->cmdcmplt_total); in ahd_stat_timer()
8896 ahd->cmdcmplt_bucket = (ahd->cmdcmplt_bucket+1) & (AHD_STAT_BUCKETS-1); in ahd_stat_timer()
8897 ahd->cmdcmplt_total -= ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]; in ahd_stat_timer()
8898 ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket] = 0; in ahd_stat_timer()
8899 ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US); in ahd_stat_timer()
8900 ahd_unlock(ahd, &s); in ahd_stat_timer()
8906 ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb) in ahd_handle_scsi_status() argument
8922 if (ahd_is_paused(ahd)) { in ahd_handle_scsi_status()
8926 ahd_pause(ahd); in ahd_handle_scsi_status()
8930 ahd_freeze_devq(ahd, scb); in ahd_handle_scsi_status()
8932 ahd->qfreeze_cnt++; in ahd_handle_scsi_status()
8933 ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt); in ahd_handle_scsi_status()
8936 ahd_unpause(ahd); in ahd_handle_scsi_status()
8946 ahd_done(ahd, scb); in ahd_handle_scsi_status()
8956 ahd_sync_sense(ahd, scb, BUS_DMASYNC_POSTREAD); in ahd_handle_scsi_status()
8961 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
8971 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
9009 ahd_done(ahd, scb); in ahd_handle_scsi_status()
9023 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
9033 SCB_GET_TARGET(ahd, scb), in ahd_handle_scsi_status()
9035 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_scsi_status()
9037 targ_info = ahd_fetch_transinfo(ahd, in ahd_handle_scsi_status()
9048 ahd_update_residual(ahd, scb); in ahd_handle_scsi_status()
9051 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
9056 sg = ahd_sg_setup(ahd, scb, sg, ahd_get_sense_bufaddr(ahd, scb), in ahd_handle_scsi_status()
9057 ahd_get_sense_bufsize(ahd, scb), in ahd_handle_scsi_status()
9066 sc->length = ahd_get_sense_bufsize(ahd, scb); in ahd_handle_scsi_status()
9087 ahd_update_neg_request(ahd, &devinfo, in ahd_handle_scsi_status()
9098 ahd_setup_data_scb(ahd, scb); in ahd_handle_scsi_status()
9100 ahd_queue_scb(ahd, scb); in ahd_handle_scsi_status()
9105 ahd_name(ahd)); in ahd_handle_scsi_status()
9108 ahd_done(ahd, scb); in ahd_handle_scsi_status()
9114 ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb) in ahd_handle_scb_status() argument
9117 ahd_handle_scsi_status(ahd, scb); in ahd_handle_scb_status()
9119 ahd_calc_residual(ahd, scb); in ahd_handle_scb_status()
9120 ahd_done(ahd, scb); in ahd_handle_scb_status()
9128 ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb) in ahd_calc_residual() argument
9178 ahd_print_path(ahd, scb); in ahd_calc_residual()
9181 ahd_freeze_devq(ahd, scb); in ahd_calc_residual()
9196 sg = ahd_sg_bus_to_virt(ahd, scb, resid_sgptr & SG_PTR_MASK); in ahd_calc_residual()
9218 ahd_print_path(ahd, scb); in ahd_calc_residual()
9231 ahd_queue_lstate_event(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate, in ahd_queue_lstate_event() argument
9282 ahd_send_lstate_events(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate) in ahd_send_lstate_events() argument
9318 ahd_dumpseq(struct ahd_softc* ahd) in ahd_dumpseq() argument
9325 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM); in ahd_dumpseq()
9326 ahd_outw(ahd, PRGMCNT, 0); in ahd_dumpseq()
9330 ahd_insb(ahd, SEQRAM, ins_bytes, 4); in ahd_dumpseq()
9340 ahd_loadseq(struct ahd_softc *ahd) in ahd_loadseq() argument
9360 ahd_name(ahd)); in ahd_loadseq()
9392 sg_prefetch_align = ahd->pci_cachesize; in ahd_loadseq()
9415 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) in ahd_loadseq()
9439 (ahd->overrun_buf - (uint8_t *)ahd->qoutfifo) / 256; in ahd_loadseq()
9445 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM); in ahd_loadseq()
9446 ahd_outw(ahd, PRGMCNT, 0); in ahd_loadseq()
9449 if (ahd_check_patch(ahd, &cur_patch, i, &skip_addr) == 0) { in ahd_loadseq()
9477 ahd_download_instr(ahd, i, download_consts); in ahd_loadseq()
9481 ahd->num_critical_sections = cs_count; in ahd_loadseq()
9485 ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC); in ahd_loadseq()
9486 if (ahd->critical_sections == NULL) in ahd_loadseq()
9488 memcpy(ahd->critical_sections, cs_table, cs_count); in ahd_loadseq()
9490 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE); in ahd_loadseq()
9495 ahd_name(ahd), ahd->features, ahd->bugs, ahd->flags); in ahd_loadseq()
9500 ahd_check_patch(struct ahd_softc *ahd, const struct patch **start_patch, in ahd_check_patch() argument
9513 if (cur_patch->patch_func(ahd) == 0) { in ahd_check_patch()
9536 ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address) in ahd_resolve_seqaddr() argument
9549 ahd_check_patch(ahd, &cur_patch, i, &skip_addr); in ahd_resolve_seqaddr()
9565 ahd_download_instr(struct ahd_softc *ahd, u_int instrptr, uint8_t *dconsts) in ahd_download_instr() argument
9593 fmt3_ins->address = ahd_resolve_seqaddr(ahd, fmt3_ins->address); in ahd_download_instr()
9624 ahd_outsb(ahd, SEQRAM, instr.bytes, 4); in ahd_download_instr()
9634 ahd_probe_stack_size(struct ahd_softc *ahd) in ahd_probe_stack_size() argument
9649 ahd_outb(ahd, STACK, i & 0xFF); in ahd_probe_stack_size()
9650 ahd_outb(ahd, STACK, (i >> 8) & 0xFF); in ahd_probe_stack_size()
9657 stack_entry = ahd_inb(ahd, STACK) in ahd_probe_stack_size()
9658 |(ahd_inb(ahd, STACK) << 8); in ahd_probe_stack_size()
9717 ahd_dump_card_state(struct ahd_softc *ahd) in ahd_dump_card_state() argument
9728 if (ahd_is_paused(ahd)) { in ahd_dump_card_state()
9732 ahd_pause(ahd); in ahd_dump_card_state()
9734 saved_modes = ahd_save_modes(ahd); in ahd_dump_card_state()
9735 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); in ahd_dump_card_state()
9738 ahd_name(ahd), in ahd_dump_card_state()
9739 ahd_inw(ahd, CURADDR), in ahd_dump_card_state()
9740 ahd_build_mode_state(ahd, ahd->saved_src_mode, in ahd_dump_card_state()
9741 ahd->saved_dst_mode)); in ahd_dump_card_state()
9745 if (ahd_check_cmdcmpltqueues(ahd)) in ahd_dump_card_state()
9752 ahd_intstat_print(ahd_inb(ahd, INTSTAT), &cur_col, 50); in ahd_dump_card_state()
9753 ahd_seloid_print(ahd_inb(ahd, SELOID), &cur_col, 50); in ahd_dump_card_state()
9754 ahd_selid_print(ahd_inb(ahd, SELID), &cur_col, 50); in ahd_dump_card_state()
9755 ahd_hs_mailbox_print(ahd_inb(ahd, LOCAL_HS_MAILBOX), &cur_col, 50); in ahd_dump_card_state()
9756 ahd_intctl_print(ahd_inb(ahd, INTCTL), &cur_col, 50); in ahd_dump_card_state()
9757 ahd_seqintstat_print(ahd_inb(ahd, SEQINTSTAT), &cur_col, 50); in ahd_dump_card_state()
9758 ahd_saved_mode_print(ahd_inb(ahd, SAVED_MODE), &cur_col, 50); in ahd_dump_card_state()
9759 ahd_dffstat_print(ahd_inb(ahd, DFFSTAT), &cur_col, 50); in ahd_dump_card_state()
9760 ahd_scsisigi_print(ahd_inb(ahd, SCSISIGI), &cur_col, 50); in ahd_dump_card_state()
9761 ahd_scsiphase_print(ahd_inb(ahd, SCSIPHASE), &cur_col, 50); in ahd_dump_card_state()
9762 ahd_scsibus_print(ahd_inb(ahd, SCSIBUS), &cur_col, 50); in ahd_dump_card_state()
9763 ahd_lastphase_print(ahd_inb(ahd, LASTPHASE), &cur_col, 50); in ahd_dump_card_state()
9764 ahd_scsiseq0_print(ahd_inb(ahd, SCSISEQ0), &cur_col, 50); in ahd_dump_card_state()
9765 ahd_scsiseq1_print(ahd_inb(ahd, SCSISEQ1), &cur_col, 50); in ahd_dump_card_state()
9766 ahd_seqctl0_print(ahd_inb(ahd, SEQCTL0), &cur_col, 50); in ahd_dump_card_state()
9767 ahd_seqintctl_print(ahd_inb(ahd, SEQINTCTL), &cur_col, 50); in ahd_dump_card_state()
9768 ahd_seq_flags_print(ahd_inb(ahd, SEQ_FLAGS), &cur_col, 50); in ahd_dump_card_state()
9769 ahd_seq_flags2_print(ahd_inb(ahd, SEQ_FLAGS2), &cur_col, 50); in ahd_dump_card_state()
9770 ahd_qfreeze_count_print(ahd_inw(ahd, QFREEZE_COUNT), &cur_col, 50); in ahd_dump_card_state()
9771 ahd_kernel_qfreeze_count_print(ahd_inw(ahd, KERNEL_QFREEZE_COUNT), in ahd_dump_card_state()
9773 ahd_mk_message_scb_print(ahd_inw(ahd, MK_MESSAGE_SCB), &cur_col, 50); in ahd_dump_card_state()
9774 ahd_mk_message_scsiid_print(ahd_inb(ahd, MK_MESSAGE_SCSIID), in ahd_dump_card_state()
9776 ahd_sstat0_print(ahd_inb(ahd, SSTAT0), &cur_col, 50); in ahd_dump_card_state()
9777 ahd_sstat1_print(ahd_inb(ahd, SSTAT1), &cur_col, 50); in ahd_dump_card_state()
9778 ahd_sstat2_print(ahd_inb(ahd, SSTAT2), &cur_col, 50); in ahd_dump_card_state()
9779 ahd_sstat3_print(ahd_inb(ahd, SSTAT3), &cur_col, 50); in ahd_dump_card_state()
9780 ahd_perrdiag_print(ahd_inb(ahd, PERRDIAG), &cur_col, 50); in ahd_dump_card_state()
9781 ahd_simode1_print(ahd_inb(ahd, SIMODE1), &cur_col, 50); in ahd_dump_card_state()
9782 ahd_lqistat0_print(ahd_inb(ahd, LQISTAT0), &cur_col, 50); in ahd_dump_card_state()
9783 ahd_lqistat1_print(ahd_inb(ahd, LQISTAT1), &cur_col, 50); in ahd_dump_card_state()
9784 ahd_lqistat2_print(ahd_inb(ahd, LQISTAT2), &cur_col, 50); in ahd_dump_card_state()
9785 ahd_lqostat0_print(ahd_inb(ahd, LQOSTAT0), &cur_col, 50); in ahd_dump_card_state()
9786 ahd_lqostat1_print(ahd_inb(ahd, LQOSTAT1), &cur_col, 50); in ahd_dump_card_state()
9787 ahd_lqostat2_print(ahd_inb(ahd, LQOSTAT2), &cur_col, 50); in ahd_dump_card_state()
9791 ahd->scb_data.numscbs, ahd_inw(ahd, CMDS_PENDING), in ahd_dump_card_state()
9792 ahd_inw(ahd, LASTSCB), ahd_inw(ahd, CURRSCB), in ahd_dump_card_state()
9793 ahd_inw(ahd, NEXTSCB)); in ahd_dump_card_state()
9796 ahd_search_qinfifo(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS, in ahd_dump_card_state()
9799 saved_scb_index = ahd_get_scbptr(ahd); in ahd_dump_card_state()
9802 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_dump_card_state()
9806 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT)); in ahd_dump_card_state()
9807 ahd_set_scbptr(ahd, SCB_GET_TAG(scb)); in ahd_dump_card_state()
9808 ahd_scb_control_print(ahd_inb_scbram(ahd, SCB_CONTROL), in ahd_dump_card_state()
9810 ahd_scb_scsiid_print(ahd_inb_scbram(ahd, SCB_SCSIID), in ahd_dump_card_state()
9817 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) { in ahd_dump_card_state()
9827 LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) { in ahd_dump_card_state()
9835 scb_index = ahd_inw(ahd, COMPLETE_SCB_DMAINPROG_HEAD); in ahd_dump_card_state()
9838 ahd_set_scbptr(ahd, scb_index); in ahd_dump_card_state()
9840 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_dump_card_state()
9845 scb_index = ahd_inw(ahd, COMPLETE_SCB_HEAD); in ahd_dump_card_state()
9848 ahd_set_scbptr(ahd, scb_index); in ahd_dump_card_state()
9850 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_dump_card_state()
9856 scb_index = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD); in ahd_dump_card_state()
9859 ahd_set_scbptr(ahd, scb_index); in ahd_dump_card_state()
9861 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_dump_card_state()
9865 scb_index = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD); in ahd_dump_card_state()
9868 ahd_set_scbptr(ahd, scb_index); in ahd_dump_card_state()
9870 scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE); in ahd_dump_card_state()
9873 ahd_set_scbptr(ahd, saved_scb_index); in ahd_dump_card_state()
9874 dffstat = ahd_inb(ahd, DFFSTAT); in ahd_dump_card_state()
9881 ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i); in ahd_dump_card_state()
9882 fifo_scbptr = ahd_get_scbptr(ahd); in ahd_dump_card_state()
9884 ahd_name(ahd), i, in ahd_dump_card_state()
9886 ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr); in ahd_dump_card_state()
9888 ahd_seqimode_print(ahd_inb(ahd, SEQIMODE), &cur_col, 50); in ahd_dump_card_state()
9889 ahd_seqintsrc_print(ahd_inb(ahd, SEQINTSRC), &cur_col, 50); in ahd_dump_card_state()
9890 ahd_dfcntrl_print(ahd_inb(ahd, DFCNTRL), &cur_col, 50); in ahd_dump_card_state()
9891 ahd_dfstatus_print(ahd_inb(ahd, DFSTATUS), &cur_col, 50); in ahd_dump_card_state()
9892 ahd_sg_cache_shadow_print(ahd_inb(ahd, SG_CACHE_SHADOW), in ahd_dump_card_state()
9894 ahd_sg_state_print(ahd_inb(ahd, SG_STATE), &cur_col, 50); in ahd_dump_card_state()
9895 ahd_dffsxfrctl_print(ahd_inb(ahd, DFFSXFRCTL), &cur_col, 50); in ahd_dump_card_state()
9896 ahd_soffcnt_print(ahd_inb(ahd, SOFFCNT), &cur_col, 50); in ahd_dump_card_state()
9897 ahd_mdffstat_print(ahd_inb(ahd, MDFFSTAT), &cur_col, 50); in ahd_dump_card_state()
9903 ahd_inl(ahd, SHADDR+4), in ahd_dump_card_state()
9904 ahd_inl(ahd, SHADDR), in ahd_dump_card_state()
9905 (ahd_inb(ahd, SHCNT) in ahd_dump_card_state()
9906 | (ahd_inb(ahd, SHCNT + 1) << 8) in ahd_dump_card_state()
9907 | (ahd_inb(ahd, SHCNT + 2) << 16))); in ahd_dump_card_state()
9913 ahd_inl(ahd, HADDR+4), in ahd_dump_card_state()
9914 ahd_inl(ahd, HADDR), in ahd_dump_card_state()
9915 (ahd_inb(ahd, HCNT) in ahd_dump_card_state()
9916 | (ahd_inb(ahd, HCNT + 1) << 8) in ahd_dump_card_state()
9917 | (ahd_inb(ahd, HCNT + 2) << 16))); in ahd_dump_card_state()
9918 ahd_ccsgctl_print(ahd_inb(ahd, CCSGCTL), &cur_col, 50); in ahd_dump_card_state()
9921 fifo_scb = ahd_lookup_scb(ahd, fifo_scbptr); in ahd_dump_card_state()
9929 printk("0x%x ", ahd_inb(ahd, LQIN + i)); in ahd_dump_card_state()
9931 ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG); in ahd_dump_card_state()
9933 ahd_name(ahd), ahd_inb(ahd, LQISTATE), ahd_inb(ahd, LQOSTATE), in ahd_dump_card_state()
9934 ahd_inb(ahd, OPTIONMODE)); in ahd_dump_card_state()
9936 ahd_name(ahd), ahd_inb(ahd, OS_SPACE_CNT), in ahd_dump_card_state()
9937 ahd_inb(ahd, MAXCMDCNT)); in ahd_dump_card_state()
9939 ahd_name(ahd), ahd_inb(ahd, SAVED_SCSIID), in ahd_dump_card_state()
9940 ahd_inb(ahd, SAVED_LUN)); in ahd_dump_card_state()
9941 ahd_simode0_print(ahd_inb(ahd, SIMODE0), &cur_col, 50); in ahd_dump_card_state()
9943 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); in ahd_dump_card_state()
9945 ahd_ccscbctl_print(ahd_inb(ahd, CCSCBCTL), &cur_col, 50); in ahd_dump_card_state()
9947 ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode); in ahd_dump_card_state()
9949 ahd_name(ahd), ahd_inw(ahd, REG0), ahd_inw(ahd, SINDEX), in ahd_dump_card_state()
9950 ahd_inw(ahd, DINDEX)); in ahd_dump_card_state()
9952 ahd_name(ahd), ahd_get_scbptr(ahd), in ahd_dump_card_state()
9953 ahd_inw_scbram(ahd, SCB_NEXT), in ahd_dump_card_state()
9954 ahd_inw_scbram(ahd, SCB_NEXT2)); in ahd_dump_card_state()
9956 ahd_inb_scbram(ahd, SCB_CDB_STORE), in ahd_dump_card_state()
9957 ahd_inb_scbram(ahd, SCB_CDB_STORE+1), in ahd_dump_card_state()
9958 ahd_inb_scbram(ahd, SCB_CDB_STORE+2), in ahd_dump_card_state()
9959 ahd_inb_scbram(ahd, SCB_CDB_STORE+3), in ahd_dump_card_state()
9960 ahd_inb_scbram(ahd, SCB_CDB_STORE+4), in ahd_dump_card_state()
9961 ahd_inb_scbram(ahd, SCB_CDB_STORE+5)); in ahd_dump_card_state()
9963 for (i = 0; i < ahd->stack_size; i++) { in ahd_dump_card_state()
9964 ahd->saved_stack[i] = in ahd_dump_card_state()
9965 ahd_inb(ahd, STACK)|(ahd_inb(ahd, STACK) << 8); in ahd_dump_card_state()
9966 printk(" 0x%x", ahd->saved_stack[i]); in ahd_dump_card_state()
9968 for (i = ahd->stack_size-1; i >= 0; i--) { in ahd_dump_card_state()
9969 ahd_outb(ahd, STACK, ahd->saved_stack[i] & 0xFF); in ahd_dump_card_state()
9970 ahd_outb(ahd, STACK, (ahd->saved_stack[i] >> 8) & 0xFF); in ahd_dump_card_state()
9973 ahd_restore_modes(ahd, saved_modes); in ahd_dump_card_state()
9975 ahd_unpause(ahd); in ahd_dump_card_state()
9980 ahd_dump_scbs(struct ahd_softc *ahd)
9986 saved_modes = ahd_save_modes(ahd);
9987 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
9988 saved_scb_index = ahd_get_scbptr(ahd);
9990 ahd_set_scbptr(ahd, i);
9993 ahd_inb_scbram(ahd, SCB_CONTROL),
9994 ahd_inb_scbram(ahd, SCB_SCSIID),
9995 ahd_inw_scbram(ahd, SCB_NEXT),
9996 ahd_inw_scbram(ahd, SCB_NEXT2),
9997 ahd_inl_scbram(ahd, SCB_SGPTR),
9998 ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR));
10001 ahd_set_scbptr(ahd, saved_scb_index);
10002 ahd_restore_modes(ahd, saved_modes);
10014 ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf, in ahd_read_seeprom() argument
10026 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_read_seeprom()
10030 ahd_outb(ahd, SEEADR, cur_addr); in ahd_read_seeprom()
10031 ahd_outb(ahd, SEECTL, SEEOP_READ | SEESTART); in ahd_read_seeprom()
10033 error = ahd_wait_seeprom(ahd); in ahd_read_seeprom()
10040 *bytestream_ptr++ = ahd_inb(ahd, SEEDAT); in ahd_read_seeprom()
10041 *bytestream_ptr = ahd_inb(ahd, SEEDAT+1); in ahd_read_seeprom()
10046 *buf = ahd_inw(ahd, SEEDAT); in ahd_read_seeprom()
10059 ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf, in ahd_write_seeprom() argument
10067 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_write_seeprom()
10071 ahd_outb(ahd, SEEADR, SEEOP_EWEN_ADDR); in ahd_write_seeprom()
10072 ahd_outb(ahd, SEECTL, SEEOP_EWEN | SEESTART); in ahd_write_seeprom()
10073 error = ahd_wait_seeprom(ahd); in ahd_write_seeprom()
10084 ahd_outw(ahd, SEEDAT, *buf++); in ahd_write_seeprom()
10085 ahd_outb(ahd, SEEADR, cur_addr); in ahd_write_seeprom()
10086 ahd_outb(ahd, SEECTL, SEEOP_WRITE | SEESTART); in ahd_write_seeprom()
10088 retval = ahd_wait_seeprom(ahd); in ahd_write_seeprom()
10096 ahd_outb(ahd, SEEADR, SEEOP_EWDS_ADDR); in ahd_write_seeprom()
10097 ahd_outb(ahd, SEECTL, SEEOP_EWDS | SEESTART); in ahd_write_seeprom()
10098 error = ahd_wait_seeprom(ahd); in ahd_write_seeprom()
10108 ahd_wait_seeprom(struct ahd_softc *ahd) in ahd_wait_seeprom() argument
10113 while ((ahd_inb(ahd, SEESTAT) & (SEEARBACK|SEEBUSY)) != 0 && --cnt) in ahd_wait_seeprom()
10176 ahd_acquire_seeprom(struct ahd_softc *ahd) in ahd_acquire_seeprom() argument
10190 error = ahd_read_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, &seetype); in ahd_acquire_seeprom()
10199 ahd_release_seeprom(struct ahd_softc *ahd) in ahd_release_seeprom() argument
10208 ahd_wait_flexport(struct ahd_softc *ahd) in ahd_wait_flexport() argument
10212 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_wait_flexport()
10214 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt) in ahd_wait_flexport()
10223 ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value) in ahd_write_flexport() argument
10227 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_write_flexport()
10230 ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3)); in ahd_write_flexport()
10231 error = ahd_wait_flexport(ahd); in ahd_write_flexport()
10234 ahd_outb(ahd, BRDDAT, value); in ahd_write_flexport()
10235 ahd_flush_device_writes(ahd); in ahd_write_flexport()
10236 ahd_outb(ahd, BRDCTL, BRDSTB|BRDEN|(addr << 3)); in ahd_write_flexport()
10237 ahd_flush_device_writes(ahd); in ahd_write_flexport()
10238 ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3)); in ahd_write_flexport()
10239 ahd_flush_device_writes(ahd); in ahd_write_flexport()
10240 ahd_outb(ahd, BRDCTL, 0); in ahd_write_flexport()
10241 ahd_flush_device_writes(ahd); in ahd_write_flexport()
10246 ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value) in ahd_read_flexport() argument
10250 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); in ahd_read_flexport()
10253 ahd_outb(ahd, BRDCTL, BRDRW|BRDEN|(addr << 3)); in ahd_read_flexport()
10254 error = ahd_wait_flexport(ahd); in ahd_read_flexport()
10257 *value = ahd_inb(ahd, BRDDAT); in ahd_read_flexport()
10258 ahd_outb(ahd, BRDCTL, 0); in ahd_read_flexport()
10259 ahd_flush_device_writes(ahd); in ahd_read_flexport()
10266 ahd_find_tmode_devs(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb, in ahd_find_tmode_devs() argument
10272 if ((ahd->features & AHD_TARGETMODE) == 0) in ahd_find_tmode_devs()
10282 *lstate = ahd->black_hole; in ahd_find_tmode_devs()
10286 max_id = (ahd->features & AHD_WIDE) ? 16 : 8; in ahd_find_tmode_devs()
10293 *tstate = ahd->enabled_targets[ccb->ccb_h.target_id]; in ahd_find_tmode_devs()
10307 ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb) in ahd_handle_en_lun() argument
10320 status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate, &lstate, in ahd_handle_en_lun()
10328 if ((ahd->features & AHD_MULTIROLE) != 0) { in ahd_handle_en_lun()
10331 our_id = ahd->our_id; in ahd_handle_en_lun()
10333 if ((ahd->features & AHD_MULTI_TID) != 0 in ahd_handle_en_lun()
10334 && (ahd->flags & AHD_INITIATORROLE) != 0) { in ahd_handle_en_lun()
10343 } else if ((ahd->flags & AHD_INITIATORROLE) != 0 in ahd_handle_en_lun()
10344 || ahd->enabled_luns > 0) { in ahd_handle_en_lun()
10366 if ((ahd->flags & AHD_TARGETROLE) == 0 in ahd_handle_en_lun()
10371 ahd_lock(ahd, &s); in ahd_handle_en_lun()
10372 if (LIST_FIRST(&ahd->pending_scbs) != NULL) { in ahd_handle_en_lun()
10374 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10377 ahd->flags |= AHD_TARGETROLE; in ahd_handle_en_lun()
10378 if ((ahd->features & AHD_MULTIROLE) == 0) in ahd_handle_en_lun()
10379 ahd->flags &= ~AHD_INITIATORROLE; in ahd_handle_en_lun()
10380 ahd_pause(ahd); in ahd_handle_en_lun()
10381 ahd_loadseq(ahd); in ahd_handle_en_lun()
10382 ahd_restart(ahd); in ahd_handle_en_lun()
10383 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10388 channel = SIM_CHANNEL(ahd, sim); in ahd_handle_en_lun()
10420 tstate = ahd_alloc_tstate(ahd, target, channel); in ahd_handle_en_lun()
10448 ahd_lock(ahd, &s); in ahd_handle_en_lun()
10449 ahd_pause(ahd); in ahd_handle_en_lun()
10452 ahd->enabled_luns++; in ahd_handle_en_lun()
10454 if ((ahd->features & AHD_MULTI_TID) != 0) { in ahd_handle_en_lun()
10457 targid_mask = ahd_inw(ahd, TARGID); in ahd_handle_en_lun()
10459 ahd_outw(ahd, TARGID, targid_mask); in ahd_handle_en_lun()
10460 ahd_update_scsiid(ahd, targid_mask); in ahd_handle_en_lun()
10465 channel = SIM_CHANNEL(ahd, sim); in ahd_handle_en_lun()
10466 our_id = SIM_SCSI_ID(ahd, sim); in ahd_handle_en_lun()
10477 sblkctl = ahd_inb(ahd, SBLKCTL); in ahd_handle_en_lun()
10480 if ((ahd->features & AHD_TWIN) == 0) in ahd_handle_en_lun()
10483 ahd->our_id = target; in ahd_handle_en_lun()
10486 ahd_outb(ahd, SBLKCTL, in ahd_handle_en_lun()
10489 ahd_outb(ahd, SCSIID, target); in ahd_handle_en_lun()
10492 ahd_outb(ahd, SBLKCTL, sblkctl); in ahd_handle_en_lun()
10496 ahd->black_hole = lstate; in ahd_handle_en_lun()
10498 if (ahd->black_hole != NULL && ahd->enabled_luns > 0) { in ahd_handle_en_lun()
10499 scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE); in ahd_handle_en_lun()
10501 ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1); in ahd_handle_en_lun()
10502 scsiseq1 = ahd_inb(ahd, SCSISEQ1); in ahd_handle_en_lun()
10504 ahd_outb(ahd, SCSISEQ1, scsiseq1); in ahd_handle_en_lun()
10506 ahd_unpause(ahd); in ahd_handle_en_lun()
10507 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10520 ahd_lock(ahd, &s); in ahd_handle_en_lun()
10523 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_handle_en_lun()
10531 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10547 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10556 ahd_pause(ahd); in ahd_handle_en_lun()
10560 ahd->enabled_luns--; in ahd_handle_en_lun()
10568 ahd_free_tstate(ahd, target, channel, in ahd_handle_en_lun()
10570 if (ahd->features & AHD_MULTI_TID) { in ahd_handle_en_lun()
10573 targid_mask = ahd_inw(ahd, TARGID); in ahd_handle_en_lun()
10575 ahd_outw(ahd, TARGID, targid_mask); in ahd_handle_en_lun()
10576 ahd_update_scsiid(ahd, targid_mask); in ahd_handle_en_lun()
10581 ahd->black_hole = NULL; in ahd_handle_en_lun()
10589 if (ahd->enabled_luns == 0) { in ahd_handle_en_lun()
10593 scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE); in ahd_handle_en_lun()
10595 ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1); in ahd_handle_en_lun()
10596 scsiseq1 = ahd_inb(ahd, SCSISEQ1); in ahd_handle_en_lun()
10598 ahd_outb(ahd, SCSISEQ1, scsiseq1); in ahd_handle_en_lun()
10600 if ((ahd->features & AHD_MULTIROLE) == 0) { in ahd_handle_en_lun()
10602 ahd->flags &= ~AHD_TARGETROLE; in ahd_handle_en_lun()
10603 ahd->flags |= AHD_INITIATORROLE; in ahd_handle_en_lun()
10604 ahd_pause(ahd); in ahd_handle_en_lun()
10605 ahd_loadseq(ahd); in ahd_handle_en_lun()
10606 ahd_restart(ahd); in ahd_handle_en_lun()
10613 ahd_unpause(ahd); in ahd_handle_en_lun()
10614 ahd_unlock(ahd, &s); in ahd_handle_en_lun()
10620 ahd_update_scsiid(struct ahd_softc *ahd, u_int targid_mask) in ahd_update_scsiid() argument
10626 if ((ahd->features & AHD_MULTI_TID) == 0) in ahd_update_scsiid()
10635 if ((ahd->features & AHD_ULTRA2) != 0) in ahd_update_scsiid()
10636 scsiid = ahd_inb(ahd, SCSIID_ULTRA2); in ahd_update_scsiid()
10638 scsiid = ahd_inb(ahd, SCSIID); in ahd_update_scsiid()
10646 our_id = ahd->our_id; in ahd_update_scsiid()
10652 if ((ahd->features & AHD_ULTRA2) != 0) in ahd_update_scsiid()
10653 ahd_outb(ahd, SCSIID_ULTRA2, scsiid); in ahd_update_scsiid()
10655 ahd_outb(ahd, SCSIID, scsiid); in ahd_update_scsiid()
10660 ahd_run_tqinfifo(struct ahd_softc *ahd, int paused) in ahd_run_tqinfifo() argument
10664 ahd_sync_tqinfifo(ahd, BUS_DMASYNC_POSTREAD); in ahd_run_tqinfifo()
10665 while ((cmd = &ahd->targetcmds[ahd->tqinfifonext])->cmd_valid != 0) { in ahd_run_tqinfifo()
10671 if (ahd_handle_target_cmd(ahd, cmd) != 0) in ahd_run_tqinfifo()
10675 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, in ahd_run_tqinfifo()
10676 ahd->shared_data_map.dmamap, in ahd_run_tqinfifo()
10677 ahd_targetcmd_offset(ahd, ahd->tqinfifonext), in ahd_run_tqinfifo()
10680 ahd->tqinfifonext++; in ahd_run_tqinfifo()
10686 if ((ahd->tqinfifonext & (HOST_TQINPOS - 1)) == 1) { in ahd_run_tqinfifo()
10689 hs_mailbox = ahd_inb(ahd, HS_MAILBOX); in ahd_run_tqinfifo()
10691 hs_mailbox |= ahd->tqinfifonext & HOST_TQINPOS; in ahd_run_tqinfifo()
10692 ahd_outb(ahd, HS_MAILBOX, hs_mailbox); in ahd_run_tqinfifo()
10698 ahd_handle_target_cmd(struct ahd_softc *ahd, struct target_cmd *cmd) in ahd_handle_target_cmd() argument
10708 initiator = SCSIID_TARGET(ahd, cmd->scsiid); in ahd_handle_target_cmd()
10713 tstate = ahd->enabled_targets[target]; in ahd_handle_target_cmd()
10722 lstate = ahd->black_hole; in ahd_handle_target_cmd()
10726 ahd->flags |= AHD_TQINFIFO_BLOCKED; in ahd_handle_target_cmd()
10732 ahd->flags &= ~AHD_TQINFIFO_BLOCKED; in ahd_handle_target_cmd()
10737 lstate == ahd->black_hole ? "(Black Holed)" : ""); in ahd_handle_target_cmd()
10741 if (lstate == ahd->black_hole) { in ahd_handle_target_cmd()
10800 initiator, target, lun, ahd->pending_device); in ahd_handle_target_cmd()
10802 ahd->pending_device = lstate; in ahd_handle_target_cmd()