Lines Matching refs:adapter
154 pvscsi_dev(const struct pvscsi_adapter *adapter) in pvscsi_dev() argument
156 return &(adapter->dev->dev); in pvscsi_dev()
160 pvscsi_find_context(const struct pvscsi_adapter *adapter, struct scsi_cmnd *cmd) in pvscsi_find_context() argument
164 end = &adapter->cmd_map[adapter->req_depth]; in pvscsi_find_context()
165 for (ctx = adapter->cmd_map; ctx < end; ctx++) in pvscsi_find_context()
173 pvscsi_acquire_context(struct pvscsi_adapter *adapter, struct scsi_cmnd *cmd) in pvscsi_acquire_context() argument
177 if (list_empty(&adapter->cmd_pool)) in pvscsi_acquire_context()
180 ctx = list_first_entry(&adapter->cmd_pool, struct pvscsi_ctx, list); in pvscsi_acquire_context()
187 static void pvscsi_release_context(struct pvscsi_adapter *adapter, in pvscsi_release_context() argument
192 list_add(&ctx->list, &adapter->cmd_pool); in pvscsi_release_context()
200 static u64 pvscsi_map_context(const struct pvscsi_adapter *adapter, in pvscsi_map_context() argument
203 return ctx - adapter->cmd_map + 1; in pvscsi_map_context()
207 pvscsi_get_context(const struct pvscsi_adapter *adapter, u64 context) in pvscsi_get_context() argument
209 return &adapter->cmd_map[context - 1]; in pvscsi_get_context()
212 static void pvscsi_reg_write(const struct pvscsi_adapter *adapter, in pvscsi_reg_write() argument
215 writel(val, adapter->mmioBase + offset); in pvscsi_reg_write()
218 static u32 pvscsi_reg_read(const struct pvscsi_adapter *adapter, u32 offset) in pvscsi_reg_read() argument
220 return readl(adapter->mmioBase + offset); in pvscsi_reg_read()
223 static u32 pvscsi_read_intr_status(const struct pvscsi_adapter *adapter) in pvscsi_read_intr_status() argument
225 return pvscsi_reg_read(adapter, PVSCSI_REG_OFFSET_INTR_STATUS); in pvscsi_read_intr_status()
228 static void pvscsi_write_intr_status(const struct pvscsi_adapter *adapter, in pvscsi_write_intr_status() argument
231 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_INTR_STATUS, val); in pvscsi_write_intr_status()
234 static void pvscsi_unmask_intr(const struct pvscsi_adapter *adapter) in pvscsi_unmask_intr() argument
239 if (adapter->use_msg) in pvscsi_unmask_intr()
242 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_INTR_MASK, intr_bits); in pvscsi_unmask_intr()
245 static void pvscsi_mask_intr(const struct pvscsi_adapter *adapter) in pvscsi_mask_intr() argument
247 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_INTR_MASK, 0); in pvscsi_mask_intr()
250 static void pvscsi_write_cmd_desc(const struct pvscsi_adapter *adapter, in pvscsi_write_cmd_desc() argument
257 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_COMMAND, cmd); in pvscsi_write_cmd_desc()
259 pvscsi_reg_write(adapter, in pvscsi_write_cmd_desc()
263 static void pvscsi_abort_cmd(const struct pvscsi_adapter *adapter, in pvscsi_abort_cmd() argument
269 cmd.context = pvscsi_map_context(adapter, ctx); in pvscsi_abort_cmd()
271 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_ABORT_CMD, &cmd, sizeof(cmd)); in pvscsi_abort_cmd()
274 static void pvscsi_kick_rw_io(const struct pvscsi_adapter *adapter) in pvscsi_kick_rw_io() argument
276 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_KICK_RW_IO, 0); in pvscsi_kick_rw_io()
279 static void pvscsi_process_request_ring(const struct pvscsi_adapter *adapter) in pvscsi_process_request_ring() argument
281 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_KICK_NON_RW_IO, 0); in pvscsi_process_request_ring()
292 static void pvscsi_kick_io(const struct pvscsi_adapter *adapter, in pvscsi_kick_io() argument
296 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_kick_io()
298 if (!adapter->use_req_threshold || in pvscsi_kick_io()
300 pvscsi_kick_rw_io(adapter); in pvscsi_kick_io()
302 pvscsi_process_request_ring(adapter); in pvscsi_kick_io()
306 static void ll_adapter_reset(const struct pvscsi_adapter *adapter) in ll_adapter_reset() argument
308 dev_dbg(pvscsi_dev(adapter), "Adapter Reset on %p\n", adapter); in ll_adapter_reset()
310 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_ADAPTER_RESET, NULL, 0); in ll_adapter_reset()
313 static void ll_bus_reset(const struct pvscsi_adapter *adapter) in ll_bus_reset() argument
315 dev_dbg(pvscsi_dev(adapter), "Resetting bus on %p\n", adapter); in ll_bus_reset()
317 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_RESET_BUS, NULL, 0); in ll_bus_reset()
320 static void ll_device_reset(const struct pvscsi_adapter *adapter, u32 target) in ll_device_reset() argument
324 dev_dbg(pvscsi_dev(adapter), "Resetting device: target=%u\n", target); in ll_device_reset()
328 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_RESET_DEVICE, in ll_device_reset()
352 static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, in pvscsi_map_buffers() argument
378 ctx->sglPA = pci_map_single(adapter->dev, ctx->sgl, in pvscsi_map_buffers()
380 if (pci_dma_mapping_error(adapter->dev, ctx->sglPA)) { in pvscsi_map_buffers()
395 ctx->dataPA = pci_map_single(adapter->dev, sg, bufflen, in pvscsi_map_buffers()
397 if (pci_dma_mapping_error(adapter->dev, ctx->dataPA)) { in pvscsi_map_buffers()
408 static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter, in pvscsi_unmap_buffers() argument
423 pci_unmap_single(adapter->dev, ctx->sglPA, in pvscsi_unmap_buffers()
428 pci_unmap_single(adapter->dev, ctx->dataPA, bufflen, in pvscsi_unmap_buffers()
432 pci_unmap_single(adapter->dev, ctx->sensePA, in pvscsi_unmap_buffers()
436 static int pvscsi_allocate_rings(struct pvscsi_adapter *adapter) in pvscsi_allocate_rings() argument
438 adapter->rings_state = pci_alloc_consistent(adapter->dev, PAGE_SIZE, in pvscsi_allocate_rings()
439 &adapter->ringStatePA); in pvscsi_allocate_rings()
440 if (!adapter->rings_state) in pvscsi_allocate_rings()
443 adapter->req_pages = min(PVSCSI_MAX_NUM_PAGES_REQ_RING, in pvscsi_allocate_rings()
445 adapter->req_depth = adapter->req_pages in pvscsi_allocate_rings()
447 adapter->req_ring = pci_alloc_consistent(adapter->dev, in pvscsi_allocate_rings()
448 adapter->req_pages * PAGE_SIZE, in pvscsi_allocate_rings()
449 &adapter->reqRingPA); in pvscsi_allocate_rings()
450 if (!adapter->req_ring) in pvscsi_allocate_rings()
453 adapter->cmp_pages = min(PVSCSI_MAX_NUM_PAGES_CMP_RING, in pvscsi_allocate_rings()
455 adapter->cmp_ring = pci_alloc_consistent(adapter->dev, in pvscsi_allocate_rings()
456 adapter->cmp_pages * PAGE_SIZE, in pvscsi_allocate_rings()
457 &adapter->cmpRingPA); in pvscsi_allocate_rings()
458 if (!adapter->cmp_ring) in pvscsi_allocate_rings()
461 BUG_ON(!IS_ALIGNED(adapter->ringStatePA, PAGE_SIZE)); in pvscsi_allocate_rings()
462 BUG_ON(!IS_ALIGNED(adapter->reqRingPA, PAGE_SIZE)); in pvscsi_allocate_rings()
463 BUG_ON(!IS_ALIGNED(adapter->cmpRingPA, PAGE_SIZE)); in pvscsi_allocate_rings()
465 if (!adapter->use_msg) in pvscsi_allocate_rings()
468 adapter->msg_pages = min(PVSCSI_MAX_NUM_PAGES_MSG_RING, in pvscsi_allocate_rings()
470 adapter->msg_ring = pci_alloc_consistent(adapter->dev, in pvscsi_allocate_rings()
471 adapter->msg_pages * PAGE_SIZE, in pvscsi_allocate_rings()
472 &adapter->msgRingPA); in pvscsi_allocate_rings()
473 if (!adapter->msg_ring) in pvscsi_allocate_rings()
475 BUG_ON(!IS_ALIGNED(adapter->msgRingPA, PAGE_SIZE)); in pvscsi_allocate_rings()
480 static void pvscsi_setup_all_rings(const struct pvscsi_adapter *adapter) in pvscsi_setup_all_rings() argument
486 cmd.ringsStatePPN = adapter->ringStatePA >> PAGE_SHIFT; in pvscsi_setup_all_rings()
487 cmd.reqRingNumPages = adapter->req_pages; in pvscsi_setup_all_rings()
488 cmd.cmpRingNumPages = adapter->cmp_pages; in pvscsi_setup_all_rings()
490 base = adapter->reqRingPA; in pvscsi_setup_all_rings()
491 for (i = 0; i < adapter->req_pages; i++) { in pvscsi_setup_all_rings()
496 base = adapter->cmpRingPA; in pvscsi_setup_all_rings()
497 for (i = 0; i < adapter->cmp_pages; i++) { in pvscsi_setup_all_rings()
502 memset(adapter->rings_state, 0, PAGE_SIZE); in pvscsi_setup_all_rings()
503 memset(adapter->req_ring, 0, adapter->req_pages * PAGE_SIZE); in pvscsi_setup_all_rings()
504 memset(adapter->cmp_ring, 0, adapter->cmp_pages * PAGE_SIZE); in pvscsi_setup_all_rings()
506 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_SETUP_RINGS, in pvscsi_setup_all_rings()
509 if (adapter->use_msg) { in pvscsi_setup_all_rings()
512 cmd_msg.numPages = adapter->msg_pages; in pvscsi_setup_all_rings()
514 base = adapter->msgRingPA; in pvscsi_setup_all_rings()
515 for (i = 0; i < adapter->msg_pages; i++) { in pvscsi_setup_all_rings()
519 memset(adapter->msg_ring, 0, adapter->msg_pages * PAGE_SIZE); in pvscsi_setup_all_rings()
521 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_SETUP_MSG_RING, in pvscsi_setup_all_rings()
537 static void pvscsi_complete_request(struct pvscsi_adapter *adapter, in pvscsi_complete_request() argument
546 ctx = pvscsi_get_context(adapter, e->context); in pvscsi_complete_request()
549 pvscsi_unmap_buffers(adapter, ctx); in pvscsi_complete_request()
550 pvscsi_release_context(adapter, ctx); in pvscsi_complete_request()
643 static void pvscsi_process_completion_ring(struct pvscsi_adapter *adapter) in pvscsi_process_completion_ring() argument
645 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_process_completion_ring()
646 struct PVSCSIRingCmpDesc *ring = adapter->cmp_ring; in pvscsi_process_completion_ring()
659 pvscsi_complete_request(adapter, e); in pvscsi_process_completion_ring()
674 static int pvscsi_queue_ring(struct pvscsi_adapter *adapter, in pvscsi_queue_ring() argument
682 s = adapter->rings_state; in pvscsi_queue_ring()
701 e = adapter->req_ring + (s->reqProdIdx & MASK(req_entries)); in pvscsi_queue_ring()
709 ctx->sensePA = pci_map_single(adapter->dev, cmd->sense_buffer, in pvscsi_queue_ring()
712 if (pci_dma_mapping_error(adapter->dev, ctx->sensePA)) { in pvscsi_queue_ring()
739 if (pvscsi_map_buffers(adapter, ctx, cmd, e) != 0) { in pvscsi_queue_ring()
741 pci_unmap_single(adapter->dev, ctx->sensePA, in pvscsi_queue_ring()
749 e->context = pvscsi_map_context(adapter, ctx); in pvscsi_queue_ring()
761 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_queue_lck() local
765 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_queue_lck()
767 ctx = pvscsi_acquire_context(adapter, cmd); in pvscsi_queue_lck()
768 if (!ctx || pvscsi_queue_ring(adapter, ctx, cmd) != 0) { in pvscsi_queue_lck()
770 pvscsi_release_context(adapter, ctx); in pvscsi_queue_lck()
771 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_queue_lck()
780 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_queue_lck()
782 pvscsi_kick_io(adapter, cmd->cmnd[0]); in pvscsi_queue_lck()
791 struct pvscsi_adapter *adapter = shost_priv(cmd->device->host); in DEF_SCSI_QCMD() local
799 adapter->host->host_no, cmd); in DEF_SCSI_QCMD()
801 spin_lock_irqsave(&adapter->hw_lock, flags); in DEF_SCSI_QCMD()
807 pvscsi_process_completion_ring(adapter); in DEF_SCSI_QCMD()
813 ctx = pvscsi_find_context(adapter, cmd); in DEF_SCSI_QCMD()
825 pvscsi_abort_cmd(adapter, ctx); in DEF_SCSI_QCMD()
826 spin_unlock_irqrestore(&adapter->hw_lock, flags); in DEF_SCSI_QCMD()
829 spin_lock_irqsave(&adapter->hw_lock, flags); in DEF_SCSI_QCMD()
851 spin_unlock_irqrestore(&adapter->hw_lock, flags); in DEF_SCSI_QCMD()
861 static void pvscsi_reset_all(struct pvscsi_adapter *adapter) in pvscsi_reset_all() argument
865 for (i = 0; i < adapter->req_depth; i++) { in pvscsi_reset_all()
866 struct pvscsi_ctx *ctx = &adapter->cmd_map[i]; in pvscsi_reset_all()
871 pvscsi_unmap_buffers(adapter, ctx); in pvscsi_reset_all()
872 pvscsi_release_context(adapter, ctx); in pvscsi_reset_all()
882 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_host_reset() local
888 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_host_reset()
890 use_msg = adapter->use_msg; in pvscsi_host_reset()
893 adapter->use_msg = 0; in pvscsi_host_reset()
894 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_host_reset()
900 flush_workqueue(adapter->workqueue); in pvscsi_host_reset()
901 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_host_reset()
910 pvscsi_process_request_ring(adapter); in pvscsi_host_reset()
912 ll_adapter_reset(adapter); in pvscsi_host_reset()
921 pvscsi_process_completion_ring(adapter); in pvscsi_host_reset()
923 pvscsi_reset_all(adapter); in pvscsi_host_reset()
924 adapter->use_msg = use_msg; in pvscsi_host_reset()
925 pvscsi_setup_all_rings(adapter); in pvscsi_host_reset()
926 pvscsi_unmask_intr(adapter); in pvscsi_host_reset()
928 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_host_reset()
936 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_bus_reset() local
947 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_bus_reset()
949 pvscsi_process_request_ring(adapter); in pvscsi_bus_reset()
950 ll_bus_reset(adapter); in pvscsi_bus_reset()
951 pvscsi_process_completion_ring(adapter); in pvscsi_bus_reset()
953 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_bus_reset()
961 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_device_reset() local
972 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_device_reset()
974 pvscsi_process_request_ring(adapter); in pvscsi_device_reset()
975 ll_device_reset(adapter, cmd->device->id); in pvscsi_device_reset()
976 pvscsi_process_completion_ring(adapter); in pvscsi_device_reset()
978 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_device_reset()
987 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_info() local
991 "%u/%u/%u pages, cmd_per_lun=%u", adapter->rev, in pvscsi_info()
992 adapter->req_pages, adapter->cmp_pages, adapter->msg_pages, in pvscsi_info()
1016 static void pvscsi_process_msg(const struct pvscsi_adapter *adapter, in pvscsi_process_msg() argument
1019 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_process_msg()
1020 struct Scsi_Host *host = adapter->host; in pvscsi_process_msg()
1045 scsi_add_device(adapter->host, desc->bus, in pvscsi_process_msg()
1074 static int pvscsi_msg_pending(const struct pvscsi_adapter *adapter) in pvscsi_msg_pending() argument
1076 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_msg_pending()
1081 static void pvscsi_process_msg_ring(const struct pvscsi_adapter *adapter) in pvscsi_process_msg_ring() argument
1083 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_process_msg_ring()
1084 struct PVSCSIRingMsgDesc *ring = adapter->msg_ring; in pvscsi_process_msg_ring()
1087 while (pvscsi_msg_pending(adapter)) { in pvscsi_process_msg_ring()
1092 pvscsi_process_msg(adapter, e); in pvscsi_process_msg_ring()
1100 struct pvscsi_adapter *adapter; in pvscsi_msg_workqueue_handler() local
1102 adapter = container_of(data, struct pvscsi_adapter, work); in pvscsi_msg_workqueue_handler()
1104 pvscsi_process_msg_ring(adapter); in pvscsi_msg_workqueue_handler()
1107 static int pvscsi_setup_msg_workqueue(struct pvscsi_adapter *adapter) in pvscsi_setup_msg_workqueue() argument
1114 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_COMMAND, in pvscsi_setup_msg_workqueue()
1117 if (pvscsi_reg_read(adapter, PVSCSI_REG_OFFSET_COMMAND_STATUS) == -1) in pvscsi_setup_msg_workqueue()
1121 "vmw_pvscsi_wq_%u", adapter->host->host_no); in pvscsi_setup_msg_workqueue()
1123 adapter->workqueue = create_singlethread_workqueue(name); in pvscsi_setup_msg_workqueue()
1124 if (!adapter->workqueue) { in pvscsi_setup_msg_workqueue()
1128 INIT_WORK(&adapter->work, pvscsi_msg_workqueue_handler); in pvscsi_setup_msg_workqueue()
1133 static bool pvscsi_setup_req_threshold(struct pvscsi_adapter *adapter, in pvscsi_setup_req_threshold() argument
1141 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_COMMAND, in pvscsi_setup_req_threshold()
1143 val = pvscsi_reg_read(adapter, PVSCSI_REG_OFFSET_COMMAND_STATUS); in pvscsi_setup_req_threshold()
1153 pvscsi_write_cmd_desc(adapter, in pvscsi_setup_req_threshold()
1156 return pvscsi_reg_read(adapter, in pvscsi_setup_req_threshold()
1163 struct pvscsi_adapter *adapter = devp; in pvscsi_isr() local
1166 if (adapter->use_msi || adapter->use_msix) in pvscsi_isr()
1169 u32 val = pvscsi_read_intr_status(adapter); in pvscsi_isr()
1178 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_isr()
1180 pvscsi_process_completion_ring(adapter); in pvscsi_isr()
1181 if (adapter->use_msg && pvscsi_msg_pending(adapter)) in pvscsi_isr()
1182 queue_work(adapter->workqueue, &adapter->work); in pvscsi_isr()
1184 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_isr()
1190 static void pvscsi_free_sgls(const struct pvscsi_adapter *adapter) in pvscsi_free_sgls() argument
1192 struct pvscsi_ctx *ctx = adapter->cmd_map; in pvscsi_free_sgls()
1195 for (i = 0; i < adapter->req_depth; ++i, ++ctx) in pvscsi_free_sgls()
1199 static int pvscsi_setup_msix(const struct pvscsi_adapter *adapter, in pvscsi_setup_msix() argument
1205 ret = pci_enable_msix_exact(adapter->dev, &entry, 1); in pvscsi_setup_msix()
1214 static void pvscsi_shutdown_intr(struct pvscsi_adapter *adapter) in pvscsi_shutdown_intr() argument
1216 if (adapter->irq) { in pvscsi_shutdown_intr()
1217 free_irq(adapter->irq, adapter); in pvscsi_shutdown_intr()
1218 adapter->irq = 0; in pvscsi_shutdown_intr()
1220 if (adapter->use_msi) { in pvscsi_shutdown_intr()
1221 pci_disable_msi(adapter->dev); in pvscsi_shutdown_intr()
1222 adapter->use_msi = 0; in pvscsi_shutdown_intr()
1223 } else if (adapter->use_msix) { in pvscsi_shutdown_intr()
1224 pci_disable_msix(adapter->dev); in pvscsi_shutdown_intr()
1225 adapter->use_msix = 0; in pvscsi_shutdown_intr()
1229 static void pvscsi_release_resources(struct pvscsi_adapter *adapter) in pvscsi_release_resources() argument
1231 pvscsi_shutdown_intr(adapter); in pvscsi_release_resources()
1233 if (adapter->workqueue) in pvscsi_release_resources()
1234 destroy_workqueue(adapter->workqueue); in pvscsi_release_resources()
1236 if (adapter->mmioBase) in pvscsi_release_resources()
1237 pci_iounmap(adapter->dev, adapter->mmioBase); in pvscsi_release_resources()
1239 pci_release_regions(adapter->dev); in pvscsi_release_resources()
1241 if (adapter->cmd_map) { in pvscsi_release_resources()
1242 pvscsi_free_sgls(adapter); in pvscsi_release_resources()
1243 kfree(adapter->cmd_map); in pvscsi_release_resources()
1246 if (adapter->rings_state) in pvscsi_release_resources()
1247 pci_free_consistent(adapter->dev, PAGE_SIZE, in pvscsi_release_resources()
1248 adapter->rings_state, adapter->ringStatePA); in pvscsi_release_resources()
1250 if (adapter->req_ring) in pvscsi_release_resources()
1251 pci_free_consistent(adapter->dev, in pvscsi_release_resources()
1252 adapter->req_pages * PAGE_SIZE, in pvscsi_release_resources()
1253 adapter->req_ring, adapter->reqRingPA); in pvscsi_release_resources()
1255 if (adapter->cmp_ring) in pvscsi_release_resources()
1256 pci_free_consistent(adapter->dev, in pvscsi_release_resources()
1257 adapter->cmp_pages * PAGE_SIZE, in pvscsi_release_resources()
1258 adapter->cmp_ring, adapter->cmpRingPA); in pvscsi_release_resources()
1260 if (adapter->msg_ring) in pvscsi_release_resources()
1261 pci_free_consistent(adapter->dev, in pvscsi_release_resources()
1262 adapter->msg_pages * PAGE_SIZE, in pvscsi_release_resources()
1263 adapter->msg_ring, adapter->msgRingPA); in pvscsi_release_resources()
1279 static int pvscsi_allocate_sg(struct pvscsi_adapter *adapter) in pvscsi_allocate_sg() argument
1284 ctx = adapter->cmd_map; in pvscsi_allocate_sg()
1287 for (i = 0; i < adapter->req_depth; ++i, ++ctx) { in pvscsi_allocate_sg()
1310 static u32 pvscsi_get_max_targets(struct pvscsi_adapter *adapter) in pvscsi_get_max_targets() argument
1319 dev = pvscsi_dev(adapter); in pvscsi_get_max_targets()
1320 config_page = pci_alloc_consistent(adapter->dev, PAGE_SIZE, in pvscsi_get_max_targets()
1344 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_CONFIG, &cmd, sizeof cmd); in pvscsi_get_max_targets()
1355 pci_free_consistent(adapter->dev, PAGE_SIZE, config_page, configPagePA); in pvscsi_get_max_targets()
1362 struct pvscsi_adapter *adapter; in pvscsi_probe() local
1391 adapter = &adapter_temp; in pvscsi_probe()
1392 memset(adapter, 0, sizeof(*adapter)); in pvscsi_probe()
1393 adapter->dev = pdev; in pvscsi_probe()
1394 adapter->rev = pdev->revision; in pvscsi_probe()
1417 adapter->mmioBase = pci_iomap(pdev, i, PVSCSI_MEM_SPACE_SIZE); in pvscsi_probe()
1419 if (!adapter->mmioBase) { in pvscsi_probe()
1432 max_id = pvscsi_get_max_targets(adapter); in pvscsi_probe()
1461 adapter = shost_priv(host); in pvscsi_probe()
1462 memset(adapter, 0, sizeof(*adapter)); in pvscsi_probe()
1463 adapter->dev = pdev; in pvscsi_probe()
1464 adapter->host = host; in pvscsi_probe()
1468 adapter->rev = adapter_temp.rev; in pvscsi_probe()
1469 adapter->mmioBase = adapter_temp.mmioBase; in pvscsi_probe()
1471 spin_lock_init(&adapter->hw_lock); in pvscsi_probe()
1479 ll_adapter_reset(adapter); in pvscsi_probe()
1481 adapter->use_msg = pvscsi_setup_msg_workqueue(adapter); in pvscsi_probe()
1483 error = pvscsi_allocate_rings(adapter); in pvscsi_probe()
1493 pvscsi_setup_all_rings(adapter); in pvscsi_probe()
1495 adapter->cmd_map = kcalloc(adapter->req_depth, in pvscsi_probe()
1497 if (!adapter->cmd_map) { in pvscsi_probe()
1503 INIT_LIST_HEAD(&adapter->cmd_pool); in pvscsi_probe()
1504 for (i = 0; i < adapter->req_depth; i++) { in pvscsi_probe()
1505 struct pvscsi_ctx *ctx = adapter->cmd_map + i; in pvscsi_probe()
1506 list_add(&ctx->list, &adapter->cmd_pool); in pvscsi_probe()
1509 error = pvscsi_allocate_sg(adapter); in pvscsi_probe()
1516 pvscsi_setup_msix(adapter, &adapter->irq) == 0) { in pvscsi_probe()
1518 adapter->use_msix = 1; in pvscsi_probe()
1521 adapter->use_msi = 1; in pvscsi_probe()
1522 adapter->irq = pdev->irq; in pvscsi_probe()
1525 adapter->irq = pdev->irq; in pvscsi_probe()
1529 adapter->use_req_threshold = pvscsi_setup_req_threshold(adapter, true); in pvscsi_probe()
1531 adapter->use_req_threshold ? "en" : "dis"); in pvscsi_probe()
1533 error = request_irq(adapter->irq, pvscsi_isr, flags, in pvscsi_probe()
1534 "vmw_pvscsi", adapter); in pvscsi_probe()
1538 adapter->irq = 0; in pvscsi_probe()
1550 adapter->rev, host->host_no); in pvscsi_probe()
1552 pvscsi_unmask_intr(adapter); in pvscsi_probe()
1559 ll_adapter_reset(adapter); in pvscsi_probe()
1561 pvscsi_release_resources(adapter); in pvscsi_probe()
1569 pvscsi_release_resources(adapter); in pvscsi_probe()
1573 static void __pvscsi_shutdown(struct pvscsi_adapter *adapter) in __pvscsi_shutdown() argument
1575 pvscsi_mask_intr(adapter); in __pvscsi_shutdown()
1577 if (adapter->workqueue) in __pvscsi_shutdown()
1578 flush_workqueue(adapter->workqueue); in __pvscsi_shutdown()
1580 pvscsi_shutdown_intr(adapter); in __pvscsi_shutdown()
1582 pvscsi_process_request_ring(adapter); in __pvscsi_shutdown()
1583 pvscsi_process_completion_ring(adapter); in __pvscsi_shutdown()
1584 ll_adapter_reset(adapter); in __pvscsi_shutdown()
1590 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_shutdown() local
1592 __pvscsi_shutdown(adapter); in pvscsi_shutdown()
1598 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_remove() local
1602 __pvscsi_shutdown(adapter); in pvscsi_remove()
1603 pvscsi_release_resources(adapter); in pvscsi_remove()