1 From 63ea923a97cb0d78efcbbd229950e101588f0ddb Mon Sep 17 00:00:00 2001
2 From: Armen Baloyan <armen.baloyan@qlogic.com>
3 Date: Wed, 21 Nov 2012 02:39:53 -0500
4 Subject: SCSI: qla2xxx: Properly set result field of bsg_job reply structure for success and failure.
6 From: Armen Baloyan <armen.baloyan@qlogic.com>
8 commit 63ea923a97cb0d78efcbbd229950e101588f0ddb upstream.
10 FC transport on receiving bsg_job submission failure, calls bsg_job->job_done()
11 and sets the bsg_job->reply->result the returned value. In contrast, when the
12 success code (0) is returned fc transport doesn't call bsg_job->job_done() and
13 doesn't populate bsg_job->reply->result.
15 Signed-off-by: Steve Hodgson <steve@purestorage.com>
16 Signed-off-by: Armen Baloyan <armen.baloyan@qlogic.com>
17 Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
18 Signed-off-by: James Bottomley <JBottomley@Parallels.com>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 drivers/scsi/qla2xxx/qla_bsg.c | 65 +++++++++++++++--------------------------
23 1 file changed, 24 insertions(+), 41 deletions(-)
25 --- a/drivers/scsi/qla2xxx/qla_bsg.c
26 +++ b/drivers/scsi/qla2xxx/qla_bsg.c
27 @@ -219,7 +219,8 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct fc_
31 - bsg_job->job_done(bsg_job);
33 + bsg_job->job_done(bsg_job);
37 @@ -741,7 +742,6 @@ qla2x00_process_loopback(struct fc_bsg_j
38 if (qla81xx_get_port_config(vha, config)) {
39 ql_log(ql_log_warn, vha, 0x701f,
40 "Get port config failed.\n");
41 - bsg_job->reply->result = (DID_ERROR << 16);
43 goto done_free_dma_req;
45 @@ -761,7 +761,6 @@ qla2x00_process_loopback(struct fc_bsg_j
46 new_config, elreq.options);
49 - bsg_job->reply->result = (DID_ERROR << 16);
51 goto done_free_dma_req;
53 @@ -795,7 +794,6 @@ qla2x00_process_loopback(struct fc_bsg_j
54 "MPI reset failed.\n");
57 - bsg_job->reply->result = (DID_ERROR << 16);
59 goto done_free_dma_req;
61 @@ -812,33 +810,25 @@ qla2x00_process_loopback(struct fc_bsg_j
62 ql_log(ql_log_warn, vha, 0x702c,
63 "Vendor request %s failed.\n", type);
65 - fw_sts_ptr = ((uint8_t *)bsg_job->req->sense) +
66 - sizeof(struct fc_bsg_reply);
68 - memcpy(fw_sts_ptr, response, sizeof(response));
69 - fw_sts_ptr += sizeof(response);
70 - *fw_sts_ptr = command_sent;
72 bsg_job->reply->result = (DID_ERROR << 16);
73 + bsg_job->reply->reply_payload_rcv_len = 0;
75 ql_dbg(ql_dbg_user, vha, 0x702d,
76 "Vendor request %s completed.\n", type);
78 - bsg_job->reply_len = sizeof(struct fc_bsg_reply) +
79 - sizeof(response) + sizeof(uint8_t);
80 - bsg_job->reply->reply_payload_rcv_len =
81 - bsg_job->reply_payload.payload_len;
82 - fw_sts_ptr = ((uint8_t *)bsg_job->req->sense) +
83 - sizeof(struct fc_bsg_reply);
84 - memcpy(fw_sts_ptr, response, sizeof(response));
85 - fw_sts_ptr += sizeof(response);
86 - *fw_sts_ptr = command_sent;
87 - bsg_job->reply->result = DID_OK;
88 + bsg_job->reply->result = (DID_OK << 16);
89 sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
90 bsg_job->reply_payload.sg_cnt, rsp_data,
93 - bsg_job->job_done(bsg_job);
95 + bsg_job->reply_len = sizeof(struct fc_bsg_reply) +
96 + sizeof(response) + sizeof(uint8_t);
97 + fw_sts_ptr = ((uint8_t *)bsg_job->req->sense) +
98 + sizeof(struct fc_bsg_reply);
99 + memcpy(fw_sts_ptr, response, sizeof(response));
100 + fw_sts_ptr += sizeof(response);
101 + *fw_sts_ptr = command_sent;
103 dma_free_coherent(&ha->pdev->dev, rsp_data_len,
104 rsp_data, rsp_data_dma);
105 @@ -853,6 +843,8 @@ done_unmap_req_sg:
106 dma_unmap_sg(&ha->pdev->dev,
107 bsg_job->request_payload.sg_list,
108 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
110 + bsg_job->job_done(bsg_job);
114 @@ -877,16 +869,15 @@ qla84xx_reset(struct fc_bsg_job *bsg_job
116 ql_log(ql_log_warn, vha, 0x7030,
117 "Vendor request 84xx reset failed.\n");
119 - bsg_job->reply->result = (DID_ERROR << 16);
120 + rval = (DID_ERROR << 16);
123 ql_dbg(ql_dbg_user, vha, 0x7031,
124 "Vendor request 84xx reset completed.\n");
125 bsg_job->reply->result = DID_OK;
126 + bsg_job->job_done(bsg_job);
129 - bsg_job->job_done(bsg_job);
133 @@ -976,8 +967,7 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_
134 ql_log(ql_log_warn, vha, 0x7037,
135 "Vendor request 84xx updatefw failed.\n");
138 - bsg_job->reply->result = (DID_ERROR << 16);
139 + rval = (DID_ERROR << 16);
141 ql_dbg(ql_dbg_user, vha, 0x7038,
142 "Vendor request 84xx updatefw completed.\n");
143 @@ -986,7 +976,6 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_
144 bsg_job->reply->result = DID_OK;
147 - bsg_job->job_done(bsg_job);
148 dma_pool_free(ha->s_dma_pool, mn, mn_dma);
151 @@ -996,6 +985,8 @@ done_unmap_sg:
152 dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
153 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
156 + bsg_job->job_done(bsg_job);
160 @@ -1163,8 +1154,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_
161 ql_log(ql_log_warn, vha, 0x7043,
162 "Vendor request 84xx mgmt failed.\n");
165 - bsg_job->reply->result = (DID_ERROR << 16);
166 + rval = (DID_ERROR << 16);
169 ql_dbg(ql_dbg_user, vha, 0x7044,
170 @@ -1184,8 +1174,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_
174 - bsg_job->job_done(bsg_job);
178 dma_free_coherent(&ha->pdev->dev, data_len, mgmt_b, mgmt_dma);
179 @@ -1200,6 +1188,8 @@ done_unmap_sg:
181 dma_pool_free(ha->s_dma_pool, mn, mn_dma);
184 + bsg_job->job_done(bsg_job);
188 @@ -1276,9 +1266,7 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job
189 fcport->port_name[3], fcport->port_name[4],
190 fcport->port_name[5], fcport->port_name[6],
191 fcport->port_name[7], rval, fcport->fp_speed, mb[0], mb[1]);
193 - bsg_job->reply->result = (DID_ERROR << 16);
195 + rval = (DID_ERROR << 16);
197 if (!port_param->mode) {
198 bsg_job->reply_len = sizeof(struct fc_bsg_reply) +
199 @@ -1292,9 +1280,9 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job
202 bsg_job->reply->result = DID_OK;
203 + bsg_job->job_done(bsg_job);
206 - bsg_job->job_done(bsg_job);
210 @@ -1887,8 +1875,6 @@ qla2x00_process_vendor_specific(struct f
211 return qla24xx_process_bidir_cmd(bsg_job);
214 - bsg_job->reply->result = (DID_ERROR << 16);
215 - bsg_job->job_done(bsg_job);
219 @@ -1919,8 +1905,6 @@ qla24xx_bsg_request(struct fc_bsg_job *b
220 ql_dbg(ql_dbg_user, vha, 0x709f,
221 "BSG: ISP abort active/needed -- cmd=%d.\n",
222 bsg_job->request->msgcode);
223 - bsg_job->reply->result = (DID_ERROR << 16);
224 - bsg_job->job_done(bsg_job);
228 @@ -1943,7 +1927,6 @@ qla24xx_bsg_request(struct fc_bsg_job *b
231 ql_log(ql_log_warn, vha, 0x705a, "Unsupported BSG request.\n");
232 - bsg_job->reply->result = ret;