aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/be2iscsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/be2iscsi')
-rw-r--r--drivers/scsi/be2iscsi/be.h11
-rw-r--r--drivers/scsi/be2iscsi/be_cmds.c121
-rw-r--r--drivers/scsi/be2iscsi/be_cmds.h10
-rw-r--r--drivers/scsi/be2iscsi/be_iscsi.c13
-rw-r--r--drivers/scsi/be2iscsi/be_main.c107
-rw-r--r--drivers/scsi/be2iscsi/be_main.h23
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.c22
7 files changed, 221 insertions, 86 deletions
diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 2e28f6c419fe..1bfb0bd01198 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -98,6 +98,14 @@ struct be_mcc_obj {
98 struct be_queue_info cq; 98 struct be_queue_info cq;
99}; 99};
100 100
101struct beiscsi_mcc_tag_state {
102#define MCC_TAG_STATE_COMPLETED 0x00
103#define MCC_TAG_STATE_RUNNING 0x01
104#define MCC_TAG_STATE_TIMEOUT 0x02
105 uint8_t tag_state;
106 struct be_dma_mem tag_mem_state;
107};
108
101struct be_ctrl_info { 109struct be_ctrl_info {
102 u8 __iomem *csr; 110 u8 __iomem *csr;
103 u8 __iomem *db; /* Door Bell */ 111 u8 __iomem *db; /* Door Bell */
@@ -122,6 +130,8 @@ struct be_ctrl_info {
122 unsigned short mcc_alloc_index; 130 unsigned short mcc_alloc_index;
123 unsigned short mcc_free_index; 131 unsigned short mcc_free_index;
124 unsigned int mcc_tag_available; 132 unsigned int mcc_tag_available;
133
134 struct beiscsi_mcc_tag_state ptag_state[MAX_MCC_CMD + 1];
125}; 135};
126 136
127#include "be_cmds.h" 137#include "be_cmds.h"
@@ -129,6 +139,7 @@ struct be_ctrl_info {
129#define PAGE_SHIFT_4K 12 139#define PAGE_SHIFT_4K 12
130#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K) 140#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K)
131#define mcc_timeout 120000 /* 12s timeout */ 141#define mcc_timeout 120000 /* 12s timeout */
142#define BEISCSI_LOGOUT_SYNC_DELAY 250
132 143
133/* Returns number of pages spanned by the data starting at the given addr */ 144/* Returns number of pages spanned by the data starting at the given addr */
134#define PAGES_4K_SPANNED(_address, size) \ 145#define PAGES_4K_SPANNED(_address, size) \
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 3338391b64de..1432ed5e9fc6 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -138,7 +138,7 @@ unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
138 * @phba: Driver private structure 138 * @phba: Driver private structure
139 * @tag: Tag for the MBX Command 139 * @tag: Tag for the MBX Command
140 * @wrb: the WRB used for the MBX Command 140 * @wrb: the WRB used for the MBX Command
141 * @cmd_hdr: IOCTL Hdr for the MBX Cmd 141 * @mbx_cmd_mem: ptr to memory allocated for MBX Cmd
142 * 142 *
143 * Waits for MBX completion with the passed TAG. 143 * Waits for MBX completion with the passed TAG.
144 * 144 *
@@ -148,21 +148,26 @@ unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
148 **/ 148 **/
149int beiscsi_mccq_compl(struct beiscsi_hba *phba, 149int beiscsi_mccq_compl(struct beiscsi_hba *phba,
150 uint32_t tag, struct be_mcc_wrb **wrb, 150 uint32_t tag, struct be_mcc_wrb **wrb,
151 void *cmd_hdr) 151 struct be_dma_mem *mbx_cmd_mem)
152{ 152{
153 int rc = 0; 153 int rc = 0;
154 uint32_t mcc_tag_response; 154 uint32_t mcc_tag_response;
155 uint16_t status = 0, addl_status = 0, wrb_num = 0; 155 uint16_t status = 0, addl_status = 0, wrb_num = 0;
156 struct be_mcc_wrb *temp_wrb; 156 struct be_mcc_wrb *temp_wrb;
157 struct be_cmd_req_hdr *ioctl_hdr; 157 struct be_cmd_req_hdr *mbx_hdr;
158 struct be_cmd_resp_hdr *ioctl_resp_hdr; 158 struct be_cmd_resp_hdr *mbx_resp_hdr;
159 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; 159 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
160 160
161 if (beiscsi_error(phba)) { 161 if (beiscsi_error(phba)) {
162 free_mcc_tag(&phba->ctrl, tag); 162 free_mcc_tag(&phba->ctrl, tag);
163 return -EIO; 163 return -EPERM;
164 } 164 }
165 165
166 /* Set MBX Tag state to Active */
167 spin_lock(&phba->ctrl.mbox_lock);
168 phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_RUNNING;
169 spin_unlock(&phba->ctrl.mbox_lock);
170
166 /* wait for the mccq completion */ 171 /* wait for the mccq completion */
167 rc = wait_event_interruptible_timeout( 172 rc = wait_event_interruptible_timeout(
168 phba->ctrl.mcc_wait[tag], 173 phba->ctrl.mcc_wait[tag],
@@ -171,56 +176,71 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
171 BEISCSI_HOST_MBX_TIMEOUT)); 176 BEISCSI_HOST_MBX_TIMEOUT));
172 177
173 if (rc <= 0) { 178 if (rc <= 0) {
179 struct be_dma_mem *tag_mem;
180 /* Set MBX Tag state to timeout */
181 spin_lock(&phba->ctrl.mbox_lock);
182 phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_TIMEOUT;
183 spin_unlock(&phba->ctrl.mbox_lock);
184
185 /* Store resource addr to be freed later */
186 tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state;
187 if (mbx_cmd_mem) {
188 tag_mem->size = mbx_cmd_mem->size;
189 tag_mem->va = mbx_cmd_mem->va;
190 tag_mem->dma = mbx_cmd_mem->dma;
191 } else
192 tag_mem->size = 0;
193
174 beiscsi_log(phba, KERN_ERR, 194 beiscsi_log(phba, KERN_ERR,
175 BEISCSI_LOG_INIT | BEISCSI_LOG_EH | 195 BEISCSI_LOG_INIT | BEISCSI_LOG_EH |
176 BEISCSI_LOG_CONFIG, 196 BEISCSI_LOG_CONFIG,
177 "BC_%d : MBX Cmd Completion timed out\n"); 197 "BC_%d : MBX Cmd Completion timed out\n");
178 rc = -EBUSY; 198 return -EBUSY;
179 199 } else {
180 /* decrement the mccq used count */
181 atomic_dec(&phba->ctrl.mcc_obj.q.used);
182
183 goto release_mcc_tag;
184 } else
185 rc = 0; 200 rc = 0;
201 /* Set MBX Tag state to completed */
202 spin_lock(&phba->ctrl.mbox_lock);
203 phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_COMPLETED;
204 spin_unlock(&phba->ctrl.mbox_lock);
205 }
186 206
187 mcc_tag_response = phba->ctrl.mcc_numtag[tag]; 207 mcc_tag_response = phba->ctrl.mcc_numtag[tag];
188 status = (mcc_tag_response & CQE_STATUS_MASK); 208 status = (mcc_tag_response & CQE_STATUS_MASK);
189 addl_status = ((mcc_tag_response & CQE_STATUS_ADDL_MASK) >> 209 addl_status = ((mcc_tag_response & CQE_STATUS_ADDL_MASK) >>
190 CQE_STATUS_ADDL_SHIFT); 210 CQE_STATUS_ADDL_SHIFT);
191 211
192 if (cmd_hdr) { 212 if (mbx_cmd_mem) {
193 ioctl_hdr = (struct be_cmd_req_hdr *)cmd_hdr; 213 mbx_hdr = (struct be_cmd_req_hdr *)mbx_cmd_mem->va;
194 } else { 214 } else {
195 wrb_num = (mcc_tag_response & CQE_STATUS_WRB_MASK) >> 215 wrb_num = (mcc_tag_response & CQE_STATUS_WRB_MASK) >>
196 CQE_STATUS_WRB_SHIFT; 216 CQE_STATUS_WRB_SHIFT;
197 temp_wrb = (struct be_mcc_wrb *)queue_get_wrb(mccq, wrb_num); 217 temp_wrb = (struct be_mcc_wrb *)queue_get_wrb(mccq, wrb_num);
198 ioctl_hdr = embedded_payload(temp_wrb); 218 mbx_hdr = embedded_payload(temp_wrb);
199 219
200 if (wrb) 220 if (wrb)
201 *wrb = temp_wrb; 221 *wrb = temp_wrb;
202 } 222 }
203 223
204 if (status || addl_status) { 224 if (status || addl_status) {
205 beiscsi_log(phba, KERN_ERR, 225 beiscsi_log(phba, KERN_WARNING,
206 BEISCSI_LOG_INIT | BEISCSI_LOG_EH | 226 BEISCSI_LOG_INIT | BEISCSI_LOG_EH |
207 BEISCSI_LOG_CONFIG, 227 BEISCSI_LOG_CONFIG,
208 "BC_%d : MBX Cmd Failed for " 228 "BC_%d : MBX Cmd Failed for "
209 "Subsys : %d Opcode : %d with " 229 "Subsys : %d Opcode : %d with "
210 "Status : %d and Extd_Status : %d\n", 230 "Status : %d and Extd_Status : %d\n",
211 ioctl_hdr->subsystem, 231 mbx_hdr->subsystem,
212 ioctl_hdr->opcode, 232 mbx_hdr->opcode,
213 status, addl_status); 233 status, addl_status);
214 234
215 if (status == MCC_STATUS_INSUFFICIENT_BUFFER) { 235 if (status == MCC_STATUS_INSUFFICIENT_BUFFER) {
216 ioctl_resp_hdr = (struct be_cmd_resp_hdr *) ioctl_hdr; 236 mbx_resp_hdr = (struct be_cmd_resp_hdr *) mbx_hdr;
217 beiscsi_log(phba, KERN_WARNING, 237 beiscsi_log(phba, KERN_WARNING,
218 BEISCSI_LOG_INIT | BEISCSI_LOG_EH | 238 BEISCSI_LOG_INIT | BEISCSI_LOG_EH |
219 BEISCSI_LOG_CONFIG, 239 BEISCSI_LOG_CONFIG,
220 "BC_%d : Insufficent Buffer Error " 240 "BC_%d : Insufficent Buffer Error "
221 "Resp_Len : %d Actual_Resp_Len : %d\n", 241 "Resp_Len : %d Actual_Resp_Len : %d\n",
222 ioctl_resp_hdr->response_length, 242 mbx_resp_hdr->response_length,
223 ioctl_resp_hdr->actual_resp_len); 243 mbx_resp_hdr->actual_resp_len);
224 244
225 rc = -EAGAIN; 245 rc = -EAGAIN;
226 goto release_mcc_tag; 246 goto release_mcc_tag;
@@ -319,6 +339,7 @@ static int be_mcc_compl_process(struct be_ctrl_info *ctrl,
319int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl, 339int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
320 struct be_mcc_compl *compl) 340 struct be_mcc_compl *compl)
321{ 341{
342 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
322 u16 compl_status, extd_status; 343 u16 compl_status, extd_status;
323 unsigned short tag; 344 unsigned short tag;
324 345
@@ -338,7 +359,32 @@ int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
338 ctrl->mcc_numtag[tag] |= (compl->tag0 & 0x00FF0000); 359 ctrl->mcc_numtag[tag] |= (compl->tag0 & 0x00FF0000);
339 ctrl->mcc_numtag[tag] |= (extd_status & 0x000000FF) << 8; 360 ctrl->mcc_numtag[tag] |= (extd_status & 0x000000FF) << 8;
340 ctrl->mcc_numtag[tag] |= (compl_status & 0x000000FF); 361 ctrl->mcc_numtag[tag] |= (compl_status & 0x000000FF);
341 wake_up_interruptible(&ctrl->mcc_wait[tag]); 362
363 if (ctrl->ptag_state[tag].tag_state == MCC_TAG_STATE_RUNNING) {
364 wake_up_interruptible(&ctrl->mcc_wait[tag]);
365 } else if (ctrl->ptag_state[tag].tag_state == MCC_TAG_STATE_TIMEOUT) {
366 struct be_dma_mem *tag_mem;
367 tag_mem = &ctrl->ptag_state[tag].tag_mem_state;
368
369 beiscsi_log(phba, KERN_WARNING,
370 BEISCSI_LOG_MBOX | BEISCSI_LOG_INIT |
371 BEISCSI_LOG_CONFIG,
372 "BC_%d : MBX Completion for timeout Command "
373 "from FW\n");
374 /* Check if memory needs to be freed */
375 if (tag_mem->size)
376 pci_free_consistent(ctrl->pdev, tag_mem->size,
377 tag_mem->va, tag_mem->dma);
378
379 /* Change tag state */
380 spin_lock(&phba->ctrl.mbox_lock);
381 ctrl->ptag_state[tag].tag_state = MCC_TAG_STATE_COMPLETED;
382 spin_unlock(&phba->ctrl.mbox_lock);
383
384 /* Free MCC Tag */
385 free_mcc_tag(ctrl, tag);
386 }
387
342 return 0; 388 return 0;
343} 389}
344 390
@@ -354,8 +400,23 @@ static struct be_mcc_compl *be_mcc_compl_get(struct beiscsi_hba *phba)
354 return NULL; 400 return NULL;
355} 401}
356 402
357static void be2iscsi_fail_session(struct iscsi_cls_session *cls_session) 403/**
404 * be2iscsi_fail_session(): Closing session with appropriate error
405 * @cls_session: ptr to session
406 *
407 * Depending on adapter state appropriate error flag is passed.
408 **/
409void be2iscsi_fail_session(struct iscsi_cls_session *cls_session)
358{ 410{
411 struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
412 struct beiscsi_hba *phba = iscsi_host_priv(shost);
413 uint32_t iscsi_err_flag;
414
415 if (phba->state & BE_ADAPTER_STATE_SHUTDOWN)
416 iscsi_err_flag = ISCSI_ERR_INVALID_HOST;
417 else
418 iscsi_err_flag = ISCSI_ERR_CONN_FAILED;
419
359 iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED); 420 iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED);
360} 421}
361 422
@@ -386,18 +447,6 @@ void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
386 } 447 }
387} 448}
388 449
389static void beiscsi_cq_notify(struct beiscsi_hba *phba, u16 qid, bool arm,
390 u16 num_popped)
391{
392 u32 val = 0;
393 val |= qid & DB_CQ_RING_ID_MASK;
394 if (arm)
395 val |= 1 << DB_CQ_REARM_SHIFT;
396 val |= num_popped << DB_CQ_NUM_POPPED_SHIFT;
397 iowrite32(val, phba->db_va + DB_CQ_OFFSET);
398}
399
400
401int beiscsi_process_mcc(struct beiscsi_hba *phba) 450int beiscsi_process_mcc(struct beiscsi_hba *phba)
402{ 451{
403 struct be_mcc_compl *compl; 452 struct be_mcc_compl *compl;
@@ -428,7 +477,7 @@ int beiscsi_process_mcc(struct beiscsi_hba *phba)
428 } 477 }
429 478
430 if (num) 479 if (num)
431 beiscsi_cq_notify(phba, phba->ctrl.mcc_obj.cq.id, true, num); 480 hwi_ring_cq_db(phba, phba->ctrl.mcc_obj.cq.id, num, 1, 0);
432 481
433 spin_unlock_bh(&phba->ctrl.mcc_cq_lock); 482 spin_unlock_bh(&phba->ctrl.mcc_cq_lock);
434 return status; 483 return status;
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 627ebbe0172c..7cf7f99ee442 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -103,7 +103,7 @@ struct be_mcc_compl {
103 103
104/********** MCC door bell ************/ 104/********** MCC door bell ************/
105#define DB_MCCQ_OFFSET 0x140 105#define DB_MCCQ_OFFSET 0x140
106#define DB_MCCQ_RING_ID_MASK 0x7FF /* bits 0 - 10 */ 106#define DB_MCCQ_RING_ID_MASK 0xFFFF /* bits 0 - 15 */
107/* Number of entries posted */ 107/* Number of entries posted */
108#define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */ 108#define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
109 109
@@ -709,7 +709,8 @@ unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba);
709void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag); 709void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
710 710
711int beiscsi_mccq_compl(struct beiscsi_hba *phba, 711int beiscsi_mccq_compl(struct beiscsi_hba *phba,
712 uint32_t tag, struct be_mcc_wrb **wrb, void *cmd_va); 712 uint32_t tag, struct be_mcc_wrb **wrb,
713 struct be_dma_mem *mbx_cmd_mem);
713/*ISCSI Functuions */ 714/*ISCSI Functuions */
714int be_cmd_fw_initialize(struct be_ctrl_info *ctrl); 715int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
715int be_cmd_fw_uninit(struct be_ctrl_info *ctrl); 716int be_cmd_fw_uninit(struct be_ctrl_info *ctrl);
@@ -1017,8 +1018,8 @@ struct be_mcc_wrb_context {
1017 int *users_final_status; 1018 int *users_final_status;
1018} __packed; 1019} __packed;
1019 1020
1020#define DB_DEF_PDU_RING_ID_MASK 0x3FF /* bits 0 - 9 */ 1021#define DB_DEF_PDU_RING_ID_MASK 0x3FFF /* bits 0 - 13 */
1021#define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 0 - 9 */ 1022#define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 16 - 29 */
1022#define DB_DEF_PDU_REARM_SHIFT 14 1023#define DB_DEF_PDU_REARM_SHIFT 14
1023#define DB_DEF_PDU_EVENT_SHIFT 15 1024#define DB_DEF_PDU_EVENT_SHIFT 15
1024#define DB_DEF_PDU_CQPROC_SHIFT 16 1025#define DB_DEF_PDU_CQPROC_SHIFT 16
@@ -1317,4 +1318,5 @@ void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
1317void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr, 1318void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1318 u8 subsystem, u8 opcode, int cmd_len); 1319 u8 subsystem, u8 opcode, int cmd_len);
1319 1320
1321void be2iscsi_fail_session(struct iscsi_cls_session *cls_session);
1320#endif /* !BEISCSI_CMDS_H */ 1322#endif /* !BEISCSI_CMDS_H */
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 889066d9d6fb..a3df43324c98 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -793,7 +793,7 @@ static int beiscsi_get_port_speed(struct Scsi_Host *shost)
793 ihost->port_speed = ISCSI_PORT_SPEED_10MBPS; 793 ihost->port_speed = ISCSI_PORT_SPEED_10MBPS;
794 break; 794 break;
795 case BE2ISCSI_LINK_SPEED_100MBPS: 795 case BE2ISCSI_LINK_SPEED_100MBPS:
796 ihost->port_speed = BE2ISCSI_LINK_SPEED_100MBPS; 796 ihost->port_speed = ISCSI_PORT_SPEED_100MBPS;
797 break; 797 break;
798 case BE2ISCSI_LINK_SPEED_1GBPS: 798 case BE2ISCSI_LINK_SPEED_1GBPS:
799 ihost->port_speed = ISCSI_PORT_SPEED_1GBPS; 799 ihost->port_speed = ISCSI_PORT_SPEED_1GBPS;
@@ -1153,16 +1153,18 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
1153 return -EAGAIN; 1153 return -EAGAIN;
1154 } 1154 }
1155 1155
1156 ret = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); 1156 ret = beiscsi_mccq_compl(phba, tag, NULL, &nonemb_cmd);
1157 if (ret) { 1157 if (ret) {
1158 beiscsi_log(phba, KERN_ERR, 1158 beiscsi_log(phba, KERN_ERR,
1159 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, 1159 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
1160 "BS_%d : mgmt_open_connection Failed"); 1160 "BS_%d : mgmt_open_connection Failed");
1161 1161
1162 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 1162 if (ret != -EBUSY)
1163 nonemb_cmd.va, nonemb_cmd.dma); 1163 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1164 nonemb_cmd.va, nonemb_cmd.dma);
1165
1164 beiscsi_free_ep(beiscsi_ep); 1166 beiscsi_free_ep(beiscsi_ep);
1165 return -EBUSY; 1167 return ret;
1166 } 1168 }
1167 1169
1168 ptcpcnct_out = (struct tcp_connect_and_offload_out *)nonemb_cmd.va; 1170 ptcpcnct_out = (struct tcp_connect_and_offload_out *)nonemb_cmd.va;
@@ -1359,6 +1361,7 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)
1359 beiscsi_mccq_compl(phba, tag, NULL, NULL); 1361 beiscsi_mccq_compl(phba, tag, NULL, NULL);
1360 beiscsi_close_conn(beiscsi_ep, tcp_upload_flag); 1362 beiscsi_close_conn(beiscsi_ep, tcp_upload_flag);
1361free_ep: 1363free_ep:
1364 msleep(BEISCSI_LOGOUT_SYNC_DELAY);
1362 beiscsi_free_ep(beiscsi_ep); 1365 beiscsi_free_ep(beiscsi_ep);
1363 beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid); 1366 beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid);
1364 iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep); 1367 iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep);
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index a929c3c9aedc..0d822297aa80 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -228,24 +228,25 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
228 struct invalidate_command_table *inv_tbl; 228 struct invalidate_command_table *inv_tbl;
229 struct be_dma_mem nonemb_cmd; 229 struct be_dma_mem nonemb_cmd;
230 unsigned int cid, tag, num_invalidate; 230 unsigned int cid, tag, num_invalidate;
231 int rc;
231 232
232 cls_session = starget_to_session(scsi_target(sc->device)); 233 cls_session = starget_to_session(scsi_target(sc->device));
233 session = cls_session->dd_data; 234 session = cls_session->dd_data;
234 235
235 spin_lock_bh(&session->lock); 236 spin_lock_bh(&session->frwd_lock);
236 if (!aborted_task || !aborted_task->sc) { 237 if (!aborted_task || !aborted_task->sc) {
237 /* we raced */ 238 /* we raced */
238 spin_unlock_bh(&session->lock); 239 spin_unlock_bh(&session->frwd_lock);
239 return SUCCESS; 240 return SUCCESS;
240 } 241 }
241 242
242 aborted_io_task = aborted_task->dd_data; 243 aborted_io_task = aborted_task->dd_data;
243 if (!aborted_io_task->scsi_cmnd) { 244 if (!aborted_io_task->scsi_cmnd) {
244 /* raced or invalid command */ 245 /* raced or invalid command */
245 spin_unlock_bh(&session->lock); 246 spin_unlock_bh(&session->frwd_lock);
246 return SUCCESS; 247 return SUCCESS;
247 } 248 }
248 spin_unlock_bh(&session->lock); 249 spin_unlock_bh(&session->frwd_lock);
249 /* Invalidate WRB Posted for this Task */ 250 /* Invalidate WRB Posted for this Task */
250 AMAP_SET_BITS(struct amap_iscsi_wrb, invld, 251 AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
251 aborted_io_task->pwrb_handle->pwrb, 252 aborted_io_task->pwrb_handle->pwrb,
@@ -285,9 +286,11 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
285 return FAILED; 286 return FAILED;
286 } 287 }
287 288
288 beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); 289 rc = beiscsi_mccq_compl(phba, tag, NULL, &nonemb_cmd);
289 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 290 if (rc != -EBUSY)
290 nonemb_cmd.va, nonemb_cmd.dma); 291 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
292 nonemb_cmd.va, nonemb_cmd.dma);
293
291 return iscsi_eh_abort(sc); 294 return iscsi_eh_abort(sc);
292} 295}
293 296
@@ -303,13 +306,14 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
303 struct invalidate_command_table *inv_tbl; 306 struct invalidate_command_table *inv_tbl;
304 struct be_dma_mem nonemb_cmd; 307 struct be_dma_mem nonemb_cmd;
305 unsigned int cid, tag, i, num_invalidate; 308 unsigned int cid, tag, i, num_invalidate;
309 int rc;
306 310
307 /* invalidate iocbs */ 311 /* invalidate iocbs */
308 cls_session = starget_to_session(scsi_target(sc->device)); 312 cls_session = starget_to_session(scsi_target(sc->device));
309 session = cls_session->dd_data; 313 session = cls_session->dd_data;
310 spin_lock_bh(&session->lock); 314 spin_lock_bh(&session->frwd_lock);
311 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) { 315 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) {
312 spin_unlock_bh(&session->lock); 316 spin_unlock_bh(&session->frwd_lock);
313 return FAILED; 317 return FAILED;
314 } 318 }
315 conn = session->leadconn; 319 conn = session->leadconn;
@@ -325,7 +329,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
325 if (!abrt_task->sc || abrt_task->state == ISCSI_TASK_FREE) 329 if (!abrt_task->sc || abrt_task->state == ISCSI_TASK_FREE)
326 continue; 330 continue;
327 331
328 if (abrt_task->sc->device->lun != abrt_task->sc->device->lun) 332 if (sc->device->lun != abrt_task->sc->device->lun)
329 continue; 333 continue;
330 334
331 /* Invalidate WRB Posted for this Task */ 335 /* Invalidate WRB Posted for this Task */
@@ -338,7 +342,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
338 num_invalidate++; 342 num_invalidate++;
339 inv_tbl++; 343 inv_tbl++;
340 } 344 }
341 spin_unlock_bh(&session->lock); 345 spin_unlock_bh(&session->frwd_lock);
342 inv_tbl = phba->inv_tbl; 346 inv_tbl = phba->inv_tbl;
343 347
344 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, 348 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
@@ -363,9 +367,10 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
363 return FAILED; 367 return FAILED;
364 } 368 }
365 369
366 beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); 370 rc = beiscsi_mccq_compl(phba, tag, NULL, &nonemb_cmd);
367 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 371 if (rc != -EBUSY)
368 nonemb_cmd.va, nonemb_cmd.dma); 372 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
373 nonemb_cmd.va, nonemb_cmd.dma);
369 return iscsi_eh_device_reset(sc); 374 return iscsi_eh_device_reset(sc);
370} 375}
371 376
@@ -674,8 +679,19 @@ static int beiscsi_enable_pci(struct pci_dev *pcidev)
674 } 679 }
675 680
676 pci_set_master(pcidev); 681 pci_set_master(pcidev);
677 if (pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(64))) { 682 ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(64));
678 ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(32)); 683 if (ret) {
684 ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(32));
685 if (ret) {
686 dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n");
687 pci_disable_device(pcidev);
688 return ret;
689 } else {
690 ret = pci_set_consistent_dma_mask(pcidev,
691 DMA_BIT_MASK(32));
692 }
693 } else {
694 ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(64));
679 if (ret) { 695 if (ret) {
680 dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n"); 696 dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n");
681 pci_disable_device(pcidev); 697 pci_disable_device(pcidev);
@@ -804,14 +820,23 @@ static void hwi_ring_eq_db(struct beiscsi_hba *phba,
804 unsigned char rearm, unsigned char event) 820 unsigned char rearm, unsigned char event)
805{ 821{
806 u32 val = 0; 822 u32 val = 0;
807 val |= id & DB_EQ_RING_ID_MASK; 823
808 if (rearm) 824 if (rearm)
809 val |= 1 << DB_EQ_REARM_SHIFT; 825 val |= 1 << DB_EQ_REARM_SHIFT;
810 if (clr_interrupt) 826 if (clr_interrupt)
811 val |= 1 << DB_EQ_CLR_SHIFT; 827 val |= 1 << DB_EQ_CLR_SHIFT;
812 if (event) 828 if (event)
813 val |= 1 << DB_EQ_EVNT_SHIFT; 829 val |= 1 << DB_EQ_EVNT_SHIFT;
830
814 val |= num_processed << DB_EQ_NUM_POPPED_SHIFT; 831 val |= num_processed << DB_EQ_NUM_POPPED_SHIFT;
832 /* Setting lower order EQ_ID Bits */
833 val |= (id & DB_EQ_RING_ID_LOW_MASK);
834
835 /* Setting Higher order EQ_ID Bits */
836 val |= (((id >> DB_EQ_HIGH_FEILD_SHIFT) &
837 DB_EQ_RING_ID_HIGH_MASK)
838 << DB_EQ_HIGH_SET_SHIFT);
839
815 iowrite32(val, phba->db_va + DB_EQ_OFFSET); 840 iowrite32(val, phba->db_va + DB_EQ_OFFSET);
816} 841}
817 842
@@ -1043,15 +1068,25 @@ free_msix_irqs:
1043 return ret; 1068 return ret;
1044} 1069}
1045 1070
1046static void hwi_ring_cq_db(struct beiscsi_hba *phba, 1071void hwi_ring_cq_db(struct beiscsi_hba *phba,
1047 unsigned int id, unsigned int num_processed, 1072 unsigned int id, unsigned int num_processed,
1048 unsigned char rearm, unsigned char event) 1073 unsigned char rearm, unsigned char event)
1049{ 1074{
1050 u32 val = 0; 1075 u32 val = 0;
1051 val |= id & DB_CQ_RING_ID_MASK; 1076
1052 if (rearm) 1077 if (rearm)
1053 val |= 1 << DB_CQ_REARM_SHIFT; 1078 val |= 1 << DB_CQ_REARM_SHIFT;
1079
1054 val |= num_processed << DB_CQ_NUM_POPPED_SHIFT; 1080 val |= num_processed << DB_CQ_NUM_POPPED_SHIFT;
1081
1082 /* Setting lower order CQ_ID Bits */
1083 val |= (id & DB_CQ_RING_ID_LOW_MASK);
1084
1085 /* Setting Higher order CQ_ID Bits */
1086 val |= (((id >> DB_CQ_HIGH_FEILD_SHIFT) &
1087 DB_CQ_RING_ID_HIGH_MASK)
1088 << DB_CQ_HIGH_SET_SHIFT);
1089
1055 iowrite32(val, phba->db_va + DB_CQ_OFFSET); 1090 iowrite32(val, phba->db_va + DB_CQ_OFFSET);
1056} 1091}
1057 1092
@@ -1100,9 +1135,9 @@ beiscsi_process_async_pdu(struct beiscsi_conn *beiscsi_conn,
1100 return 1; 1135 return 1;
1101 } 1136 }
1102 1137
1103 spin_lock_bh(&session->lock); 1138 spin_lock_bh(&session->back_lock);
1104 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)ppdu, pbuffer, buf_len); 1139 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)ppdu, pbuffer, buf_len);
1105 spin_unlock_bh(&session->lock); 1140 spin_unlock_bh(&session->back_lock);
1106 return 0; 1141 return 0;
1107} 1142}
1108 1143
@@ -1292,8 +1327,10 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
1292 resid = csol_cqe->res_cnt; 1327 resid = csol_cqe->res_cnt;
1293 1328
1294 if (!task->sc) { 1329 if (!task->sc) {
1295 if (io_task->scsi_cmnd) 1330 if (io_task->scsi_cmnd) {
1296 scsi_dma_unmap(io_task->scsi_cmnd); 1331 scsi_dma_unmap(io_task->scsi_cmnd);
1332 io_task->scsi_cmnd = NULL;
1333 }
1297 1334
1298 return; 1335 return;
1299 } 1336 }
@@ -1330,6 +1367,7 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
1330 conn->rxdata_octets += resid; 1367 conn->rxdata_octets += resid;
1331unmap: 1368unmap:
1332 scsi_dma_unmap(io_task->scsi_cmnd); 1369 scsi_dma_unmap(io_task->scsi_cmnd);
1370 io_task->scsi_cmnd = NULL;
1333 iscsi_complete_scsi_task(task, exp_cmdsn, max_cmdsn); 1371 iscsi_complete_scsi_task(task, exp_cmdsn, max_cmdsn);
1334} 1372}
1335 1373
@@ -1518,7 +1556,7 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn,
1518 pwrb = pwrb_handle->pwrb; 1556 pwrb = pwrb_handle->pwrb;
1519 type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type; 1557 type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type;
1520 1558
1521 spin_lock_bh(&session->lock); 1559 spin_lock_bh(&session->back_lock);
1522 switch (type) { 1560 switch (type) {
1523 case HWH_TYPE_IO: 1561 case HWH_TYPE_IO:
1524 case HWH_TYPE_IO_RD: 1562 case HWH_TYPE_IO_RD:
@@ -1557,7 +1595,7 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn,
1557 break; 1595 break;
1558 } 1596 }
1559 1597
1560 spin_unlock_bh(&session->lock); 1598 spin_unlock_bh(&session->back_lock);
1561} 1599}
1562 1600
1563static struct list_head *hwi_get_async_busy_list(struct hwi_async_pdu_context 1601static struct list_head *hwi_get_async_busy_list(struct hwi_async_pdu_context
@@ -4310,12 +4348,16 @@ static int beiscsi_get_boot_info(struct beiscsi_hba *phba)
4310 goto boot_freemem; 4348 goto boot_freemem;
4311 } 4349 }
4312 4350
4313 ret = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); 4351 ret = beiscsi_mccq_compl(phba, tag, NULL, &nonemb_cmd);
4314 if (ret) { 4352 if (ret) {
4315 beiscsi_log(phba, KERN_ERR, 4353 beiscsi_log(phba, KERN_ERR,
4316 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, 4354 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
4317 "BM_%d : beiscsi_get_session_info Failed"); 4355 "BM_%d : beiscsi_get_session_info Failed");
4318 goto boot_freemem; 4356
4357 if (ret != -EBUSY)
4358 goto boot_freemem;
4359 else
4360 return ret;
4319 } 4361 }
4320 4362
4321 session_resp = nonemb_cmd.va ; 4363 session_resp = nonemb_cmd.va ;
@@ -4575,6 +4617,11 @@ static void beiscsi_cleanup_task(struct iscsi_task *task)
4575 spin_unlock(&phba->io_sgl_lock); 4617 spin_unlock(&phba->io_sgl_lock);
4576 io_task->psgl_handle = NULL; 4618 io_task->psgl_handle = NULL;
4577 } 4619 }
4620
4621 if (io_task->scsi_cmnd) {
4622 scsi_dma_unmap(io_task->scsi_cmnd);
4623 io_task->scsi_cmnd = NULL;
4624 }
4578 } else { 4625 } else {
4579 if (!beiscsi_conn->login_in_progress) 4626 if (!beiscsi_conn->login_in_progress)
4580 beiscsi_free_mgmt_task_handles(beiscsi_conn, task); 4627 beiscsi_free_mgmt_task_handles(beiscsi_conn, task);
@@ -4596,9 +4643,9 @@ beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn,
4596 * login/startup related tasks. 4643 * login/startup related tasks.
4597 */ 4644 */
4598 beiscsi_conn->login_in_progress = 0; 4645 beiscsi_conn->login_in_progress = 0;
4599 spin_lock_bh(&session->lock); 4646 spin_lock_bh(&session->back_lock);
4600 beiscsi_cleanup_task(task); 4647 beiscsi_cleanup_task(task);
4601 spin_unlock_bh(&session->lock); 4648 spin_unlock_bh(&session->back_lock);
4602 4649
4603 pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid); 4650 pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid);
4604 4651
@@ -5222,6 +5269,8 @@ static void beiscsi_shutdown(struct pci_dev *pcidev)
5222 return; 5269 return;
5223 } 5270 }
5224 5271
5272 phba->state = BE_ADAPTER_STATE_SHUTDOWN;
5273 iscsi_host_for_each_session(phba->shost, be2iscsi_fail_session);
5225 beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD); 5274 beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD);
5226 pci_disable_device(pcidev); 5275 pci_disable_device(pcidev);
5227} 5276}
@@ -5529,6 +5578,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
5529 phba->ctrl.mcc_tag[i] = i + 1; 5578 phba->ctrl.mcc_tag[i] = i + 1;
5530 phba->ctrl.mcc_numtag[i + 1] = 0; 5579 phba->ctrl.mcc_numtag[i + 1] = 0;
5531 phba->ctrl.mcc_tag_available++; 5580 phba->ctrl.mcc_tag_available++;
5581 memset(&phba->ctrl.ptag_state[i].tag_mem_state, 0,
5582 sizeof(struct beiscsi_mcc_tag_state));
5532 } 5583 }
5533 5584
5534 phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0; 5585 phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0;
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 31fa27b4a9b2..9380b55bdeaf 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -36,7 +36,7 @@
36#include <scsi/scsi_transport_iscsi.h> 36#include <scsi/scsi_transport_iscsi.h>
37 37
38#define DRV_NAME "be2iscsi" 38#define DRV_NAME "be2iscsi"
39#define BUILD_STR "10.0.659.0" 39#define BUILD_STR "10.2.125.0"
40#define BE_NAME "Emulex OneConnect" \ 40#define BE_NAME "Emulex OneConnect" \
41 "Open-iSCSI Driver version" BUILD_STR 41 "Open-iSCSI Driver version" BUILD_STR
42#define DRV_DESC BE_NAME " " "Driver" 42#define DRV_DESC BE_NAME " " "Driver"
@@ -97,9 +97,14 @@
97 97
98#define INVALID_SESS_HANDLE 0xFFFFFFFF 98#define INVALID_SESS_HANDLE 0xFFFFFFFF
99 99
100/**
101 * Adapter States
102 **/
100#define BE_ADAPTER_LINK_UP 0x001 103#define BE_ADAPTER_LINK_UP 0x001
101#define BE_ADAPTER_LINK_DOWN 0x002 104#define BE_ADAPTER_LINK_DOWN 0x002
102#define BE_ADAPTER_PCI_ERR 0x004 105#define BE_ADAPTER_PCI_ERR 0x004
106#define BE_ADAPTER_STATE_SHUTDOWN 0x008
107
103 108
104#define BEISCSI_CLEAN_UNLOAD 0x01 109#define BEISCSI_CLEAN_UNLOAD 0x01
105#define BEISCSI_EEH_UNLOAD 0x02 110#define BEISCSI_EEH_UNLOAD 0x02
@@ -135,11 +140,15 @@
135#define DB_RXULP0_OFFSET 0xA0 140#define DB_RXULP0_OFFSET 0xA0
136/********* Event Q door bell *************/ 141/********* Event Q door bell *************/
137#define DB_EQ_OFFSET DB_CQ_OFFSET 142#define DB_EQ_OFFSET DB_CQ_OFFSET
138#define DB_EQ_RING_ID_MASK 0x1FF /* bits 0 - 8 */ 143#define DB_EQ_RING_ID_LOW_MASK 0x1FF /* bits 0 - 8 */
139/* Clear the interrupt for this eq */ 144/* Clear the interrupt for this eq */
140#define DB_EQ_CLR_SHIFT (9) /* bit 9 */ 145#define DB_EQ_CLR_SHIFT (9) /* bit 9 */
141/* Must be 1 */ 146/* Must be 1 */
142#define DB_EQ_EVNT_SHIFT (10) /* bit 10 */ 147#define DB_EQ_EVNT_SHIFT (10) /* bit 10 */
148/* Higher Order EQ_ID bit */
149#define DB_EQ_RING_ID_HIGH_MASK 0x1F /* bits 11 - 15 */
150#define DB_EQ_HIGH_SET_SHIFT 11
151#define DB_EQ_HIGH_FEILD_SHIFT 9
143/* Number of event entries processed */ 152/* Number of event entries processed */
144#define DB_EQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */ 153#define DB_EQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */
145/* Rearm bit */ 154/* Rearm bit */
@@ -147,7 +156,12 @@
147 156
148/********* Compl Q door bell *************/ 157/********* Compl Q door bell *************/
149#define DB_CQ_OFFSET 0x120 158#define DB_CQ_OFFSET 0x120
150#define DB_CQ_RING_ID_MASK 0x3FF /* bits 0 - 9 */ 159#define DB_CQ_RING_ID_LOW_MASK 0x3FF /* bits 0 - 9 */
160/* Higher Order CQ_ID bit */
161#define DB_CQ_RING_ID_HIGH_MASK 0x1F /* bits 11 - 15 */
162#define DB_CQ_HIGH_SET_SHIFT 11
163#define DB_CQ_HIGH_FEILD_SHIFT 10
164
151/* Number of event entries processed */ 165/* Number of event entries processed */
152#define DB_CQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */ 166#define DB_CQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */
153/* Rearm bit */ 167/* Rearm bit */
@@ -821,6 +835,9 @@ void beiscsi_process_all_cqs(struct work_struct *work);
821void beiscsi_free_mgmt_task_handles(struct beiscsi_conn *beiscsi_conn, 835void beiscsi_free_mgmt_task_handles(struct beiscsi_conn *beiscsi_conn,
822 struct iscsi_task *task); 836 struct iscsi_task *task);
823 837
838void hwi_ring_cq_db(struct beiscsi_hba *phba,
839 unsigned int id, unsigned int num_processed,
840 unsigned char rearm, unsigned char event);
824static inline bool beiscsi_error(struct beiscsi_hba *phba) 841static inline bool beiscsi_error(struct beiscsi_hba *phba)
825{ 842{
826 return phba->ue_detected || phba->fw_timeout; 843 return phba->ue_detected || phba->fw_timeout;
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index b2fcac78feaa..088bdf752cfa 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -828,22 +828,25 @@ static int mgmt_exec_nonemb_cmd(struct beiscsi_hba *phba,
828 be_mcc_notify(phba); 828 be_mcc_notify(phba);
829 spin_unlock(&ctrl->mbox_lock); 829 spin_unlock(&ctrl->mbox_lock);
830 830
831 rc = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd->va); 831 rc = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd);
832
833 if (resp_buf)
834 memcpy(resp_buf, nonemb_cmd->va, resp_buf_len);
835
832 if (rc) { 836 if (rc) {
833 /* Check if the IOCTL needs to be re-issued */ 837 /* Check if the MBX Cmd needs to be re-issued */
834 if (rc == -EAGAIN) 838 if (rc == -EAGAIN)
835 return rc; 839 return rc;
836 840
837 beiscsi_log(phba, KERN_ERR, 841 beiscsi_log(phba, KERN_WARNING,
838 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, 842 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
839 "BG_%d : mgmt_exec_nonemb_cmd Failed status\n"); 843 "BG_%d : mgmt_exec_nonemb_cmd Failed status\n");
840 844
841 goto free_cmd; 845 if (rc != -EBUSY)
846 goto free_cmd;
847 else
848 return rc;
842 } 849 }
843
844 if (resp_buf)
845 memcpy(resp_buf, nonemb_cmd->va, resp_buf_len);
846
847free_cmd: 850free_cmd:
848 pci_free_consistent(ctrl->pdev, nonemb_cmd->size, 851 pci_free_consistent(ctrl->pdev, nonemb_cmd->size,
849 nonemb_cmd->va, nonemb_cmd->dma); 852 nonemb_cmd->va, nonemb_cmd->dma);
@@ -1348,7 +1351,6 @@ int mgmt_set_vlan(struct beiscsi_hba *phba,
1348{ 1351{
1349 int rc; 1352 int rc;
1350 unsigned int tag; 1353 unsigned int tag;
1351 struct be_mcc_wrb *wrb = NULL;
1352 1354
1353 tag = be_cmd_set_vlan(phba, vlan_tag); 1355 tag = be_cmd_set_vlan(phba, vlan_tag);
1354 if (!tag) { 1356 if (!tag) {
@@ -1358,7 +1360,7 @@ int mgmt_set_vlan(struct beiscsi_hba *phba,
1358 return -EBUSY; 1360 return -EBUSY;
1359 } 1361 }
1360 1362
1361 rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL); 1363 rc = beiscsi_mccq_compl(phba, tag, NULL, NULL);
1362 if (rc) { 1364 if (rc) {
1363 beiscsi_log(phba, KERN_ERR, 1365 beiscsi_log(phba, KERN_ERR,
1364 (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX), 1366 (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),