]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
9c5bb0665c5ba41192a762064a81725f574b4e2b
[thirdparty/kernel/stable-queue.git] /
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.
5
6 From: Armen Baloyan <armen.baloyan@qlogic.com>
7
8 commit 63ea923a97cb0d78efcbbd229950e101588f0ddb upstream.
9
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.
14
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>
20
21 ---
22 drivers/scsi/qla2xxx/qla_bsg.c | 65 +++++++++++++++--------------------------
23 1 file changed, 24 insertions(+), 41 deletions(-)
24
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_
28 break;
29 }
30 exit_fcp_prio_cfg:
31 - bsg_job->job_done(bsg_job);
32 + if (!ret)
33 + bsg_job->job_done(bsg_job);
34 return ret;
35 }
36
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);
42 rval = -EPERM;
43 goto done_free_dma_req;
44 }
45 @@ -761,7 +761,6 @@ qla2x00_process_loopback(struct fc_bsg_j
46 new_config, elreq.options);
47
48 if (rval) {
49 - bsg_job->reply->result = (DID_ERROR << 16);
50 rval = -EPERM;
51 goto done_free_dma_req;
52 }
53 @@ -795,7 +794,6 @@ qla2x00_process_loopback(struct fc_bsg_j
54 "MPI reset failed.\n");
55 }
56
57 - bsg_job->reply->result = (DID_ERROR << 16);
58 rval = -EIO;
59 goto done_free_dma_req;
60 }
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);
64
65 - fw_sts_ptr = ((uint8_t *)bsg_job->req->sense) +
66 - sizeof(struct fc_bsg_reply);
67 -
68 - memcpy(fw_sts_ptr, response, sizeof(response));
69 - fw_sts_ptr += sizeof(response);
70 - *fw_sts_ptr = command_sent;
71 rval = 0;
72 bsg_job->reply->result = (DID_ERROR << 16);
73 + bsg_job->reply->reply_payload_rcv_len = 0;
74 } else {
75 ql_dbg(ql_dbg_user, vha, 0x702d,
76 "Vendor request %s completed.\n", type);
77 -
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,
91 rsp_data_len);
92 }
93 - bsg_job->job_done(bsg_job);
94 +
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;
102
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);
109 + if (!rval)
110 + bsg_job->job_done(bsg_job);
111 return rval;
112 }
113
114 @@ -877,16 +869,15 @@ qla84xx_reset(struct fc_bsg_job *bsg_job
115 if (rval) {
116 ql_log(ql_log_warn, vha, 0x7030,
117 "Vendor request 84xx reset failed.\n");
118 - rval = 0;
119 - bsg_job->reply->result = (DID_ERROR << 16);
120 + rval = (DID_ERROR << 16);
121
122 } else {
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);
127 }
128
129 - bsg_job->job_done(bsg_job);
130 return rval;
131 }
132
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");
136
137 - rval = 0;
138 - bsg_job->reply->result = (DID_ERROR << 16);
139 + rval = (DID_ERROR << 16);
140 } else {
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;
145 }
146
147 - bsg_job->job_done(bsg_job);
148 dma_pool_free(ha->s_dma_pool, mn, mn_dma);
149
150 done_free_fw_buf:
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);
154
155 + if (!rval)
156 + bsg_job->job_done(bsg_job);
157 return rval;
158 }
159
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");
163
164 - rval = 0;
165 - bsg_job->reply->result = (DID_ERROR << 16);
166 + rval = (DID_ERROR << 16);
167
168 } else {
169 ql_dbg(ql_dbg_user, vha, 0x7044,
170 @@ -1184,8 +1174,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_
171 }
172 }
173
174 - bsg_job->job_done(bsg_job);
175 -
176 done_unmap_sg:
177 if (mgmt_b)
178 dma_free_coherent(&ha->pdev->dev, data_len, mgmt_b, mgmt_dma);
179 @@ -1200,6 +1188,8 @@ done_unmap_sg:
180 exit_mgmt:
181 dma_pool_free(ha->s_dma_pool, mn, mn_dma);
182
183 + if (!rval)
184 + bsg_job->job_done(bsg_job);
185 return rval;
186 }
187
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]);
192 - rval = 0;
193 - bsg_job->reply->result = (DID_ERROR << 16);
194 -
195 + rval = (DID_ERROR << 16);
196 } else {
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
200 }
201
202 bsg_job->reply->result = DID_OK;
203 + bsg_job->job_done(bsg_job);
204 }
205
206 - bsg_job->job_done(bsg_job);
207 return rval;
208 }
209
210 @@ -1887,8 +1875,6 @@ qla2x00_process_vendor_specific(struct f
211 return qla24xx_process_bidir_cmd(bsg_job);
212
213 default:
214 - bsg_job->reply->result = (DID_ERROR << 16);
215 - bsg_job->job_done(bsg_job);
216 return -ENOSYS;
217 }
218 }
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);
225 return -EBUSY;
226 }
227
228 @@ -1943,7 +1927,6 @@ qla24xx_bsg_request(struct fc_bsg_job *b
229 case FC_BSG_RPT_CT:
230 default:
231 ql_log(ql_log_warn, vha, 0x705a, "Unsupported BSG request.\n");
232 - bsg_job->reply->result = ret;
233 break;
234 }
235 return ret;