Lines Matching full:hba
77 static int hptiop_send_sync_msg(struct hpt_iop_hba *hba,
79 static void hptiop_request_callback_itl(struct hpt_iop_hba *hba,
81 static void hptiop_request_callback_mv(struct hpt_iop_hba *hba, u_int64_t req);
82 static void hptiop_request_callback_mvfrey(struct hpt_iop_hba *hba,
84 static void hptiop_os_message_callback(struct hpt_iop_hba *hba, u_int32_t msg);
85 static int hptiop_do_ioctl_itl(struct hpt_iop_hba *hba,
87 static int hptiop_do_ioctl_mv(struct hpt_iop_hba *hba,
89 static int hptiop_do_ioctl_mvfrey(struct hpt_iop_hba *hba,
91 static int hptiop_rescan_bus(struct hpt_iop_hba *hba);
92 static int hptiop_alloc_pci_res_itl(struct hpt_iop_hba *hba);
93 static int hptiop_alloc_pci_res_mv(struct hpt_iop_hba *hba);
94 static int hptiop_alloc_pci_res_mvfrey(struct hpt_iop_hba *hba);
95 static int hptiop_get_config_itl(struct hpt_iop_hba *hba,
97 static int hptiop_get_config_mv(struct hpt_iop_hba *hba,
99 static int hptiop_get_config_mvfrey(struct hpt_iop_hba *hba,
101 static int hptiop_set_config_itl(struct hpt_iop_hba *hba,
103 static int hptiop_set_config_mv(struct hpt_iop_hba *hba,
105 static int hptiop_set_config_mvfrey(struct hpt_iop_hba *hba,
107 static int hptiop_internal_memalloc_mv(struct hpt_iop_hba *hba);
108 static int hptiop_internal_memalloc_mvfrey(struct hpt_iop_hba *hba);
109 static int hptiop_internal_memfree_itl(struct hpt_iop_hba *hba);
110 static int hptiop_internal_memfree_mv(struct hpt_iop_hba *hba);
111 static int hptiop_internal_memfree_mvfrey(struct hpt_iop_hba *hba);
112 static int hptiop_post_ioctl_command_itl(struct hpt_iop_hba *hba,
114 static int hptiop_post_ioctl_command_mv(struct hpt_iop_hba *hba,
117 static int hptiop_post_ioctl_command_mvfrey(struct hpt_iop_hba *hba,
120 static void hptiop_post_req_itl(struct hpt_iop_hba *hba,
123 static void hptiop_post_req_mv(struct hpt_iop_hba *hba,
126 static void hptiop_post_req_mvfrey(struct hpt_iop_hba *hba,
129 static void hptiop_post_msg_itl(struct hpt_iop_hba *hba, u_int32_t msg);
130 static void hptiop_post_msg_mv(struct hpt_iop_hba *hba, u_int32_t msg);
131 static void hptiop_post_msg_mvfrey(struct hpt_iop_hba *hba, u_int32_t msg);
132 static void hptiop_enable_intr_itl(struct hpt_iop_hba *hba);
133 static void hptiop_enable_intr_mv(struct hpt_iop_hba *hba);
134 static void hptiop_enable_intr_mvfrey(struct hpt_iop_hba *hba);
135 static void hptiop_disable_intr_itl(struct hpt_iop_hba *hba);
136 static void hptiop_disable_intr_mv(struct hpt_iop_hba *hba);
137 static void hptiop_disable_intr_mvfrey(struct hpt_iop_hba *hba);
138 static void hptiop_free_srb(struct hpt_iop_hba *hba, struct hpt_iop_srb *srb);
139 static int hptiop_os_query_remove_device(struct hpt_iop_hba *hba, int tid);
149 static void hptiop_release_resource(struct hpt_iop_hba *hba);
166 #define BUS_SPACE_WRT4_ITL(offset, value) bus_space_write_4(hba->bar0t,\
167 hba->bar0h, offsetof(struct hpt_iopmu_itl, offset), (value))
168 #define BUS_SPACE_RD4_ITL(offset) bus_space_read_4(hba->bar0t,\
169 hba->bar0h, offsetof(struct hpt_iopmu_itl, offset))
171 #define BUS_SPACE_WRT4_MV0(offset, value) bus_space_write_4(hba->bar0t,\
172 hba->bar0h, offsetof(struct hpt_iopmv_regs, offset), value)
173 #define BUS_SPACE_RD4_MV0(offset) bus_space_read_4(hba->bar0t,\
174 hba->bar0h, offsetof(struct hpt_iopmv_regs, offset))
175 #define BUS_SPACE_WRT4_MV2(offset, value) bus_space_write_4(hba->bar2t,\
176 hba->bar2h, offsetof(struct hpt_iopmu_mv, offset), value)
177 #define BUS_SPACE_RD4_MV2(offset) bus_space_read_4(hba->bar2t,\
178 hba->bar2h, offsetof(struct hpt_iopmu_mv, offset))
180 #define BUS_SPACE_WRT4_MVFREY2(offset, value) bus_space_write_4(hba->bar2t,\
181 hba->bar2h, offsetof(struct hpt_iopmu_mvfrey, offset), value)
182 #define BUS_SPACE_RD4_MVFREY2(offset) bus_space_read_4(hba->bar2t,\
183 hba->bar2h, offsetof(struct hpt_iopmu_mvfrey, offset))
188 struct hpt_iop_hba *hba = hba_from_dev(dev); in hptiop_open() local
190 if (hba==NULL) in hptiop_open()
192 if (hba->flag & HPT_IOCTL_FLAG_OPEN) in hptiop_open()
194 hba->flag |= HPT_IOCTL_FLAG_OPEN; in hptiop_open()
201 struct hpt_iop_hba *hba = hba_from_dev(dev); in hptiop_close() local
202 hba->flag &= ~(u_int32_t)HPT_IOCTL_FLAG_OPEN; in hptiop_close()
210 struct hpt_iop_hba *hba = hba_from_dev(dev); in hptiop_ioctl() local
214 ret = hba->ops->do_ioctl(hba, in hptiop_ioctl()
218 ret = hptiop_rescan_bus(hba); in hptiop_ioctl()
224 static u_int64_t hptiop_mv_outbound_read(struct hpt_iop_hba *hba) in hptiop_mv_outbound_read() argument
231 bus_space_read_region_4(hba->bar2t, hba->bar2h, in hptiop_mv_outbound_read()
247 static void hptiop_mv_inbound_write(u_int64_t p, struct hpt_iop_hba *hba) in hptiop_mv_inbound_write() argument
255 bus_space_write_region_4(hba->bar2t, hba->bar2h, in hptiop_mv_inbound_write()
262 static void hptiop_post_msg_itl(struct hpt_iop_hba *hba, u_int32_t msg) in hptiop_post_msg_itl() argument
268 static void hptiop_post_msg_mv(struct hpt_iop_hba *hba, u_int32_t msg) in hptiop_post_msg_mv() argument
277 static void hptiop_post_msg_mvfrey(struct hpt_iop_hba *hba, u_int32_t msg) in hptiop_post_msg_mvfrey() argument
283 static int hptiop_wait_ready_itl(struct hpt_iop_hba * hba, u_int32_t millisec) in hptiop_wait_ready_itl() argument
304 static int hptiop_wait_ready_mv(struct hpt_iop_hba * hba, u_int32_t millisec) in hptiop_wait_ready_mv() argument
306 if (hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec)) in hptiop_wait_ready_mv()
312 static int hptiop_wait_ready_mvfrey(struct hpt_iop_hba * hba, in hptiop_wait_ready_mvfrey() argument
315 if (hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec)) in hptiop_wait_ready_mvfrey()
321 static void hptiop_request_callback_itl(struct hpt_iop_hba * hba, in hptiop_request_callback_itl() argument
332 if (hba->firmware_version > 0x01020000 || in hptiop_request_callback_itl()
333 hba->interface_version > 0x01020000) { in hptiop_request_callback_itl()
334 srb = hba->srb[index & ~(u_int32_t) in hptiop_request_callback_itl()
343 srb = hba->srb[index & in hptiop_request_callback_itl()
353 temp = bus_space_read_4(hba->bar0t, hba->bar0h, index + in hptiop_request_callback_itl()
355 result = bus_space_read_4(hba->bar0t, hba->bar0h, index + in hptiop_request_callback_itl()
361 bus_space_write_region_4(hba->bar0t, hba->bar0h, index + in hptiop_request_callback_itl()
364 wakeup((void *)((unsigned long)hba->u.itl.mu + index)); in hptiop_request_callback_itl()
369 bus_space_read_region_4(hba->bar0t, hba->bar0h, index + in hptiop_request_callback_itl()
373 dxfer = bus_space_read_4(hba->bar0t, hba->bar0h, in hptiop_request_callback_itl()
392 bus_dmamap_sync(hba->io_dmat, in hptiop_request_callback_itl()
394 bus_dmamap_unload(hba->io_dmat, srb->dma_map); in hptiop_request_callback_itl()
397 bus_dmamap_sync(hba->io_dmat, in hptiop_request_callback_itl()
399 bus_dmamap_unload(hba->io_dmat, srb->dma_map); in hptiop_request_callback_itl()
430 bus_space_read_region_1(hba->bar0t, hba->bar0h, in hptiop_request_callback_itl()
452 hptiop_free_srb(hba, srb); in hptiop_request_callback_itl()
458 static void hptiop_drain_outbound_queue_itl(struct hpt_iop_hba *hba) in hptiop_drain_outbound_queue_itl() argument
464 hptiop_request_callback_itl(hba, req); in hptiop_drain_outbound_queue_itl()
466 temp = bus_space_read_4(hba->bar0t, in hptiop_drain_outbound_queue_itl()
467 hba->bar0h,req + in hptiop_drain_outbound_queue_itl()
472 bus_space_read_region_4(hba->bar0t, in hptiop_drain_outbound_queue_itl()
473 hba->bar0h,req + in hptiop_drain_outbound_queue_itl()
478 hptiop_request_callback_itl(hba, req); in hptiop_drain_outbound_queue_itl()
481 bus_space_write_region_4(hba->bar0t, in hptiop_drain_outbound_queue_itl()
482 hba->bar0h,req + in hptiop_drain_outbound_queue_itl()
488 hptiop_request_callback_itl(hba, req); in hptiop_drain_outbound_queue_itl()
493 static int hptiop_intr_itl(struct hpt_iop_hba * hba) in hptiop_intr_itl() argument
504 hptiop_os_message_callback(hba, msg); in hptiop_intr_itl()
509 hptiop_drain_outbound_queue_itl(hba); in hptiop_intr_itl()
516 static void hptiop_request_callback_mv(struct hpt_iop_hba * hba, in hptiop_request_callback_mv() argument
527 srb = hba->srb[context >> MVIOP_REQUEST_NUMBER_START_BIT]; in hptiop_request_callback_mv()
546 bus_dmamap_sync(hba->io_dmat, in hptiop_request_callback_mv()
548 bus_dmamap_unload(hba->io_dmat, srb->dma_map); in hptiop_request_callback_mv()
551 bus_dmamap_sync(hba->io_dmat, in hptiop_request_callback_mv()
553 bus_dmamap_unload(hba->io_dmat, srb->dma_map); in hptiop_request_callback_mv()
594 hptiop_free_srb(hba, srb); in hptiop_request_callback_mv()
597 struct hpt_iop_request_ioctl_command *req = hba->ctlcfg_ptr; in hptiop_request_callback_mv()
599 hba->config_done = 1; in hptiop_request_callback_mv()
601 hba->config_done = -1; in hptiop_request_callback_mv()
606 hba->config_done = 1; in hptiop_request_callback_mv()
608 device_printf(hba->pcidev, "wrong callback type\n"); in hptiop_request_callback_mv()
612 static void hptiop_request_callback_mvfrey(struct hpt_iop_hba * hba, in hptiop_request_callback_mvfrey() argument
625 hba->config_done = 1; in hptiop_request_callback_mvfrey()
629 srb = hba->srb[(_tag >> 4) & 0xff]; in hptiop_request_callback_mvfrey()
653 bus_dmamap_sync(hba->io_dmat, in hptiop_request_callback_mvfrey()
655 bus_dmamap_unload(hba->io_dmat, srb->dma_map); in hptiop_request_callback_mvfrey()
658 bus_dmamap_sync(hba->io_dmat, in hptiop_request_callback_mvfrey()
660 bus_dmamap_unload(hba->io_dmat, srb->dma_map); in hptiop_request_callback_mvfrey()
701 hptiop_free_srb(hba, srb); in hptiop_request_callback_mvfrey()
706 hba->config_done = 1; in hptiop_request_callback_mvfrey()
708 hba->config_done = -1; in hptiop_request_callback_mvfrey()
709 wakeup((struct hpt_iop_request_ioctl_command *)hba->ctlcfg_ptr); in hptiop_request_callback_mvfrey()
712 device_printf(hba->pcidev, "wrong callback type\n"); in hptiop_request_callback_mvfrey()
717 static void hptiop_drain_outbound_queue_mv(struct hpt_iop_hba * hba) in hptiop_drain_outbound_queue_mv() argument
721 while ((req = hptiop_mv_outbound_read(hba))) { in hptiop_drain_outbound_queue_mv()
724 hptiop_request_callback_mv(hba, req); in hptiop_drain_outbound_queue_mv()
730 static int hptiop_intr_mv(struct hpt_iop_hba * hba) in hptiop_intr_mv() argument
743 hptiop_os_message_callback(hba, msg); in hptiop_intr_mv()
748 hptiop_drain_outbound_queue_mv(hba); in hptiop_intr_mv()
755 static int hptiop_intr_mvfrey(struct hpt_iop_hba * hba) in hptiop_intr_mvfrey() argument
760 if (hba->initialized) { in hptiop_intr_mvfrey()
769 hptiop_os_message_callback(hba, msg); in hptiop_intr_mvfrey()
778 cptr = *hba->u.mvfrey.outlist_cptr & 0xff; in hptiop_intr_mvfrey()
779 while (hba->u.mvfrey.outlist_rptr != cptr) { in hptiop_intr_mvfrey()
780 hba->u.mvfrey.outlist_rptr++; in hptiop_intr_mvfrey()
781 if (hba->u.mvfrey.outlist_rptr == hba->u.mvfrey.list_count) { in hptiop_intr_mvfrey()
782 hba->u.mvfrey.outlist_rptr = 0; in hptiop_intr_mvfrey()
785 _tag = hba->u.mvfrey.outlist[hba->u.mvfrey.outlist_rptr].val; in hptiop_intr_mvfrey()
786 hptiop_request_callback_mvfrey(hba, _tag); in hptiop_intr_mvfrey()
789 } while (cptr != (*hba->u.mvfrey.outlist_cptr & 0xff)); in hptiop_intr_mvfrey()
792 if (hba->initialized) { in hptiop_intr_mvfrey()
799 static int hptiop_send_sync_request_itl(struct hpt_iop_hba * hba, in hptiop_send_sync_request_itl() argument
809 hptiop_intr_itl(hba); in hptiop_send_sync_request_itl()
810 bus_space_read_region_4(hba->bar0t, hba->bar0h, req32 + in hptiop_send_sync_request_itl()
821 static int hptiop_send_sync_request_mv(struct hpt_iop_hba *hba, in hptiop_send_sync_request_mv() argument
826 hba->config_done = 0; in hptiop_send_sync_request_mv()
828 phy_addr = hba->ctlcfgcmd_phy | in hptiop_send_sync_request_mv()
833 hptiop_mv_inbound_write(phy_addr, hba); in hptiop_send_sync_request_mv()
837 hptiop_intr_mv(hba); in hptiop_send_sync_request_mv()
838 if (hba->config_done) in hptiop_send_sync_request_mv()
845 static int hptiop_send_sync_request_mvfrey(struct hpt_iop_hba *hba, in hptiop_send_sync_request_mvfrey() argument
853 hba->config_done = 0; in hptiop_send_sync_request_mvfrey()
855 phy_addr = hba->ctlcfgcmd_phy; in hptiop_send_sync_request_mvfrey()
863 hba->u.mvfrey.inlist_wptr++; in hptiop_send_sync_request_mvfrey()
864 index = hba->u.mvfrey.inlist_wptr & 0x3fff; in hptiop_send_sync_request_mvfrey()
866 if (index == hba->u.mvfrey.list_count) { in hptiop_send_sync_request_mvfrey()
868 hba->u.mvfrey.inlist_wptr &= ~0x3fff; in hptiop_send_sync_request_mvfrey()
869 hba->u.mvfrey.inlist_wptr ^= CL_POINTER_TOGGLE; in hptiop_send_sync_request_mvfrey()
872 hba->u.mvfrey.inlist[index].addr = phy_addr; in hptiop_send_sync_request_mvfrey()
873 hba->u.mvfrey.inlist[index].intrfc_len = (reqhdr->size + 3) / 4; in hptiop_send_sync_request_mvfrey()
875 BUS_SPACE_WRT4_MVFREY2(inbound_write_ptr, hba->u.mvfrey.inlist_wptr); in hptiop_send_sync_request_mvfrey()
879 hptiop_intr_mvfrey(hba); in hptiop_send_sync_request_mvfrey()
880 if (hba->config_done) in hptiop_send_sync_request_mvfrey()
887 static int hptiop_send_sync_msg(struct hpt_iop_hba *hba, in hptiop_send_sync_msg() argument
892 hba->msg_done = 0; in hptiop_send_sync_msg()
893 hba->ops->post_msg(hba, msg); in hptiop_send_sync_msg()
896 hba->ops->iop_intr(hba); in hptiop_send_sync_msg()
897 if (hba->msg_done) in hptiop_send_sync_msg()
902 return hba->msg_done? 0 : -1; in hptiop_send_sync_msg()
905 static int hptiop_get_config_itl(struct hpt_iop_hba * hba, in hptiop_get_config_itl() argument
920 bus_space_write_region_4(hba->bar0t, hba->bar0h, in hptiop_get_config_itl()
924 if (hptiop_send_sync_request_itl(hba, req32, 20000)) { in hptiop_get_config_itl()
929 bus_space_read_region_4(hba->bar0t, hba->bar0h, in hptiop_get_config_itl()
938 static int hptiop_get_config_mv(struct hpt_iop_hba * hba, in hptiop_get_config_mv() argument
943 if (!(req = hba->ctlcfg_ptr)) in hptiop_get_config_mv()
952 if (hptiop_send_sync_request_mv(hba, req, 20000)) { in hptiop_get_config_mv()
961 static int hptiop_get_config_mvfrey(struct hpt_iop_hba * hba, in hptiop_get_config_mvfrey() argument
964 struct hpt_iop_request_get_config *info = hba->u.mvfrey.config; in hptiop_get_config_mvfrey()
992 static int hptiop_set_config_itl(struct hpt_iop_hba *hba, in hptiop_set_config_itl() argument
1008 bus_space_write_region_4(hba->bar0t, hba->bar0h, req32, in hptiop_set_config_itl()
1012 if (hptiop_send_sync_request_itl(hba, req32, 20000)) { in hptiop_set_config_itl()
1022 static int hptiop_set_config_mv(struct hpt_iop_hba *hba, in hptiop_set_config_mv() argument
1027 if (!(req = hba->ctlcfg_ptr)) in hptiop_set_config_mv()
1041 if (hptiop_send_sync_request_mv(hba, req, 20000)) { in hptiop_set_config_mv()
1049 static int hptiop_set_config_mvfrey(struct hpt_iop_hba *hba, in hptiop_set_config_mvfrey() argument
1054 if (!(req = hba->ctlcfg_ptr)) in hptiop_set_config_mvfrey()
1066 if (hptiop_send_sync_request_mvfrey(hba, req, 20000)) { in hptiop_set_config_mvfrey()
1074 static int hptiop_post_ioctl_command_itl(struct hpt_iop_hba *hba, in hptiop_post_ioctl_command_itl() argument
1082 (hba->max_request_size - in hptiop_post_ioctl_command_itl()
1084 device_printf(hba->pcidev, "request size beyond max value"); in hptiop_post_ioctl_command_itl()
1093 req.header.context = req32 + (u_int64_t)(unsigned long)hba->u.itl.mu; in hptiop_post_ioctl_command_itl()
1099 bus_space_write_region_4(hba->bar0t, hba->bar0h, req32, (u_int32_t *)&req, in hptiop_post_ioctl_command_itl()
1102 hptiop_lock_adapter(hba); in hptiop_post_ioctl_command_itl()
1107 bus_space_read_region_4(hba->bar0t, hba->bar0h, req32 + in hptiop_post_ioctl_command_itl()
1111 if (hptiop_sleep(hba, (void *)((unsigned long)hba->u.itl.mu + req32), in hptiop_post_ioctl_command_itl()
1114 hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET, 60000); in hptiop_post_ioctl_command_itl()
1115 bus_space_read_region_4(hba->bar0t, hba->bar0h,req32 + in hptiop_post_ioctl_command_itl()
1121 hptiop_unlock_adapter(hba); in hptiop_post_ioctl_command_itl()
1125 static int hptiop_bus_space_copyin(struct hpt_iop_hba *hba, u_int32_t bus, in hptiop_bus_space_copyin() argument
1134 bus_space_write_1(hba->bar0t, hba->bar0h, bus + i, byte); in hptiop_bus_space_copyin()
1140 static int hptiop_bus_space_copyout(struct hpt_iop_hba *hba, u_int32_t bus, in hptiop_bus_space_copyout() argument
1147 byte = bus_space_read_1(hba->bar0t, hba->bar0h, bus + i); in hptiop_bus_space_copyout()
1155 static int hptiop_do_ioctl_itl(struct hpt_iop_hba *hba, in hptiop_do_ioctl_itl() argument
1170 if (hptiop_bus_space_copyin(hba, req32 + in hptiop_do_ioctl_itl()
1175 if (hptiop_post_ioctl_command_itl(hba, req32, pParams)) in hptiop_do_ioctl_itl()
1178 result = bus_space_read_4(hba->bar0t, hba->bar0h, req32 + in hptiop_do_ioctl_itl()
1184 if (hptiop_bus_space_copyout(hba, req32 + in hptiop_do_ioctl_itl()
1191 if (hptiop_bus_space_copyout(hba, req32 + in hptiop_do_ioctl_itl()
1208 static int hptiop_post_ioctl_command_mv(struct hpt_iop_hba *hba, in hptiop_post_ioctl_command_mv() argument
1216 (hba->max_request_size - in hptiop_post_ioctl_command_mv()
1218 device_printf(hba->pcidev, "request size beyond max value"); in hptiop_post_ioctl_command_mv()
1233 req_phy = hba->ctlcfgcmd_phy | MVIOP_MU_QUEUE_ADDR_HOST_BIT | size; in hptiop_post_ioctl_command_mv()
1234 hptiop_mv_inbound_write(req_phy, hba); in hptiop_post_ioctl_command_mv()
1238 while (hba->config_done == 0) { in hptiop_post_ioctl_command_mv()
1239 if (hptiop_sleep(hba, req, PPAUSE, in hptiop_post_ioctl_command_mv()
1242 hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET, 60000); in hptiop_post_ioctl_command_mv()
1247 static int hptiop_do_ioctl_mv(struct hpt_iop_hba *hba, in hptiop_do_ioctl_mv() argument
1256 req = (struct hpt_iop_request_ioctl_command *)(hba->ctlcfg_ptr); in hptiop_do_ioctl_mv()
1257 hba->config_done = 0; in hptiop_do_ioctl_mv()
1258 hptiop_lock_adapter(hba); in hptiop_do_ioctl_mv()
1263 if (hptiop_post_ioctl_command_mv(hba, req, pParams)) in hptiop_do_ioctl_mv()
1266 if (hba->config_done == 1) { in hptiop_do_ioctl_mv()
1279 hptiop_unlock_adapter(hba); in hptiop_do_ioctl_mv()
1283 hptiop_unlock_adapter(hba); in hptiop_do_ioctl_mv()
1288 static int hptiop_post_ioctl_command_mvfrey(struct hpt_iop_hba *hba, in hptiop_post_ioctl_command_mvfrey() argument
1295 phy_addr = hba->ctlcfgcmd_phy; in hptiop_post_ioctl_command_mvfrey()
1298 (hba->max_request_size - in hptiop_post_ioctl_command_mvfrey()
1300 device_printf(hba->pcidev, "request size beyond max value"); in hptiop_post_ioctl_command_mvfrey()
1320 hba->u.mvfrey.inlist_wptr++; in hptiop_post_ioctl_command_mvfrey()
1321 index = hba->u.mvfrey.inlist_wptr & 0x3fff; in hptiop_post_ioctl_command_mvfrey()
1323 if (index == hba->u.mvfrey.list_count) { in hptiop_post_ioctl_command_mvfrey()
1325 hba->u.mvfrey.inlist_wptr &= ~0x3fff; in hptiop_post_ioctl_command_mvfrey()
1326 hba->u.mvfrey.inlist_wptr ^= CL_POINTER_TOGGLE; in hptiop_post_ioctl_command_mvfrey()
1329 hba->u.mvfrey.inlist[index].addr = phy_addr; in hptiop_post_ioctl_command_mvfrey()
1330 hba->u.mvfrey.inlist[index].intrfc_len = (req->header.size + 3) / 4; in hptiop_post_ioctl_command_mvfrey()
1332 BUS_SPACE_WRT4_MVFREY2(inbound_write_ptr, hba->u.mvfrey.inlist_wptr); in hptiop_post_ioctl_command_mvfrey()
1335 while (hba->config_done == 0) { in hptiop_post_ioctl_command_mvfrey()
1336 if (hptiop_sleep(hba, req, PPAUSE, in hptiop_post_ioctl_command_mvfrey()
1339 hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET, 60000); in hptiop_post_ioctl_command_mvfrey()
1344 static int hptiop_do_ioctl_mvfrey(struct hpt_iop_hba *hba, in hptiop_do_ioctl_mvfrey() argument
1353 req = (struct hpt_iop_request_ioctl_command *)(hba->ctlcfg_ptr); in hptiop_do_ioctl_mvfrey()
1354 hba->config_done = 0; in hptiop_do_ioctl_mvfrey()
1355 hptiop_lock_adapter(hba); in hptiop_do_ioctl_mvfrey()
1360 if (hptiop_post_ioctl_command_mvfrey(hba, req, pParams)) in hptiop_do_ioctl_mvfrey()
1363 if (hba->config_done == 1) { in hptiop_do_ioctl_mvfrey()
1376 hptiop_unlock_adapter(hba); in hptiop_do_ioctl_mvfrey()
1380 hptiop_unlock_adapter(hba); in hptiop_do_ioctl_mvfrey()
1385 static int hptiop_rescan_bus(struct hpt_iop_hba * hba) in hptiop_rescan_bus() argument
1391 if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(hba->sim), in hptiop_rescan_bus()
1405 static int hptiop_alloc_pci_res_itl(struct hpt_iop_hba *hba) in hptiop_alloc_pci_res_itl() argument
1407 hba->bar0_rid = 0x10; in hptiop_alloc_pci_res_itl()
1408 hba->bar0_res = bus_alloc_resource_any(hba->pcidev, in hptiop_alloc_pci_res_itl()
1409 SYS_RES_MEMORY, &hba->bar0_rid, RF_ACTIVE); in hptiop_alloc_pci_res_itl()
1411 if (hba->bar0_res == NULL) { in hptiop_alloc_pci_res_itl()
1412 device_printf(hba->pcidev, in hptiop_alloc_pci_res_itl()
1416 hba->bar0t = rman_get_bustag(hba->bar0_res); in hptiop_alloc_pci_res_itl()
1417 hba->bar0h = rman_get_bushandle(hba->bar0_res); in hptiop_alloc_pci_res_itl()
1418 hba->u.itl.mu = (struct hpt_iopmu_itl *) in hptiop_alloc_pci_res_itl()
1419 rman_get_virtual(hba->bar0_res); in hptiop_alloc_pci_res_itl()
1421 if (!hba->u.itl.mu) { in hptiop_alloc_pci_res_itl()
1422 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_alloc_pci_res_itl()
1423 hba->bar0_rid, hba->bar0_res); in hptiop_alloc_pci_res_itl()
1424 device_printf(hba->pcidev, "alloc mem res failed\n"); in hptiop_alloc_pci_res_itl()
1431 static int hptiop_alloc_pci_res_mv(struct hpt_iop_hba *hba) in hptiop_alloc_pci_res_mv() argument
1433 hba->bar0_rid = 0x10; in hptiop_alloc_pci_res_mv()
1434 hba->bar0_res = bus_alloc_resource_any(hba->pcidev, in hptiop_alloc_pci_res_mv()
1435 SYS_RES_MEMORY, &hba->bar0_rid, RF_ACTIVE); in hptiop_alloc_pci_res_mv()
1437 if (hba->bar0_res == NULL) { in hptiop_alloc_pci_res_mv()
1438 device_printf(hba->pcidev, "failed to get iop bar0.\n"); in hptiop_alloc_pci_res_mv()
1441 hba->bar0t = rman_get_bustag(hba->bar0_res); in hptiop_alloc_pci_res_mv()
1442 hba->bar0h = rman_get_bushandle(hba->bar0_res); in hptiop_alloc_pci_res_mv()
1443 hba->u.mv.regs = (struct hpt_iopmv_regs *) in hptiop_alloc_pci_res_mv()
1444 rman_get_virtual(hba->bar0_res); in hptiop_alloc_pci_res_mv()
1446 if (!hba->u.mv.regs) { in hptiop_alloc_pci_res_mv()
1447 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_alloc_pci_res_mv()
1448 hba->bar0_rid, hba->bar0_res); in hptiop_alloc_pci_res_mv()
1449 device_printf(hba->pcidev, "alloc bar0 mem res failed\n"); in hptiop_alloc_pci_res_mv()
1453 hba->bar2_rid = 0x18; in hptiop_alloc_pci_res_mv()
1454 hba->bar2_res = bus_alloc_resource_any(hba->pcidev, in hptiop_alloc_pci_res_mv()
1455 SYS_RES_MEMORY, &hba->bar2_rid, RF_ACTIVE); in hptiop_alloc_pci_res_mv()
1457 if (hba->bar2_res == NULL) { in hptiop_alloc_pci_res_mv()
1458 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_alloc_pci_res_mv()
1459 hba->bar0_rid, hba->bar0_res); in hptiop_alloc_pci_res_mv()
1460 device_printf(hba->pcidev, "failed to get iop bar2.\n"); in hptiop_alloc_pci_res_mv()
1464 hba->bar2t = rman_get_bustag(hba->bar2_res); in hptiop_alloc_pci_res_mv()
1465 hba->bar2h = rman_get_bushandle(hba->bar2_res); in hptiop_alloc_pci_res_mv()
1466 hba->u.mv.mu = (struct hpt_iopmu_mv *)rman_get_virtual(hba->bar2_res); in hptiop_alloc_pci_res_mv()
1468 if (!hba->u.mv.mu) { in hptiop_alloc_pci_res_mv()
1469 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_alloc_pci_res_mv()
1470 hba->bar0_rid, hba->bar0_res); in hptiop_alloc_pci_res_mv()
1471 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_alloc_pci_res_mv()
1472 hba->bar2_rid, hba->bar2_res); in hptiop_alloc_pci_res_mv()
1473 device_printf(hba->pcidev, "alloc mem bar2 res failed\n"); in hptiop_alloc_pci_res_mv()
1480 static int hptiop_alloc_pci_res_mvfrey(struct hpt_iop_hba *hba) in hptiop_alloc_pci_res_mvfrey() argument
1482 hba->bar0_rid = 0x10; in hptiop_alloc_pci_res_mvfrey()
1483 hba->bar0_res = bus_alloc_resource_any(hba->pcidev, in hptiop_alloc_pci_res_mvfrey()
1484 SYS_RES_MEMORY, &hba->bar0_rid, RF_ACTIVE); in hptiop_alloc_pci_res_mvfrey()
1486 if (hba->bar0_res == NULL) { in hptiop_alloc_pci_res_mvfrey()
1487 device_printf(hba->pcidev, "failed to get iop bar0.\n"); in hptiop_alloc_pci_res_mvfrey()
1490 hba->bar0t = rman_get_bustag(hba->bar0_res); in hptiop_alloc_pci_res_mvfrey()
1491 hba->bar0h = rman_get_bushandle(hba->bar0_res); in hptiop_alloc_pci_res_mvfrey()
1492 hba->u.mvfrey.config = (struct hpt_iop_request_get_config *) in hptiop_alloc_pci_res_mvfrey()
1493 rman_get_virtual(hba->bar0_res); in hptiop_alloc_pci_res_mvfrey()
1495 if (!hba->u.mvfrey.config) { in hptiop_alloc_pci_res_mvfrey()
1496 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_alloc_pci_res_mvfrey()
1497 hba->bar0_rid, hba->bar0_res); in hptiop_alloc_pci_res_mvfrey()
1498 device_printf(hba->pcidev, "alloc bar0 mem res failed\n"); in hptiop_alloc_pci_res_mvfrey()
1502 hba->bar2_rid = 0x18; in hptiop_alloc_pci_res_mvfrey()
1503 hba->bar2_res = bus_alloc_resource_any(hba->pcidev, in hptiop_alloc_pci_res_mvfrey()
1504 SYS_RES_MEMORY, &hba->bar2_rid, RF_ACTIVE); in hptiop_alloc_pci_res_mvfrey()
1506 if (hba->bar2_res == NULL) { in hptiop_alloc_pci_res_mvfrey()
1507 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_alloc_pci_res_mvfrey()
1508 hba->bar0_rid, hba->bar0_res); in hptiop_alloc_pci_res_mvfrey()
1509 device_printf(hba->pcidev, "failed to get iop bar2.\n"); in hptiop_alloc_pci_res_mvfrey()
1513 hba->bar2t = rman_get_bustag(hba->bar2_res); in hptiop_alloc_pci_res_mvfrey()
1514 hba->bar2h = rman_get_bushandle(hba->bar2_res); in hptiop_alloc_pci_res_mvfrey()
1515 hba->u.mvfrey.mu = in hptiop_alloc_pci_res_mvfrey()
1516 (struct hpt_iopmu_mvfrey *)rman_get_virtual(hba->bar2_res); in hptiop_alloc_pci_res_mvfrey()
1518 if (!hba->u.mvfrey.mu) { in hptiop_alloc_pci_res_mvfrey()
1519 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_alloc_pci_res_mvfrey()
1520 hba->bar0_rid, hba->bar0_res); in hptiop_alloc_pci_res_mvfrey()
1521 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_alloc_pci_res_mvfrey()
1522 hba->bar2_rid, hba->bar2_res); in hptiop_alloc_pci_res_mvfrey()
1523 device_printf(hba->pcidev, "alloc mem bar2 res failed\n"); in hptiop_alloc_pci_res_mvfrey()
1530 static void hptiop_release_pci_res_itl(struct hpt_iop_hba *hba) in hptiop_release_pci_res_itl() argument
1532 if (hba->bar0_res) in hptiop_release_pci_res_itl()
1533 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_release_pci_res_itl()
1534 hba->bar0_rid, hba->bar0_res); in hptiop_release_pci_res_itl()
1537 static void hptiop_release_pci_res_mv(struct hpt_iop_hba *hba) in hptiop_release_pci_res_mv() argument
1539 if (hba->bar0_res) in hptiop_release_pci_res_mv()
1540 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_release_pci_res_mv()
1541 hba->bar0_rid, hba->bar0_res); in hptiop_release_pci_res_mv()
1542 if (hba->bar2_res) in hptiop_release_pci_res_mv()
1543 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_release_pci_res_mv()
1544 hba->bar2_rid, hba->bar2_res); in hptiop_release_pci_res_mv()
1547 static void hptiop_release_pci_res_mvfrey(struct hpt_iop_hba *hba) in hptiop_release_pci_res_mvfrey() argument
1549 if (hba->bar0_res) in hptiop_release_pci_res_mvfrey()
1550 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_release_pci_res_mvfrey()
1551 hba->bar0_rid, hba->bar0_res); in hptiop_release_pci_res_mvfrey()
1552 if (hba->bar2_res) in hptiop_release_pci_res_mvfrey()
1553 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_release_pci_res_mvfrey()
1554 hba->bar2_rid, hba->bar2_res); in hptiop_release_pci_res_mvfrey()
1557 static int hptiop_internal_memalloc_mv(struct hpt_iop_hba *hba) in hptiop_internal_memalloc_mv() argument
1559 if (bus_dma_tag_create(hba->parent_dmat, in hptiop_internal_memalloc_mv()
1571 &hba->ctlcfg_dmat)) { in hptiop_internal_memalloc_mv()
1572 device_printf(hba->pcidev, "alloc ctlcfg_dmat failed\n"); in hptiop_internal_memalloc_mv()
1576 if (bus_dmamem_alloc(hba->ctlcfg_dmat, (void **)&hba->ctlcfg_ptr, in hptiop_internal_memalloc_mv()
1578 &hba->ctlcfg_dmamap) != 0) { in hptiop_internal_memalloc_mv()
1579 device_printf(hba->pcidev, in hptiop_internal_memalloc_mv()
1581 bus_dma_tag_destroy(hba->ctlcfg_dmat); in hptiop_internal_memalloc_mv()
1585 if (bus_dmamap_load(hba->ctlcfg_dmat, in hptiop_internal_memalloc_mv()
1586 hba->ctlcfg_dmamap, hba->ctlcfg_ptr, in hptiop_internal_memalloc_mv()
1588 hptiop_mv_map_ctlcfg, hba, 0)) { in hptiop_internal_memalloc_mv()
1589 device_printf(hba->pcidev, "bus_dmamap_load failed!\n"); in hptiop_internal_memalloc_mv()
1590 if (hba->ctlcfg_dmat) { in hptiop_internal_memalloc_mv()
1591 bus_dmamem_free(hba->ctlcfg_dmat, in hptiop_internal_memalloc_mv()
1592 hba->ctlcfg_ptr, hba->ctlcfg_dmamap); in hptiop_internal_memalloc_mv()
1593 bus_dma_tag_destroy(hba->ctlcfg_dmat); in hptiop_internal_memalloc_mv()
1601 static int hptiop_internal_memalloc_mvfrey(struct hpt_iop_hba *hba) in hptiop_internal_memalloc_mvfrey() argument
1611 hba->u.mvfrey.list_count = list_count; in hptiop_internal_memalloc_mvfrey()
1612 hba->u.mvfrey.internal_mem_size = 0x800 in hptiop_internal_memalloc_mvfrey()
1616 if (bus_dma_tag_create(hba->parent_dmat, in hptiop_internal_memalloc_mvfrey()
1622 hba->u.mvfrey.internal_mem_size, in hptiop_internal_memalloc_mvfrey()
1628 &hba->ctlcfg_dmat)) { in hptiop_internal_memalloc_mvfrey()
1629 device_printf(hba->pcidev, "alloc ctlcfg_dmat failed\n"); in hptiop_internal_memalloc_mvfrey()
1633 if (bus_dmamem_alloc(hba->ctlcfg_dmat, (void **)&hba->ctlcfg_ptr, in hptiop_internal_memalloc_mvfrey()
1635 &hba->ctlcfg_dmamap) != 0) { in hptiop_internal_memalloc_mvfrey()
1636 device_printf(hba->pcidev, in hptiop_internal_memalloc_mvfrey()
1638 bus_dma_tag_destroy(hba->ctlcfg_dmat); in hptiop_internal_memalloc_mvfrey()
1642 if (bus_dmamap_load(hba->ctlcfg_dmat, in hptiop_internal_memalloc_mvfrey()
1643 hba->ctlcfg_dmamap, hba->ctlcfg_ptr, in hptiop_internal_memalloc_mvfrey()
1644 hba->u.mvfrey.internal_mem_size, in hptiop_internal_memalloc_mvfrey()
1645 hptiop_mvfrey_map_ctlcfg, hba, 0)) { in hptiop_internal_memalloc_mvfrey()
1646 device_printf(hba->pcidev, "bus_dmamap_load failed!\n"); in hptiop_internal_memalloc_mvfrey()
1647 if (hba->ctlcfg_dmat) { in hptiop_internal_memalloc_mvfrey()
1648 bus_dmamem_free(hba->ctlcfg_dmat, in hptiop_internal_memalloc_mvfrey()
1649 hba->ctlcfg_ptr, hba->ctlcfg_dmamap); in hptiop_internal_memalloc_mvfrey()
1650 bus_dma_tag_destroy(hba->ctlcfg_dmat); in hptiop_internal_memalloc_mvfrey()
1658 static int hptiop_internal_memfree_itl(struct hpt_iop_hba *hba) { in hptiop_internal_memfree_itl() argument
1662 static int hptiop_internal_memfree_mv(struct hpt_iop_hba *hba) in hptiop_internal_memfree_mv() argument
1664 if (hba->ctlcfg_dmat) { in hptiop_internal_memfree_mv()
1665 bus_dmamap_unload(hba->ctlcfg_dmat, hba->ctlcfg_dmamap); in hptiop_internal_memfree_mv()
1666 bus_dmamem_free(hba->ctlcfg_dmat, in hptiop_internal_memfree_mv()
1667 hba->ctlcfg_ptr, hba->ctlcfg_dmamap); in hptiop_internal_memfree_mv()
1668 bus_dma_tag_destroy(hba->ctlcfg_dmat); in hptiop_internal_memfree_mv()
1674 static int hptiop_internal_memfree_mvfrey(struct hpt_iop_hba *hba) in hptiop_internal_memfree_mvfrey() argument
1676 if (hba->ctlcfg_dmat) { in hptiop_internal_memfree_mvfrey()
1677 bus_dmamap_unload(hba->ctlcfg_dmat, hba->ctlcfg_dmamap); in hptiop_internal_memfree_mvfrey()
1678 bus_dmamem_free(hba->ctlcfg_dmat, in hptiop_internal_memfree_mvfrey()
1679 hba->ctlcfg_ptr, hba->ctlcfg_dmamap); in hptiop_internal_memfree_mvfrey()
1680 bus_dma_tag_destroy(hba->ctlcfg_dmat); in hptiop_internal_memfree_mvfrey()
1686 static int hptiop_reset_comm_mvfrey(struct hpt_iop_hba *hba) in hptiop_reset_comm_mvfrey() argument
1690 if (hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET_COMM, 3000)) in hptiop_reset_comm_mvfrey()
1699 hba->u.mvfrey.inlist_phy & 0xffffffff); in hptiop_reset_comm_mvfrey()
1701 (hba->u.mvfrey.inlist_phy >> 16) >> 16); in hptiop_reset_comm_mvfrey()
1704 hba->u.mvfrey.outlist_phy & 0xffffffff); in hptiop_reset_comm_mvfrey()
1706 (hba->u.mvfrey.outlist_phy >> 16) >> 16); in hptiop_reset_comm_mvfrey()
1709 hba->u.mvfrey.outlist_cptr_phy & 0xffffffff); in hptiop_reset_comm_mvfrey()
1711 (hba->u.mvfrey.outlist_cptr_phy >> 16) >> 16); in hptiop_reset_comm_mvfrey()
1713 hba->u.mvfrey.inlist_wptr = (hba->u.mvfrey.list_count - 1) in hptiop_reset_comm_mvfrey()
1715 *hba->u.mvfrey.outlist_cptr = (hba->u.mvfrey.list_count - 1) in hptiop_reset_comm_mvfrey()
1717 hba->u.mvfrey.outlist_rptr = hba->u.mvfrey.list_count - 1; in hptiop_reset_comm_mvfrey()
1799 struct hpt_iop_hba *hba; in hptiop_probe() local
1856 hba = (struct hpt_iop_hba *)device_get_softc(dev); in hptiop_probe()
1857 bzero(hba, sizeof(struct hpt_iop_hba)); in hptiop_probe()
1858 hba->ops = ops; in hptiop_probe()
1860 KdPrint(("hba->ops=%p\n", hba->ops)); in hptiop_probe()
1867 struct hpt_iop_hba *hba = (struct hpt_iop_hba *)device_get_softc(dev); in hptiop_attach() local
1880 pci_get_function(dev), hba->ops)); in hptiop_attach()
1883 hba->pcidev = dev; in hptiop_attach()
1884 hba->pciunit = unit; in hptiop_attach()
1886 if (hba->ops->alloc_pci_res(hba)) in hptiop_attach()
1889 if (hba->ops->iop_wait_ready(hba, 2000)) { in hptiop_attach()
1894 mtx_init(&hba->lock, "hptioplock", NULL, MTX_DEF); in hptiop_attach()
1908 &hba->parent_dmat /* tag */)) in hptiop_attach()
1914 if (hba->ops->family == MV_BASED_IOP) { in hptiop_attach()
1915 if (hba->ops->internal_memalloc(hba)) { in hptiop_attach()
1921 if (hba->ops->get_config(hba, &iop_config)) { in hptiop_attach()
1926 hba->firmware_version = iop_config.firmware_version; in hptiop_attach()
1927 hba->interface_version = iop_config.interface_version; in hptiop_attach()
1928 hba->max_requests = iop_config.max_requests; in hptiop_attach()
1929 hba->max_devices = iop_config.max_devices; in hptiop_attach()
1930 hba->max_request_size = iop_config.request_size; in hptiop_attach()
1931 hba->max_sg_count = iop_config.max_sg_count; in hptiop_attach()
1933 if (hba->ops->family == MVFREY_BASED_IOP) { in hptiop_attach()
1934 if (hba->ops->internal_memalloc(hba)) { in hptiop_attach()
1938 if (hba->ops->reset_comm(hba)) { in hptiop_attach()
1944 if (bus_dma_tag_create(hba->parent_dmat,/* parent */ in hptiop_attach()
1950 PAGE_SIZE * (hba->max_sg_count-1), /* maxsize */ in hptiop_attach()
1951 hba->max_sg_count, /* nsegments */ in hptiop_attach()
1955 &hba->lock, /* lockfuncarg */ in hptiop_attach()
1956 &hba->io_dmat /* tag */)) in hptiop_attach()
1962 if (bus_dma_tag_create(hba->parent_dmat,/* parent */ in hptiop_attach()
1974 &hba->srb_dmat /* tag */)) in hptiop_attach()
1980 if (bus_dmamem_alloc(hba->srb_dmat, (void **)&hba->uncached_ptr, in hptiop_attach()
1982 &hba->srb_dmamap) != 0) in hptiop_attach()
1988 if (bus_dmamap_load(hba->srb_dmat, in hptiop_attach()
1989 hba->srb_dmamap, hba->uncached_ptr, in hptiop_attach()
1991 hptiop_map_srb, hba, 0)) in hptiop_attach()
1997 if ((devq = cam_simq_alloc(hba->max_requests - 1 )) == NULL) { in hptiop_attach()
2002 hba->sim = cam_sim_alloc(hptiop_action, hptiop_poll, driver_name, in hptiop_attach()
2003 hba, unit, &hba->lock, hba->max_requests - 1, 1, devq); in hptiop_attach()
2004 if (!hba->sim) { in hptiop_attach()
2009 hptiop_lock_adapter(hba); in hptiop_attach()
2010 if (xpt_bus_register(hba->sim, dev, 0) != CAM_SUCCESS) in hptiop_attach()
2016 if (xpt_create_path(&hba->path, /*periph */ NULL, in hptiop_attach()
2017 cam_sim_path(hba->sim), CAM_TARGET_WILDCARD, in hptiop_attach()
2022 hptiop_unlock_adapter(hba); in hptiop_attach()
2026 set_config.vbus_id = cam_sim_path(hba->sim); in hptiop_attach()
2029 if (hba->ops->set_config(hba, &set_config)) { in hptiop_attach()
2035 xpt_setup_ccb(&ccb.ccb_h, hba->path, /*priority*/5); in hptiop_attach()
2039 ccb.callback_arg = hba->sim; in hptiop_attach()
2043 if ((hba->irq_res = bus_alloc_resource_any(hba->pcidev, SYS_RES_IRQ, in hptiop_attach()
2049 if (bus_setup_intr(hba->pcidev, hba->irq_res, INTR_TYPE_CAM | INTR_MPSAFE, in hptiop_attach()
2050 NULL, hptiop_pci_intr, hba, &hba->irq_handle)) in hptiop_attach()
2056 if (hptiop_send_sync_msg(hba, in hptiop_attach()
2062 hba->ops->enable_intr(hba); in hptiop_attach()
2063 hba->initialized = 1; in hptiop_attach()
2070 args.mda_si_drv1 = hba; in hptiop_attach()
2072 make_dev_s(&args, &hba->ioctl_dev, "%s%d", driver_name, unit); in hptiop_attach()
2078 bus_teardown_intr(dev, hba->irq_res, hba->irq_handle); in hptiop_attach()
2081 bus_release_resource(dev, SYS_RES_IRQ, 0, hba->irq_res); in hptiop_attach()
2083 hptiop_lock_adapter(hba); in hptiop_attach()
2085 xpt_free_path(hba->path); in hptiop_attach()
2088 xpt_bus_deregister(cam_sim_path(hba->sim)); in hptiop_attach()
2091 cam_sim_free(hba->sim, /*free devq*/ TRUE); in hptiop_attach()
2092 hptiop_unlock_adapter(hba); in hptiop_attach()
2095 if (hba->uncached_ptr) in hptiop_attach()
2096 bus_dmamap_unload(hba->srb_dmat, hba->srb_dmamap); in hptiop_attach()
2099 if (hba->uncached_ptr) in hptiop_attach()
2100 bus_dmamem_free(hba->srb_dmat, in hptiop_attach()
2101 hba->uncached_ptr, hba->srb_dmamap); in hptiop_attach()
2104 if (hba->srb_dmat) in hptiop_attach()
2105 bus_dma_tag_destroy(hba->srb_dmat); in hptiop_attach()
2108 if (hba->io_dmat) in hptiop_attach()
2109 bus_dma_tag_destroy(hba->io_dmat); in hptiop_attach()
2112 hba->ops->internal_memfree(hba); in hptiop_attach()
2115 if (hba->parent_dmat) in hptiop_attach()
2116 bus_dma_tag_destroy(hba->parent_dmat); in hptiop_attach()
2119 if (hba->ops->release_pci_res) in hptiop_attach()
2120 hba->ops->release_pci_res(hba); in hptiop_attach()
2127 struct hpt_iop_hba * hba = (struct hpt_iop_hba *)device_get_softc(dev); in hptiop_detach() local
2131 hptiop_lock_adapter(hba); in hptiop_detach()
2132 for (i = 0; i < hba->max_devices; i++) in hptiop_detach()
2133 if (hptiop_os_query_remove_device(hba, i)) { in hptiop_detach()
2135 hba->pciunit, i); in hptiop_detach()
2141 if (hptiop_send_sync_msg(hba, in hptiop_detach()
2144 hptiop_unlock_adapter(hba); in hptiop_detach()
2146 hptiop_release_resource(hba); in hptiop_detach()
2149 hptiop_unlock_adapter(hba); in hptiop_detach()
2155 struct hpt_iop_hba * hba = (struct hpt_iop_hba *)device_get_softc(dev); in hptiop_shutdown() local
2159 if (hba->flag & HPT_IOCTL_FLAG_OPEN) { in hptiop_shutdown()
2160 device_printf(dev, "%d device is busy", hba->pciunit); in hptiop_shutdown()
2164 hba->ops->disable_intr(hba); in hptiop_shutdown()
2166 if (hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_SHUTDOWN, 60000)) in hptiop_shutdown()
2174 struct hpt_iop_hba * hba = (struct hpt_iop_hba *)arg; in hptiop_pci_intr() local
2175 hptiop_lock_adapter(hba); in hptiop_pci_intr()
2176 hba->ops->iop_intr(hba); in hptiop_pci_intr()
2177 hptiop_unlock_adapter(hba); in hptiop_pci_intr()
2182 struct hpt_iop_hba *hba; in hptiop_poll() local
2184 hba = cam_sim_softc(sim); in hptiop_poll()
2185 hba->ops->iop_intr(hba); in hptiop_poll()
2193 static void hptiop_enable_intr_itl(struct hpt_iop_hba *hba) in hptiop_enable_intr_itl() argument
2199 static void hptiop_enable_intr_mv(struct hpt_iop_hba *hba) in hptiop_enable_intr_mv() argument
2210 static void hptiop_enable_intr_mvfrey(struct hpt_iop_hba *hba) in hptiop_enable_intr_mvfrey() argument
2222 static void hptiop_disable_intr_itl(struct hpt_iop_hba *hba) in hptiop_disable_intr_itl() argument
2233 static void hptiop_disable_intr_mv(struct hpt_iop_hba *hba) in hptiop_disable_intr_mv() argument
2244 static void hptiop_disable_intr_mvfrey(struct hpt_iop_hba *hba) in hptiop_disable_intr_mvfrey() argument
2258 struct hpt_iop_hba * hba = (struct hpt_iop_hba *)argv; in hptiop_reset_adapter() local
2259 if (hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET, 60000)) in hptiop_reset_adapter()
2261 hptiop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_START_BACKGROUND_TASK, 5000); in hptiop_reset_adapter()
2264 static void *hptiop_get_srb(struct hpt_iop_hba * hba) in hptiop_get_srb() argument
2268 if (hba->srb_list) { in hptiop_get_srb()
2269 srb = hba->srb_list; in hptiop_get_srb()
2270 hba->srb_list = srb->next; in hptiop_get_srb()
2277 static void hptiop_free_srb(struct hpt_iop_hba *hba, struct hpt_iop_srb *srb) in hptiop_free_srb() argument
2279 srb->next = hba->srb_list; in hptiop_free_srb()
2280 hba->srb_list = srb; in hptiop_free_srb()
2285 struct hpt_iop_hba * hba = (struct hpt_iop_hba *)cam_sim_softc(sim); in hptiop_action() local
2293 ccb->ccb_h.target_id >= hba->max_devices || in hptiop_action()
2301 if ((srb = hptiop_get_srb(hba)) == NULL) { in hptiop_action()
2302 device_printf(hba->pcidev, "srb allocated failed"); in hptiop_action()
2309 error = bus_dmamap_load_ccb(hba->io_dmat, in hptiop_action()
2317 device_printf(hba->pcidev, in hptiop_action()
2319 hba->pciunit, error); in hptiop_action()
2320 xpt_freeze_simq(hba->sim, 1); in hptiop_action()
2322 hptiop_free_srb(hba, srb); in hptiop_action()
2330 device_printf(hba->pcidev, "reset adapter"); in hptiop_action()
2331 hba->msg_done = 0; in hptiop_action()
2332 hptiop_reset_adapter(hba); in hptiop_action()
2353 cpi->max_target = hba->max_devices; in hptiop_action()
2357 cpi->initiator_id = hba->max_devices; in hptiop_action()
2380 static void hptiop_post_req_itl(struct hpt_iop_hba *hba, in hptiop_post_req_itl() argument
2403 device_printf(hba->pcidev, "invalid req offset\n"); in hptiop_post_req_itl()
2405 bus_dmamap_unload(hba->io_dmat, srb->dma_map); in hptiop_post_req_itl()
2406 hptiop_free_srb(hba, srb); in hptiop_post_req_itl()
2435 bus_space_write_region_1(hba->bar0t, hba->bar0h, iop_req32, in hptiop_post_req_itl()
2439 bus_dmamap_sync(hba->io_dmat, in hptiop_post_req_itl()
2443 bus_dmamap_sync(hba->io_dmat, in hptiop_post_req_itl()
2478 bus_dmamap_sync(hba->io_dmat, in hptiop_post_req_itl()
2481 bus_dmamap_sync(hba->io_dmat, in hptiop_post_req_itl()
2485 if (hba->firmware_version > 0x01020000 in hptiop_post_req_itl()
2486 || hba->interface_version > 0x01020000) { in hptiop_post_req_itl()
2505 static void hptiop_post_req_mv(struct hpt_iop_hba *hba, in hptiop_post_req_mv() argument
2543 bus_dmamap_sync(hba->io_dmat, in hptiop_post_req_mv()
2547 bus_dmamap_sync(hba->io_dmat, in hptiop_post_req_mv()
2556 | imin(3, size), hba); in hptiop_post_req_mv()
2559 static void hptiop_post_req_mvfrey(struct hpt_iop_hba *hba, in hptiop_post_req_mvfrey() argument
2597 bus_dmamap_sync(hba->io_dmat, in hptiop_post_req_mvfrey()
2601 bus_dmamap_sync(hba->io_dmat, in hptiop_post_req_mvfrey()
2611 hba->u.mvfrey.inlist_wptr++; in hptiop_post_req_mvfrey()
2612 index = hba->u.mvfrey.inlist_wptr & 0x3fff; in hptiop_post_req_mvfrey()
2614 if (index == hba->u.mvfrey.list_count) { in hptiop_post_req_mvfrey()
2616 hba->u.mvfrey.inlist_wptr &= ~0x3fff; in hptiop_post_req_mvfrey()
2617 hba->u.mvfrey.inlist_wptr ^= CL_POINTER_TOGGLE; in hptiop_post_req_mvfrey()
2620 hba->u.mvfrey.inlist[index].addr = req_phy; in hptiop_post_req_mvfrey()
2621 hba->u.mvfrey.inlist[index].intrfc_len = (req->header.size + 3) / 4; in hptiop_post_req_mvfrey()
2623 BUS_SPACE_WRT4_MVFREY2(inbound_write_ptr, hba->u.mvfrey.inlist_wptr); in hptiop_post_req_mvfrey()
2627 callout_reset(&srb->timeout, 20 * hz, hptiop_reset_adapter, hba); in hptiop_post_req_mvfrey()
2636 struct hpt_iop_hba *hba = srb->hba; in hptiop_post_scsi_command() local
2638 if (error || nsegs > hba->max_sg_count) { in hptiop_post_scsi_command()
2644 bus_dmamap_unload(hba->io_dmat, srb->dma_map); in hptiop_post_scsi_command()
2645 hptiop_free_srb(hba, srb); in hptiop_post_scsi_command()
2650 hba->ops->post_req(hba, srb, segs, nsegs); in hptiop_post_scsi_command()
2656 struct hpt_iop_hba *hba = (struct hpt_iop_hba *)arg; in hptiop_mv_map_ctlcfg() local
2657 hba->ctlcfgcmd_phy = ((u_int64_t)segs->ds_addr + 0x1F) in hptiop_mv_map_ctlcfg()
2659 hba->ctlcfg_ptr = (u_int8_t *)(((unsigned long)hba->ctlcfg_ptr + 0x1F) in hptiop_mv_map_ctlcfg()
2666 struct hpt_iop_hba *hba = (struct hpt_iop_hba *)arg; in hptiop_mvfrey_map_ctlcfg() local
2669 u_int32_t list_count = hba->u.mvfrey.list_count; in hptiop_mvfrey_map_ctlcfg()
2673 p = (u_int8_t *)(((unsigned long)hba->ctlcfg_ptr + 0x1F) in hptiop_mvfrey_map_ctlcfg()
2676 hba->ctlcfgcmd_phy = phy; in hptiop_mvfrey_map_ctlcfg()
2677 hba->ctlcfg_ptr = p; in hptiop_mvfrey_map_ctlcfg()
2682 hba->u.mvfrey.inlist = (struct mvfrey_inlist_entry *)p; in hptiop_mvfrey_map_ctlcfg()
2683 hba->u.mvfrey.inlist_phy = phy; in hptiop_mvfrey_map_ctlcfg()
2688 hba->u.mvfrey.outlist = (struct mvfrey_outlist_entry *)p; in hptiop_mvfrey_map_ctlcfg()
2689 hba->u.mvfrey.outlist_phy = phy; in hptiop_mvfrey_map_ctlcfg()
2694 hba->u.mvfrey.outlist_cptr = (u_int32_t *)p; in hptiop_mvfrey_map_ctlcfg()
2695 hba->u.mvfrey.outlist_cptr_phy = phy; in hptiop_mvfrey_map_ctlcfg()
2701 struct hpt_iop_hba * hba = (struct hpt_iop_hba *)arg; in hptiop_map_srb() local
2707 device_printf(hba->pcidev, "hptiop_map_srb error"); in hptiop_map_srb()
2713 (((unsigned long)hba->uncached_ptr + 0x1F) in hptiop_map_srb()
2720 if (bus_dmamap_create(hba->io_dmat, in hptiop_map_srb()
2722 device_printf(hba->pcidev, "dmamap create failed"); in hptiop_map_srb()
2727 tmp_srb->hba = hba; in hptiop_map_srb()
2729 if (hba->ctlcfg_ptr == 0) {/*itl iop*/ in hptiop_map_srb()
2739 callout_init_mtx(&tmp_srb->timeout, &hba->lock, 0); in hptiop_map_srb()
2740 hptiop_free_srb(hba, tmp_srb); in hptiop_map_srb()
2741 hba->srb[i] = tmp_srb; in hptiop_map_srb()
2745 device_printf(hba->pcidev, "invalid alignment"); in hptiop_map_srb()
2751 static void hptiop_os_message_callback(struct hpt_iop_hba * hba, u_int32_t msg) in hptiop_os_message_callback() argument
2753 hba->msg_done = 1; in hptiop_os_message_callback()
2756 static int hptiop_os_query_remove_device(struct hpt_iop_hba * hba, in hptiop_os_query_remove_device() argument
2763 status = xpt_create_path(&path, NULL, hba->sim->path_id, target_id, 0); in hptiop_os_query_remove_device()
2768 device_printf(hba->pcidev, "%d ," in hptiop_os_query_remove_device()
2771 hba->pciunit, target_id, periph->refcount); in hptiop_os_query_remove_device()
2780 static void hptiop_release_resource(struct hpt_iop_hba *hba) in hptiop_release_resource() argument
2784 if (hba->ioctl_dev) in hptiop_release_resource()
2785 destroy_dev(hba->ioctl_dev); in hptiop_release_resource()
2787 if (hba->path) { in hptiop_release_resource()
2791 xpt_setup_ccb(&ccb.ccb_h, hba->path, /*priority*/5); in hptiop_release_resource()
2795 ccb.callback_arg = hba->sim; in hptiop_release_resource()
2797 xpt_free_path(hba->path); in hptiop_release_resource()
2800 if (hba->irq_handle) in hptiop_release_resource()
2801 bus_teardown_intr(hba->pcidev, hba->irq_res, hba->irq_handle); in hptiop_release_resource()
2803 if (hba->sim) { in hptiop_release_resource()
2804 hptiop_lock_adapter(hba); in hptiop_release_resource()
2805 xpt_bus_deregister(cam_sim_path(hba->sim)); in hptiop_release_resource()
2806 cam_sim_free(hba->sim, TRUE); in hptiop_release_resource()
2807 hptiop_unlock_adapter(hba); in hptiop_release_resource()
2810 if (hba->ctlcfg_dmat) { in hptiop_release_resource()
2811 bus_dmamap_unload(hba->ctlcfg_dmat, hba->ctlcfg_dmamap); in hptiop_release_resource()
2812 bus_dmamem_free(hba->ctlcfg_dmat, in hptiop_release_resource()
2813 hba->ctlcfg_ptr, hba->ctlcfg_dmamap); in hptiop_release_resource()
2814 bus_dma_tag_destroy(hba->ctlcfg_dmat); in hptiop_release_resource()
2818 struct hpt_iop_srb *srb = hba->srb[i]; in hptiop_release_resource()
2820 bus_dmamap_destroy(hba->io_dmat, srb->dma_map); in hptiop_release_resource()
2824 if (hba->srb_dmat) { in hptiop_release_resource()
2825 bus_dmamap_unload(hba->srb_dmat, hba->srb_dmamap); in hptiop_release_resource()
2826 bus_dmamap_destroy(hba->srb_dmat, hba->srb_dmamap); in hptiop_release_resource()
2827 bus_dma_tag_destroy(hba->srb_dmat); in hptiop_release_resource()
2830 if (hba->io_dmat) in hptiop_release_resource()
2831 bus_dma_tag_destroy(hba->io_dmat); in hptiop_release_resource()
2833 if (hba->parent_dmat) in hptiop_release_resource()
2834 bus_dma_tag_destroy(hba->parent_dmat); in hptiop_release_resource()
2836 if (hba->irq_res) in hptiop_release_resource()
2837 bus_release_resource(hba->pcidev, SYS_RES_IRQ, in hptiop_release_resource()
2838 0, hba->irq_res); in hptiop_release_resource()
2840 if (hba->bar0_res) in hptiop_release_resource()
2841 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_release_resource()
2842 hba->bar0_rid, hba->bar0_res); in hptiop_release_resource()
2843 if (hba->bar2_res) in hptiop_release_resource()
2844 bus_release_resource(hba->pcidev, SYS_RES_MEMORY, in hptiop_release_resource()
2845 hba->bar2_rid, hba->bar2_res); in hptiop_release_resource()
2846 mtx_destroy(&hba->lock); in hptiop_release_resource()