Lines Matching refs:hostdata
110 struct ibmvscsi_host_data *hostdata);
125 struct ibmvscsi_host_data *hostdata = in ibmvscsi_handle_event() local
127 vio_disable_interrupts(to_vio_dev(hostdata->dev)); in ibmvscsi_handle_event()
128 tasklet_schedule(&hostdata->srp_task); in ibmvscsi_handle_event()
141 struct ibmvscsi_host_data *hostdata, in ibmvscsi_release_crq_queue() argument
145 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_release_crq_queue()
146 free_irq(vdev->irq, (void *)hostdata); in ibmvscsi_release_crq_queue()
147 tasklet_kill(&hostdata->srp_task); in ibmvscsi_release_crq_queue()
153 dma_unmap_single(hostdata->dev, in ibmvscsi_release_crq_queue()
194 static int ibmvscsi_send_crq(struct ibmvscsi_host_data *hostdata, in ibmvscsi_send_crq() argument
197 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_send_crq()
213 struct ibmvscsi_host_data *hostdata = (struct ibmvscsi_host_data *)data; in ibmvscsi_task() local
214 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_task()
220 while ((crq = crq_queue_next_crq(&hostdata->queue)) != NULL) { in ibmvscsi_task()
221 ibmvscsi_handle_crq(crq, hostdata); in ibmvscsi_task()
227 crq = crq_queue_next_crq(&hostdata->queue); in ibmvscsi_task()
230 ibmvscsi_handle_crq(crq, hostdata); in ibmvscsi_task()
260 static void set_adapter_info(struct ibmvscsi_host_data *hostdata) in set_adapter_info() argument
262 memset(&hostdata->madapter_info, 0x00, in set_adapter_info()
263 sizeof(hostdata->madapter_info)); in set_adapter_info()
265 dev_info(hostdata->dev, "SRP_VERSION: %s\n", SRP_VERSION); in set_adapter_info()
266 strcpy(hostdata->madapter_info.srp_version, SRP_VERSION); in set_adapter_info()
268 strncpy(hostdata->madapter_info.partition_name, partition_name, in set_adapter_info()
269 sizeof(hostdata->madapter_info.partition_name)); in set_adapter_info()
271 hostdata->madapter_info.partition_number = in set_adapter_info()
274 hostdata->madapter_info.mad_version = cpu_to_be32(SRP_MAD_VERSION_1); in set_adapter_info()
275 hostdata->madapter_info.os_type = cpu_to_be32(SRP_MAD_OS_LINUX); in set_adapter_info()
285 struct ibmvscsi_host_data *hostdata) in ibmvscsi_reset_crq_queue() argument
288 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_reset_crq_queue()
301 set_adapter_info(hostdata); in ibmvscsi_reset_crq_queue()
309 dev_warn(hostdata->dev, "Partner adapter not ready\n"); in ibmvscsi_reset_crq_queue()
311 dev_warn(hostdata->dev, "couldn't register crq--rc 0x%x\n", rc); in ibmvscsi_reset_crq_queue()
326 struct ibmvscsi_host_data *hostdata, in ibmvscsi_init_crq_queue() argument
331 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_init_crq_queue()
339 queue->msg_token = dma_map_single(hostdata->dev, queue->msgs, in ibmvscsi_init_crq_queue()
343 if (dma_mapping_error(hostdata->dev, queue->msg_token)) in ibmvscsi_init_crq_queue()
347 set_adapter_info(hostdata); in ibmvscsi_init_crq_queue()
355 hostdata); in ibmvscsi_init_crq_queue()
359 dev_warn(hostdata->dev, "Partner adapter not ready\n"); in ibmvscsi_init_crq_queue()
362 dev_warn(hostdata->dev, "Error %d opening adapter\n", rc); in ibmvscsi_init_crq_queue()
369 tasklet_init(&hostdata->srp_task, (void *)ibmvscsi_task, in ibmvscsi_init_crq_queue()
370 (unsigned long)hostdata); in ibmvscsi_init_crq_queue()
374 0, "ibmvscsi", (void *)hostdata) != 0) { in ibmvscsi_init_crq_queue()
375 dev_err(hostdata->dev, "couldn't register irq 0x%x\n", in ibmvscsi_init_crq_queue()
382 dev_err(hostdata->dev, "Error %d enabling interrupts!!!\n", rc); in ibmvscsi_init_crq_queue()
389 tasklet_kill(&hostdata->srp_task); in ibmvscsi_init_crq_queue()
397 dma_unmap_single(hostdata->dev, in ibmvscsi_init_crq_queue()
413 struct ibmvscsi_host_data *hostdata) in ibmvscsi_reenable_crq_queue() argument
416 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_reenable_crq_queue()
418 set_adapter_info(hostdata); in ibmvscsi_reenable_crq_queue()
428 dev_err(hostdata->dev, "Error %d enabling adapter\n", rc); in ibmvscsi_reenable_crq_queue()
444 int size, struct ibmvscsi_host_data *hostdata) in initialize_event_pool() argument
455 dma_alloc_coherent(hostdata->dev, in initialize_event_pool()
472 evt->hostdata = hostdata; in initialize_event_pool()
488 struct ibmvscsi_host_data *hostdata) in release_event_pool() argument
495 dma_free_coherent(hostdata->dev, in release_event_pool()
502 dev_warn(hostdata->dev, "releasing event pool with %d " in release_event_pool()
505 dma_free_coherent(hostdata->dev, in release_event_pool()
538 dev_err(evt->hostdata->dev, "Freeing invalid event_struct %p " in free_event_struct()
543 dev_err(evt->hostdata->dev, "Freeing event_struct %p " in free_event_struct()
782 static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code) in purge_requests() argument
787 spin_lock_irqsave(hostdata->host->host_lock, flags); in purge_requests()
788 while (!list_empty(&hostdata->sent)) { in purge_requests()
789 evt = list_first_entry(&hostdata->sent, struct srp_event_struct, list); in purge_requests()
793 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in purge_requests()
797 evt->hostdata->dev); in purge_requests()
803 free_event_struct(&evt->hostdata->pool, evt); in purge_requests()
804 spin_lock_irqsave(hostdata->host->host_lock, flags); in purge_requests()
806 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in purge_requests()
816 static void ibmvscsi_set_request_limit(struct ibmvscsi_host_data *hostdata, int limit) in ibmvscsi_set_request_limit() argument
820 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_set_request_limit()
821 atomic_set(&hostdata->request_limit, limit); in ibmvscsi_set_request_limit()
822 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_set_request_limit()
829 static void ibmvscsi_reset_host(struct ibmvscsi_host_data *hostdata) in ibmvscsi_reset_host() argument
831 scsi_block_requests(hostdata->host); in ibmvscsi_reset_host()
832 ibmvscsi_set_request_limit(hostdata, 0); in ibmvscsi_reset_host()
834 purge_requests(hostdata, DID_ERROR); in ibmvscsi_reset_host()
835 hostdata->action = IBMVSCSI_HOST_ACTION_RESET; in ibmvscsi_reset_host()
836 wake_up(&hostdata->work_wait_q); in ibmvscsi_reset_host()
848 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in ibmvscsi_timeout() local
850 dev_err(hostdata->dev, "Command timed out (%x). Resetting connection\n", in ibmvscsi_timeout()
853 ibmvscsi_reset_host(hostdata); in ibmvscsi_timeout()
870 struct ibmvscsi_host_data *hostdata, in ibmvscsi_send_srp_event() argument
887 atomic_dec_if_positive(&hostdata->request_limit); in ibmvscsi_send_srp_event()
917 list_for_each_entry(tmp_evt, &hostdata->sent, list) { in ibmvscsi_send_srp_event()
934 list_add_tail(&evt_struct->list, &hostdata->sent); in ibmvscsi_send_srp_event()
942 rc = ibmvscsi_send_crq(hostdata, be64_to_cpu(crq_as_u64[0]), in ibmvscsi_send_srp_event()
954 dev_warn(hostdata->dev, "send warning. " in ibmvscsi_send_srp_event()
958 dev_err(hostdata->dev, "send error %d\n", rc); in ibmvscsi_send_srp_event()
960 atomic_inc(&hostdata->request_limit); in ibmvscsi_send_srp_event()
967 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); in ibmvscsi_send_srp_event()
969 free_event_struct(&hostdata->pool, evt_struct); in ibmvscsi_send_srp_event()
971 atomic_inc(&hostdata->request_limit); in ibmvscsi_send_srp_event()
975 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); in ibmvscsi_send_srp_event()
983 free_event_struct(&hostdata->pool, evt_struct); in ibmvscsi_send_srp_event()
1001 dev_warn(evt_struct->hostdata->dev, in handle_cmd_rsp()
1013 evt_struct->hostdata->dev); in handle_cmd_rsp()
1047 struct ibmvscsi_host_data *hostdata = shost_priv(cmnd->device->host); in ibmvscsi_queuecommand_lck() local
1052 evt_struct = get_event_struct(&hostdata->pool); in ibmvscsi_queuecommand_lck()
1063 if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { in ibmvscsi_queuecommand_lck()
1067 free_event_struct(&hostdata->pool, evt_struct); in ibmvscsi_queuecommand_lck()
1092 return ibmvscsi_send_srp_event(evt_struct, hostdata, 0); in ibmvscsi_queuecommand_lck()
1108 static int map_persist_bufs(struct ibmvscsi_host_data *hostdata) in DEF_SCSI_QCMD()
1111 hostdata->caps_addr = dma_map_single(hostdata->dev, &hostdata->caps, in DEF_SCSI_QCMD()
1112 sizeof(hostdata->caps), DMA_BIDIRECTIONAL); in DEF_SCSI_QCMD()
1114 if (dma_mapping_error(hostdata->dev, hostdata->caps_addr)) { in DEF_SCSI_QCMD()
1115 dev_err(hostdata->dev, "Unable to map capabilities buffer!\n"); in DEF_SCSI_QCMD()
1119 hostdata->adapter_info_addr = dma_map_single(hostdata->dev, in DEF_SCSI_QCMD()
1120 &hostdata->madapter_info, in DEF_SCSI_QCMD()
1121 sizeof(hostdata->madapter_info), in DEF_SCSI_QCMD()
1123 if (dma_mapping_error(hostdata->dev, hostdata->adapter_info_addr)) { in DEF_SCSI_QCMD()
1124 dev_err(hostdata->dev, "Unable to map adapter info buffer!\n"); in DEF_SCSI_QCMD()
1125 dma_unmap_single(hostdata->dev, hostdata->caps_addr, in DEF_SCSI_QCMD()
1126 sizeof(hostdata->caps), DMA_BIDIRECTIONAL); in DEF_SCSI_QCMD()
1139 static void unmap_persist_bufs(struct ibmvscsi_host_data *hostdata) in unmap_persist_bufs() argument
1141 dma_unmap_single(hostdata->dev, hostdata->caps_addr, in unmap_persist_bufs()
1142 sizeof(hostdata->caps), DMA_BIDIRECTIONAL); in unmap_persist_bufs()
1144 dma_unmap_single(hostdata->dev, hostdata->adapter_info_addr, in unmap_persist_bufs()
1145 sizeof(hostdata->madapter_info), DMA_BIDIRECTIONAL); in unmap_persist_bufs()
1157 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in login_rsp() local
1162 dev_info(hostdata->dev, "SRP_LOGIN_REJ reason %u\n", in login_rsp()
1165 ibmvscsi_set_request_limit(hostdata, -1); in login_rsp()
1168 dev_err(hostdata->dev, "Invalid login response typecode 0x%02x!\n", in login_rsp()
1171 ibmvscsi_set_request_limit(hostdata, -1); in login_rsp()
1175 dev_info(hostdata->dev, "SRP_LOGIN succeeded\n"); in login_rsp()
1176 hostdata->client_migrated = 0; in login_rsp()
1182 ibmvscsi_set_request_limit(hostdata, in login_rsp()
1186 hostdata->action = IBMVSCSI_HOST_ACTION_UNBLOCK; in login_rsp()
1187 wake_up(&hostdata->work_wait_q); in login_rsp()
1196 static int send_srp_login(struct ibmvscsi_host_data *hostdata) in send_srp_login() argument
1201 struct srp_event_struct *evt_struct = get_event_struct(&hostdata->pool); in send_srp_login()
1218 ibmvscsi_set_request_limit(hostdata, 0); in send_srp_login()
1220 spin_lock_irqsave(hostdata->host->host_lock, flags); in send_srp_login()
1221 rc = ibmvscsi_send_srp_event(evt_struct, hostdata, login_timeout * 2); in send_srp_login()
1222 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in send_srp_login()
1223 dev_info(hostdata->dev, "sent SRP login\n"); in send_srp_login()
1235 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in capabilities_rsp() local
1238 dev_err(hostdata->dev, "error 0x%X getting capabilities info\n", in capabilities_rsp()
1241 if (hostdata->caps.migration.common.server_support != in capabilities_rsp()
1243 dev_info(hostdata->dev, "Partition migration not supported\n"); in capabilities_rsp()
1246 if (hostdata->caps.reserve.common.server_support == in capabilities_rsp()
1248 dev_info(hostdata->dev, "Client reserve enabled\n"); in capabilities_rsp()
1250 dev_info(hostdata->dev, "Client reserve not supported\n"); in capabilities_rsp()
1254 send_srp_login(hostdata); in capabilities_rsp()
1262 static void send_mad_capabilities(struct ibmvscsi_host_data *hostdata) in send_mad_capabilities() argument
1267 struct device_node *of_node = hostdata->dev->of_node; in send_mad_capabilities()
1270 evt_struct = get_event_struct(&hostdata->pool); in send_mad_capabilities()
1279 hostdata->caps.flags = cpu_to_be32(CAP_LIST_SUPPORTED); in send_mad_capabilities()
1280 if (hostdata->client_migrated) in send_mad_capabilities()
1281 hostdata->caps.flags |= cpu_to_be32(CLIENT_MIGRATED); in send_mad_capabilities()
1283 strlcpy(hostdata->caps.name, dev_name(&hostdata->host->shost_gendev), in send_mad_capabilities()
1284 sizeof(hostdata->caps.name)); in send_mad_capabilities()
1287 location = location ? location : dev_name(hostdata->dev); in send_mad_capabilities()
1288 strlcpy(hostdata->caps.loc, location, sizeof(hostdata->caps.loc)); in send_mad_capabilities()
1291 req->buffer = cpu_to_be64(hostdata->caps_addr); in send_mad_capabilities()
1293 hostdata->caps.migration.common.cap_type = in send_mad_capabilities()
1295 hostdata->caps.migration.common.length = in send_mad_capabilities()
1296 cpu_to_be16(sizeof(hostdata->caps.migration)); in send_mad_capabilities()
1297 hostdata->caps.migration.common.server_support = in send_mad_capabilities()
1299 hostdata->caps.migration.ecl = cpu_to_be32(1); in send_mad_capabilities()
1302 hostdata->caps.reserve.common.cap_type = in send_mad_capabilities()
1304 hostdata->caps.reserve.common.length = in send_mad_capabilities()
1305 cpu_to_be16(sizeof(hostdata->caps.reserve)); in send_mad_capabilities()
1306 hostdata->caps.reserve.common.server_support = in send_mad_capabilities()
1308 hostdata->caps.reserve.type = in send_mad_capabilities()
1311 cpu_to_be16(sizeof(hostdata->caps)); in send_mad_capabilities()
1313 req->common.length = cpu_to_be16(sizeof(hostdata->caps) - in send_mad_capabilities()
1314 sizeof(hostdata->caps.reserve)); in send_mad_capabilities()
1316 spin_lock_irqsave(hostdata->host->host_lock, flags); in send_mad_capabilities()
1317 if (ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2)) in send_mad_capabilities()
1318 dev_err(hostdata->dev, "couldn't send CAPABILITIES_REQ!\n"); in send_mad_capabilities()
1319 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in send_mad_capabilities()
1331 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in fast_fail_rsp() local
1335 dev_err(hostdata->dev, "fast_fail not supported in server\n"); in fast_fail_rsp()
1337 dev_err(hostdata->dev, "fast_fail request failed\n"); in fast_fail_rsp()
1339 dev_err(hostdata->dev, "error 0x%X enabling fast_fail\n", status); in fast_fail_rsp()
1341 send_mad_capabilities(hostdata); in fast_fail_rsp()
1350 static int enable_fast_fail(struct ibmvscsi_host_data *hostdata) in enable_fast_fail() argument
1358 send_mad_capabilities(hostdata); in enable_fast_fail()
1362 evt_struct = get_event_struct(&hostdata->pool); in enable_fast_fail()
1372 spin_lock_irqsave(hostdata->host->host_lock, flags); in enable_fast_fail()
1373 rc = ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2); in enable_fast_fail()
1374 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in enable_fast_fail()
1387 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in adapter_info_rsp() local
1390 dev_err(hostdata->dev, "error %d getting adapter info\n", in adapter_info_rsp()
1393 dev_info(hostdata->dev, "host srp version: %s, " in adapter_info_rsp()
1395 hostdata->madapter_info.srp_version, in adapter_info_rsp()
1396 hostdata->madapter_info.partition_name, in adapter_info_rsp()
1397 be32_to_cpu(hostdata->madapter_info.partition_number), in adapter_info_rsp()
1398 be32_to_cpu(hostdata->madapter_info.os_type), in adapter_info_rsp()
1399 be32_to_cpu(hostdata->madapter_info.port_max_txu[0])); in adapter_info_rsp()
1401 if (hostdata->madapter_info.port_max_txu[0]) in adapter_info_rsp()
1402 hostdata->host->max_sectors = in adapter_info_rsp()
1403 be32_to_cpu(hostdata->madapter_info.port_max_txu[0]) >> 9; in adapter_info_rsp()
1405 if (be32_to_cpu(hostdata->madapter_info.os_type) == SRP_MAD_OS_AIX && in adapter_info_rsp()
1406 strcmp(hostdata->madapter_info.srp_version, "1.6a") <= 0) { in adapter_info_rsp()
1407 dev_err(hostdata->dev, "host (Ver. %s) doesn't support large transfers\n", in adapter_info_rsp()
1408 hostdata->madapter_info.srp_version); in adapter_info_rsp()
1409 dev_err(hostdata->dev, "limiting scatterlists to %d\n", in adapter_info_rsp()
1411 hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS; in adapter_info_rsp()
1414 if (be32_to_cpu(hostdata->madapter_info.os_type) == SRP_MAD_OS_AIX) { in adapter_info_rsp()
1415 enable_fast_fail(hostdata); in adapter_info_rsp()
1420 send_srp_login(hostdata); in adapter_info_rsp()
1432 static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata) in send_mad_adapter_info() argument
1438 evt_struct = get_event_struct(&hostdata->pool); in send_mad_adapter_info()
1450 req->common.length = cpu_to_be16(sizeof(hostdata->madapter_info)); in send_mad_adapter_info()
1451 req->buffer = cpu_to_be64(hostdata->adapter_info_addr); in send_mad_adapter_info()
1453 spin_lock_irqsave(hostdata->host->host_lock, flags); in send_mad_adapter_info()
1454 if (ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2)) in send_mad_adapter_info()
1455 dev_err(hostdata->dev, "couldn't send ADAPTER_INFO_REQ!\n"); in send_mad_adapter_info()
1456 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in send_mad_adapter_info()
1463 static void init_adapter(struct ibmvscsi_host_data *hostdata) in init_adapter() argument
1465 send_mad_adapter_info(hostdata); in init_adapter()
1489 struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host); in ibmvscsi_eh_abort_handler() local
1502 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1506 list_for_each_entry(tmp_evt, &hostdata->sent, list) { in ibmvscsi_eh_abort_handler()
1514 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1518 evt = get_event_struct(&hostdata->pool); in ibmvscsi_eh_abort_handler()
1520 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1543 rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, abort_timeout * 2); in ibmvscsi_eh_abort_handler()
1548 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1550 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1553 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1592 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1594 list_for_each_entry(tmp_evt, &hostdata->sent, list) { in ibmvscsi_eh_abort_handler()
1602 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1614 found_evt->hostdata->dev); in ibmvscsi_eh_abort_handler()
1615 free_event_struct(&found_evt->hostdata->pool, found_evt); in ibmvscsi_eh_abort_handler()
1616 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1617 atomic_inc(&hostdata->request_limit); in ibmvscsi_eh_abort_handler()
1628 struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host); in ibmvscsi_eh_device_reset_handler() local
1638 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1641 evt = get_event_struct(&hostdata->pool); in ibmvscsi_eh_device_reset_handler()
1643 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1665 rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, reset_timeout * 2); in ibmvscsi_eh_device_reset_handler()
1670 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1672 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1675 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1712 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1713 list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) { in ibmvscsi_eh_device_reset_handler()
1719 tmp_evt->hostdata->dev); in ibmvscsi_eh_device_reset_handler()
1720 free_event_struct(&tmp_evt->hostdata->pool, in ibmvscsi_eh_device_reset_handler()
1722 atomic_inc(&hostdata->request_limit); in ibmvscsi_eh_device_reset_handler()
1729 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1740 struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host); in ibmvscsi_eh_host_reset_handler() local
1742 dev_err(hostdata->dev, "Resetting connection due to error recovery\n"); in ibmvscsi_eh_host_reset_handler()
1744 ibmvscsi_reset_host(hostdata); in ibmvscsi_eh_host_reset_handler()
1748 atomic_read(&hostdata->request_limit) < 2;) { in ibmvscsi_eh_host_reset_handler()
1753 if (atomic_read(&hostdata->request_limit) <= 0) in ibmvscsi_eh_host_reset_handler()
1766 struct ibmvscsi_host_data *hostdata) in ibmvscsi_handle_crq() argument
1777 dev_info(hostdata->dev, "partner initialized\n"); in ibmvscsi_handle_crq()
1779 rc = ibmvscsi_send_crq(hostdata, 0xC002000000000000LL, 0); in ibmvscsi_handle_crq()
1782 init_adapter(hostdata); in ibmvscsi_handle_crq()
1784 dev_err(hostdata->dev, "Unable to send init rsp. rc=%ld\n", rc); in ibmvscsi_handle_crq()
1789 dev_info(hostdata->dev, "partner initialization complete\n"); in ibmvscsi_handle_crq()
1792 init_adapter(hostdata); in ibmvscsi_handle_crq()
1795 dev_err(hostdata->dev, "unknown crq message type: %d\n", crq->format); in ibmvscsi_handle_crq()
1799 scsi_block_requests(hostdata->host); in ibmvscsi_handle_crq()
1800 ibmvscsi_set_request_limit(hostdata, 0); in ibmvscsi_handle_crq()
1803 dev_info(hostdata->dev, "Re-enabling adapter!\n"); in ibmvscsi_handle_crq()
1804 hostdata->client_migrated = 1; in ibmvscsi_handle_crq()
1805 hostdata->action = IBMVSCSI_HOST_ACTION_REENABLE; in ibmvscsi_handle_crq()
1806 purge_requests(hostdata, DID_REQUEUE); in ibmvscsi_handle_crq()
1807 wake_up(&hostdata->work_wait_q); in ibmvscsi_handle_crq()
1809 dev_err(hostdata->dev, "Virtual adapter failed rc %d!\n", in ibmvscsi_handle_crq()
1811 ibmvscsi_reset_host(hostdata); in ibmvscsi_handle_crq()
1817 dev_err(hostdata->dev, "got an invalid message type 0x%02x\n", in ibmvscsi_handle_crq()
1826 if (!valid_event_struct(&hostdata->pool, evt_struct)) { in ibmvscsi_handle_crq()
1827 dev_err(hostdata->dev, "returned correlation_token 0x%p is invalid!\n", in ibmvscsi_handle_crq()
1833 dev_err(hostdata->dev, "received duplicate correlation_token 0x%p!\n", in ibmvscsi_handle_crq()
1840 &hostdata->request_limit); in ibmvscsi_handle_crq()
1849 dev_err(hostdata->dev, "returned done() is NULL; not running it!\n"); in ibmvscsi_handle_crq()
1855 spin_lock_irqsave(evt_struct->hostdata->host->host_lock, flags); in ibmvscsi_handle_crq()
1857 free_event_struct(&evt_struct->hostdata->pool, evt_struct); in ibmvscsi_handle_crq()
1858 spin_unlock_irqrestore(evt_struct->hostdata->host->host_lock, flags); in ibmvscsi_handle_crq()
1906 struct ibmvscsi_host_data *hostdata = shost_priv(shost); in show_host_vhost_loc() local
1909 len = snprintf(buf, sizeof(hostdata->caps.loc), "%s\n", in show_host_vhost_loc()
1910 hostdata->caps.loc); in show_host_vhost_loc()
1926 struct ibmvscsi_host_data *hostdata = shost_priv(shost); in show_host_vhost_name() local
1929 len = snprintf(buf, sizeof(hostdata->caps.name), "%s\n", in show_host_vhost_name()
1930 hostdata->caps.name); in show_host_vhost_name()
1946 struct ibmvscsi_host_data *hostdata = shost_priv(shost); in show_host_srp_version() local
1950 hostdata->madapter_info.srp_version); in show_host_srp_version()
1967 struct ibmvscsi_host_data *hostdata = shost_priv(shost); in show_host_partition_name() local
1971 hostdata->madapter_info.partition_name); in show_host_partition_name()
1988 struct ibmvscsi_host_data *hostdata = shost_priv(shost); in show_host_partition_number() local
1992 be32_to_cpu(hostdata->madapter_info.partition_number)); in show_host_partition_number()
2008 struct ibmvscsi_host_data *hostdata = shost_priv(shost); in show_host_mad_version() local
2012 be32_to_cpu(hostdata->madapter_info.mad_version)); in show_host_mad_version()
2028 struct ibmvscsi_host_data *hostdata = shost_priv(shost); in show_host_os_type() local
2032 be32_to_cpu(hostdata->madapter_info.os_type)); in show_host_os_type()
2060 struct ibmvscsi_host_data *hostdata = shost_priv(shost); in ibmvscsi_host_reset() local
2062 dev_info(hostdata->dev, "Initiating adapter reset!\n"); in ibmvscsi_host_reset()
2063 ibmvscsi_reset_host(hostdata); in ibmvscsi_host_reset()
2122 static void ibmvscsi_do_work(struct ibmvscsi_host_data *hostdata) in ibmvscsi_do_work() argument
2128 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2129 switch (hostdata->action) { in ibmvscsi_do_work()
2134 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2135 rc = ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata); in ibmvscsi_do_work()
2136 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2138 rc = ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0); in ibmvscsi_do_work()
2139 vio_enable_interrupts(to_vio_dev(hostdata->dev)); in ibmvscsi_do_work()
2143 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2144 rc = ibmvscsi_reenable_crq_queue(&hostdata->queue, hostdata); in ibmvscsi_do_work()
2145 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2147 rc = ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0); in ibmvscsi_do_work()
2151 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2155 hostdata->action = IBMVSCSI_HOST_ACTION_NONE; in ibmvscsi_do_work()
2156 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2159 ibmvscsi_set_request_limit(hostdata, -1); in ibmvscsi_do_work()
2160 dev_err(hostdata->dev, "error after %s\n", action); in ibmvscsi_do_work()
2163 scsi_unblock_requests(hostdata->host); in ibmvscsi_do_work()
2166 static int __ibmvscsi_work_to_do(struct ibmvscsi_host_data *hostdata) in __ibmvscsi_work_to_do() argument
2170 switch (hostdata->action) { in __ibmvscsi_work_to_do()
2183 static int ibmvscsi_work_to_do(struct ibmvscsi_host_data *hostdata) in ibmvscsi_work_to_do() argument
2188 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_work_to_do()
2189 rc = __ibmvscsi_work_to_do(hostdata); in ibmvscsi_work_to_do()
2190 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_work_to_do()
2197 struct ibmvscsi_host_data *hostdata = data; in ibmvscsi_work() local
2203 rc = wait_event_interruptible(hostdata->work_wait_q, in ibmvscsi_work()
2204 ibmvscsi_work_to_do(hostdata)); in ibmvscsi_work()
2211 ibmvscsi_do_work(hostdata); in ibmvscsi_work()
2222 struct ibmvscsi_host_data *hostdata; in ibmvscsi_probe() local
2232 host = scsi_host_alloc(&driver_template, sizeof(*hostdata)); in ibmvscsi_probe()
2239 hostdata = shost_priv(host); in ibmvscsi_probe()
2240 memset(hostdata, 0x00, sizeof(*hostdata)); in ibmvscsi_probe()
2241 INIT_LIST_HEAD(&hostdata->sent); in ibmvscsi_probe()
2242 init_waitqueue_head(&hostdata->work_wait_q); in ibmvscsi_probe()
2243 hostdata->host = host; in ibmvscsi_probe()
2244 hostdata->dev = dev; in ibmvscsi_probe()
2245 ibmvscsi_set_request_limit(hostdata, -1); in ibmvscsi_probe()
2246 hostdata->host->max_sectors = IBMVSCSI_MAX_SECTORS_DEFAULT; in ibmvscsi_probe()
2248 if (map_persist_bufs(hostdata)) { in ibmvscsi_probe()
2253 hostdata->work_thread = kthread_run(ibmvscsi_work, hostdata, "%s_%d", in ibmvscsi_probe()
2256 if (IS_ERR(hostdata->work_thread)) { in ibmvscsi_probe()
2258 PTR_ERR(hostdata->work_thread)); in ibmvscsi_probe()
2262 rc = ibmvscsi_init_crq_queue(&hostdata->queue, hostdata, max_events); in ibmvscsi_probe()
2267 if (initialize_event_pool(&hostdata->pool, max_events, hostdata) != 0) { in ibmvscsi_probe()
2281 if (scsi_add_host(hostdata->host, hostdata->dev)) in ibmvscsi_probe()
2285 memcpy(ids.port_id, hostdata->madapter_info.partition_name, in ibmvscsi_probe()
2296 if (ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0) == 0 in ibmvscsi_probe()
2306 atomic_read(&hostdata->request_limit) < 2;) { in ibmvscsi_probe()
2312 if (atomic_read(&hostdata->request_limit) > 0) in ibmvscsi_probe()
2316 dev_set_drvdata(&vdev->dev, hostdata); in ibmvscsi_probe()
2318 list_add_tail(&hostdata->host_list, &ibmvscsi_head); in ibmvscsi_probe()
2323 scsi_remove_host(hostdata->host); in ibmvscsi_probe()
2325 release_event_pool(&hostdata->pool, hostdata); in ibmvscsi_probe()
2327 ibmvscsi_release_crq_queue(&hostdata->queue, hostdata, max_events); in ibmvscsi_probe()
2329 kthread_stop(hostdata->work_thread); in ibmvscsi_probe()
2331 unmap_persist_bufs(hostdata); in ibmvscsi_probe()
2340 struct ibmvscsi_host_data *hostdata = dev_get_drvdata(&vdev->dev); in ibmvscsi_remove() local
2342 srp_remove_host(hostdata->host); in ibmvscsi_remove()
2343 scsi_remove_host(hostdata->host); in ibmvscsi_remove()
2345 purge_requests(hostdata, DID_ERROR); in ibmvscsi_remove()
2346 release_event_pool(&hostdata->pool, hostdata); in ibmvscsi_remove()
2348 ibmvscsi_release_crq_queue(&hostdata->queue, hostdata, in ibmvscsi_remove()
2351 kthread_stop(hostdata->work_thread); in ibmvscsi_remove()
2352 unmap_persist_bufs(hostdata); in ibmvscsi_remove()
2355 list_del(&hostdata->host_list); in ibmvscsi_remove()
2358 scsi_host_put(hostdata->host); in ibmvscsi_remove()
2372 struct ibmvscsi_host_data *hostdata = dev_get_drvdata(dev); in ibmvscsi_resume() local
2373 vio_disable_interrupts(to_vio_dev(hostdata->dev)); in ibmvscsi_resume()
2374 tasklet_schedule(&hostdata->srp_task); in ibmvscsi_resume()