Lines Matching refs:vbus_ext
76 PVBUS_EXT vbus_ext; in hpt_attach() local
113 vbus_ext = malloc(sizeof(VBUS_EXT) + size, M_DEVBUF, M_WAITOK); in hpt_attach()
114 memset(vbus_ext, 0, sizeof(VBUS_EXT)); in hpt_attach()
115 vbus_ext->ext_type = EXT_TYPE_VBUS; in hpt_attach()
116 ldm_create_vbus((PVBUS)vbus_ext->vbus, vbus_ext); in hpt_attach()
120 ldm_for_each_vbus(vbus, vbus_ext) { in hpt_attach()
122 hba->vbus_ext = vbus_ext; in hpt_attach()
123 hba->next = vbus_ext->hba_list; in hpt_attach()
124 vbus_ext->hba_list = hba; in hpt_attach()
147 static int hpt_alloc_mem(PVBUS_EXT vbus_ext) in hpt_alloc_mem() argument
154 for (hba = vbus_ext->hba_list; hba; hba = hba->next) in hpt_alloc_mem()
157 ldm_get_mem_info((PVBUS)vbus_ext->vbus, 0); in hpt_alloc_mem()
159 for (f=vbus_ext->freelist_head; f; f=f->next) { in hpt_alloc_mem()
169 for (f=vbus_ext->freelist_dma_head; f; f=f->next) { in hpt_alloc_mem()
199 dmapool_put_page((PVBUS)vbus_ext->vbus, p, (BUS_ADDRESS)vtophys(p)); in hpt_alloc_mem()
205 static void hpt_free_mem(PVBUS_EXT vbus_ext) in hpt_free_mem() argument
212 for (f=vbus_ext->freelist_head; f; f=f->next) { in hpt_free_mem()
223 p = dmapool_get_page((PVBUS)vbus_ext->vbus, &bus); in hpt_free_mem()
228 for (f=vbus_ext->freelist_dma_head; f; f=f->next) { in hpt_free_mem()
243 dmapool_put_page((PVBUS)vbus_ext->vbus, p, bus); in hpt_free_mem()
248 while ((p = dmapool_get_page((PVBUS)vbus_ext->vbus, &bus))) in hpt_free_mem()
252 static int hpt_init_vbus(PVBUS_EXT vbus_ext) in hpt_init_vbus() argument
256 for (hba = vbus_ext->hba_list; hba; hba = hba->next) in hpt_init_vbus()
262 ldm_initialize_vbus((PVBUS)vbus_ext->vbus, &vbus_ext->hba_list->ldm_adapter); in hpt_init_vbus()
286 static int hpt_flush_vdev(PVBUS_EXT vbus_ext, PVDEV vd) in hpt_flush_vdev() argument
294 hpt_lock_vbus(vbus_ext); in hpt_flush_vdev()
305 hpt_unlock_vbus(vbus_ext); in hpt_flush_vdev()
319 while (hpt_sleep(vbus_ext, pCmd, PPAUSE, "hptfls", HPT_OSM_TIMEOUT)) { in hpt_flush_vdev()
331 hpt_unlock_vbus(vbus_ext); in hpt_flush_vdev()
336 static void hpt_stop_tasks(PVBUS_EXT vbus_ext);
337 static void hpt_shutdown_vbus(PVBUS_EXT vbus_ext, int howto) in hpt_shutdown_vbus() argument
339 PVBUS vbus = (PVBUS)vbus_ext->vbus; in hpt_shutdown_vbus()
346 hpt_stop_tasks(vbus_ext); in hpt_shutdown_vbus()
347 vbus_ext->worker.ta_context = 0; in hpt_shutdown_vbus()
354 if (hpt_flush_vdev(vbus_ext, vd)) in hpt_shutdown_vbus()
355 hpt_flush_vdev(vbus_ext, vd); in hpt_shutdown_vbus()
359 hpt_lock_vbus(vbus_ext); in hpt_shutdown_vbus()
361 hpt_unlock_vbus(vbus_ext); in hpt_shutdown_vbus()
365 for (hba=vbus_ext->hba_list; hba; hba=hba->next) in hpt_shutdown_vbus()
368 hpt_free_mem(vbus_ext); in hpt_shutdown_vbus()
370 while ((hba=vbus_ext->hba_list)) { in hpt_shutdown_vbus()
371 vbus_ext->hba_list = hba->next; in hpt_shutdown_vbus()
374 callout_drain(&vbus_ext->timer); in hpt_shutdown_vbus()
375 mtx_destroy(&vbus_ext->lock); in hpt_shutdown_vbus()
376 free(vbus_ext, M_DEVBUF); in hpt_shutdown_vbus()
380 static void __hpt_do_tasks(PVBUS_EXT vbus_ext) in __hpt_do_tasks() argument
384 tasks = vbus_ext->tasks; in __hpt_do_tasks()
385 vbus_ext->tasks = 0; in __hpt_do_tasks()
391 t->func(vbus_ext->vbus, t->data); in __hpt_do_tasks()
395 static void hpt_do_tasks(PVBUS_EXT vbus_ext, int pending) in hpt_do_tasks() argument
397 if(vbus_ext){ in hpt_do_tasks()
398 hpt_lock_vbus(vbus_ext); in hpt_do_tasks()
399 __hpt_do_tasks(vbus_ext); in hpt_do_tasks()
400 hpt_unlock_vbus(vbus_ext); in hpt_do_tasks()
409 static __inline POS_CMDEXT cmdext_get(PVBUS_EXT vbus_ext) in cmdext_get() argument
411 POS_CMDEXT p = vbus_ext->cmdext_list; in cmdext_get()
413 vbus_ext->cmdext_list = p->next; in cmdext_get()
419 p->next = p->vbus_ext->cmdext_list; in cmdext_put()
420 p->vbus_ext->cmdext_list = p; in cmdext_put()
430 ldm_reset_vbus((PVBUS)ext->vbus_ext->vbus); in hpt_timeout()
465 bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, BUS_DMASYNC_POSTREAD); in os_cmddone()
468 bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, BUS_DMASYNC_POSTWRITE); in os_cmddone()
471 bus_dmamap_unload(ext->vbus_ext->io_dmat, ext->dma_map); in os_cmddone()
517 bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, in hpt_io_dmamap_callback()
521 bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, in hpt_io_dmamap_callback()
529 static void hpt_scsi_io(PVBUS_EXT vbus_ext, union ccb *ccb) in hpt_scsi_io() argument
531 PVBUS vbus = (PVBUS)vbus_ext->vbus; in hpt_scsi_io()
774 pCmd->priv = ext = cmdext_get(vbus_ext); in hpt_scsi_io()
783 error = bus_dmamap_load_ccb(vbus_ext->io_dmat, in hpt_scsi_io()
810 PVBUS_EXT vbus_ext = (PVBUS_EXT)cam_sim_softc(sim); in hpt_action() local
814 hpt_assert_vbus_locked(vbus_ext); in hpt_action()
818 hpt_scsi_io(vbus_ext, ccb); in hpt_action()
822 ldm_reset_vbus((PVBUS)vbus_ext->vbus); in hpt_action()
875 PVBUS_EXT vbus_ext = (PVBUS_EXT)arg; in hpt_pci_intr() local
876 hpt_lock_vbus(vbus_ext); in hpt_pci_intr()
877 ldm_intr((PVBUS)vbus_ext->vbus); in hpt_pci_intr()
878 hpt_unlock_vbus(vbus_ext); in hpt_pci_intr()
883 PVBUS_EXT vbus_ext = (PVBUS_EXT)cam_sim_softc(sim); in hpt_poll() local
885 hpt_assert_vbus_locked(vbus_ext); in hpt_poll()
886 ldm_intr((PVBUS)vbus_ext->vbus); in hpt_poll()
912 static void __hpt_do_ioctl(PVBUS_EXT vbus_ext, IOCTL_ARG *ioctl_args) in __hpt_do_ioctl() argument
918 hpt_lock_vbus(vbus_ext); in __hpt_do_ioctl()
919 ldm_ioctl((PVBUS)vbus_ext->vbus, ioctl_args); in __hpt_do_ioctl()
922 if (hpt_sleep(vbus_ext, ioctl_args, PPAUSE, "hptctl", HPT_OSM_TIMEOUT)==0) in __hpt_do_ioctl()
924 ldm_reset_vbus((PVBUS)vbus_ext->vbus); in __hpt_do_ioctl()
925 __hpt_do_tasks(vbus_ext); in __hpt_do_ioctl()
930 hpt_unlock_vbus(vbus_ext); in __hpt_do_ioctl()
936 PVBUS_EXT vbus_ext; in hpt_do_ioctl() local
938 ldm_for_each_vbus(vbus, vbus_ext) { in hpt_do_ioctl()
939 __hpt_do_ioctl(vbus_ext, ioctl_args); in hpt_do_ioctl()
980 static int __hpt_stop_tasks(PVBUS_EXT vbus_ext, DEVICEID id) in __hpt_stop_tasks() argument
1009 __hpt_stop_tasks(vbus_ext, devinfo.u.array.Members[i]); in __hpt_stop_tasks()
1014 static void hpt_stop_tasks(PVBUS_EXT vbus_ext) in hpt_stop_tasks() argument
1022 __hpt_stop_tasks(vbus_ext, ids[i]); in hpt_stop_tasks()
1046 PVBUS_EXT vbus_ext; in hpt_final_init() local
1055 ldm_for_each_vbus(vbus, vbus_ext) { in hpt_final_init()
1056 if (hpt_alloc_mem(vbus_ext)) { in hpt_final_init()
1070 ldm_for_each_vbus(vbus, vbus_ext) { in hpt_final_init()
1072 mtx_init(&vbus_ext->lock, "hptsleeplock", NULL, MTX_DEF); in hpt_final_init()
1073 callout_init_mtx(&vbus_ext->timer, &vbus_ext->lock, 0); in hpt_final_init()
1074 if (hpt_init_vbus(vbus_ext)) { in hpt_final_init()
1081 ldm_for_each_vbus(vbus, vbus_ext) { in hpt_final_init()
1096 &vbus_ext->lock, /* lockfuncarg */ in hpt_final_init()
1097 &vbus_ext->io_dmat /* tag */)) in hpt_final_init()
1104 ext->vbus_ext = vbus_ext; in hpt_final_init()
1105 ext->next = vbus_ext->cmdext_list; in hpt_final_init()
1106 vbus_ext->cmdext_list = ext; in hpt_final_init()
1108 if (bus_dmamap_create(vbus_ext->io_dmat, 0, &ext->dma_map)) { in hpt_final_init()
1112 callout_init_mtx(&ext->timeout, &vbus_ext->lock, 0); in hpt_final_init()
1119 vbus_ext->sim = cam_sim_alloc(hpt_action, hpt_poll, driver_name, in hpt_final_init()
1120 vbus_ext, unit_number, &vbus_ext->lock, os_max_queue_comm, /*tagged*/8, devq); in hpt_final_init()
1122 if (!vbus_ext->sim) { in hpt_final_init()
1128 hpt_lock_vbus(vbus_ext); in hpt_final_init()
1129 if (xpt_bus_register(vbus_ext->sim, NULL, 0) != CAM_SUCCESS) { in hpt_final_init()
1130 hpt_unlock_vbus(vbus_ext); in hpt_final_init()
1132 cam_sim_free(vbus_ext->sim, /*free devq*/ TRUE); in hpt_final_init()
1133 vbus_ext->sim = NULL; in hpt_final_init()
1137 if (xpt_create_path(&vbus_ext->path, /*periph */ NULL, in hpt_final_init()
1138 cam_sim_path(vbus_ext->sim), CAM_TARGET_WILDCARD, in hpt_final_init()
1141 hpt_unlock_vbus(vbus_ext); in hpt_final_init()
1143 xpt_bus_deregister(cam_sim_path(vbus_ext->sim)); in hpt_final_init()
1144 cam_sim_free(vbus_ext->sim, /*free_devq*/TRUE); in hpt_final_init()
1145 vbus_ext->sim = NULL; in hpt_final_init()
1150 xpt_setup_ccb(&ccb.ccb_h, vbus_ext->path, /*priority*/5); in hpt_final_init()
1154 ccb.callback_arg = vbus_ext; in hpt_final_init()
1156 hpt_unlock_vbus(vbus_ext); in hpt_final_init()
1158 for (hba = vbus_ext->hba_list; hba; hba = hba->next) { in hpt_final_init()
1167 NULL, hpt_pci_intr, vbus_ext, &hba->irq_handle)) in hpt_final_init()
1176 vbus_ext->shutdown_eh = EVENTHANDLER_REGISTER(shutdown_final, in hpt_final_init()
1177 hpt_shutdown_vbus, vbus_ext, SHUTDOWN_PRI_DEFAULT); in hpt_final_init()
1178 if (!vbus_ext->shutdown_eh) in hpt_final_init()
1182 ldm_for_each_vbus(vbus, vbus_ext) { in hpt_final_init()
1183 TASK_INIT(&vbus_ext->worker, 0, (task_fn_t *)hpt_do_tasks, vbus_ext); in hpt_final_init()
1184 if (vbus_ext->tasks) in hpt_final_init()
1185 TASK_ENQUEUE(&vbus_ext->worker); in hpt_final_init()
1366 PVBUS_EXT vbus_ext; in hpt_rescan_bus() local
1368 ldm_for_each_vbus(vbus, vbus_ext) { in hpt_rescan_bus()
1373 if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(vbus_ext->sim), in hpt_rescan_bus()