aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-09-16 16:44:43 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-26 11:42:02 -0400
commit2ebf8c94d431078d93599ba56efa58bf850078a1 (patch)
tree73090229bb39f830da0f32794ac216e5c4424464
parent0da90747353c0f5b663c9c25fd56cd21440d222c (diff)
mei: propagate error from write routines instead of ENODEV
ENODEV will cause application to try to reconnect since it assumes that device went through the reset write errors are not always fatal it can happen due to resource contention Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/mei/amthif.c24
-rw-r--r--drivers/misc/mei/client.c17
-rw-r--r--drivers/misc/mei/hbm.c2
-rw-r--r--drivers/misc/mei/interrupt.c20
4 files changed, 36 insertions, 27 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index d0fdc134068a..718f3a14c1ca 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -312,13 +312,13 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
312 mei_hdr.me_addr = dev->iamthif_cl.me_client_id; 312 mei_hdr.me_addr = dev->iamthif_cl.me_client_id;
313 mei_hdr.reserved = 0; 313 mei_hdr.reserved = 0;
314 dev->iamthif_msg_buf_index += mei_hdr.length; 314 dev->iamthif_msg_buf_index += mei_hdr.length;
315 if (mei_write_message(dev, &mei_hdr, 315 ret = mei_write_message(dev, &mei_hdr, dev->iamthif_msg_buf);
316 (unsigned char *)dev->iamthif_msg_buf)) 316 if (ret)
317 return -ENODEV; 317 return ret;
318 318
319 if (mei_hdr.msg_complete) { 319 if (mei_hdr.msg_complete) {
320 if (mei_cl_flow_ctrl_reduce(&dev->iamthif_cl)) 320 if (mei_cl_flow_ctrl_reduce(&dev->iamthif_cl))
321 return -ENODEV; 321 return -EIO;
322 dev->iamthif_flow_control_pending = true; 322 dev->iamthif_flow_control_pending = true;
323 dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL; 323 dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
324 dev_dbg(&dev->pdev->dev, "add amthif cb to write waiting list\n"); 324 dev_dbg(&dev->pdev->dev, "add amthif cb to write waiting list\n");
@@ -458,6 +458,7 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
458 struct mei_msg_hdr mei_hdr; 458 struct mei_msg_hdr mei_hdr;
459 size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index; 459 size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index;
460 u32 msg_slots = mei_data2slots(len); 460 u32 msg_slots = mei_data2slots(len);
461 int rets;
461 462
462 mei_hdr.host_addr = cl->host_client_id; 463 mei_hdr.host_addr = cl->host_client_id;
463 mei_hdr.me_addr = cl->me_client_id; 464 mei_hdr.me_addr = cl->me_client_id;
@@ -480,16 +481,17 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
480 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr)); 481 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(&mei_hdr));
481 482
482 *slots -= msg_slots; 483 *slots -= msg_slots;
483 if (mei_write_message(dev, &mei_hdr, 484 rets = mei_write_message(dev, &mei_hdr,
484 dev->iamthif_msg_buf + dev->iamthif_msg_buf_index)) { 485 dev->iamthif_msg_buf + dev->iamthif_msg_buf_index);
485 dev->iamthif_state = MEI_IAMTHIF_IDLE; 486 if (rets) {
486 cl->status = -ENODEV; 487 dev->iamthif_state = MEI_IAMTHIF_IDLE;
487 list_del(&cb->list); 488 cl->status = rets;
488 return -ENODEV; 489 list_del(&cb->list);
490 return rets;
489 } 491 }
490 492
491 if (mei_cl_flow_ctrl_reduce(cl)) 493 if (mei_cl_flow_ctrl_reduce(cl))
492 return -ENODEV; 494 return -EIO;
493 495
494 dev->iamthif_msg_buf_index += mei_hdr.length; 496 dev->iamthif_msg_buf_index += mei_hdr.length;
495 cl->status = 0; 497 cl->status = 0;
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index bccc3164ea4c..1a53d961302a 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -706,6 +706,7 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
706 struct mei_msg_hdr mei_hdr; 706 struct mei_msg_hdr mei_hdr;
707 size_t len = cb->request_buffer.size - cb->buf_idx; 707 size_t len = cb->request_buffer.size - cb->buf_idx;
708 u32 msg_slots = mei_data2slots(len); 708 u32 msg_slots = mei_data2slots(len);
709 int rets;
709 710
710 mei_hdr.host_addr = cl->host_client_id; 711 mei_hdr.host_addr = cl->host_client_id;
711 mei_hdr.me_addr = cl->me_client_id; 712 mei_hdr.me_addr = cl->me_client_id;
@@ -729,11 +730,12 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
729 cb->request_buffer.size, cb->buf_idx); 730 cb->request_buffer.size, cb->buf_idx);
730 731
731 *slots -= msg_slots; 732 *slots -= msg_slots;
732 if (mei_write_message(dev, &mei_hdr, 733 rets = mei_write_message(dev, &mei_hdr,
733 cb->request_buffer.data + cb->buf_idx)) { 734 cb->request_buffer.data + cb->buf_idx);
734 cl->status = -ENODEV; 735 if (rets) {
736 cl->status = rets;
735 list_move_tail(&cb->list, &cmpl_list->list); 737 list_move_tail(&cb->list, &cmpl_list->list);
736 return -ENODEV; 738 return rets;
737 } 739 }
738 740
739 cl->status = 0; 741 cl->status = 0;
@@ -742,7 +744,7 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
742 744
743 if (mei_hdr.msg_complete) { 745 if (mei_hdr.msg_complete) {
744 if (mei_cl_flow_ctrl_reduce(cl)) 746 if (mei_cl_flow_ctrl_reduce(cl))
745 return -ENODEV; 747 return -EIO;
746 list_move_tail(&cb->list, &dev->write_waiting_list.list); 748 list_move_tail(&cb->list, &dev->write_waiting_list.list);
747 } 749 }
748 750
@@ -811,10 +813,9 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)
811 mei_hdr.reserved = 0; 813 mei_hdr.reserved = 0;
812 814
813 815
814 if (mei_write_message(dev, &mei_hdr, buf->data)) { 816 rets = mei_write_message(dev, &mei_hdr, buf->data);
815 rets = -EIO; 817 if (rets)
816 goto err; 818 goto err;
817 }
818 819
819 cl->writing_state = MEI_WRITING; 820 cl->writing_state = MEI_WRITING;
820 cb->buf_idx = mei_hdr.length; 821 cb->buf_idx = mei_hdr.length;
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index f706fe8a3286..f1c974a0bc0d 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -170,7 +170,7 @@ int mei_hbm_start_req(struct mei_device *dev)
170 dev_err(&dev->pdev->dev, "version message write failed\n"); 170 dev_err(&dev->pdev->dev, "version message write failed\n");
171 dev->dev_state = MEI_DEV_RESETTING; 171 dev->dev_state = MEI_DEV_RESETTING;
172 mei_reset(dev, 1); 172 mei_reset(dev, 1);
173 return -ENODEV; 173 return -EIO;
174 } 174 }
175 dev->hbm_state = MEI_HBM_START; 175 dev->hbm_state = MEI_HBM_START;
176 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT; 176 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index be42c700b15a..e4bb9aee40a1 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -216,9 +216,11 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
216 s32 *slots, struct mei_cl_cb *cmpl_list) 216 s32 *slots, struct mei_cl_cb *cmpl_list)
217{ 217{
218 struct mei_device *dev = cl->dev; 218 struct mei_device *dev = cl->dev;
219
220 u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control)); 219 u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control));
221 220
221 int ret;
222
223
222 if (*slots < msg_slots) { 224 if (*slots < msg_slots) {
223 /* return the cancel routine */ 225 /* return the cancel routine */
224 list_del(&cb->list); 226 list_del(&cb->list);
@@ -227,12 +229,14 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
227 229
228 *slots -= msg_slots; 230 *slots -= msg_slots;
229 231
230 if (mei_hbm_cl_flow_control_req(dev, cl)) { 232 ret = mei_hbm_cl_flow_control_req(dev, cl);
231 cl->status = -ENODEV; 233 if (ret) {
234 cl->status = ret;
232 cb->buf_idx = 0; 235 cb->buf_idx = 0;
233 list_move_tail(&cb->list, &cmpl_list->list); 236 list_move_tail(&cb->list, &cmpl_list->list);
234 return -ENODEV; 237 return ret;
235 } 238 }
239
236 list_move_tail(&cb->list, &dev->read_list.list); 240 list_move_tail(&cb->list, &dev->read_list.list);
237 241
238 return 0; 242 return 0;
@@ -254,6 +258,7 @@ static int mei_cl_irq_ioctl(struct mei_cl *cl, struct mei_cl_cb *cb,
254 s32 *slots, struct mei_cl_cb *cmpl_list) 258 s32 *slots, struct mei_cl_cb *cmpl_list)
255{ 259{
256 struct mei_device *dev = cl->dev; 260 struct mei_device *dev = cl->dev;
261 int ret;
257 262
258 u32 msg_slots = 263 u32 msg_slots =
259 mei_data2slots(sizeof(struct hbm_client_connect_request)); 264 mei_data2slots(sizeof(struct hbm_client_connect_request));
@@ -268,11 +273,12 @@ static int mei_cl_irq_ioctl(struct mei_cl *cl, struct mei_cl_cb *cb,
268 273
269 cl->state = MEI_FILE_CONNECTING; 274 cl->state = MEI_FILE_CONNECTING;
270 275
271 if (mei_hbm_cl_connect_req(dev, cl)) { 276 ret = mei_hbm_cl_connect_req(dev, cl);
272 cl->status = -ENODEV; 277 if (ret) {
278 cl->status = ret;
273 cb->buf_idx = 0; 279 cb->buf_idx = 0;
274 list_del(&cb->list); 280 list_del(&cb->list);
275 return -ENODEV; 281 return ret;
276 } 282 }
277 283
278 list_move_tail(&cb->list, &dev->ctrl_rd_list.list); 284 list_move_tail(&cb->list, &dev->ctrl_rd_list.list);