aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ibmvscsi/ibmvscsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/ibmvscsi/ibmvscsi.c')
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c67
1 files changed, 36 insertions, 31 deletions
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 822b9fa706f3..eaefeddb2b4a 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -87,7 +87,7 @@ static int max_channel = 3;
87static int init_timeout = 5; 87static int init_timeout = 5;
88static int max_requests = 50; 88static int max_requests = 50;
89 89
90#define IBMVSCSI_VERSION "1.5.7" 90#define IBMVSCSI_VERSION "1.5.8"
91 91
92MODULE_DESCRIPTION("IBM Virtual SCSI"); 92MODULE_DESCRIPTION("IBM Virtual SCSI");
93MODULE_AUTHOR("Dave Boutcher"); 93MODULE_AUTHOR("Dave Boutcher");
@@ -534,7 +534,6 @@ static int map_data_for_srp_cmd(struct scsi_cmnd *cmd,
534static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, 534static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
535 struct ibmvscsi_host_data *hostdata) 535 struct ibmvscsi_host_data *hostdata)
536{ 536{
537 struct scsi_cmnd *cmnd;
538 u64 *crq_as_u64 = (u64 *) &evt_struct->crq; 537 u64 *crq_as_u64 = (u64 *) &evt_struct->crq;
539 int rc; 538 int rc;
540 539
@@ -544,19 +543,8 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
544 * can handle more requests (can_queue) when we actually can't 543 * can handle more requests (can_queue) when we actually can't
545 */ 544 */
546 if ((evt_struct->crq.format == VIOSRP_SRP_FORMAT) && 545 if ((evt_struct->crq.format == VIOSRP_SRP_FORMAT) &&
547 (atomic_dec_if_positive(&hostdata->request_limit) < 0)) { 546 (atomic_dec_if_positive(&hostdata->request_limit) < 0))
548 /* See if the adapter is disabled */ 547 goto send_error;
549 if (atomic_read(&hostdata->request_limit) < 0)
550 goto send_error;
551
552 printk(KERN_WARNING
553 "ibmvscsi: Warning, request_limit exceeded\n");
554 unmap_cmd_data(&evt_struct->iu.srp.cmd,
555 evt_struct,
556 hostdata->dev);
557 free_event_struct(&hostdata->pool, evt_struct);
558 return SCSI_MLQUEUE_HOST_BUSY;
559 }
560 548
561 /* Copy the IU into the transfer area */ 549 /* Copy the IU into the transfer area */
562 *evt_struct->xfer_iu = evt_struct->iu; 550 *evt_struct->xfer_iu = evt_struct->iu;
@@ -572,7 +560,7 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
572 ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) { 560 ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) {
573 list_del(&evt_struct->list); 561 list_del(&evt_struct->list);
574 562
575 printk(KERN_ERR "ibmvscsi: failed to send event struct rc %d\n", 563 printk(KERN_ERR "ibmvscsi: send error %d\n",
576 rc); 564 rc);
577 goto send_error; 565 goto send_error;
578 } 566 }
@@ -582,14 +570,8 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
582 send_error: 570 send_error:
583 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); 571 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev);
584 572
585 if ((cmnd = evt_struct->cmnd) != NULL) {
586 cmnd->result = DID_ERROR << 16;
587 evt_struct->cmnd_done(cmnd);
588 } else if (evt_struct->done)
589 evt_struct->done(evt_struct);
590
591 free_event_struct(&hostdata->pool, evt_struct); 573 free_event_struct(&hostdata->pool, evt_struct);
592 return 0; 574 return SCSI_MLQUEUE_HOST_BUSY;
593} 575}
594 576
595/** 577/**
@@ -802,7 +784,8 @@ static void login_rsp(struct srp_event_struct *evt_struct)
802 case SRP_LOGIN_RSP_TYPE: /* it worked! */ 784 case SRP_LOGIN_RSP_TYPE: /* it worked! */
803 break; 785 break;
804 case SRP_LOGIN_REJ_TYPE: /* refused! */ 786 case SRP_LOGIN_REJ_TYPE: /* refused! */
805 printk(KERN_INFO "ibmvscsi: SRP_LOGIN_REQ rejected\n"); 787 printk(KERN_INFO "ibmvscsi: SRP_LOGIN_REJ reason %u\n",
788 evt_struct->xfer_iu->srp.login_rej.reason);
806 /* Login failed. */ 789 /* Login failed. */
807 atomic_set(&hostdata->request_limit, -1); 790 atomic_set(&hostdata->request_limit, -1);
808 return; 791 return;
@@ -834,6 +817,9 @@ static void login_rsp(struct srp_event_struct *evt_struct)
834 return; 817 return;
835 } 818 }
836 819
820 /* If we had any pending I/Os, kick them */
821 scsi_unblock_requests(hostdata->host);
822
837 send_mad_adapter_info(hostdata); 823 send_mad_adapter_info(hostdata);
838 return; 824 return;
839} 825}
@@ -862,6 +848,7 @@ static int send_srp_login(struct ibmvscsi_host_data *hostdata)
862 init_timeout * HZ); 848 init_timeout * HZ);
863 849
864 login = &evt_struct->iu.srp.login_req; 850 login = &evt_struct->iu.srp.login_req;
851 memset(login, 0x00, sizeof(struct srp_login_req));
865 login->type = SRP_LOGIN_REQ_TYPE; 852 login->type = SRP_LOGIN_REQ_TYPE;
866 login->max_requested_initiator_to_target_iulen = sizeof(union srp_iu); 853 login->max_requested_initiator_to_target_iulen = sizeof(union srp_iu);
867 login->required_buffer_formats = 0x0006; 854 login->required_buffer_formats = 0x0006;
@@ -1122,7 +1109,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
1122 * purge_requests: Our virtual adapter just shut down. purge any sent requests 1109 * purge_requests: Our virtual adapter just shut down. purge any sent requests
1123 * @hostdata: the adapter 1110 * @hostdata: the adapter
1124 */ 1111 */
1125static void purge_requests(struct ibmvscsi_host_data *hostdata) 1112static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code)
1126{ 1113{
1127 struct srp_event_struct *tmp_evt, *pos; 1114 struct srp_event_struct *tmp_evt, *pos;
1128 unsigned long flags; 1115 unsigned long flags;
@@ -1131,7 +1118,7 @@ static void purge_requests(struct ibmvscsi_host_data *hostdata)
1131 list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) { 1118 list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) {
1132 list_del(&tmp_evt->list); 1119 list_del(&tmp_evt->list);
1133 if (tmp_evt->cmnd) { 1120 if (tmp_evt->cmnd) {
1134 tmp_evt->cmnd->result = (DID_ERROR << 16); 1121 tmp_evt->cmnd->result = (error_code << 16);
1135 unmap_cmd_data(&tmp_evt->iu.srp.cmd, 1122 unmap_cmd_data(&tmp_evt->iu.srp.cmd,
1136 tmp_evt, 1123 tmp_evt,
1137 tmp_evt->hostdata->dev); 1124 tmp_evt->hostdata->dev);
@@ -1186,12 +1173,30 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
1186 printk(KERN_ERR "ibmvscsi: unknown crq message type\n"); 1173 printk(KERN_ERR "ibmvscsi: unknown crq message type\n");
1187 } 1174 }
1188 return; 1175 return;
1189 case 0xFF: /* Hypervisor telling us the connection is closed */ 1176 case 0xFF: /* Hypervisor telling us the connection is closed */
1190 printk(KERN_INFO "ibmvscsi: Virtual adapter failed!\n"); 1177 scsi_block_requests(hostdata->host);
1178 if (crq->format == 0x06) {
1179 /* We need to re-setup the interpartition connection */
1180 printk(KERN_INFO
1181 "ibmvscsi: Re-enabling adapter!\n");
1182 purge_requests(hostdata, DID_REQUEUE);
1183 if (ibmvscsi_reenable_crq_queue(&hostdata->queue,
1184 hostdata) == 0)
1185 if (ibmvscsi_send_crq(hostdata,
1186 0xC001000000000000LL, 0))
1187 printk(KERN_ERR
1188 "ibmvscsi: transmit error after"
1189 " enable\n");
1190 } else {
1191 printk(KERN_INFO
1192 "ibmvscsi: Virtual adapter failed rc %d!\n",
1193 crq->format);
1191 1194
1192 atomic_set(&hostdata->request_limit, -1); 1195 atomic_set(&hostdata->request_limit, -1);
1193 purge_requests(hostdata); 1196 purge_requests(hostdata, DID_ERROR);
1194 ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata); 1197 ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata);
1198 }
1199 scsi_unblock_requests(hostdata->host);
1195 return; 1200 return;
1196 case 0x80: /* real payload */ 1201 case 0x80: /* real payload */
1197 break; 1202 break;