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()
142 struct ibmvscsi_host_data *hostdata, in ibmvscsi_release_crq_queue() argument
146 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_release_crq_queue()
147 free_irq(vdev->irq, (void *)hostdata); in ibmvscsi_release_crq_queue()
148 tasklet_kill(&hostdata->srp_task); in ibmvscsi_release_crq_queue()
154 dma_unmap_single(hostdata->dev, in ibmvscsi_release_crq_queue()
195 static int ibmvscsi_send_crq(struct ibmvscsi_host_data *hostdata, in ibmvscsi_send_crq() argument
198 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_send_crq()
214 struct ibmvscsi_host_data *hostdata = (struct ibmvscsi_host_data *)data; in ibmvscsi_task() local
215 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_task()
221 while ((crq = crq_queue_next_crq(&hostdata->queue)) != NULL) { in ibmvscsi_task()
222 ibmvscsi_handle_crq(crq, hostdata); in ibmvscsi_task()
228 crq = crq_queue_next_crq(&hostdata->queue); in ibmvscsi_task()
231 ibmvscsi_handle_crq(crq, hostdata); in ibmvscsi_task()
261 static void set_adapter_info(struct ibmvscsi_host_data *hostdata) in set_adapter_info() argument
263 memset(&hostdata->madapter_info, 0x00, in set_adapter_info()
264 sizeof(hostdata->madapter_info)); in set_adapter_info()
266 dev_info(hostdata->dev, "SRP_VERSION: %s\n", SRP_VERSION); in set_adapter_info()
267 strcpy(hostdata->madapter_info.srp_version, SRP_VERSION); in set_adapter_info()
269 strncpy(hostdata->madapter_info.partition_name, partition_name, in set_adapter_info()
270 sizeof(hostdata->madapter_info.partition_name)); in set_adapter_info()
272 hostdata->madapter_info.partition_number = in set_adapter_info()
275 hostdata->madapter_info.mad_version = cpu_to_be32(SRP_MAD_VERSION_1); in set_adapter_info()
276 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()
327 struct ibmvscsi_host_data *hostdata, in ibmvscsi_init_crq_queue() argument
332 struct vio_dev *vdev = to_vio_dev(hostdata->dev); in ibmvscsi_init_crq_queue()
340 queue->msg_token = dma_map_single(hostdata->dev, queue->msgs, in ibmvscsi_init_crq_queue()
344 if (dma_mapping_error(hostdata->dev, queue->msg_token)) in ibmvscsi_init_crq_queue()
348 set_adapter_info(hostdata); in ibmvscsi_init_crq_queue()
356 hostdata); in ibmvscsi_init_crq_queue()
360 dev_warn(hostdata->dev, "Partner adapter not ready\n"); in ibmvscsi_init_crq_queue()
363 dev_warn(hostdata->dev, "Error %d opening adapter\n", rc); in ibmvscsi_init_crq_queue()
370 tasklet_init(&hostdata->srp_task, (void *)ibmvscsi_task, in ibmvscsi_init_crq_queue()
371 (unsigned long)hostdata); in ibmvscsi_init_crq_queue()
375 0, "ibmvscsi", (void *)hostdata) != 0) { in ibmvscsi_init_crq_queue()
376 dev_err(hostdata->dev, "couldn't register irq 0x%x\n", in ibmvscsi_init_crq_queue()
383 dev_err(hostdata->dev, "Error %d enabling interrupts!!!\n", rc); in ibmvscsi_init_crq_queue()
390 tasklet_kill(&hostdata->srp_task); in ibmvscsi_init_crq_queue()
398 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()
537 dev_err(evt->hostdata->dev, "Freeing invalid event_struct %p " in free_event_struct()
542 dev_err(evt->hostdata->dev, "Freeing event_struct %p " in free_event_struct()
783 static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code) in purge_requests() argument
788 spin_lock_irqsave(hostdata->host->host_lock, flags); in purge_requests()
789 while (!list_empty(&hostdata->sent)) { in purge_requests()
790 evt = list_first_entry(&hostdata->sent, struct srp_event_struct, list); in purge_requests()
794 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in purge_requests()
798 evt->hostdata->dev); in purge_requests()
804 free_event_struct(&evt->hostdata->pool, evt); in purge_requests()
805 spin_lock_irqsave(hostdata->host->host_lock, flags); in purge_requests()
807 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in purge_requests()
817 static void ibmvscsi_set_request_limit(struct ibmvscsi_host_data *hostdata, int limit) in ibmvscsi_set_request_limit() argument
821 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_set_request_limit()
822 atomic_set(&hostdata->request_limit, limit); in ibmvscsi_set_request_limit()
823 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_set_request_limit()
830 static void ibmvscsi_reset_host(struct ibmvscsi_host_data *hostdata) in ibmvscsi_reset_host() argument
832 scsi_block_requests(hostdata->host); in ibmvscsi_reset_host()
833 ibmvscsi_set_request_limit(hostdata, 0); in ibmvscsi_reset_host()
835 purge_requests(hostdata, DID_ERROR); in ibmvscsi_reset_host()
836 hostdata->action = IBMVSCSI_HOST_ACTION_RESET; in ibmvscsi_reset_host()
837 wake_up(&hostdata->work_wait_q); in ibmvscsi_reset_host()
849 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in ibmvscsi_timeout() local
851 dev_err(hostdata->dev, "Command timed out (%x). Resetting connection\n", in ibmvscsi_timeout()
854 ibmvscsi_reset_host(hostdata); in ibmvscsi_timeout()
871 struct ibmvscsi_host_data *hostdata, in ibmvscsi_send_srp_event() argument
888 atomic_dec_if_positive(&hostdata->request_limit); in ibmvscsi_send_srp_event()
918 list_for_each_entry(tmp_evt, &hostdata->sent, list) { in ibmvscsi_send_srp_event()
935 list_add_tail(&evt_struct->list, &hostdata->sent); in ibmvscsi_send_srp_event()
943 rc = ibmvscsi_send_crq(hostdata, be64_to_cpu(crq_as_u64[0]), in ibmvscsi_send_srp_event()
955 dev_warn(hostdata->dev, "send warning. " in ibmvscsi_send_srp_event()
959 dev_err(hostdata->dev, "send error %d\n", rc); in ibmvscsi_send_srp_event()
961 atomic_inc(&hostdata->request_limit); in ibmvscsi_send_srp_event()
968 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); in ibmvscsi_send_srp_event()
970 free_event_struct(&hostdata->pool, evt_struct); in ibmvscsi_send_srp_event()
972 atomic_inc(&hostdata->request_limit); in ibmvscsi_send_srp_event()
976 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); in ibmvscsi_send_srp_event()
984 free_event_struct(&hostdata->pool, evt_struct); in ibmvscsi_send_srp_event()
1002 dev_warn(evt_struct->hostdata->dev, in handle_cmd_rsp()
1014 evt_struct->hostdata->dev); in handle_cmd_rsp()
1048 struct ibmvscsi_host_data *hostdata = shost_priv(cmnd->device->host); in ibmvscsi_queuecommand_lck() local
1053 evt_struct = get_event_struct(&hostdata->pool); in ibmvscsi_queuecommand_lck()
1065 if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { in ibmvscsi_queuecommand_lck()
1069 free_event_struct(&hostdata->pool, evt_struct); in ibmvscsi_queuecommand_lck()
1094 return ibmvscsi_send_srp_event(evt_struct, hostdata, 0); in ibmvscsi_queuecommand_lck()
1110 static int map_persist_bufs(struct ibmvscsi_host_data *hostdata) in DEF_SCSI_QCMD()
1113 hostdata->caps_addr = dma_map_single(hostdata->dev, &hostdata->caps, in DEF_SCSI_QCMD()
1114 sizeof(hostdata->caps), DMA_BIDIRECTIONAL); in DEF_SCSI_QCMD()
1116 if (dma_mapping_error(hostdata->dev, hostdata->caps_addr)) { in DEF_SCSI_QCMD()
1117 dev_err(hostdata->dev, "Unable to map capabilities buffer!\n"); in DEF_SCSI_QCMD()
1121 hostdata->adapter_info_addr = dma_map_single(hostdata->dev, in DEF_SCSI_QCMD()
1122 &hostdata->madapter_info, in DEF_SCSI_QCMD()
1123 sizeof(hostdata->madapter_info), in DEF_SCSI_QCMD()
1125 if (dma_mapping_error(hostdata->dev, hostdata->adapter_info_addr)) { in DEF_SCSI_QCMD()
1126 dev_err(hostdata->dev, "Unable to map adapter info buffer!\n"); in DEF_SCSI_QCMD()
1127 dma_unmap_single(hostdata->dev, hostdata->caps_addr, in DEF_SCSI_QCMD()
1128 sizeof(hostdata->caps), DMA_BIDIRECTIONAL); in DEF_SCSI_QCMD()
1141 static void unmap_persist_bufs(struct ibmvscsi_host_data *hostdata) in unmap_persist_bufs() argument
1143 dma_unmap_single(hostdata->dev, hostdata->caps_addr, in unmap_persist_bufs()
1144 sizeof(hostdata->caps), DMA_BIDIRECTIONAL); in unmap_persist_bufs()
1146 dma_unmap_single(hostdata->dev, hostdata->adapter_info_addr, in unmap_persist_bufs()
1147 sizeof(hostdata->madapter_info), DMA_BIDIRECTIONAL); in unmap_persist_bufs()
1159 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in login_rsp() local
1164 dev_info(hostdata->dev, "SRP_LOGIN_REJ reason %u\n", in login_rsp()
1167 ibmvscsi_set_request_limit(hostdata, -1); in login_rsp()
1170 dev_err(hostdata->dev, "Invalid login response typecode 0x%02x!\n", in login_rsp()
1173 ibmvscsi_set_request_limit(hostdata, -1); in login_rsp()
1177 dev_info(hostdata->dev, "SRP_LOGIN succeeded\n"); in login_rsp()
1178 hostdata->client_migrated = 0; in login_rsp()
1184 ibmvscsi_set_request_limit(hostdata, in login_rsp()
1188 hostdata->action = IBMVSCSI_HOST_ACTION_UNBLOCK; in login_rsp()
1189 wake_up(&hostdata->work_wait_q); in login_rsp()
1198 static int send_srp_login(struct ibmvscsi_host_data *hostdata) in send_srp_login() argument
1203 struct srp_event_struct *evt_struct = get_event_struct(&hostdata->pool); in send_srp_login()
1220 ibmvscsi_set_request_limit(hostdata, 0); in send_srp_login()
1222 spin_lock_irqsave(hostdata->host->host_lock, flags); in send_srp_login()
1223 rc = ibmvscsi_send_srp_event(evt_struct, hostdata, login_timeout * 2); in send_srp_login()
1224 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in send_srp_login()
1225 dev_info(hostdata->dev, "sent SRP login\n"); in send_srp_login()
1237 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in capabilities_rsp() local
1240 dev_err(hostdata->dev, "error 0x%X getting capabilities info\n", in capabilities_rsp()
1243 if (hostdata->caps.migration.common.server_support != in capabilities_rsp()
1245 dev_info(hostdata->dev, "Partition migration not supported\n"); in capabilities_rsp()
1248 if (hostdata->caps.reserve.common.server_support == in capabilities_rsp()
1250 dev_info(hostdata->dev, "Client reserve enabled\n"); in capabilities_rsp()
1252 dev_info(hostdata->dev, "Client reserve not supported\n"); in capabilities_rsp()
1256 send_srp_login(hostdata); in capabilities_rsp()
1264 static void send_mad_capabilities(struct ibmvscsi_host_data *hostdata) in send_mad_capabilities() argument
1269 struct device_node *of_node = hostdata->dev->of_node; in send_mad_capabilities()
1272 evt_struct = get_event_struct(&hostdata->pool); in send_mad_capabilities()
1281 hostdata->caps.flags = cpu_to_be32(CAP_LIST_SUPPORTED); in send_mad_capabilities()
1282 if (hostdata->client_migrated) in send_mad_capabilities()
1283 hostdata->caps.flags |= cpu_to_be32(CLIENT_MIGRATED); in send_mad_capabilities()
1285 strlcpy(hostdata->caps.name, dev_name(&hostdata->host->shost_gendev), in send_mad_capabilities()
1286 sizeof(hostdata->caps.name)); in send_mad_capabilities()
1289 location = location ? location : dev_name(hostdata->dev); in send_mad_capabilities()
1290 strlcpy(hostdata->caps.loc, location, sizeof(hostdata->caps.loc)); in send_mad_capabilities()
1293 req->buffer = cpu_to_be64(hostdata->caps_addr); in send_mad_capabilities()
1295 hostdata->caps.migration.common.cap_type = in send_mad_capabilities()
1297 hostdata->caps.migration.common.length = in send_mad_capabilities()
1298 cpu_to_be16(sizeof(hostdata->caps.migration)); in send_mad_capabilities()
1299 hostdata->caps.migration.common.server_support = in send_mad_capabilities()
1301 hostdata->caps.migration.ecl = cpu_to_be32(1); in send_mad_capabilities()
1304 hostdata->caps.reserve.common.cap_type = in send_mad_capabilities()
1306 hostdata->caps.reserve.common.length = in send_mad_capabilities()
1307 cpu_to_be16(sizeof(hostdata->caps.reserve)); in send_mad_capabilities()
1308 hostdata->caps.reserve.common.server_support = in send_mad_capabilities()
1310 hostdata->caps.reserve.type = in send_mad_capabilities()
1313 cpu_to_be16(sizeof(hostdata->caps)); in send_mad_capabilities()
1315 req->common.length = cpu_to_be16(sizeof(hostdata->caps) - in send_mad_capabilities()
1316 sizeof(hostdata->caps.reserve)); in send_mad_capabilities()
1318 spin_lock_irqsave(hostdata->host->host_lock, flags); in send_mad_capabilities()
1319 if (ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2)) in send_mad_capabilities()
1320 dev_err(hostdata->dev, "couldn't send CAPABILITIES_REQ!\n"); in send_mad_capabilities()
1321 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in send_mad_capabilities()
1333 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in fast_fail_rsp() local
1337 dev_err(hostdata->dev, "fast_fail not supported in server\n"); in fast_fail_rsp()
1339 dev_err(hostdata->dev, "fast_fail request failed\n"); in fast_fail_rsp()
1341 dev_err(hostdata->dev, "error 0x%X enabling fast_fail\n", status); in fast_fail_rsp()
1343 send_mad_capabilities(hostdata); in fast_fail_rsp()
1352 static int enable_fast_fail(struct ibmvscsi_host_data *hostdata) in enable_fast_fail() argument
1360 send_mad_capabilities(hostdata); in enable_fast_fail()
1364 evt_struct = get_event_struct(&hostdata->pool); in enable_fast_fail()
1374 spin_lock_irqsave(hostdata->host->host_lock, flags); in enable_fast_fail()
1375 rc = ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2); in enable_fast_fail()
1376 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in enable_fast_fail()
1389 struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; in adapter_info_rsp() local
1392 dev_err(hostdata->dev, "error %d getting adapter info\n", in adapter_info_rsp()
1395 dev_info(hostdata->dev, "host srp version: %s, " in adapter_info_rsp()
1397 hostdata->madapter_info.srp_version, in adapter_info_rsp()
1398 hostdata->madapter_info.partition_name, in adapter_info_rsp()
1399 be32_to_cpu(hostdata->madapter_info.partition_number), in adapter_info_rsp()
1400 be32_to_cpu(hostdata->madapter_info.os_type), in adapter_info_rsp()
1401 be32_to_cpu(hostdata->madapter_info.port_max_txu[0])); in adapter_info_rsp()
1403 if (hostdata->madapter_info.port_max_txu[0]) in adapter_info_rsp()
1404 hostdata->host->max_sectors = in adapter_info_rsp()
1405 be32_to_cpu(hostdata->madapter_info.port_max_txu[0]) >> 9; in adapter_info_rsp()
1407 if (be32_to_cpu(hostdata->madapter_info.os_type) == SRP_MAD_OS_AIX && in adapter_info_rsp()
1408 strcmp(hostdata->madapter_info.srp_version, "1.6a") <= 0) { in adapter_info_rsp()
1409 dev_err(hostdata->dev, "host (Ver. %s) doesn't support large transfers\n", in adapter_info_rsp()
1410 hostdata->madapter_info.srp_version); in adapter_info_rsp()
1411 dev_err(hostdata->dev, "limiting scatterlists to %d\n", in adapter_info_rsp()
1413 hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS; in adapter_info_rsp()
1416 if (be32_to_cpu(hostdata->madapter_info.os_type) == SRP_MAD_OS_AIX) { in adapter_info_rsp()
1417 enable_fast_fail(hostdata); in adapter_info_rsp()
1422 send_srp_login(hostdata); in adapter_info_rsp()
1434 static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata) in send_mad_adapter_info() argument
1440 evt_struct = get_event_struct(&hostdata->pool); in send_mad_adapter_info()
1452 req->common.length = cpu_to_be16(sizeof(hostdata->madapter_info)); in send_mad_adapter_info()
1453 req->buffer = cpu_to_be64(hostdata->adapter_info_addr); in send_mad_adapter_info()
1455 spin_lock_irqsave(hostdata->host->host_lock, flags); in send_mad_adapter_info()
1456 if (ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2)) in send_mad_adapter_info()
1457 dev_err(hostdata->dev, "couldn't send ADAPTER_INFO_REQ!\n"); in send_mad_adapter_info()
1458 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in send_mad_adapter_info()
1464 static void init_adapter(struct ibmvscsi_host_data *hostdata) in init_adapter() argument
1466 send_mad_adapter_info(hostdata); in init_adapter()
1490 struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host); in ibmvscsi_eh_abort_handler() local
1503 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1507 list_for_each_entry(tmp_evt, &hostdata->sent, list) { in ibmvscsi_eh_abort_handler()
1515 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1519 evt = get_event_struct(&hostdata->pool); in ibmvscsi_eh_abort_handler()
1521 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1544 rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, abort_timeout * 2); in ibmvscsi_eh_abort_handler()
1549 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1551 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1554 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1593 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1595 list_for_each_entry(tmp_evt, &hostdata->sent, list) { in ibmvscsi_eh_abort_handler()
1603 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1615 found_evt->hostdata->dev); in ibmvscsi_eh_abort_handler()
1616 free_event_struct(&found_evt->hostdata->pool, found_evt); in ibmvscsi_eh_abort_handler()
1617 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_abort_handler()
1618 atomic_inc(&hostdata->request_limit); in ibmvscsi_eh_abort_handler()
1629 struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host); in ibmvscsi_eh_device_reset_handler() local
1639 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1642 evt = get_event_struct(&hostdata->pool); in ibmvscsi_eh_device_reset_handler()
1644 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1666 rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, reset_timeout * 2); in ibmvscsi_eh_device_reset_handler()
1671 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1673 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1676 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1713 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1714 list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) { in ibmvscsi_eh_device_reset_handler()
1720 tmp_evt->hostdata->dev); in ibmvscsi_eh_device_reset_handler()
1721 free_event_struct(&tmp_evt->hostdata->pool, in ibmvscsi_eh_device_reset_handler()
1723 atomic_inc(&hostdata->request_limit); in ibmvscsi_eh_device_reset_handler()
1730 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_eh_device_reset_handler()
1741 struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host); in ibmvscsi_eh_host_reset_handler() local
1743 dev_err(hostdata->dev, "Resetting connection due to error recovery\n"); in ibmvscsi_eh_host_reset_handler()
1745 ibmvscsi_reset_host(hostdata); in ibmvscsi_eh_host_reset_handler()
1749 atomic_read(&hostdata->request_limit) < 2;) { in ibmvscsi_eh_host_reset_handler()
1754 if (atomic_read(&hostdata->request_limit) <= 0) in ibmvscsi_eh_host_reset_handler()
1767 struct ibmvscsi_host_data *hostdata) in ibmvscsi_handle_crq() argument
1778 dev_info(hostdata->dev, "partner initialized\n"); in ibmvscsi_handle_crq()
1780 rc = ibmvscsi_send_crq(hostdata, 0xC002000000000000LL, 0); in ibmvscsi_handle_crq()
1783 init_adapter(hostdata); in ibmvscsi_handle_crq()
1785 dev_err(hostdata->dev, "Unable to send init rsp. rc=%ld\n", rc); in ibmvscsi_handle_crq()
1790 dev_info(hostdata->dev, "partner initialization complete\n"); in ibmvscsi_handle_crq()
1793 init_adapter(hostdata); in ibmvscsi_handle_crq()
1796 dev_err(hostdata->dev, "unknown crq message type: %d\n", crq->format); in ibmvscsi_handle_crq()
1800 scsi_block_requests(hostdata->host); in ibmvscsi_handle_crq()
1801 ibmvscsi_set_request_limit(hostdata, 0); in ibmvscsi_handle_crq()
1804 dev_info(hostdata->dev, "Re-enabling adapter!\n"); in ibmvscsi_handle_crq()
1805 hostdata->client_migrated = 1; in ibmvscsi_handle_crq()
1806 hostdata->action = IBMVSCSI_HOST_ACTION_REENABLE; in ibmvscsi_handle_crq()
1807 purge_requests(hostdata, DID_REQUEUE); in ibmvscsi_handle_crq()
1808 wake_up(&hostdata->work_wait_q); in ibmvscsi_handle_crq()
1810 dev_err(hostdata->dev, "Virtual adapter failed rc %d!\n", in ibmvscsi_handle_crq()
1812 ibmvscsi_reset_host(hostdata); in ibmvscsi_handle_crq()
1818 dev_err(hostdata->dev, "got an invalid message type 0x%02x\n", in ibmvscsi_handle_crq()
1827 if (!valid_event_struct(&hostdata->pool, evt_struct)) { in ibmvscsi_handle_crq()
1828 dev_err(hostdata->dev, "returned correlation_token 0x%p is invalid!\n", in ibmvscsi_handle_crq()
1834 dev_err(hostdata->dev, "received duplicate correlation_token 0x%p!\n", in ibmvscsi_handle_crq()
1841 &hostdata->request_limit); in ibmvscsi_handle_crq()
1850 dev_err(hostdata->dev, "returned done() is NULL; not running it!\n"); in ibmvscsi_handle_crq()
1856 spin_lock_irqsave(evt_struct->hostdata->host->host_lock, flags); in ibmvscsi_handle_crq()
1858 free_event_struct(&evt_struct->hostdata->pool, evt_struct); in ibmvscsi_handle_crq()
1859 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()
2124 static void ibmvscsi_do_work(struct ibmvscsi_host_data *hostdata) in ibmvscsi_do_work() argument
2130 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2131 switch (hostdata->action) { in ibmvscsi_do_work()
2136 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2137 rc = ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata); in ibmvscsi_do_work()
2138 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2140 rc = ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0); in ibmvscsi_do_work()
2141 vio_enable_interrupts(to_vio_dev(hostdata->dev)); in ibmvscsi_do_work()
2145 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2146 rc = ibmvscsi_reenable_crq_queue(&hostdata->queue, hostdata); in ibmvscsi_do_work()
2147 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2149 rc = ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0); in ibmvscsi_do_work()
2153 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2157 hostdata->action = IBMVSCSI_HOST_ACTION_NONE; in ibmvscsi_do_work()
2158 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_do_work()
2161 ibmvscsi_set_request_limit(hostdata, -1); in ibmvscsi_do_work()
2162 dev_err(hostdata->dev, "error after %s\n", action); in ibmvscsi_do_work()
2165 scsi_unblock_requests(hostdata->host); in ibmvscsi_do_work()
2168 static int __ibmvscsi_work_to_do(struct ibmvscsi_host_data *hostdata) in __ibmvscsi_work_to_do() argument
2172 switch (hostdata->action) { in __ibmvscsi_work_to_do()
2185 static int ibmvscsi_work_to_do(struct ibmvscsi_host_data *hostdata) in ibmvscsi_work_to_do() argument
2190 spin_lock_irqsave(hostdata->host->host_lock, flags); in ibmvscsi_work_to_do()
2191 rc = __ibmvscsi_work_to_do(hostdata); in ibmvscsi_work_to_do()
2192 spin_unlock_irqrestore(hostdata->host->host_lock, flags); in ibmvscsi_work_to_do()
2199 struct ibmvscsi_host_data *hostdata = data; in ibmvscsi_work() local
2205 rc = wait_event_interruptible(hostdata->work_wait_q, in ibmvscsi_work()
2206 ibmvscsi_work_to_do(hostdata)); in ibmvscsi_work()
2213 ibmvscsi_do_work(hostdata); in ibmvscsi_work()
2224 struct ibmvscsi_host_data *hostdata; in ibmvscsi_probe() local
2234 host = scsi_host_alloc(&driver_template, sizeof(*hostdata)); in ibmvscsi_probe()
2241 hostdata = shost_priv(host); in ibmvscsi_probe()
2242 memset(hostdata, 0x00, sizeof(*hostdata)); in ibmvscsi_probe()
2243 INIT_LIST_HEAD(&hostdata->sent); in ibmvscsi_probe()
2244 init_waitqueue_head(&hostdata->work_wait_q); in ibmvscsi_probe()
2245 hostdata->host = host; in ibmvscsi_probe()
2246 hostdata->dev = dev; in ibmvscsi_probe()
2247 ibmvscsi_set_request_limit(hostdata, -1); in ibmvscsi_probe()
2248 hostdata->host->max_sectors = IBMVSCSI_MAX_SECTORS_DEFAULT; in ibmvscsi_probe()
2250 if (map_persist_bufs(hostdata)) { in ibmvscsi_probe()
2255 hostdata->work_thread = kthread_run(ibmvscsi_work, hostdata, "%s_%d", in ibmvscsi_probe()
2258 if (IS_ERR(hostdata->work_thread)) { in ibmvscsi_probe()
2260 PTR_ERR(hostdata->work_thread)); in ibmvscsi_probe()
2264 rc = ibmvscsi_init_crq_queue(&hostdata->queue, hostdata, max_events); in ibmvscsi_probe()
2269 if (initialize_event_pool(&hostdata->pool, max_events, hostdata) != 0) { in ibmvscsi_probe()
2283 if (scsi_add_host(hostdata->host, hostdata->dev)) in ibmvscsi_probe()
2287 memcpy(ids.port_id, hostdata->madapter_info.partition_name, in ibmvscsi_probe()
2298 if (ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0) == 0 in ibmvscsi_probe()
2308 atomic_read(&hostdata->request_limit) < 2;) { in ibmvscsi_probe()
2314 if (atomic_read(&hostdata->request_limit) > 0) in ibmvscsi_probe()
2318 dev_set_drvdata(&vdev->dev, hostdata); in ibmvscsi_probe()
2320 list_add_tail(&hostdata->host_list, &ibmvscsi_head); in ibmvscsi_probe()
2325 scsi_remove_host(hostdata->host); in ibmvscsi_probe()
2327 release_event_pool(&hostdata->pool, hostdata); in ibmvscsi_probe()
2329 ibmvscsi_release_crq_queue(&hostdata->queue, hostdata, max_events); in ibmvscsi_probe()
2331 kthread_stop(hostdata->work_thread); in ibmvscsi_probe()
2333 unmap_persist_bufs(hostdata); in ibmvscsi_probe()
2342 struct ibmvscsi_host_data *hostdata = dev_get_drvdata(&vdev->dev); in ibmvscsi_remove() local
2344 srp_remove_host(hostdata->host); in ibmvscsi_remove()
2345 scsi_remove_host(hostdata->host); in ibmvscsi_remove()
2347 purge_requests(hostdata, DID_ERROR); in ibmvscsi_remove()
2348 release_event_pool(&hostdata->pool, hostdata); in ibmvscsi_remove()
2350 ibmvscsi_release_crq_queue(&hostdata->queue, hostdata, in ibmvscsi_remove()
2353 kthread_stop(hostdata->work_thread); in ibmvscsi_remove()
2354 unmap_persist_bufs(hostdata); in ibmvscsi_remove()
2357 list_del(&hostdata->host_list); in ibmvscsi_remove()
2360 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()