Lines Matching refs:adapter
149 pvscsi_dev(const struct pvscsi_adapter *adapter) in pvscsi_dev() argument
151 return &(adapter->dev->dev); in pvscsi_dev()
155 pvscsi_find_context(const struct pvscsi_adapter *adapter, struct scsi_cmnd *cmd) in pvscsi_find_context() argument
159 end = &adapter->cmd_map[adapter->req_depth]; in pvscsi_find_context()
160 for (ctx = adapter->cmd_map; ctx < end; ctx++) in pvscsi_find_context()
168 pvscsi_acquire_context(struct pvscsi_adapter *adapter, struct scsi_cmnd *cmd) in pvscsi_acquire_context() argument
172 if (list_empty(&adapter->cmd_pool)) in pvscsi_acquire_context()
175 ctx = list_first_entry(&adapter->cmd_pool, struct pvscsi_ctx, list); in pvscsi_acquire_context()
182 static void pvscsi_release_context(struct pvscsi_adapter *adapter, in pvscsi_release_context() argument
187 list_add(&ctx->list, &adapter->cmd_pool); in pvscsi_release_context()
195 static u64 pvscsi_map_context(const struct pvscsi_adapter *adapter, in pvscsi_map_context() argument
198 return ctx - adapter->cmd_map + 1; in pvscsi_map_context()
202 pvscsi_get_context(const struct pvscsi_adapter *adapter, u64 context) in pvscsi_get_context() argument
204 return &adapter->cmd_map[context - 1]; in pvscsi_get_context()
207 static void pvscsi_reg_write(const struct pvscsi_adapter *adapter, in pvscsi_reg_write() argument
210 writel(val, adapter->mmioBase + offset); in pvscsi_reg_write()
213 static u32 pvscsi_reg_read(const struct pvscsi_adapter *adapter, u32 offset) in pvscsi_reg_read() argument
215 return readl(adapter->mmioBase + offset); in pvscsi_reg_read()
218 static u32 pvscsi_read_intr_status(const struct pvscsi_adapter *adapter) in pvscsi_read_intr_status() argument
220 return pvscsi_reg_read(adapter, PVSCSI_REG_OFFSET_INTR_STATUS); in pvscsi_read_intr_status()
223 static void pvscsi_write_intr_status(const struct pvscsi_adapter *adapter, in pvscsi_write_intr_status() argument
226 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_INTR_STATUS, val); in pvscsi_write_intr_status()
229 static void pvscsi_unmask_intr(const struct pvscsi_adapter *adapter) in pvscsi_unmask_intr() argument
234 if (adapter->use_msg) in pvscsi_unmask_intr()
237 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_INTR_MASK, intr_bits); in pvscsi_unmask_intr()
240 static void pvscsi_mask_intr(const struct pvscsi_adapter *adapter) in pvscsi_mask_intr() argument
242 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_INTR_MASK, 0); in pvscsi_mask_intr()
245 static void pvscsi_write_cmd_desc(const struct pvscsi_adapter *adapter, in pvscsi_write_cmd_desc() argument
252 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_COMMAND, cmd); in pvscsi_write_cmd_desc()
254 pvscsi_reg_write(adapter, in pvscsi_write_cmd_desc()
258 static void pvscsi_abort_cmd(const struct pvscsi_adapter *adapter, in pvscsi_abort_cmd() argument
264 cmd.context = pvscsi_map_context(adapter, ctx); in pvscsi_abort_cmd()
266 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_ABORT_CMD, &cmd, sizeof(cmd)); in pvscsi_abort_cmd()
269 static void pvscsi_kick_rw_io(const struct pvscsi_adapter *adapter) in pvscsi_kick_rw_io() argument
271 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_KICK_RW_IO, 0); in pvscsi_kick_rw_io()
274 static void pvscsi_process_request_ring(const struct pvscsi_adapter *adapter) in pvscsi_process_request_ring() argument
276 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_KICK_NON_RW_IO, 0); in pvscsi_process_request_ring()
287 static void pvscsi_kick_io(const struct pvscsi_adapter *adapter, in pvscsi_kick_io() argument
291 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_kick_io()
293 if (!adapter->use_req_threshold || in pvscsi_kick_io()
295 pvscsi_kick_rw_io(adapter); in pvscsi_kick_io()
297 pvscsi_process_request_ring(adapter); in pvscsi_kick_io()
301 static void ll_adapter_reset(const struct pvscsi_adapter *adapter) in ll_adapter_reset() argument
303 dev_dbg(pvscsi_dev(adapter), "Adapter Reset on %p\n", adapter); in ll_adapter_reset()
305 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_ADAPTER_RESET, NULL, 0); in ll_adapter_reset()
308 static void ll_bus_reset(const struct pvscsi_adapter *adapter) in ll_bus_reset() argument
310 dev_dbg(pvscsi_dev(adapter), "Resetting bus on %p\n", adapter); in ll_bus_reset()
312 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_RESET_BUS, NULL, 0); in ll_bus_reset()
315 static void ll_device_reset(const struct pvscsi_adapter *adapter, u32 target) in ll_device_reset() argument
319 dev_dbg(pvscsi_dev(adapter), "Resetting device: target=%u\n", target); in ll_device_reset()
323 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_RESET_DEVICE, in ll_device_reset()
347 static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, in pvscsi_map_buffers() argument
373 ctx->sglPA = dma_map_single(&adapter->dev->dev, in pvscsi_map_buffers()
375 if (dma_mapping_error(&adapter->dev->dev, ctx->sglPA)) { in pvscsi_map_buffers()
390 ctx->dataPA = dma_map_single(&adapter->dev->dev, sg, bufflen, in pvscsi_map_buffers()
392 if (dma_mapping_error(&adapter->dev->dev, ctx->dataPA)) { in pvscsi_map_buffers()
414 static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter, in pvscsi_unmap_buffers() argument
429 dma_unmap_single(&adapter->dev->dev, ctx->sglPA, in pvscsi_unmap_buffers()
434 dma_unmap_single(&adapter->dev->dev, ctx->dataPA, in pvscsi_unmap_buffers()
438 dma_unmap_single(&adapter->dev->dev, ctx->sensePA, in pvscsi_unmap_buffers()
442 static int pvscsi_allocate_rings(struct pvscsi_adapter *adapter) in pvscsi_allocate_rings() argument
444 adapter->rings_state = dma_alloc_coherent(&adapter->dev->dev, PAGE_SIZE, in pvscsi_allocate_rings()
445 &adapter->ringStatePA, GFP_KERNEL); in pvscsi_allocate_rings()
446 if (!adapter->rings_state) in pvscsi_allocate_rings()
449 adapter->req_pages = min(PVSCSI_MAX_NUM_PAGES_REQ_RING, in pvscsi_allocate_rings()
451 adapter->req_depth = adapter->req_pages in pvscsi_allocate_rings()
453 adapter->req_ring = dma_alloc_coherent(&adapter->dev->dev, in pvscsi_allocate_rings()
454 adapter->req_pages * PAGE_SIZE, &adapter->reqRingPA, in pvscsi_allocate_rings()
456 if (!adapter->req_ring) in pvscsi_allocate_rings()
459 adapter->cmp_pages = min(PVSCSI_MAX_NUM_PAGES_CMP_RING, in pvscsi_allocate_rings()
461 adapter->cmp_ring = dma_alloc_coherent(&adapter->dev->dev, in pvscsi_allocate_rings()
462 adapter->cmp_pages * PAGE_SIZE, &adapter->cmpRingPA, in pvscsi_allocate_rings()
464 if (!adapter->cmp_ring) in pvscsi_allocate_rings()
467 BUG_ON(!IS_ALIGNED(adapter->ringStatePA, PAGE_SIZE)); in pvscsi_allocate_rings()
468 BUG_ON(!IS_ALIGNED(adapter->reqRingPA, PAGE_SIZE)); in pvscsi_allocate_rings()
469 BUG_ON(!IS_ALIGNED(adapter->cmpRingPA, PAGE_SIZE)); in pvscsi_allocate_rings()
471 if (!adapter->use_msg) in pvscsi_allocate_rings()
474 adapter->msg_pages = min(PVSCSI_MAX_NUM_PAGES_MSG_RING, in pvscsi_allocate_rings()
476 adapter->msg_ring = dma_alloc_coherent(&adapter->dev->dev, in pvscsi_allocate_rings()
477 adapter->msg_pages * PAGE_SIZE, &adapter->msgRingPA, in pvscsi_allocate_rings()
479 if (!adapter->msg_ring) in pvscsi_allocate_rings()
481 BUG_ON(!IS_ALIGNED(adapter->msgRingPA, PAGE_SIZE)); in pvscsi_allocate_rings()
486 static void pvscsi_setup_all_rings(const struct pvscsi_adapter *adapter) in pvscsi_setup_all_rings() argument
492 cmd.ringsStatePPN = adapter->ringStatePA >> PAGE_SHIFT; in pvscsi_setup_all_rings()
493 cmd.reqRingNumPages = adapter->req_pages; in pvscsi_setup_all_rings()
494 cmd.cmpRingNumPages = adapter->cmp_pages; in pvscsi_setup_all_rings()
496 base = adapter->reqRingPA; in pvscsi_setup_all_rings()
497 for (i = 0; i < adapter->req_pages; i++) { in pvscsi_setup_all_rings()
502 base = adapter->cmpRingPA; in pvscsi_setup_all_rings()
503 for (i = 0; i < adapter->cmp_pages; i++) { in pvscsi_setup_all_rings()
508 memset(adapter->rings_state, 0, PAGE_SIZE); in pvscsi_setup_all_rings()
509 memset(adapter->req_ring, 0, adapter->req_pages * PAGE_SIZE); in pvscsi_setup_all_rings()
510 memset(adapter->cmp_ring, 0, adapter->cmp_pages * PAGE_SIZE); in pvscsi_setup_all_rings()
512 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_SETUP_RINGS, in pvscsi_setup_all_rings()
515 if (adapter->use_msg) { in pvscsi_setup_all_rings()
518 cmd_msg.numPages = adapter->msg_pages; in pvscsi_setup_all_rings()
520 base = adapter->msgRingPA; in pvscsi_setup_all_rings()
521 for (i = 0; i < adapter->msg_pages; i++) { in pvscsi_setup_all_rings()
525 memset(adapter->msg_ring, 0, adapter->msg_pages * PAGE_SIZE); in pvscsi_setup_all_rings()
527 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_SETUP_MSG_RING, in pvscsi_setup_all_rings()
543 static void pvscsi_complete_request(struct pvscsi_adapter *adapter, in pvscsi_complete_request() argument
552 ctx = pvscsi_get_context(adapter, e->context); in pvscsi_complete_request()
555 pvscsi_unmap_buffers(adapter, ctx); in pvscsi_complete_request()
558 pvscsi_release_context(adapter, ctx); in pvscsi_complete_request()
659 static void pvscsi_process_completion_ring(struct pvscsi_adapter *adapter) in pvscsi_process_completion_ring() argument
661 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_process_completion_ring()
662 struct PVSCSIRingCmpDesc *ring = adapter->cmp_ring; in pvscsi_process_completion_ring()
675 pvscsi_complete_request(adapter, e); in pvscsi_process_completion_ring()
690 static int pvscsi_queue_ring(struct pvscsi_adapter *adapter, in pvscsi_queue_ring() argument
698 s = adapter->rings_state; in pvscsi_queue_ring()
717 e = adapter->req_ring + (s->reqProdIdx & MASK(req_entries)); in pvscsi_queue_ring()
725 ctx->sensePA = dma_map_single(&adapter->dev->dev, in pvscsi_queue_ring()
728 if (dma_mapping_error(&adapter->dev->dev, ctx->sensePA)) { in pvscsi_queue_ring()
755 if (pvscsi_map_buffers(adapter, ctx, cmd, e) != 0) { in pvscsi_queue_ring()
757 dma_unmap_single(&adapter->dev->dev, ctx->sensePA, in pvscsi_queue_ring()
765 e->context = pvscsi_map_context(adapter, ctx); in pvscsi_queue_ring()
777 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_queue_lck() local
782 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_queue_lck()
784 ctx = pvscsi_acquire_context(adapter, cmd); in pvscsi_queue_lck()
785 if (!ctx || pvscsi_queue_ring(adapter, ctx, cmd) != 0) { in pvscsi_queue_lck()
787 pvscsi_release_context(adapter, ctx); in pvscsi_queue_lck()
788 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_queue_lck()
797 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_queue_lck()
799 pvscsi_kick_io(adapter, op); in pvscsi_queue_lck()
808 struct pvscsi_adapter *adapter = shost_priv(cmd->device->host); in DEF_SCSI_QCMD() local
816 adapter->host->host_no, cmd); in DEF_SCSI_QCMD()
818 spin_lock_irqsave(&adapter->hw_lock, flags); in DEF_SCSI_QCMD()
824 pvscsi_process_completion_ring(adapter); in DEF_SCSI_QCMD()
830 ctx = pvscsi_find_context(adapter, cmd); in DEF_SCSI_QCMD()
842 pvscsi_abort_cmd(adapter, ctx); in DEF_SCSI_QCMD()
843 spin_unlock_irqrestore(&adapter->hw_lock, flags); in DEF_SCSI_QCMD()
846 spin_lock_irqsave(&adapter->hw_lock, flags); in DEF_SCSI_QCMD()
868 spin_unlock_irqrestore(&adapter->hw_lock, flags); in DEF_SCSI_QCMD()
878 static void pvscsi_reset_all(struct pvscsi_adapter *adapter) in pvscsi_reset_all() argument
882 for (i = 0; i < adapter->req_depth; i++) { in pvscsi_reset_all()
883 struct pvscsi_ctx *ctx = &adapter->cmd_map[i]; in pvscsi_reset_all()
888 pvscsi_unmap_buffers(adapter, ctx); in pvscsi_reset_all()
890 pvscsi_release_context(adapter, ctx); in pvscsi_reset_all()
900 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_host_reset() local
906 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_host_reset()
908 use_msg = adapter->use_msg; in pvscsi_host_reset()
911 adapter->use_msg = false; in pvscsi_host_reset()
912 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_host_reset()
918 flush_workqueue(adapter->workqueue); in pvscsi_host_reset()
919 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_host_reset()
928 pvscsi_process_request_ring(adapter); in pvscsi_host_reset()
930 ll_adapter_reset(adapter); in pvscsi_host_reset()
939 pvscsi_process_completion_ring(adapter); in pvscsi_host_reset()
941 pvscsi_reset_all(adapter); in pvscsi_host_reset()
942 adapter->use_msg = use_msg; in pvscsi_host_reset()
943 pvscsi_setup_all_rings(adapter); in pvscsi_host_reset()
944 pvscsi_unmask_intr(adapter); in pvscsi_host_reset()
946 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_host_reset()
954 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_bus_reset() local
965 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_bus_reset()
967 pvscsi_process_request_ring(adapter); in pvscsi_bus_reset()
968 ll_bus_reset(adapter); in pvscsi_bus_reset()
969 pvscsi_process_completion_ring(adapter); in pvscsi_bus_reset()
971 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_bus_reset()
979 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_device_reset() local
990 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_device_reset()
992 pvscsi_process_request_ring(adapter); in pvscsi_device_reset()
993 ll_device_reset(adapter, cmd->device->id); in pvscsi_device_reset()
994 pvscsi_process_completion_ring(adapter); in pvscsi_device_reset()
996 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_device_reset()
1005 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_info() local
1009 "%u/%u/%u pages, cmd_per_lun=%u", adapter->rev, in pvscsi_info()
1010 adapter->req_pages, adapter->cmp_pages, adapter->msg_pages, in pvscsi_info()
1033 static void pvscsi_process_msg(const struct pvscsi_adapter *adapter, in pvscsi_process_msg() argument
1036 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_process_msg()
1037 struct Scsi_Host *host = adapter->host; in pvscsi_process_msg()
1062 scsi_add_device(adapter->host, desc->bus, in pvscsi_process_msg()
1091 static int pvscsi_msg_pending(const struct pvscsi_adapter *adapter) in pvscsi_msg_pending() argument
1093 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_msg_pending()
1098 static void pvscsi_process_msg_ring(const struct pvscsi_adapter *adapter) in pvscsi_process_msg_ring() argument
1100 struct PVSCSIRingsState *s = adapter->rings_state; in pvscsi_process_msg_ring()
1101 struct PVSCSIRingMsgDesc *ring = adapter->msg_ring; in pvscsi_process_msg_ring()
1104 while (pvscsi_msg_pending(adapter)) { in pvscsi_process_msg_ring()
1109 pvscsi_process_msg(adapter, e); in pvscsi_process_msg_ring()
1117 struct pvscsi_adapter *adapter; in pvscsi_msg_workqueue_handler() local
1119 adapter = container_of(data, struct pvscsi_adapter, work); in pvscsi_msg_workqueue_handler()
1121 pvscsi_process_msg_ring(adapter); in pvscsi_msg_workqueue_handler()
1124 static int pvscsi_setup_msg_workqueue(struct pvscsi_adapter *adapter) in pvscsi_setup_msg_workqueue() argument
1131 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_COMMAND, in pvscsi_setup_msg_workqueue()
1134 if (pvscsi_reg_read(adapter, PVSCSI_REG_OFFSET_COMMAND_STATUS) == -1) in pvscsi_setup_msg_workqueue()
1138 "vmw_pvscsi_wq_%u", adapter->host->host_no); in pvscsi_setup_msg_workqueue()
1140 adapter->workqueue = in pvscsi_setup_msg_workqueue()
1142 if (!adapter->workqueue) { in pvscsi_setup_msg_workqueue()
1146 INIT_WORK(&adapter->work, pvscsi_msg_workqueue_handler); in pvscsi_setup_msg_workqueue()
1151 static bool pvscsi_setup_req_threshold(struct pvscsi_adapter *adapter, in pvscsi_setup_req_threshold() argument
1159 pvscsi_reg_write(adapter, PVSCSI_REG_OFFSET_COMMAND, in pvscsi_setup_req_threshold()
1161 val = pvscsi_reg_read(adapter, PVSCSI_REG_OFFSET_COMMAND_STATUS); in pvscsi_setup_req_threshold()
1171 pvscsi_write_cmd_desc(adapter, in pvscsi_setup_req_threshold()
1174 return pvscsi_reg_read(adapter, in pvscsi_setup_req_threshold()
1181 struct pvscsi_adapter *adapter = devp; in pvscsi_isr() local
1184 spin_lock_irqsave(&adapter->hw_lock, flags); in pvscsi_isr()
1185 pvscsi_process_completion_ring(adapter); in pvscsi_isr()
1186 if (adapter->use_msg && pvscsi_msg_pending(adapter)) in pvscsi_isr()
1187 queue_work(adapter->workqueue, &adapter->work); in pvscsi_isr()
1188 spin_unlock_irqrestore(&adapter->hw_lock, flags); in pvscsi_isr()
1195 struct pvscsi_adapter *adapter = devp; in pvscsi_shared_isr() local
1196 u32 val = pvscsi_read_intr_status(adapter); in pvscsi_shared_isr()
1204 static void pvscsi_free_sgls(const struct pvscsi_adapter *adapter) in pvscsi_free_sgls() argument
1206 struct pvscsi_ctx *ctx = adapter->cmd_map; in pvscsi_free_sgls()
1209 for (i = 0; i < adapter->req_depth; ++i, ++ctx) in pvscsi_free_sgls()
1213 static void pvscsi_shutdown_intr(struct pvscsi_adapter *adapter) in pvscsi_shutdown_intr() argument
1215 free_irq(pci_irq_vector(adapter->dev, 0), adapter); in pvscsi_shutdown_intr()
1216 pci_free_irq_vectors(adapter->dev); in pvscsi_shutdown_intr()
1219 static void pvscsi_release_resources(struct pvscsi_adapter *adapter) in pvscsi_release_resources() argument
1221 if (adapter->workqueue) in pvscsi_release_resources()
1222 destroy_workqueue(adapter->workqueue); in pvscsi_release_resources()
1224 if (adapter->mmioBase) in pvscsi_release_resources()
1225 pci_iounmap(adapter->dev, adapter->mmioBase); in pvscsi_release_resources()
1227 pci_release_regions(adapter->dev); in pvscsi_release_resources()
1229 if (adapter->cmd_map) { in pvscsi_release_resources()
1230 pvscsi_free_sgls(adapter); in pvscsi_release_resources()
1231 kfree(adapter->cmd_map); in pvscsi_release_resources()
1234 if (adapter->rings_state) in pvscsi_release_resources()
1235 dma_free_coherent(&adapter->dev->dev, PAGE_SIZE, in pvscsi_release_resources()
1236 adapter->rings_state, adapter->ringStatePA); in pvscsi_release_resources()
1238 if (adapter->req_ring) in pvscsi_release_resources()
1239 dma_free_coherent(&adapter->dev->dev, in pvscsi_release_resources()
1240 adapter->req_pages * PAGE_SIZE, in pvscsi_release_resources()
1241 adapter->req_ring, adapter->reqRingPA); in pvscsi_release_resources()
1243 if (adapter->cmp_ring) in pvscsi_release_resources()
1244 dma_free_coherent(&adapter->dev->dev, in pvscsi_release_resources()
1245 adapter->cmp_pages * PAGE_SIZE, in pvscsi_release_resources()
1246 adapter->cmp_ring, adapter->cmpRingPA); in pvscsi_release_resources()
1248 if (adapter->msg_ring) in pvscsi_release_resources()
1249 dma_free_coherent(&adapter->dev->dev, in pvscsi_release_resources()
1250 adapter->msg_pages * PAGE_SIZE, in pvscsi_release_resources()
1251 adapter->msg_ring, adapter->msgRingPA); in pvscsi_release_resources()
1267 static int pvscsi_allocate_sg(struct pvscsi_adapter *adapter) in pvscsi_allocate_sg() argument
1272 ctx = adapter->cmd_map; in pvscsi_allocate_sg()
1275 for (i = 0; i < adapter->req_depth; ++i, ++ctx) { in pvscsi_allocate_sg()
1298 static u32 pvscsi_get_max_targets(struct pvscsi_adapter *adapter) in pvscsi_get_max_targets() argument
1307 dev = pvscsi_dev(adapter); in pvscsi_get_max_targets()
1308 config_page = dma_alloc_coherent(&adapter->dev->dev, PAGE_SIZE, in pvscsi_get_max_targets()
1331 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_CONFIG, &cmd, sizeof cmd); in pvscsi_get_max_targets()
1342 dma_free_coherent(&adapter->dev->dev, PAGE_SIZE, config_page, in pvscsi_get_max_targets()
1351 struct pvscsi_adapter *adapter; in pvscsi_probe() local
1377 adapter = &adapter_temp; in pvscsi_probe()
1378 memset(adapter, 0, sizeof(*adapter)); in pvscsi_probe()
1379 adapter->dev = pdev; in pvscsi_probe()
1380 adapter->rev = pdev->revision; in pvscsi_probe()
1403 adapter->mmioBase = pci_iomap(pdev, i, PVSCSI_MEM_SPACE_SIZE); in pvscsi_probe()
1405 if (!adapter->mmioBase) { in pvscsi_probe()
1418 max_id = pvscsi_get_max_targets(adapter); in pvscsi_probe()
1447 adapter = shost_priv(host); in pvscsi_probe()
1448 memset(adapter, 0, sizeof(*adapter)); in pvscsi_probe()
1449 adapter->dev = pdev; in pvscsi_probe()
1450 adapter->host = host; in pvscsi_probe()
1454 adapter->rev = adapter_temp.rev; in pvscsi_probe()
1455 adapter->mmioBase = adapter_temp.mmioBase; in pvscsi_probe()
1457 spin_lock_init(&adapter->hw_lock); in pvscsi_probe()
1465 ll_adapter_reset(adapter); in pvscsi_probe()
1467 adapter->use_msg = pvscsi_setup_msg_workqueue(adapter); in pvscsi_probe()
1469 error = pvscsi_allocate_rings(adapter); in pvscsi_probe()
1479 pvscsi_setup_all_rings(adapter); in pvscsi_probe()
1481 adapter->cmd_map = kcalloc(adapter->req_depth, in pvscsi_probe()
1483 if (!adapter->cmd_map) { in pvscsi_probe()
1489 INIT_LIST_HEAD(&adapter->cmd_pool); in pvscsi_probe()
1490 for (i = 0; i < adapter->req_depth; i++) { in pvscsi_probe()
1491 struct pvscsi_ctx *ctx = adapter->cmd_map + i; in pvscsi_probe()
1492 list_add(&ctx->list, &adapter->cmd_pool); in pvscsi_probe()
1495 error = pvscsi_allocate_sg(adapter); in pvscsi_probe()
1506 error = pci_alloc_irq_vectors(adapter->dev, 1, 1, irq_flag); in pvscsi_probe()
1510 adapter->use_req_threshold = pvscsi_setup_req_threshold(adapter, true); in pvscsi_probe()
1512 adapter->use_req_threshold ? "en" : "dis"); in pvscsi_probe()
1514 if (adapter->dev->msix_enabled || adapter->dev->msi_enabled) { in pvscsi_probe()
1516 adapter->dev->msix_enabled ? "-X" : ""); in pvscsi_probe()
1518 0, "vmw_pvscsi", adapter); in pvscsi_probe()
1522 IRQF_SHARED, "vmw_pvscsi", adapter); in pvscsi_probe()
1539 adapter->rev, host->host_no); in pvscsi_probe()
1541 pvscsi_unmask_intr(adapter); in pvscsi_probe()
1548 ll_adapter_reset(adapter); in pvscsi_probe()
1550 pvscsi_shutdown_intr(adapter); in pvscsi_probe()
1551 pvscsi_release_resources(adapter); in pvscsi_probe()
1559 pvscsi_shutdown_intr(adapter); in pvscsi_probe()
1560 pvscsi_release_resources(adapter); in pvscsi_probe()
1564 static void __pvscsi_shutdown(struct pvscsi_adapter *adapter) in __pvscsi_shutdown() argument
1566 pvscsi_mask_intr(adapter); in __pvscsi_shutdown()
1568 if (adapter->workqueue) in __pvscsi_shutdown()
1569 flush_workqueue(adapter->workqueue); in __pvscsi_shutdown()
1571 pvscsi_shutdown_intr(adapter); in __pvscsi_shutdown()
1573 pvscsi_process_request_ring(adapter); in __pvscsi_shutdown()
1574 pvscsi_process_completion_ring(adapter); in __pvscsi_shutdown()
1575 ll_adapter_reset(adapter); in __pvscsi_shutdown()
1581 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_shutdown() local
1583 __pvscsi_shutdown(adapter); in pvscsi_shutdown()
1589 struct pvscsi_adapter *adapter = shost_priv(host); in pvscsi_remove() local
1593 __pvscsi_shutdown(adapter); in pvscsi_remove()
1594 pvscsi_release_resources(adapter); in pvscsi_remove()