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
17 #include <linux/pci.h>
18 #include <linux/sched.h>
19 #include <linux/wait.h>
20 #include <linux/delay.h>
24 #include "interface.h"
25 #include <linux/mei.h>
27 const char *mei_dev_state_str(int state
)
29 #define MEI_DEV_STATE(state) case MEI_DEV_##state: return #state
31 MEI_DEV_STATE(INITIALIZING
);
32 MEI_DEV_STATE(INIT_CLIENTS
);
33 MEI_DEV_STATE(ENABLED
);
34 MEI_DEV_STATE(RESETING
);
35 MEI_DEV_STATE(DISABLED
);
36 MEI_DEV_STATE(RECOVERING_FROM_RESET
);
37 MEI_DEV_STATE(POWER_DOWN
);
38 MEI_DEV_STATE(POWER_UP
);
46 const uuid_le mei_amthi_guid
= UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac,
47 0xa8, 0x46, 0xe0, 0xff, 0x65,
51 * mei_io_list_init - Sets up a queue list.
53 * @list: An instance io list structure
54 * @dev: the device structure
56 void mei_io_list_init(struct mei_io_list
*list
)
58 /* initialize our queue list */
59 INIT_LIST_HEAD(&list
->mei_cb
.cb_list
);
63 * mei_io_list_flush - removes list entry belonging to cl.
65 * @list: An instance of our list structure
66 * @cl: private data of the file object
68 void mei_io_list_flush(struct mei_io_list
*list
, struct mei_cl
*cl
)
70 struct mei_cl_cb
*pos
;
71 struct mei_cl_cb
*next
;
73 list_for_each_entry_safe(pos
, next
, &list
->mei_cb
.cb_list
, cb_list
) {
74 if (pos
->file_private
) {
75 struct mei_cl
*cl_tmp
;
76 cl_tmp
= (struct mei_cl
*)pos
->file_private
;
77 if (mei_cl_cmp_id(cl
, cl_tmp
))
78 list_del(&pos
->cb_list
);
83 * mei_cl_flush_queues - flushes queue lists belonging to cl.
85 * @dev: the device structure
86 * @cl: private data of the file object
88 int mei_cl_flush_queues(struct mei_cl
*cl
)
93 dev_dbg(&cl
->dev
->pdev
->dev
, "remove list entry belonging to cl\n");
94 mei_io_list_flush(&cl
->dev
->read_list
, cl
);
95 mei_io_list_flush(&cl
->dev
->write_list
, cl
);
96 mei_io_list_flush(&cl
->dev
->write_waiting_list
, cl
);
97 mei_io_list_flush(&cl
->dev
->ctrl_wr_list
, cl
);
98 mei_io_list_flush(&cl
->dev
->ctrl_rd_list
, cl
);
99 mei_io_list_flush(&cl
->dev
->amthi_cmd_list
, cl
);
100 mei_io_list_flush(&cl
->dev
->amthi_read_complete_list
, cl
);
107 * mei_reset_iamthif_params - initializes mei device iamthif
109 * @dev: the device structure
111 static void mei_reset_iamthif_params(struct mei_device
*dev
)
113 /* reset iamthif parameters. */
114 dev
->iamthif_current_cb
= NULL
;
115 dev
->iamthif_msg_buf_size
= 0;
116 dev
->iamthif_msg_buf_index
= 0;
117 dev
->iamthif_canceled
= false;
118 dev
->iamthif_ioctl
= false;
119 dev
->iamthif_state
= MEI_IAMTHIF_IDLE
;
120 dev
->iamthif_timer
= 0;
124 * init_mei_device - allocates and initializes the mei device structure
126 * @pdev: The pci device structure
128 * returns The mei_device_device pointer on success, NULL on failure.
130 struct mei_device
*mei_device_init(struct pci_dev
*pdev
)
132 struct mei_device
*dev
;
134 dev
= kzalloc(sizeof(struct mei_device
), GFP_KERNEL
);
138 /* setup our list array */
139 INIT_LIST_HEAD(&dev
->file_list
);
140 INIT_LIST_HEAD(&dev
->wd_cl
.link
);
141 INIT_LIST_HEAD(&dev
->iamthif_cl
.link
);
142 mutex_init(&dev
->device_lock
);
143 init_waitqueue_head(&dev
->wait_recvd_msg
);
144 init_waitqueue_head(&dev
->wait_stop_wd
);
145 dev
->dev_state
= MEI_DEV_INITIALIZING
;
146 dev
->iamthif_state
= MEI_IAMTHIF_IDLE
;
147 dev
->wd_interface_reg
= false;
150 mei_io_list_init(&dev
->read_list
);
151 mei_io_list_init(&dev
->write_list
);
152 mei_io_list_init(&dev
->write_waiting_list
);
153 mei_io_list_init(&dev
->ctrl_wr_list
);
154 mei_io_list_init(&dev
->ctrl_rd_list
);
155 mei_io_list_init(&dev
->amthi_cmd_list
);
156 mei_io_list_init(&dev
->amthi_read_complete_list
);
162 * mei_hw_init - initializes host and fw to start work.
164 * @dev: the device structure
166 * returns 0 on success, <0 on failure.
168 int mei_hw_init(struct mei_device
*dev
)
173 mutex_lock(&dev
->device_lock
);
175 dev
->host_hw_state
= mei_hcsr_read(dev
);
176 dev
->me_hw_state
= mei_mecsr_read(dev
);
177 dev_dbg(&dev
->pdev
->dev
, "host_hw_state = 0x%08x, mestate = 0x%08x.\n",
178 dev
->host_hw_state
, dev
->me_hw_state
);
180 /* acknowledge interrupt and stop interupts */
181 if ((dev
->host_hw_state
& H_IS
) == H_IS
)
182 mei_reg_write(dev
, H_CSR
, dev
->host_hw_state
);
184 /* Doesn't change in runtime */
185 dev
->hbuf_depth
= (dev
->host_hw_state
& H_CBD
) >> 24;
187 dev
->recvd_msg
= false;
188 dev_dbg(&dev
->pdev
->dev
, "reset in start the mei device.\n");
192 dev_dbg(&dev
->pdev
->dev
, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
193 dev
->host_hw_state
, dev
->me_hw_state
);
195 /* wait for ME to turn on ME_RDY */
196 if (!dev
->recvd_msg
) {
197 mutex_unlock(&dev
->device_lock
);
198 err
= wait_event_interruptible_timeout(dev
->wait_recvd_msg
,
199 dev
->recvd_msg
, MEI_INTEROP_TIMEOUT
);
200 mutex_lock(&dev
->device_lock
);
203 if (err
<= 0 && !dev
->recvd_msg
) {
204 dev
->dev_state
= MEI_DEV_DISABLED
;
205 dev_dbg(&dev
->pdev
->dev
,
206 "wait_event_interruptible_timeout failed"
207 "on wait for ME to turn on ME_RDY.\n");
212 if (!(((dev
->host_hw_state
& H_RDY
) == H_RDY
) &&
213 ((dev
->me_hw_state
& ME_RDY_HRA
) == ME_RDY_HRA
))) {
214 dev
->dev_state
= MEI_DEV_DISABLED
;
215 dev_dbg(&dev
->pdev
->dev
,
216 "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
217 dev
->host_hw_state
, dev
->me_hw_state
);
219 if (!(dev
->host_hw_state
& H_RDY
))
220 dev_dbg(&dev
->pdev
->dev
, "host turn off H_RDY.\n");
222 if (!(dev
->me_hw_state
& ME_RDY_HRA
))
223 dev_dbg(&dev
->pdev
->dev
, "ME turn off ME_RDY.\n");
225 dev_err(&dev
->pdev
->dev
, "link layer initialization failed.\n");
230 if (dev
->version
.major_version
!= HBM_MAJOR_VERSION
||
231 dev
->version
.minor_version
!= HBM_MINOR_VERSION
) {
232 dev_dbg(&dev
->pdev
->dev
, "MEI start failed.\n");
237 dev
->recvd_msg
= false;
238 dev_dbg(&dev
->pdev
->dev
, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
239 dev
->host_hw_state
, dev
->me_hw_state
);
240 dev_dbg(&dev
->pdev
->dev
, "ME turn on ME_RDY and host turn on H_RDY.\n");
241 dev_dbg(&dev
->pdev
->dev
, "link layer has been established.\n");
242 dev_dbg(&dev
->pdev
->dev
, "MEI start success.\n");
246 mutex_unlock(&dev
->device_lock
);
251 * mei_hw_reset - resets fw via mei csr register.
253 * @dev: the device structure
254 * @interrupts_enabled: if interrupt should be enabled after reset.
256 static void mei_hw_reset(struct mei_device
*dev
, int interrupts_enabled
)
258 dev
->host_hw_state
|= (H_RST
| H_IG
);
260 if (interrupts_enabled
)
261 mei_enable_interrupts(dev
);
263 mei_disable_interrupts(dev
);
267 * mei_reset - resets host and fw.
269 * @dev: the device structure
270 * @interrupts_enabled: if interrupt should be enabled after reset.
272 void mei_reset(struct mei_device
*dev
, int interrupts_enabled
)
274 struct mei_cl
*cl_pos
= NULL
;
275 struct mei_cl
*cl_next
= NULL
;
276 struct mei_cl_cb
*cb_pos
= NULL
;
277 struct mei_cl_cb
*cb_next
= NULL
;
280 if (dev
->dev_state
== MEI_DEV_RECOVERING_FROM_RESET
) {
281 dev
->need_reset
= true;
285 unexpected
= (dev
->dev_state
!= MEI_DEV_INITIALIZING
&&
286 dev
->dev_state
!= MEI_DEV_DISABLED
&&
287 dev
->dev_state
!= MEI_DEV_POWER_DOWN
&&
288 dev
->dev_state
!= MEI_DEV_POWER_UP
);
290 dev
->host_hw_state
= mei_hcsr_read(dev
);
292 dev_dbg(&dev
->pdev
->dev
, "before reset host_hw_state = 0x%08x.\n",
295 mei_hw_reset(dev
, interrupts_enabled
);
297 dev
->host_hw_state
&= ~H_RST
;
298 dev
->host_hw_state
|= H_IG
;
302 dev_dbg(&dev
->pdev
->dev
, "currently saved host_hw_state = 0x%08x.\n",
305 dev
->need_reset
= false;
307 if (dev
->dev_state
!= MEI_DEV_INITIALIZING
) {
308 if (dev
->dev_state
!= MEI_DEV_DISABLED
&&
309 dev
->dev_state
!= MEI_DEV_POWER_DOWN
)
310 dev
->dev_state
= MEI_DEV_RESETING
;
312 list_for_each_entry_safe(cl_pos
,
313 cl_next
, &dev
->file_list
, link
) {
314 cl_pos
->state
= MEI_FILE_DISCONNECTED
;
315 cl_pos
->mei_flow_ctrl_creds
= 0;
316 cl_pos
->read_cb
= NULL
;
317 cl_pos
->timer_count
= 0;
319 /* remove entry if already in list */
320 dev_dbg(&dev
->pdev
->dev
, "list del iamthif and wd file list.\n");
321 mei_remove_client_from_file_list(dev
,
322 dev
->wd_cl
.host_client_id
);
324 mei_remove_client_from_file_list(dev
,
325 dev
->iamthif_cl
.host_client_id
);
327 mei_reset_iamthif_params(dev
);
328 dev
->extra_write_index
= 0;
331 dev
->me_clients_num
= 0;
333 dev
->wd_pending
= false;
335 /* update the state of the registers after reset */
336 dev
->host_hw_state
= mei_hcsr_read(dev
);
337 dev
->me_hw_state
= mei_mecsr_read(dev
);
339 dev_dbg(&dev
->pdev
->dev
, "after reset host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
340 dev
->host_hw_state
, dev
->me_hw_state
);
343 dev_warn(&dev
->pdev
->dev
, "unexpected reset: dev_state = %s\n",
344 mei_dev_state_str(dev
->dev_state
));
346 /* Wake up all readings so they can be interrupted */
347 list_for_each_entry_safe(cl_pos
, cl_next
, &dev
->file_list
, link
) {
348 if (waitqueue_active(&cl_pos
->rx_wait
)) {
349 dev_dbg(&dev
->pdev
->dev
, "Waking up client!\n");
350 wake_up_interruptible(&cl_pos
->rx_wait
);
353 /* remove all waiting requests */
354 list_for_each_entry_safe(cb_pos
, cb_next
,
355 &dev
->write_list
.mei_cb
.cb_list
, cb_list
) {
356 list_del(&cb_pos
->cb_list
);
357 mei_free_cb_private(cb_pos
);
364 * host_start_message - mei host sends start message.
366 * @dev: the device structure
370 void mei_host_start_message(struct mei_device
*dev
)
372 struct mei_msg_hdr
*mei_hdr
;
373 struct hbm_host_version_request
*host_start_req
;
375 /* host start message */
376 mei_hdr
= (struct mei_msg_hdr
*) &dev
->wr_msg_buf
[0];
377 mei_hdr
->host_addr
= 0;
378 mei_hdr
->me_addr
= 0;
379 mei_hdr
->length
= sizeof(struct hbm_host_version_request
);
380 mei_hdr
->msg_complete
= 1;
381 mei_hdr
->reserved
= 0;
384 (struct hbm_host_version_request
*) &dev
->wr_msg_buf
[1];
385 memset(host_start_req
, 0, sizeof(struct hbm_host_version_request
));
386 host_start_req
->hbm_cmd
= HOST_START_REQ_CMD
;
387 host_start_req
->host_version
.major_version
= HBM_MAJOR_VERSION
;
388 host_start_req
->host_version
.minor_version
= HBM_MINOR_VERSION
;
389 dev
->recvd_msg
= false;
390 if (mei_write_message(dev
, mei_hdr
, (unsigned char *)host_start_req
,
392 dev_dbg(&dev
->pdev
->dev
, "write send version message to FW fail.\n");
393 dev
->dev_state
= MEI_DEV_RESETING
;
396 dev
->init_clients_state
= MEI_START_MESSAGE
;
397 dev
->init_clients_timer
= INIT_CLIENTS_TIMEOUT
;
402 * host_enum_clients_message - host sends enumeration client request message.
404 * @dev: the device structure
408 void mei_host_enum_clients_message(struct mei_device
*dev
)
410 struct mei_msg_hdr
*mei_hdr
;
411 struct hbm_host_enum_request
*host_enum_req
;
412 mei_hdr
= (struct mei_msg_hdr
*) &dev
->wr_msg_buf
[0];
413 /* enumerate clients */
414 mei_hdr
->host_addr
= 0;
415 mei_hdr
->me_addr
= 0;
416 mei_hdr
->length
= sizeof(struct hbm_host_enum_request
);
417 mei_hdr
->msg_complete
= 1;
418 mei_hdr
->reserved
= 0;
420 host_enum_req
= (struct hbm_host_enum_request
*) &dev
->wr_msg_buf
[1];
421 memset(host_enum_req
, 0, sizeof(struct hbm_host_enum_request
));
422 host_enum_req
->hbm_cmd
= HOST_ENUM_REQ_CMD
;
423 if (mei_write_message(dev
, mei_hdr
, (unsigned char *)host_enum_req
,
425 dev
->dev_state
= MEI_DEV_RESETING
;
426 dev_dbg(&dev
->pdev
->dev
, "write send enumeration request message to FW fail.\n");
429 dev
->init_clients_state
= MEI_ENUM_CLIENTS_MESSAGE
;
430 dev
->init_clients_timer
= INIT_CLIENTS_TIMEOUT
;
436 * allocate_me_clients_storage - allocates storage for me clients
438 * @dev: the device structure
442 void mei_allocate_me_clients_storage(struct mei_device
*dev
)
444 struct mei_me_client
*clients
;
447 /* count how many ME clients we have */
448 for_each_set_bit(b
, dev
->me_clients_map
, MEI_CLIENTS_MAX
)
449 dev
->me_clients_num
++;
451 if (dev
->me_clients_num
<= 0)
455 if (dev
->me_clients
!= NULL
) {
456 kfree(dev
->me_clients
);
457 dev
->me_clients
= NULL
;
459 dev_dbg(&dev
->pdev
->dev
, "memory allocation for ME clients size=%zd.\n",
460 dev
->me_clients_num
* sizeof(struct mei_me_client
));
461 /* allocate storage for ME clients representation */
462 clients
= kcalloc(dev
->me_clients_num
,
463 sizeof(struct mei_me_client
), GFP_KERNEL
);
465 dev_dbg(&dev
->pdev
->dev
, "memory allocation for ME clients failed.\n");
466 dev
->dev_state
= MEI_DEV_RESETING
;
470 dev
->me_clients
= clients
;
474 * host_client_properties - reads properties for client
476 * @dev: the device structure
480 * = 0 - no more clients.
481 * = 1 - still have clients to send properties request.
483 int mei_host_client_properties(struct mei_device
*dev
)
485 struct mei_msg_hdr
*mei_header
;
486 struct hbm_props_request
*host_cli_req
;
488 u8 client_num
= dev
->me_client_presentation_num
;
490 b
= dev
->me_client_index
;
491 b
= find_next_bit(dev
->me_clients_map
, MEI_CLIENTS_MAX
, b
);
492 if (b
< MEI_CLIENTS_MAX
) {
493 dev
->me_clients
[client_num
].client_id
= b
;
494 dev
->me_clients
[client_num
].mei_flow_ctrl_creds
= 0;
495 mei_header
= (struct mei_msg_hdr
*)&dev
->wr_msg_buf
[0];
496 mei_header
->host_addr
= 0;
497 mei_header
->me_addr
= 0;
498 mei_header
->length
= sizeof(struct hbm_props_request
);
499 mei_header
->msg_complete
= 1;
500 mei_header
->reserved
= 0;
502 host_cli_req
= (struct hbm_props_request
*)&dev
->wr_msg_buf
[1];
504 memset(host_cli_req
, 0, sizeof(struct hbm_props_request
));
506 host_cli_req
->hbm_cmd
= HOST_CLIENT_PROPERTIES_REQ_CMD
;
507 host_cli_req
->address
= b
;
509 if (mei_write_message(dev
, mei_header
,
510 (unsigned char *)host_cli_req
,
511 mei_header
->length
)) {
512 dev
->dev_state
= MEI_DEV_RESETING
;
513 dev_dbg(&dev
->pdev
->dev
, "write send enumeration request message to FW fail.\n");
518 dev
->init_clients_timer
= INIT_CLIENTS_TIMEOUT
;
519 dev
->me_client_index
= b
;
527 * mei_init_file_private - initializes private file structure.
529 * @priv: private file structure to be initialized
530 * @file: the file structure
532 void mei_cl_init(struct mei_cl
*priv
, struct mei_device
*dev
)
534 memset(priv
, 0, sizeof(struct mei_cl
));
535 init_waitqueue_head(&priv
->wait
);
536 init_waitqueue_head(&priv
->rx_wait
);
537 init_waitqueue_head(&priv
->tx_wait
);
538 INIT_LIST_HEAD(&priv
->link
);
539 priv
->reading_state
= MEI_IDLE
;
540 priv
->writing_state
= MEI_IDLE
;
544 int mei_me_cl_by_uuid(const struct mei_device
*dev
, const uuid_le
*cuuid
)
546 int i
, res
= -ENOENT
;
548 for (i
= 0; i
< dev
->me_clients_num
; ++i
)
549 if (uuid_le_cmp(*cuuid
,
550 dev
->me_clients
[i
].props
.protocol_name
) == 0) {
560 * mei_me_cl_update_filext - searches for ME client guid
561 * sets client_id in mei_file_private if found
562 * @dev: the device structure
563 * @cl: private file structure to set client_id in
564 * @cuuid: searched uuid of ME client
565 * @client_id: id of host client to be set in file private structure
567 * returns ME client index
569 int mei_me_cl_update_filext(struct mei_device
*dev
, struct mei_cl
*cl
,
570 const uuid_le
*cuuid
, u8 host_cl_id
)
574 if (!dev
|| !cl
|| !cuuid
)
577 /* check for valid client id */
578 i
= mei_me_cl_by_uuid(dev
, cuuid
);
580 cl
->me_client_id
= dev
->me_clients
[i
].client_id
;
581 cl
->state
= MEI_FILE_CONNECTING
;
582 cl
->host_client_id
= host_cl_id
;
584 list_add_tail(&cl
->link
, &dev
->file_list
);
592 * host_init_iamthif - mei initialization iamthif client.
594 * @dev: the device structure
597 void mei_host_init_iamthif(struct mei_device
*dev
)
600 unsigned char *msg_buf
;
602 mei_cl_init(&dev
->iamthif_cl
, dev
);
603 dev
->iamthif_cl
.state
= MEI_FILE_DISCONNECTED
;
605 /* find ME amthi client */
606 i
= mei_me_cl_update_filext(dev
, &dev
->iamthif_cl
,
607 &mei_amthi_guid
, MEI_IAMTHIF_HOST_CLIENT_ID
);
609 dev_dbg(&dev
->pdev
->dev
, "failed to find iamthif client.\n");
613 /* Assign iamthif_mtu to the value received from ME */
615 dev
->iamthif_mtu
= dev
->me_clients
[i
].props
.max_msg_length
;
616 dev_dbg(&dev
->pdev
->dev
, "IAMTHIF_MTU = %d\n",
617 dev
->me_clients
[i
].props
.max_msg_length
);
619 kfree(dev
->iamthif_msg_buf
);
620 dev
->iamthif_msg_buf
= NULL
;
622 /* allocate storage for ME message buffer */
623 msg_buf
= kcalloc(dev
->iamthif_mtu
,
624 sizeof(unsigned char), GFP_KERNEL
);
626 dev_dbg(&dev
->pdev
->dev
, "memory allocation for ME message buffer failed.\n");
630 dev
->iamthif_msg_buf
= msg_buf
;
632 if (mei_connect(dev
, &dev
->iamthif_cl
)) {
633 dev_dbg(&dev
->pdev
->dev
, "Failed to connect to AMTHI client\n");
634 dev
->iamthif_cl
.state
= MEI_FILE_DISCONNECTED
;
635 dev
->iamthif_cl
.host_client_id
= 0;
637 dev
->iamthif_cl
.timer_count
= CONNECT_TIMEOUT
;
642 * mei_alloc_file_private - allocates a private file structure and sets it up.
643 * @file: the file structure
645 * returns The allocated file or NULL on failure
647 struct mei_cl
*mei_cl_allocate(struct mei_device
*dev
)
651 cl
= kmalloc(sizeof(struct mei_cl
), GFP_KERNEL
);
655 mei_cl_init(cl
, dev
);
663 * mei_disconnect_host_client - sends disconnect message to fw from host client.
665 * @dev: the device structure
666 * @cl: private data of the file object
668 * Locking: called under "dev->device_lock" lock
670 * returns 0 on success, <0 on failure.
672 int mei_disconnect_host_client(struct mei_device
*dev
, struct mei_cl
*cl
)
675 long timeout
= 15; /* 15 seconds */
676 struct mei_cl_cb
*cb
;
681 if (cl
->state
!= MEI_FILE_DISCONNECTING
)
684 cb
= kzalloc(sizeof(struct mei_cl_cb
), GFP_KERNEL
);
688 INIT_LIST_HEAD(&cb
->cb_list
);
689 cb
->file_private
= cl
;
690 cb
->major_file_operations
= MEI_CLOSE
;
691 if (dev
->mei_host_buffer_is_empty
) {
692 dev
->mei_host_buffer_is_empty
= false;
693 if (mei_disconnect(dev
, cl
)) {
695 dev_dbg(&dev
->pdev
->dev
, "failed to call mei_disconnect.\n");
698 mdelay(10); /* Wait for hardware disconnection ready */
699 list_add_tail(&cb
->cb_list
, &dev
->ctrl_rd_list
.mei_cb
.cb_list
);
701 dev_dbg(&dev
->pdev
->dev
, "add disconnect cb to control write list\n");
702 list_add_tail(&cb
->cb_list
,
703 &dev
->ctrl_wr_list
.mei_cb
.cb_list
);
705 mutex_unlock(&dev
->device_lock
);
707 err
= wait_event_timeout(dev
->wait_recvd_msg
,
708 (MEI_FILE_DISCONNECTED
== cl
->state
),
711 mutex_lock(&dev
->device_lock
);
712 if (MEI_FILE_DISCONNECTED
== cl
->state
) {
714 dev_dbg(&dev
->pdev
->dev
, "successfully disconnected from FW client.\n");
717 if (MEI_FILE_DISCONNECTED
!= cl
->state
)
718 dev_dbg(&dev
->pdev
->dev
, "wrong status client disconnect.\n");
721 dev_dbg(&dev
->pdev
->dev
,
722 "wait failed disconnect err=%08x\n",
725 dev_dbg(&dev
->pdev
->dev
, "failed to disconnect from FW client.\n");
728 mei_io_list_flush(&dev
->ctrl_rd_list
, cl
);
729 mei_io_list_flush(&dev
->ctrl_wr_list
, cl
);
731 mei_free_cb_private(cb
);
736 * mei_remove_client_from_file_list -
737 * removes file private data from device file list
739 * @dev: the device structure
740 * @host_client_id: host client id to be removed
742 void mei_remove_client_from_file_list(struct mei_device
*dev
,
745 struct mei_cl
*cl_pos
= NULL
;
746 struct mei_cl
*cl_next
= NULL
;
747 list_for_each_entry_safe(cl_pos
, cl_next
, &dev
->file_list
, link
) {
748 if (host_client_id
== cl_pos
->host_client_id
) {
749 dev_dbg(&dev
->pdev
->dev
, "remove host client = %d, ME client = %d\n",
750 cl_pos
->host_client_id
,
751 cl_pos
->me_client_id
);
752 list_del_init(&cl_pos
->link
);