3 * Intel Management Engine Interface (Intel MEI) Linux driver
4 * Copyright (c) 2003-2012, Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 #include <linux/pci.h>
19 #include <linux/kthread.h>
20 #include <linux/interrupt.h>
22 #include <linux/jiffies.h>
25 #include <linux/mei.h>
27 #include "interface.h"
31 * mei_interrupt_quick_handler - The ISR of the MEI device
33 * @irq: The irq number
34 * @dev_id: pointer to the device structure
38 irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id)
40 struct mei_device *dev = (struct mei_device *) dev_id;
41 u32 csr_reg = mei_hcsr_read(dev);
43 if ((csr_reg & H_IS) != H_IS)
46 /* clear H_IS bit in H_CSR */
47 mei_reg_write(dev, H_CSR, csr_reg);
49 return IRQ_WAKE_THREAD;
53 * _mei_cmpl - processes completed operation.
55 * @cl: private data of the file object.
56 * @cb_pos: callback block.
58 static void _mei_cmpl(struct mei_cl *cl, struct mei_cl_cb *cb_pos)
60 if (cb_pos->major_file_operations == MEI_WRITE) {
61 mei_free_cb_private(cb_pos);
63 cl->writing_state = MEI_WRITE_COMPLETE;
64 if (waitqueue_active(&cl->tx_wait))
65 wake_up_interruptible(&cl->tx_wait);
67 } else if (cb_pos->major_file_operations == MEI_READ &&
68 MEI_READING == cl->reading_state) {
69 cl->reading_state = MEI_READ_COMPLETE;
70 if (waitqueue_active(&cl->rx_wait))
71 wake_up_interruptible(&cl->rx_wait);
77 * _mei_cmpl_iamthif - processes completed iamthif operation.
79 * @dev: the device structure.
80 * @cb_pos: callback block.
82 static void _mei_cmpl_iamthif(struct mei_device *dev, struct mei_cl_cb *cb_pos)
84 if (dev->iamthif_canceled != 1) {
85 dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE;
86 dev->iamthif_stall_timer = 0;
87 memcpy(cb_pos->response_buffer.data,
89 dev->iamthif_msg_buf_index);
90 list_add_tail(&cb_pos->cb_list,
91 &dev->amthi_read_complete_list.mei_cb.cb_list);
92 dev_dbg(&dev->pdev->dev, "amthi read completed.\n");
93 dev->iamthif_timer = jiffies;
94 dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
97 mei_run_next_iamthif_cmd(dev);
100 dev_dbg(&dev->pdev->dev, "completing amthi call back.\n");
101 wake_up_interruptible(&dev->iamthif_cl.wait);
106 * mei_irq_thread_read_amthi_message - bottom half read routine after ISR to
107 * handle the read amthi message data processing.
109 * @complete_list: An instance of our list structure
110 * @dev: the device structure
111 * @mei_hdr: header of amthi message
113 * returns 0 on success, <0 on failure.
115 static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list,
116 struct mei_device *dev,
117 struct mei_msg_hdr *mei_hdr)
120 struct mei_cl_cb *cb;
121 unsigned char *buffer;
123 BUG_ON(mei_hdr->me_addr != dev->iamthif_cl.me_client_id);
124 BUG_ON(dev->iamthif_state != MEI_IAMTHIF_READING);
126 buffer = dev->iamthif_msg_buf + dev->iamthif_msg_buf_index;
127 BUG_ON(dev->iamthif_mtu < dev->iamthif_msg_buf_index + mei_hdr->length);
129 mei_read_slots(dev, buffer, mei_hdr->length);
131 dev->iamthif_msg_buf_index += mei_hdr->length;
133 if (!mei_hdr->msg_complete)
136 dev_dbg(&dev->pdev->dev,
137 "amthi_message_buffer_index =%d\n",
140 dev_dbg(&dev->pdev->dev, "completed amthi read.\n ");
141 if (!dev->iamthif_current_cb)
144 cb = dev->iamthif_current_cb;
145 dev->iamthif_current_cb = NULL;
147 cl = (struct mei_cl *)cb->file_private;
151 dev->iamthif_stall_timer = 0;
152 cb->information = dev->iamthif_msg_buf_index;
153 cb->read_time = jiffies;
154 if (dev->iamthif_ioctl && cl == &dev->iamthif_cl) {
155 /* found the iamthif cb */
156 dev_dbg(&dev->pdev->dev, "complete the amthi read cb.\n ");
157 dev_dbg(&dev->pdev->dev, "add the amthi read cb to complete.\n ");
158 list_add_tail(&cb->cb_list,
159 &complete_list->mei_cb.cb_list);
165 * _mei_irq_thread_state_ok - checks if mei header matches file private data
167 * @cl: private data of the file object
168 * @mei_hdr: header of mei client message
170 * returns !=0 if matches, 0 if no match.
172 static int _mei_irq_thread_state_ok(struct mei_cl *cl,
173 struct mei_msg_hdr *mei_hdr)
175 return (cl->host_client_id == mei_hdr->host_addr &&
176 cl->me_client_id == mei_hdr->me_addr &&
177 cl->state == MEI_FILE_CONNECTED &&
178 MEI_READ_COMPLETE != cl->reading_state);
182 * mei_irq_thread_read_client_message - bottom half read routine after ISR to
183 * handle the read mei client message data processing.
185 * @complete_list: An instance of our list structure
186 * @dev: the device structure
187 * @mei_hdr: header of mei client message
189 * returns 0 on success, <0 on failure.
191 static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
192 struct mei_device *dev,
193 struct mei_msg_hdr *mei_hdr)
196 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
197 unsigned char *buffer = NULL;
199 dev_dbg(&dev->pdev->dev, "start client msg\n");
200 if (list_empty(&dev->read_list.mei_cb.cb_list))
203 list_for_each_entry_safe(cb_pos, cb_next,
204 &dev->read_list.mei_cb.cb_list, cb_list) {
205 cl = (struct mei_cl *)cb_pos->file_private;
206 if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
207 cl->reading_state = MEI_READING;
208 buffer = cb_pos->response_buffer.data + cb_pos->information;
210 if (cb_pos->response_buffer.size <
211 mei_hdr->length + cb_pos->information) {
212 dev_dbg(&dev->pdev->dev, "message overflow.\n");
213 list_del(&cb_pos->cb_list);
217 mei_read_slots(dev, buffer, mei_hdr->length);
219 cb_pos->information += mei_hdr->length;
220 if (mei_hdr->msg_complete) {
222 list_del(&cb_pos->cb_list);
223 dev_dbg(&dev->pdev->dev,
224 "completed read host client = %d,"
226 "data length = %lu\n",
229 cb_pos->information);
231 *(cb_pos->response_buffer.data +
232 cb_pos->information) = '\0';
233 dev_dbg(&dev->pdev->dev, "cb_pos->res_buffer - %s\n",
234 cb_pos->response_buffer.data);
235 list_add_tail(&cb_pos->cb_list,
236 &complete_list->mei_cb.cb_list);
245 dev_dbg(&dev->pdev->dev, "message read\n");
247 mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
248 dev_dbg(&dev->pdev->dev, "discarding message, header =%08x.\n",
249 *(u32 *) dev->rd_msg_buf);
256 * _mei_irq_thread_iamthif_read - prepares to read iamthif data.
258 * @dev: the device structure.
259 * @slots: free slots.
261 * returns 0, OK; otherwise, error.
263 static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots)
266 if (((*slots) * sizeof(u32)) < (sizeof(struct mei_msg_hdr)
267 + sizeof(struct hbm_flow_control))) {
270 *slots -= mei_data2slots(sizeof(struct hbm_flow_control));
271 if (mei_send_flow_control(dev, &dev->iamthif_cl)) {
272 dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n");
276 dev_dbg(&dev->pdev->dev, "iamthif flow control success\n");
277 dev->iamthif_state = MEI_IAMTHIF_READING;
278 dev->iamthif_flow_control_pending = false;
279 dev->iamthif_msg_buf_index = 0;
280 dev->iamthif_msg_buf_size = 0;
281 dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER;
282 dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
287 * _mei_irq_thread_close - processes close related operation.
289 * @dev: the device structure.
290 * @slots: free slots.
291 * @cb_pos: callback block.
292 * @cl: private data of the file object.
293 * @cmpl_list: complete list.
295 * returns 0, OK; otherwise, error.
297 static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
298 struct mei_cl_cb *cb_pos,
300 struct mei_io_list *cmpl_list)
302 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
303 sizeof(struct hbm_client_disconnect_request)))
306 *slots -= mei_data2slots(sizeof(struct hbm_client_disconnect_request));
308 if (mei_disconnect(dev, cl)) {
310 cb_pos->information = 0;
311 list_move_tail(&cb_pos->cb_list,
312 &cmpl_list->mei_cb.cb_list);
315 cl->state = MEI_FILE_DISCONNECTING;
317 cb_pos->information = 0;
318 list_move_tail(&cb_pos->cb_list,
319 &dev->ctrl_rd_list.mei_cb.cb_list);
320 cl->timer_count = MEI_CONNECT_TIMEOUT;
327 * is_treat_specially_client - checks if the message belongs
328 * to the file private data.
330 * @cl: private data of the file object
331 * @rs: connect response bus message
334 static bool is_treat_specially_client(struct mei_cl *cl,
335 struct hbm_client_connect_response *rs)
338 if (cl->host_client_id == rs->host_addr &&
339 cl->me_client_id == rs->me_addr) {
341 cl->state = MEI_FILE_CONNECTED;
345 cl->state = MEI_FILE_DISCONNECTED;
346 cl->status = -ENODEV;
356 * mei_client_connect_response - connects to response irq routine
358 * @dev: the device structure
359 * @rs: connect response bus message
361 static void mei_client_connect_response(struct mei_device *dev,
362 struct hbm_client_connect_response *rs)
366 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
368 dev_dbg(&dev->pdev->dev,
369 "connect_response:\n"
377 /* if WD or iamthif client treat specially */
379 if (is_treat_specially_client(&(dev->wd_cl), rs)) {
380 dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n");
381 mei_watchdog_register(dev);
383 /* next step in the state maching */
384 mei_host_init_iamthif(dev);
388 if (is_treat_specially_client(&(dev->iamthif_cl), rs)) {
389 dev->iamthif_state = MEI_IAMTHIF_IDLE;
392 list_for_each_entry_safe(cb_pos, cb_next,
393 &dev->ctrl_rd_list.mei_cb.cb_list, cb_list) {
395 cl = (struct mei_cl *)cb_pos->file_private;
397 list_del(&cb_pos->cb_list);
400 if (MEI_IOCTL == cb_pos->major_file_operations) {
401 if (is_treat_specially_client(cl, rs)) {
402 list_del(&cb_pos->cb_list);
412 * mei_client_disconnect_response - disconnects from response irq routine
414 * @dev: the device structure
415 * @rs: disconnect response bus message
417 static void mei_client_disconnect_response(struct mei_device *dev,
418 struct hbm_client_connect_response *rs)
421 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
423 dev_dbg(&dev->pdev->dev,
424 "disconnect_response:\n"
432 list_for_each_entry_safe(cb_pos, cb_next,
433 &dev->ctrl_rd_list.mei_cb.cb_list, cb_list) {
434 cl = (struct mei_cl *)cb_pos->file_private;
437 list_del(&cb_pos->cb_list);
441 dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n");
442 if (cl->host_client_id == rs->host_addr &&
443 cl->me_client_id == rs->me_addr) {
445 list_del(&cb_pos->cb_list);
447 cl->state = MEI_FILE_DISCONNECTED;
457 * same_flow_addr - tells if they have the same address.
459 * @file: private data of the file object.
460 * @flow: flow control.
462 * returns !=0, same; 0,not.
464 static int same_flow_addr(struct mei_cl *cl, struct hbm_flow_control *flow)
466 return (cl->host_client_id == flow->host_addr &&
467 cl->me_client_id == flow->me_addr);
471 * add_single_flow_creds - adds single buffer credentials.
473 * @file: private data ot the file object.
474 * @flow: flow control.
476 static void add_single_flow_creds(struct mei_device *dev,
477 struct hbm_flow_control *flow)
479 struct mei_me_client *client;
482 for (i = 0; i < dev->me_clients_num; i++) {
483 client = &dev->me_clients[i];
484 if (client && flow->me_addr == client->client_id) {
485 if (client->props.single_recv_buf) {
486 client->mei_flow_ctrl_creds++;
487 dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
489 dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
490 client->mei_flow_ctrl_creds);
492 BUG(); /* error in flow control */
499 * mei_client_flow_control_response - flow control response irq routine
501 * @dev: the device structure
502 * @flow_control: flow control response bus message
504 static void mei_client_flow_control_response(struct mei_device *dev,
505 struct hbm_flow_control *flow_control)
507 struct mei_cl *cl_pos = NULL;
508 struct mei_cl *cl_next = NULL;
510 if (!flow_control->host_addr) {
511 /* single receive buffer */
512 add_single_flow_creds(dev, flow_control);
514 /* normal connection */
515 list_for_each_entry_safe(cl_pos, cl_next,
516 &dev->file_list, link) {
517 dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in file_list\n");
519 dev_dbg(&dev->pdev->dev, "cl of host client %d ME client %d.\n",
520 cl_pos->host_client_id,
521 cl_pos->me_client_id);
522 dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
523 flow_control->host_addr,
524 flow_control->me_addr);
525 if (same_flow_addr(cl_pos, flow_control)) {
526 dev_dbg(&dev->pdev->dev, "recv ctrl msg for host %d ME %d.\n",
527 flow_control->host_addr,
528 flow_control->me_addr);
529 cl_pos->mei_flow_ctrl_creds++;
530 dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
531 cl_pos->mei_flow_ctrl_creds);
539 * same_disconn_addr - tells if they have the same address
541 * @file: private data of the file object.
542 * @disconn: disconnection request.
544 * returns !=0, same; 0,not.
546 static int same_disconn_addr(struct mei_cl *cl,
547 struct hbm_client_disconnect_request *disconn)
549 return (cl->host_client_id == disconn->host_addr &&
550 cl->me_client_id == disconn->me_addr);
554 * mei_client_disconnect_request - disconnects from request irq routine
556 * @dev: the device structure.
557 * @disconnect_req: disconnect request bus message.
559 static void mei_client_disconnect_request(struct mei_device *dev,
560 struct hbm_client_disconnect_request *disconnect_req)
562 struct mei_msg_hdr *mei_hdr;
563 struct hbm_client_connect_response *disconnect_res;
564 struct mei_cl *cl_pos = NULL;
565 struct mei_cl *cl_next = NULL;
567 list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
568 if (same_disconn_addr(cl_pos, disconnect_req)) {
569 dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
570 disconnect_req->host_addr,
571 disconnect_req->me_addr);
572 cl_pos->state = MEI_FILE_DISCONNECTED;
573 cl_pos->timer_count = 0;
574 if (cl_pos == &dev->wd_cl)
575 dev->wd_pending = false;
576 else if (cl_pos == &dev->iamthif_cl)
577 dev->iamthif_timer = 0;
579 /* prepare disconnect response */
581 (struct mei_msg_hdr *) &dev->ext_msg_buf[0];
582 mei_hdr->host_addr = 0;
583 mei_hdr->me_addr = 0;
585 sizeof(struct hbm_client_connect_response);
586 mei_hdr->msg_complete = 1;
587 mei_hdr->reserved = 0;
590 (struct hbm_client_connect_response *)
591 &dev->ext_msg_buf[1];
592 disconnect_res->host_addr = cl_pos->host_client_id;
593 disconnect_res->me_addr = cl_pos->me_client_id;
594 disconnect_res->hbm_cmd = CLIENT_DISCONNECT_RES_CMD;
595 disconnect_res->status = 0;
596 dev->extra_write_index = 2;
604 * mei_irq_thread_read_bus_message - bottom half read routine after ISR to
605 * handle the read bus message cmd processing.
607 * @dev: the device structure
608 * @mei_hdr: header of bus message
610 static void mei_irq_thread_read_bus_message(struct mei_device *dev,
611 struct mei_msg_hdr *mei_hdr)
613 struct mei_bus_message *mei_msg;
614 struct hbm_host_version_response *version_res;
615 struct hbm_client_connect_response *connect_res;
616 struct hbm_client_connect_response *disconnect_res;
617 struct hbm_flow_control *flow_control;
618 struct hbm_props_response *props_res;
619 struct hbm_host_enum_response *enum_res;
620 struct hbm_client_disconnect_request *disconnect_req;
621 struct hbm_host_stop_request *host_stop_req;
625 /* read the message to our buffer */
626 BUG_ON(mei_hdr->length >= sizeof(dev->rd_msg_buf));
627 mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
628 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
630 switch (mei_msg->hbm_cmd) {
631 case HOST_START_RES_CMD:
632 version_res = (struct hbm_host_version_response *) mei_msg;
633 if (version_res->host_version_supported) {
634 dev->version.major_version = HBM_MAJOR_VERSION;
635 dev->version.minor_version = HBM_MINOR_VERSION;
636 if (dev->mei_state == MEI_INIT_CLIENTS &&
637 dev->init_clients_state == MEI_START_MESSAGE) {
638 dev->init_clients_timer = 0;
639 mei_host_enum_clients_message(dev);
641 dev->recvd_msg = false;
642 dev_dbg(&dev->pdev->dev, "IMEI reset due to received host start response bus message.\n");
647 dev->version = version_res->me_max_version;
648 /* send stop message */
649 mei_hdr = (struct mei_msg_hdr *)&dev->wr_msg_buf[0];
650 mei_hdr->host_addr = 0;
651 mei_hdr->me_addr = 0;
652 mei_hdr->length = sizeof(struct hbm_host_stop_request);
653 mei_hdr->msg_complete = 1;
654 mei_hdr->reserved = 0;
656 host_stop_req = (struct hbm_host_stop_request *)
659 memset(host_stop_req,
661 sizeof(struct hbm_host_stop_request));
662 host_stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
663 host_stop_req->reason = DRIVER_STOP_REQUEST;
664 mei_write_message(dev, mei_hdr,
665 (unsigned char *) (host_stop_req),
667 dev_dbg(&dev->pdev->dev, "version mismatch.\n");
671 dev->recvd_msg = true;
672 dev_dbg(&dev->pdev->dev, "host start response message received.\n");
675 case CLIENT_CONNECT_RES_CMD:
677 (struct hbm_client_connect_response *) mei_msg;
678 mei_client_connect_response(dev, connect_res);
679 dev_dbg(&dev->pdev->dev, "client connect response message received.\n");
680 wake_up(&dev->wait_recvd_msg);
683 case CLIENT_DISCONNECT_RES_CMD:
685 (struct hbm_client_connect_response *) mei_msg;
686 mei_client_disconnect_response(dev, disconnect_res);
687 dev_dbg(&dev->pdev->dev, "client disconnect response message received.\n");
688 wake_up(&dev->wait_recvd_msg);
691 case MEI_FLOW_CONTROL_CMD:
692 flow_control = (struct hbm_flow_control *) mei_msg;
693 mei_client_flow_control_response(dev, flow_control);
694 dev_dbg(&dev->pdev->dev, "client flow control response message received.\n");
697 case HOST_CLIENT_PROPERTIES_RES_CMD:
698 props_res = (struct hbm_props_response *)mei_msg;
699 if (props_res->status || !dev->me_clients) {
700 dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message wrong status.\n");
704 if (dev->me_clients[dev->me_client_presentation_num]
705 .client_id == props_res->address) {
707 dev->me_clients[dev->me_client_presentation_num].props
708 = props_res->client_properties;
710 if (dev->mei_state == MEI_INIT_CLIENTS &&
711 dev->init_clients_state ==
712 MEI_CLIENT_PROPERTIES_MESSAGE) {
713 dev->me_client_index++;
714 dev->me_client_presentation_num++;
716 /** Send Client Properties request **/
717 res = mei_host_client_properties(dev);
719 dev_dbg(&dev->pdev->dev, "mei_host_client_properties() failed");
723 * No more clients to send to.
724 * Clear Map for indicating now ME clients
725 * with associated host client
727 bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX);
728 dev->open_handle_count = 0;
731 * Reserving the first three client IDs
732 * Client Id 0 - Reserved for MEI Bus Message communications
733 * Client Id 1 - Reserved for Watchdog
734 * Client ID 2 - Reserved for AMTHI
736 bitmap_set(dev->host_clients_map, 0, 3);
737 dev->mei_state = MEI_ENABLED;
739 /* if wd initialization fails, initialization the AMTHI client,
740 * otherwise the AMTHI client will be initialized after the WD client connect response
743 if (mei_wd_host_init(dev))
744 mei_host_init_iamthif(dev);
748 dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message");
753 dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message for wrong client ID\n");
759 case HOST_ENUM_RES_CMD:
760 enum_res = (struct hbm_host_enum_response *) mei_msg;
761 memcpy(dev->me_clients_map, enum_res->valid_addresses, 32);
762 if (dev->mei_state == MEI_INIT_CLIENTS &&
763 dev->init_clients_state == MEI_ENUM_CLIENTS_MESSAGE) {
764 dev->init_clients_timer = 0;
765 dev->me_client_presentation_num = 0;
766 dev->me_client_index = 0;
767 mei_allocate_me_clients_storage(dev);
768 dev->init_clients_state =
769 MEI_CLIENT_PROPERTIES_MESSAGE;
770 mei_host_client_properties(dev);
772 dev_dbg(&dev->pdev->dev, "reset due to received host enumeration clients response bus message.\n");
778 case HOST_STOP_RES_CMD:
779 dev->mei_state = MEI_DISABLED;
780 dev_dbg(&dev->pdev->dev, "resetting because of FW stop response.\n");
784 case CLIENT_DISCONNECT_REQ_CMD:
785 /* search for client */
787 (struct hbm_client_disconnect_request *) mei_msg;
788 mei_client_disconnect_request(dev, disconnect_req);
791 case ME_STOP_REQ_CMD:
792 /* prepare stop request */
793 mei_hdr = (struct mei_msg_hdr *) &dev->ext_msg_buf[0];
794 mei_hdr->host_addr = 0;
795 mei_hdr->me_addr = 0;
796 mei_hdr->length = sizeof(struct hbm_host_stop_request);
797 mei_hdr->msg_complete = 1;
798 mei_hdr->reserved = 0;
800 (struct hbm_host_stop_request *) &dev->ext_msg_buf[1];
801 memset(host_stop_req, 0, sizeof(struct hbm_host_stop_request));
802 host_stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
803 host_stop_req->reason = DRIVER_STOP_REQUEST;
804 host_stop_req->reserved[0] = 0;
805 host_stop_req->reserved[1] = 0;
806 dev->extra_write_index = 2;
818 * _mei_hb_read - processes read related operation.
820 * @dev: the device structure.
821 * @slots: free slots.
822 * @cb_pos: callback block.
823 * @cl: private data of the file object.
824 * @cmpl_list: complete list.
826 * returns 0, OK; otherwise, error.
828 static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
829 struct mei_cl_cb *cb_pos,
831 struct mei_io_list *cmpl_list)
833 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
834 sizeof(struct hbm_flow_control))) {
835 /* return the cancel routine */
836 list_del(&cb_pos->cb_list);
840 *slots -= mei_data2slots(sizeof(struct hbm_flow_control));
842 if (mei_send_flow_control(dev, cl)) {
843 cl->status = -ENODEV;
844 cb_pos->information = 0;
845 list_move_tail(&cb_pos->cb_list, &cmpl_list->mei_cb.cb_list);
848 list_move_tail(&cb_pos->cb_list, &dev->read_list.mei_cb.cb_list);
855 * _mei_irq_thread_ioctl - processes ioctl related operation.
857 * @dev: the device structure.
858 * @slots: free slots.
859 * @cb_pos: callback block.
860 * @cl: private data of the file object.
861 * @cmpl_list: complete list.
863 * returns 0, OK; otherwise, error.
865 static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
866 struct mei_cl_cb *cb_pos,
868 struct mei_io_list *cmpl_list)
870 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
871 sizeof(struct hbm_client_connect_request))) {
872 /* return the cancel routine */
873 list_del(&cb_pos->cb_list);
877 cl->state = MEI_FILE_CONNECTING;
878 *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
879 if (mei_connect(dev, cl)) {
880 cl->status = -ENODEV;
881 cb_pos->information = 0;
882 list_del(&cb_pos->cb_list);
885 list_move_tail(&cb_pos->cb_list,
886 &dev->ctrl_rd_list.mei_cb.cb_list);
887 cl->timer_count = MEI_CONNECT_TIMEOUT;
893 * _mei_irq_thread_cmpl - processes completed and no-iamthif operation.
895 * @dev: the device structure.
896 * @slots: free slots.
897 * @cb_pos: callback block.
898 * @cl: private data of the file object.
899 * @cmpl_list: complete list.
901 * returns 0, OK; otherwise, error.
903 static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
904 struct mei_cl_cb *cb_pos,
906 struct mei_io_list *cmpl_list)
908 struct mei_msg_hdr *mei_hdr;
910 if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
911 (cb_pos->request_buffer.size -
912 cb_pos->information))) {
913 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
914 mei_hdr->host_addr = cl->host_client_id;
915 mei_hdr->me_addr = cl->me_client_id;
916 mei_hdr->length = cb_pos->request_buffer.size -
918 mei_hdr->msg_complete = 1;
919 mei_hdr->reserved = 0;
920 dev_dbg(&dev->pdev->dev, "cb_pos->request_buffer.size =%d"
921 "mei_hdr->msg_complete = %d\n",
922 cb_pos->request_buffer.size,
923 mei_hdr->msg_complete);
924 dev_dbg(&dev->pdev->dev, "cb_pos->information =%lu\n",
925 cb_pos->information);
926 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
928 *slots -= mei_data2slots(mei_hdr->length);
929 if (mei_write_message(dev, mei_hdr,
931 (cb_pos->request_buffer.data +
932 cb_pos->information),
934 cl->status = -ENODEV;
935 list_move_tail(&cb_pos->cb_list,
936 &cmpl_list->mei_cb.cb_list);
939 if (mei_flow_ctrl_reduce(dev, cl))
942 cb_pos->information += mei_hdr->length;
943 list_move_tail(&cb_pos->cb_list,
944 &dev->write_waiting_list.mei_cb.cb_list);
946 } else if (*slots == dev->hbuf_depth) {
947 /* buffer is still empty */
948 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
949 mei_hdr->host_addr = cl->host_client_id;
950 mei_hdr->me_addr = cl->me_client_id;
952 (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
953 mei_hdr->msg_complete = 0;
954 mei_hdr->reserved = 0;
955 *slots -= mei_data2slots(mei_hdr->length);
956 if (mei_write_message(dev, mei_hdr,
958 (cb_pos->request_buffer.data +
959 cb_pos->information),
961 cl->status = -ENODEV;
962 list_move_tail(&cb_pos->cb_list,
963 &cmpl_list->mei_cb.cb_list);
966 cb_pos->information += mei_hdr->length;
967 dev_dbg(&dev->pdev->dev,
968 "cb_pos->request_buffer.size =%d"
969 " mei_hdr->msg_complete = %d\n",
970 cb_pos->request_buffer.size,
971 mei_hdr->msg_complete);
972 dev_dbg(&dev->pdev->dev, "cb_pos->information =%lu\n",
973 cb_pos->information);
974 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
986 * _mei_irq_thread_cmpl_iamthif - processes completed iamthif operation.
988 * @dev: the device structure.
989 * @slots: free slots.
990 * @cb_pos: callback block.
991 * @cl: private data of the file object.
992 * @cmpl_list: complete list.
994 * returns 0, OK; otherwise, error.
996 static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
997 struct mei_cl_cb *cb_pos,
999 struct mei_io_list *cmpl_list)
1001 struct mei_msg_hdr *mei_hdr;
1003 if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
1004 dev->iamthif_msg_buf_size -
1005 dev->iamthif_msg_buf_index)) {
1006 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
1007 mei_hdr->host_addr = cl->host_client_id;
1008 mei_hdr->me_addr = cl->me_client_id;
1009 mei_hdr->length = dev->iamthif_msg_buf_size -
1010 dev->iamthif_msg_buf_index;
1011 mei_hdr->msg_complete = 1;
1012 mei_hdr->reserved = 0;
1014 *slots -= mei_data2slots(mei_hdr->length);
1016 if (mei_write_message(dev, mei_hdr,
1017 (dev->iamthif_msg_buf +
1018 dev->iamthif_msg_buf_index),
1020 dev->iamthif_state = MEI_IAMTHIF_IDLE;
1021 cl->status = -ENODEV;
1022 list_del(&cb_pos->cb_list);
1025 if (mei_flow_ctrl_reduce(dev, cl))
1027 dev->iamthif_msg_buf_index += mei_hdr->length;
1028 cb_pos->information = dev->iamthif_msg_buf_index;
1030 dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
1031 dev->iamthif_flow_control_pending = true;
1032 /* save iamthif cb sent to amthi client */
1033 dev->iamthif_current_cb = cb_pos;
1034 list_move_tail(&cb_pos->cb_list,
1035 &dev->write_waiting_list.mei_cb.cb_list);
1038 } else if (*slots == dev->hbuf_depth) {
1039 /* buffer is still empty */
1040 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
1041 mei_hdr->host_addr = cl->host_client_id;
1042 mei_hdr->me_addr = cl->me_client_id;
1044 (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
1045 mei_hdr->msg_complete = 0;
1046 mei_hdr->reserved = 0;
1048 *slots -= mei_data2slots(mei_hdr->length);
1050 if (mei_write_message(dev, mei_hdr,
1051 (dev->iamthif_msg_buf +
1052 dev->iamthif_msg_buf_index),
1054 cl->status = -ENODEV;
1055 list_del(&cb_pos->cb_list);
1057 dev->iamthif_msg_buf_index += mei_hdr->length;
1068 * mei_irq_thread_read_handler - bottom half read routine after ISR to
1069 * handle the read processing.
1071 * @cmpl_list: An instance of our list structure
1072 * @dev: the device structure
1073 * @slots: slots to read.
1075 * returns 0 on success, <0 on failure.
1077 static int mei_irq_thread_read_handler(struct mei_io_list *cmpl_list,
1078 struct mei_device *dev,
1081 struct mei_msg_hdr *mei_hdr;
1082 struct mei_cl *cl_pos = NULL;
1083 struct mei_cl *cl_next = NULL;
1086 if (!dev->rd_msg_hdr) {
1087 dev->rd_msg_hdr = mei_mecbrw_read(dev);
1088 dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
1090 dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
1092 mei_hdr = (struct mei_msg_hdr *) &dev->rd_msg_hdr;
1093 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", mei_hdr->length);
1095 if (mei_hdr->reserved || !dev->rd_msg_hdr) {
1096 dev_dbg(&dev->pdev->dev, "corrupted message header.\n");
1101 if (mei_hdr->host_addr || mei_hdr->me_addr) {
1102 list_for_each_entry_safe(cl_pos, cl_next,
1103 &dev->file_list, link) {
1104 dev_dbg(&dev->pdev->dev,
1105 "list_for_each_entry_safe read host"
1106 " client = %d, ME client = %d\n",
1107 cl_pos->host_client_id,
1108 cl_pos->me_client_id);
1109 if (cl_pos->host_client_id == mei_hdr->host_addr &&
1110 cl_pos->me_client_id == mei_hdr->me_addr)
1114 if (&cl_pos->link == &dev->file_list) {
1115 dev_dbg(&dev->pdev->dev, "corrupted message header\n");
1120 if (((*slots) * sizeof(u32)) < mei_hdr->length) {
1121 dev_dbg(&dev->pdev->dev,
1122 "we can't read the message slots =%08x.\n",
1124 /* we can't read the message */
1129 /* decide where to read the message too */
1130 if (!mei_hdr->host_addr) {
1131 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_bus_message.\n");
1132 mei_irq_thread_read_bus_message(dev, mei_hdr);
1133 dev_dbg(&dev->pdev->dev, "end mei_irq_thread_read_bus_message.\n");
1134 } else if (mei_hdr->host_addr == dev->iamthif_cl.host_client_id &&
1135 (MEI_FILE_CONNECTED == dev->iamthif_cl.state) &&
1136 (dev->iamthif_state == MEI_IAMTHIF_READING)) {
1137 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_iamthif_message.\n");
1138 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
1140 ret = mei_irq_thread_read_amthi_message(cmpl_list,
1146 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_client_message.\n");
1147 ret = mei_irq_thread_read_client_message(cmpl_list,
1154 /* reset the number of slots and header */
1155 *slots = mei_count_full_read_slots(dev);
1156 dev->rd_msg_hdr = 0;
1158 if (*slots == -EOVERFLOW) {
1159 /* overflow - reset */
1160 dev_dbg(&dev->pdev->dev, "resetting due to slots overflow.\n");
1161 /* set the event since message has been read */
1171 * mei_irq_thread_write_handler - bottom half write routine after
1172 * ISR to handle the write processing.
1174 * @cmpl_list: An instance of our list structure
1175 * @dev: the device structure
1176 * @slots: slots to write.
1178 * returns 0 on success, <0 on failure.
1180 static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
1181 struct mei_device *dev,
1186 struct mei_cl_cb *pos = NULL, *next = NULL;
1187 struct mei_io_list *list;
1190 if (!mei_hbuf_is_empty(dev)) {
1191 dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n");
1194 *slots = mei_hbuf_empty_slots(dev);
1198 /* complete all waiting for write CB */
1199 dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n");
1201 list = &dev->write_waiting_list;
1202 list_for_each_entry_safe(pos, next, &list->mei_cb.cb_list, cb_list) {
1203 cl = (struct mei_cl *)pos->file_private;
1208 list_del(&pos->cb_list);
1209 if (MEI_WRITING == cl->writing_state &&
1210 (pos->major_file_operations == MEI_WRITE) &&
1211 (cl != &dev->iamthif_cl)) {
1212 dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n");
1213 cl->writing_state = MEI_WRITE_COMPLETE;
1214 list_add_tail(&pos->cb_list,
1215 &cmpl_list->mei_cb.cb_list);
1217 if (cl == &dev->iamthif_cl) {
1218 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
1219 if (dev->iamthif_flow_control_pending) {
1220 ret = _mei_irq_thread_iamthif_read(dev, slots);
1227 if (dev->stop && !dev->wd_pending) {
1228 dev->wd_stopped = true;
1229 wake_up_interruptible(&dev->wait_stop_wd);
1233 if (dev->extra_write_index) {
1234 dev_dbg(&dev->pdev->dev, "extra_write_index =%d.\n",
1235 dev->extra_write_index);
1236 mei_write_message(dev,
1237 (struct mei_msg_hdr *) &dev->ext_msg_buf[0],
1238 (unsigned char *) &dev->ext_msg_buf[1],
1239 (dev->extra_write_index - 1) * sizeof(u32));
1240 *slots -= dev->extra_write_index;
1241 dev->extra_write_index = 0;
1243 if (dev->mei_state == MEI_ENABLED) {
1244 if (dev->wd_pending &&
1245 mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
1246 if (mei_wd_send(dev))
1247 dev_dbg(&dev->pdev->dev, "wd send failed.\n");
1248 else if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
1251 dev->wd_pending = false;
1253 if (dev->wd_timeout)
1254 *slots -= mei_data2slots(MEI_START_WD_DATA_SIZE);
1256 *slots -= mei_data2slots(MEI_WD_PARAMS_SIZE);
1262 /* complete control write list CB */
1263 dev_dbg(&dev->pdev->dev, "complete control write list cb.\n");
1264 list_for_each_entry_safe(pos, next,
1265 &dev->ctrl_wr_list.mei_cb.cb_list, cb_list) {
1266 cl = (struct mei_cl *) pos->file_private;
1268 list_del(&pos->cb_list);
1271 switch (pos->major_file_operations) {
1273 /* send disconnect message */
1274 ret = _mei_irq_thread_close(dev, slots, pos, cl, cmpl_list);
1280 /* send flow control message */
1281 ret = _mei_irq_thread_read(dev, slots, pos, cl, cmpl_list);
1287 /* connect message */
1288 if (mei_other_client_is_connecting(dev, cl))
1290 ret = _mei_irq_thread_ioctl(dev, slots, pos, cl, cmpl_list);
1301 /* complete write list CB */
1302 dev_dbg(&dev->pdev->dev, "complete write list cb.\n");
1303 list_for_each_entry_safe(pos, next,
1304 &dev->write_list.mei_cb.cb_list, cb_list) {
1305 cl = (struct mei_cl *)pos->file_private;
1309 if (cl != &dev->iamthif_cl) {
1310 if (mei_flow_ctrl_creds(dev, cl) <= 0) {
1311 dev_dbg(&dev->pdev->dev,
1312 "No flow control credentials for client %d, not sending.\n",
1313 cl->host_client_id);
1316 ret = _mei_irq_thread_cmpl(dev, slots, pos,
1321 } else if (cl == &dev->iamthif_cl) {
1323 dev_dbg(&dev->pdev->dev, "complete amthi write cb.\n");
1324 if (mei_flow_ctrl_creds(dev, cl) <= 0) {
1325 dev_dbg(&dev->pdev->dev,
1326 "No flow control credentials for amthi client %d.\n",
1327 cl->host_client_id);
1330 ret = _mei_irq_thread_cmpl_iamthif(dev, slots, pos,
1344 * mei_timer - timer function.
1346 * @work: pointer to the work_struct structure
1348 * NOTE: This function is called by timer interrupt work
1350 void mei_timer(struct work_struct *work)
1352 unsigned long timeout;
1353 struct mei_cl *cl_pos = NULL;
1354 struct mei_cl *cl_next = NULL;
1355 struct list_head *amthi_complete_list = NULL;
1356 struct mei_cl_cb *cb_pos = NULL;
1357 struct mei_cl_cb *cb_next = NULL;
1359 struct mei_device *dev = container_of(work,
1360 struct mei_device, timer_work.work);
1363 mutex_lock(&dev->device_lock);
1364 if (dev->mei_state != MEI_ENABLED) {
1365 if (dev->mei_state == MEI_INIT_CLIENTS) {
1366 if (dev->init_clients_timer) {
1367 if (--dev->init_clients_timer == 0) {
1368 dev_dbg(&dev->pdev->dev, "IMEI reset due to init clients timeout ,init clients state = %d.\n",
1369 dev->init_clients_state);
1376 /*** connect/disconnect timeouts ***/
1377 list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
1378 if (cl_pos->timer_count) {
1379 if (--cl_pos->timer_count == 0) {
1380 dev_dbg(&dev->pdev->dev, "HECI reset due to connect/disconnect timeout.\n");
1387 if (dev->iamthif_stall_timer) {
1388 if (--dev->iamthif_stall_timer == 0) {
1389 dev_dbg(&dev->pdev->dev, "resetting because of hang to amthi.\n");
1391 dev->iamthif_msg_buf_size = 0;
1392 dev->iamthif_msg_buf_index = 0;
1393 dev->iamthif_canceled = false;
1394 dev->iamthif_ioctl = true;
1395 dev->iamthif_state = MEI_IAMTHIF_IDLE;
1396 dev->iamthif_timer = 0;
1398 if (dev->iamthif_current_cb)
1399 mei_free_cb_private(dev->iamthif_current_cb);
1401 dev->iamthif_file_object = NULL;
1402 dev->iamthif_current_cb = NULL;
1403 mei_run_next_iamthif_cmd(dev);
1407 if (dev->iamthif_timer) {
1409 timeout = dev->iamthif_timer +
1410 msecs_to_jiffies(IAMTHIF_READ_TIMER);
1412 dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
1413 dev->iamthif_timer);
1414 dev_dbg(&dev->pdev->dev, "timeout = %ld\n", timeout);
1415 dev_dbg(&dev->pdev->dev, "jiffies = %ld\n", jiffies);
1416 if (time_after(jiffies, timeout)) {
1418 * User didn't read the AMTHI data on time (15sec)
1419 * freeing AMTHI for other requests
1422 dev_dbg(&dev->pdev->dev, "freeing AMTHI for other requests\n");
1424 amthi_complete_list = &dev->amthi_read_complete_list.
1427 list_for_each_entry_safe(cb_pos, cb_next, amthi_complete_list, cb_list) {
1429 cl_pos = cb_pos->file_object->private_data;
1431 /* Finding the AMTHI entry. */
1432 if (cl_pos == &dev->iamthif_cl)
1433 list_del(&cb_pos->cb_list);
1435 if (dev->iamthif_current_cb)
1436 mei_free_cb_private(dev->iamthif_current_cb);
1438 dev->iamthif_file_object->private_data = NULL;
1439 dev->iamthif_file_object = NULL;
1440 dev->iamthif_current_cb = NULL;
1441 dev->iamthif_timer = 0;
1442 mei_run_next_iamthif_cmd(dev);
1447 schedule_delayed_work(&dev->timer_work, 2 * HZ);
1448 mutex_unlock(&dev->device_lock);
1452 * mei_interrupt_thread_handler - function called after ISR to handle the interrupt
1455 * @irq: The irq number
1456 * @dev_id: pointer to the device structure
1458 * returns irqreturn_t
1461 irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
1463 struct mei_device *dev = (struct mei_device *) dev_id;
1464 struct mei_io_list complete_list;
1465 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
1469 bool bus_message_received;
1472 dev_dbg(&dev->pdev->dev, "function called after ISR to handle the interrupt processing.\n");
1473 /* initialize our complete list */
1474 mutex_lock(&dev->device_lock);
1475 mei_io_list_init(&complete_list);
1476 dev->host_hw_state = mei_hcsr_read(dev);
1478 /* Ack the interrupt here
1479 * In case of MSI we don't go through the quick handler */
1480 if (pci_dev_msi_enabled(dev->pdev))
1481 mei_reg_write(dev, H_CSR, dev->host_hw_state);
1483 dev->me_hw_state = mei_mecsr_read(dev);
1485 /* check if ME wants a reset */
1486 if ((dev->me_hw_state & ME_RDY_HRA) == 0 &&
1487 dev->mei_state != MEI_RESETING &&
1488 dev->mei_state != MEI_INITIALIZING) {
1489 dev_dbg(&dev->pdev->dev, "FW not ready.\n");
1491 mutex_unlock(&dev->device_lock);
1495 /* check if we need to start the dev */
1496 if ((dev->host_hw_state & H_RDY) == 0) {
1497 if ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA) {
1498 dev_dbg(&dev->pdev->dev, "we need to start the dev.\n");
1499 dev->host_hw_state |= (H_IE | H_IG | H_RDY);
1501 dev->mei_state = MEI_INIT_CLIENTS;
1502 dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n");
1503 /* link is established
1504 * start sending messages.
1506 mei_host_start_message(dev);
1507 mutex_unlock(&dev->device_lock);
1510 dev_dbg(&dev->pdev->dev, "FW not ready.\n");
1511 mutex_unlock(&dev->device_lock);
1515 /* check slots available for reading */
1516 slots = mei_count_full_read_slots(dev);
1517 dev_dbg(&dev->pdev->dev, "slots =%08x extra_write_index =%08x.\n",
1518 slots, dev->extra_write_index);
1519 while (slots > 0 && !dev->extra_write_index) {
1520 dev_dbg(&dev->pdev->dev, "slots =%08x extra_write_index =%08x.\n",
1521 slots, dev->extra_write_index);
1522 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_handler.\n");
1523 rets = mei_irq_thread_read_handler(&complete_list, dev, &slots);
1527 rets = mei_irq_thread_write_handler(&complete_list, dev, &slots);
1529 dev_dbg(&dev->pdev->dev, "end of bottom half function.\n");
1530 dev->host_hw_state = mei_hcsr_read(dev);
1531 dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
1533 bus_message_received = false;
1534 if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) {
1535 dev_dbg(&dev->pdev->dev, "received waiting bus message\n");
1536 bus_message_received = true;
1538 mutex_unlock(&dev->device_lock);
1539 if (bus_message_received) {
1540 dev_dbg(&dev->pdev->dev, "wake up dev->wait_recvd_msg\n");
1541 wake_up_interruptible(&dev->wait_recvd_msg);
1542 bus_message_received = false;
1544 if (list_empty(&complete_list.mei_cb.cb_list))
1548 list_for_each_entry_safe(cb_pos, cb_next,
1549 &complete_list.mei_cb.cb_list, cb_list) {
1550 cl = (struct mei_cl *)cb_pos->file_private;
1551 list_del(&cb_pos->cb_list);
1553 if (cl != &dev->iamthif_cl) {
1554 dev_dbg(&dev->pdev->dev, "completing call back.\n");
1555 _mei_cmpl(cl, cb_pos);
1557 } else if (cl == &dev->iamthif_cl) {
1558 _mei_cmpl_iamthif(dev, cb_pos);