3 * Intel Management Engine Interface (Intel MEI) Linux driver
4 * Copyright (c) 2003-2011, 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"
27 const uuid_le mei_amthi_guid
= UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac,
28 0xa8, 0x46, 0xe0, 0xff, 0x65,
32 * mei_io_list_init - Sets up a queue list.
34 * @list: An instance io list structure
35 * @dev: the device structure
37 void mei_io_list_init(struct mei_io_list
*list
)
39 /* initialize our queue list */
40 INIT_LIST_HEAD(&list
->mei_cb
.cb_list
);
45 * mei_io_list_flush - removes list entry belonging to cl.
47 * @list: An instance of our list structure
48 * @cl: private data of the file object
50 void mei_io_list_flush(struct mei_io_list
*list
, struct mei_cl
*cl
)
52 struct mei_cl_cb
*cb_pos
= NULL
;
53 struct mei_cl_cb
*cb_next
= NULL
;
55 if (list
->status
!= 0)
58 if (list_empty(&list
->mei_cb
.cb_list
))
61 list_for_each_entry_safe(cb_pos
, cb_next
,
62 &list
->mei_cb
.cb_list
, cb_list
) {
64 struct mei_cl
*cl_tmp
;
65 cl_tmp
= (struct mei_cl
*)cb_pos
->file_private
;
66 if (mei_cl_cmp_id(cl
, cl_tmp
))
67 list_del(&cb_pos
->cb_list
);
72 * mei_cl_flush_queues - flushes queue lists belonging to cl.
74 * @dev: the device structure
75 * @cl: private data of the file object
77 int mei_cl_flush_queues(struct mei_cl
*cl
)
82 dev_dbg(&cl
->dev
->pdev
->dev
, "remove list entry belonging to cl\n");
83 mei_io_list_flush(&cl
->dev
->read_list
, cl
);
84 mei_io_list_flush(&cl
->dev
->write_list
, cl
);
85 mei_io_list_flush(&cl
->dev
->write_waiting_list
, cl
);
86 mei_io_list_flush(&cl
->dev
->ctrl_wr_list
, cl
);
87 mei_io_list_flush(&cl
->dev
->ctrl_rd_list
, cl
);
88 mei_io_list_flush(&cl
->dev
->amthi_cmd_list
, cl
);
89 mei_io_list_flush(&cl
->dev
->amthi_read_complete_list
, cl
);
96 * mei_reset_iamthif_params - initializes mei device iamthif
98 * @dev: the device structure
100 static void mei_reset_iamthif_params(struct mei_device
*dev
)
102 /* reset iamthif parameters. */
103 dev
->iamthif_current_cb
= NULL
;
104 dev
->iamthif_msg_buf_size
= 0;
105 dev
->iamthif_msg_buf_index
= 0;
106 dev
->iamthif_canceled
= false;
107 dev
->iamthif_ioctl
= false;
108 dev
->iamthif_state
= MEI_IAMTHIF_IDLE
;
109 dev
->iamthif_timer
= 0;
113 * init_mei_device - allocates and initializes the mei device structure
115 * @pdev: The pci device structure
117 * returns The mei_device_device pointer on success, NULL on failure.
119 struct mei_device
*mei_device_init(struct pci_dev
*pdev
)
121 struct mei_device
*dev
;
123 dev
= kzalloc(sizeof(struct mei_device
), GFP_KERNEL
);
127 /* setup our list array */
128 INIT_LIST_HEAD(&dev
->file_list
);
129 INIT_LIST_HEAD(&dev
->wd_cl
.link
);
130 INIT_LIST_HEAD(&dev
->iamthif_cl
.link
);
131 mutex_init(&dev
->device_lock
);
132 init_waitqueue_head(&dev
->wait_recvd_msg
);
133 init_waitqueue_head(&dev
->wait_stop_wd
);
134 dev
->mei_state
= MEI_INITIALIZING
;
135 dev
->iamthif_state
= MEI_IAMTHIF_IDLE
;
138 mei_io_list_init(&dev
->read_list
);
139 mei_io_list_init(&dev
->write_list
);
140 mei_io_list_init(&dev
->write_waiting_list
);
141 mei_io_list_init(&dev
->ctrl_wr_list
);
142 mei_io_list_init(&dev
->ctrl_rd_list
);
143 mei_io_list_init(&dev
->amthi_cmd_list
);
144 mei_io_list_init(&dev
->amthi_read_complete_list
);
150 * mei_hw_init - initializes host and fw to start work.
152 * @dev: the device structure
154 * returns 0 on success, <0 on failure.
156 int mei_hw_init(struct mei_device
*dev
)
161 mutex_lock(&dev
->device_lock
);
163 dev
->host_hw_state
= mei_hcsr_read(dev
);
164 dev
->me_hw_state
= mei_mecsr_read(dev
);
165 dev_dbg(&dev
->pdev
->dev
, "host_hw_state = 0x%08x, mestate = 0x%08x.\n",
166 dev
->host_hw_state
, dev
->me_hw_state
);
168 /* acknowledge interrupt and stop interupts */
169 if ((dev
->host_hw_state
& H_IS
) == H_IS
)
170 mei_reg_write(dev
, H_CSR
, dev
->host_hw_state
);
172 dev
->recvd_msg
= false;
173 dev_dbg(&dev
->pdev
->dev
, "reset in start the mei device.\n");
177 dev_dbg(&dev
->pdev
->dev
, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
178 dev
->host_hw_state
, dev
->me_hw_state
);
180 /* wait for ME to turn on ME_RDY */
181 if (!dev
->recvd_msg
) {
182 mutex_unlock(&dev
->device_lock
);
183 err
= wait_event_interruptible_timeout(dev
->wait_recvd_msg
,
184 dev
->recvd_msg
, MEI_INTEROP_TIMEOUT
);
185 mutex_lock(&dev
->device_lock
);
188 if (err
<= 0 && !dev
->recvd_msg
) {
189 dev
->mei_state
= MEI_DISABLED
;
190 dev_dbg(&dev
->pdev
->dev
,
191 "wait_event_interruptible_timeout failed"
192 "on wait for ME to turn on ME_RDY.\n");
197 if (!(((dev
->host_hw_state
& H_RDY
) == H_RDY
) &&
198 ((dev
->me_hw_state
& ME_RDY_HRA
) == ME_RDY_HRA
))) {
199 dev
->mei_state
= MEI_DISABLED
;
200 dev_dbg(&dev
->pdev
->dev
,
201 "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
202 dev
->host_hw_state
, dev
->me_hw_state
);
204 if (!(dev
->host_hw_state
& H_RDY
))
205 dev_dbg(&dev
->pdev
->dev
, "host turn off H_RDY.\n");
207 if (!(dev
->me_hw_state
& ME_RDY_HRA
))
208 dev_dbg(&dev
->pdev
->dev
, "ME turn off ME_RDY.\n");
210 printk(KERN_ERR
"mei: link layer initialization failed.\n");
215 if (dev
->version
.major_version
!= HBM_MAJOR_VERSION
||
216 dev
->version
.minor_version
!= HBM_MINOR_VERSION
) {
217 dev_dbg(&dev
->pdev
->dev
, "MEI start failed.\n");
222 dev
->recvd_msg
= false;
223 dev_dbg(&dev
->pdev
->dev
, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
224 dev
->host_hw_state
, dev
->me_hw_state
);
225 dev_dbg(&dev
->pdev
->dev
, "ME turn on ME_RDY and host turn on H_RDY.\n");
226 dev_dbg(&dev
->pdev
->dev
, "link layer has been established.\n");
227 dev_dbg(&dev
->pdev
->dev
, "MEI start success.\n");
231 mutex_unlock(&dev
->device_lock
);
236 * mei_hw_reset - resets fw via mei csr register.
238 * @dev: the device structure
239 * @interrupts_enabled: if interrupt should be enabled after reset.
241 static void mei_hw_reset(struct mei_device
*dev
, int interrupts_enabled
)
243 dev
->host_hw_state
|= (H_RST
| H_IG
);
245 if (interrupts_enabled
)
246 mei_enable_interrupts(dev
);
248 mei_disable_interrupts(dev
);
252 * mei_reset - resets host and fw.
254 * @dev: the device structure
255 * @interrupts_enabled: if interrupt should be enabled after reset.
257 void mei_reset(struct mei_device
*dev
, int interrupts_enabled
)
259 struct mei_cl
*cl_pos
= NULL
;
260 struct mei_cl
*cl_next
= NULL
;
261 struct mei_cl_cb
*cb_pos
= NULL
;
262 struct mei_cl_cb
*cb_next
= NULL
;
265 if (dev
->mei_state
== MEI_RECOVERING_FROM_RESET
) {
266 dev
->need_reset
= true;
270 unexpected
= (dev
->mei_state
!= MEI_INITIALIZING
&&
271 dev
->mei_state
!= MEI_DISABLED
&&
272 dev
->mei_state
!= MEI_POWER_DOWN
&&
273 dev
->mei_state
!= MEI_POWER_UP
);
275 dev
->host_hw_state
= mei_hcsr_read(dev
);
277 dev_dbg(&dev
->pdev
->dev
, "before reset host_hw_state = 0x%08x.\n",
280 mei_hw_reset(dev
, interrupts_enabled
);
282 dev
->host_hw_state
&= ~H_RST
;
283 dev
->host_hw_state
|= H_IG
;
287 dev_dbg(&dev
->pdev
->dev
, "currently saved host_hw_state = 0x%08x.\n",
290 dev
->need_reset
= false;
292 if (dev
->mei_state
!= MEI_INITIALIZING
) {
293 if (dev
->mei_state
!= MEI_DISABLED
&&
294 dev
->mei_state
!= MEI_POWER_DOWN
)
295 dev
->mei_state
= MEI_RESETING
;
297 list_for_each_entry_safe(cl_pos
,
298 cl_next
, &dev
->file_list
, link
) {
299 cl_pos
->state
= MEI_FILE_DISCONNECTED
;
300 cl_pos
->mei_flow_ctrl_creds
= 0;
301 cl_pos
->read_cb
= NULL
;
302 cl_pos
->timer_count
= 0;
304 /* remove entry if already in list */
305 dev_dbg(&dev
->pdev
->dev
, "list del iamthif and wd file list.\n");
306 mei_remove_client_from_file_list(dev
,
307 dev
->wd_cl
.host_client_id
);
309 mei_remove_client_from_file_list(dev
,
310 dev
->iamthif_cl
.host_client_id
);
312 mei_reset_iamthif_params(dev
);
313 dev
->wd_due_counter
= 0;
314 dev
->extra_write_index
= 0;
317 dev
->me_clients_num
= 0;
320 dev
->wd_pending
= false;
322 /* update the state of the registers after reset */
323 dev
->host_hw_state
= mei_hcsr_read(dev
);
324 dev
->me_hw_state
= mei_mecsr_read(dev
);
326 dev_dbg(&dev
->pdev
->dev
, "after reset host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
327 dev
->host_hw_state
, dev
->me_hw_state
);
330 dev_warn(&dev
->pdev
->dev
, "unexpected reset.\n");
332 /* Wake up all readings so they can be interrupted */
333 list_for_each_entry_safe(cl_pos
, cl_next
, &dev
->file_list
, link
) {
334 if (waitqueue_active(&cl_pos
->rx_wait
)) {
335 dev_dbg(&dev
->pdev
->dev
, "Waking up client!\n");
336 wake_up_interruptible(&cl_pos
->rx_wait
);
339 /* remove all waiting requests */
340 if (dev
->write_list
.status
== 0 &&
341 !list_empty(&dev
->write_list
.mei_cb
.cb_list
)) {
342 list_for_each_entry_safe(cb_pos
, cb_next
,
343 &dev
->write_list
.mei_cb
.cb_list
, cb_list
) {
345 list_del(&cb_pos
->cb_list
);
346 mei_free_cb_private(cb_pos
);
356 * host_start_message - mei host sends start message.
358 * @dev: the device structure
362 void mei_host_start_message(struct mei_device
*dev
)
364 struct mei_msg_hdr
*mei_hdr
;
365 struct hbm_host_version_request
*host_start_req
;
367 /* host start message */
368 mei_hdr
= (struct mei_msg_hdr
*) &dev
->wr_msg_buf
[0];
369 mei_hdr
->host_addr
= 0;
370 mei_hdr
->me_addr
= 0;
371 mei_hdr
->length
= sizeof(struct hbm_host_version_request
);
372 mei_hdr
->msg_complete
= 1;
373 mei_hdr
->reserved
= 0;
376 (struct hbm_host_version_request
*) &dev
->wr_msg_buf
[1];
377 memset(host_start_req
, 0, sizeof(struct hbm_host_version_request
));
378 host_start_req
->cmd
.cmd
= HOST_START_REQ_CMD
;
379 host_start_req
->host_version
.major_version
= HBM_MAJOR_VERSION
;
380 host_start_req
->host_version
.minor_version
= HBM_MINOR_VERSION
;
381 dev
->recvd_msg
= false;
382 if (!mei_write_message(dev
, mei_hdr
,
383 (unsigned char *) (host_start_req
),
385 dev_dbg(&dev
->pdev
->dev
, "write send version message to FW fail.\n");
386 dev
->mei_state
= MEI_RESETING
;
389 dev
->init_clients_state
= MEI_START_MESSAGE
;
390 dev
->init_clients_timer
= INIT_CLIENTS_TIMEOUT
;
395 * host_enum_clients_message - host sends enumeration client request message.
397 * @dev: the device structure
401 void mei_host_enum_clients_message(struct mei_device
*dev
)
403 struct mei_msg_hdr
*mei_hdr
;
404 struct hbm_host_enum_request
*host_enum_req
;
405 mei_hdr
= (struct mei_msg_hdr
*) &dev
->wr_msg_buf
[0];
406 /* enumerate clients */
407 mei_hdr
->host_addr
= 0;
408 mei_hdr
->me_addr
= 0;
409 mei_hdr
->length
= sizeof(struct hbm_host_enum_request
);
410 mei_hdr
->msg_complete
= 1;
411 mei_hdr
->reserved
= 0;
413 host_enum_req
= (struct hbm_host_enum_request
*) &dev
->wr_msg_buf
[1];
414 memset(host_enum_req
, 0, sizeof(struct hbm_host_enum_request
));
415 host_enum_req
->cmd
.cmd
= HOST_ENUM_REQ_CMD
;
416 if (!mei_write_message(dev
, mei_hdr
,
417 (unsigned char *) (host_enum_req
),
419 dev
->mei_state
= MEI_RESETING
;
420 dev_dbg(&dev
->pdev
->dev
, "write send enumeration request message to FW fail.\n");
423 dev
->init_clients_state
= MEI_ENUM_CLIENTS_MESSAGE
;
424 dev
->init_clients_timer
= INIT_CLIENTS_TIMEOUT
;
430 * allocate_me_clients_storage - allocates storage for me clients
432 * @dev: the device structure
436 void mei_allocate_me_clients_storage(struct mei_device
*dev
)
438 struct mei_me_client
*clients
;
441 /* count how many ME clients we have */
442 for_each_set_bit(b
, dev
->me_clients_map
, MEI_CLIENTS_MAX
)
443 dev
->me_clients_num
++;
445 if (dev
->me_clients_num
<= 0)
449 if (dev
->me_clients
!= NULL
) {
450 kfree(dev
->me_clients
);
451 dev
->me_clients
= NULL
;
453 dev_dbg(&dev
->pdev
->dev
, "memory allocation for ME clients size=%zd.\n",
454 dev
->me_clients_num
* sizeof(struct mei_me_client
));
455 /* allocate storage for ME clients representation */
456 clients
= kcalloc(dev
->me_clients_num
,
457 sizeof(struct mei_me_client
), GFP_KERNEL
);
459 dev_dbg(&dev
->pdev
->dev
, "memory allocation for ME clients failed.\n");
460 dev
->mei_state
= MEI_RESETING
;
464 dev
->me_clients
= clients
;
468 * host_client_properties - reads properties for client
470 * @dev: the device structure
474 void mei_host_client_properties(struct mei_device
*dev
)
476 struct mei_msg_hdr
*mei_header
;
477 struct hbm_props_request
*host_cli_req
;
479 u8 client_num
= dev
->me_client_presentation_num
;
481 b
= dev
->me_client_index
;
482 b
= find_next_bit(dev
->me_clients_map
, MEI_CLIENTS_MAX
, b
);
483 if (b
< MEI_CLIENTS_MAX
) {
484 dev
->me_clients
[client_num
].client_id
= b
;
485 dev
->me_clients
[client_num
].mei_flow_ctrl_creds
= 0;
486 mei_header
= (struct mei_msg_hdr
*)&dev
->wr_msg_buf
[0];
487 mei_header
->host_addr
= 0;
488 mei_header
->me_addr
= 0;
489 mei_header
->length
= sizeof(struct hbm_props_request
);
490 mei_header
->msg_complete
= 1;
491 mei_header
->reserved
= 0;
493 host_cli_req
= (struct hbm_props_request
*)&dev
->wr_msg_buf
[1];
495 memset(host_cli_req
, 0, sizeof(struct hbm_props_request
));
497 host_cli_req
->cmd
.cmd
= HOST_CLIENT_PROPERTIES_REQ_CMD
;
498 host_cli_req
->address
= b
;
500 if (!mei_write_message(dev
, mei_header
,
501 (unsigned char *)host_cli_req
,
502 mei_header
->length
)) {
503 dev
->mei_state
= MEI_RESETING
;
504 dev_dbg(&dev
->pdev
->dev
, "write send enumeration request message to FW fail.\n");
509 dev
->init_clients_timer
= INIT_CLIENTS_TIMEOUT
;
510 dev
->me_client_index
= b
;
516 * Clear Map for indicating now ME clients
517 * with associated host client
519 bitmap_zero(dev
->host_clients_map
, MEI_CLIENTS_MAX
);
520 dev
->open_handle_count
= 0;
521 bitmap_set(dev
->host_clients_map
, 0, 3);
522 dev
->mei_state
= MEI_ENABLED
;
524 mei_wd_host_init(dev
);
529 * mei_init_file_private - initializes private file structure.
531 * @priv: private file structure to be initialized
532 * @file: the file structure
534 void mei_cl_init(struct mei_cl
*priv
, struct mei_device
*dev
)
536 memset(priv
, 0, sizeof(struct mei_cl
));
537 init_waitqueue_head(&priv
->wait
);
538 init_waitqueue_head(&priv
->rx_wait
);
539 init_waitqueue_head(&priv
->tx_wait
);
540 INIT_LIST_HEAD(&priv
->link
);
541 priv
->reading_state
= MEI_IDLE
;
542 priv
->writing_state
= MEI_IDLE
;
546 int mei_find_me_client_index(const struct mei_device
*dev
, uuid_le cuuid
)
550 for (i
= 0; i
< dev
->me_clients_num
; ++i
)
551 if (uuid_le_cmp(cuuid
,
552 dev
->me_clients
[i
].props
.protocol_name
) == 0) {
562 * mei_find_me_client_update_filext - searches for ME client guid
563 * sets client_id in mei_file_private if found
564 * @dev: the device structure
565 * @priv: private file structure to set client_id in
566 * @cguid: searched guid of ME client
567 * @client_id: id of host client to be set in file private structure
569 * returns ME client index
571 u8
mei_find_me_client_update_filext(struct mei_device
*dev
, struct mei_cl
*priv
,
572 const uuid_le
*cguid
, u8 client_id
)
576 if (!dev
|| !priv
|| !cguid
)
579 /* check for valid client id */
580 i
= mei_find_me_client_index(dev
, *cguid
);
582 priv
->me_client_id
= dev
->me_clients
[i
].client_id
;
583 priv
->state
= MEI_FILE_CONNECTING
;
584 priv
->host_client_id
= client_id
;
586 list_add_tail(&priv
->link
, &dev
->file_list
);
594 * host_init_iamthif - mei initialization iamthif client.
596 * @dev: the device structure
599 void mei_host_init_iamthif(struct mei_device
*dev
)
602 unsigned char *msg_buf
;
604 mei_cl_init(&dev
->iamthif_cl
, dev
);
605 dev
->iamthif_cl
.state
= MEI_FILE_DISCONNECTED
;
607 /* find ME amthi client */
608 i
= mei_find_me_client_update_filext(dev
, &dev
->iamthif_cl
,
609 &mei_amthi_guid
, MEI_IAMTHIF_HOST_CLIENT_ID
);
610 if (dev
->iamthif_cl
.state
!= MEI_FILE_CONNECTING
) {
611 dev_dbg(&dev
->pdev
->dev
, "failed to find iamthif client.\n");
615 /* Do not render the system unusable when iamthif_mtu is not equal to
616 the value received from ME.
617 Assign iamthif_mtu to the value received from ME in order to solve the
618 hardware macro incompatibility. */
620 dev_dbg(&dev
->pdev
->dev
, "[DEFAULT] IAMTHIF = %d\n", dev
->iamthif_mtu
);
621 dev
->iamthif_mtu
= dev
->me_clients
[i
].props
.max_msg_length
;
622 dev_dbg(&dev
->pdev
->dev
,
624 dev
->me_clients
[i
].props
.max_msg_length
);
626 kfree(dev
->iamthif_msg_buf
);
627 dev
->iamthif_msg_buf
= NULL
;
629 /* allocate storage for ME message buffer */
630 msg_buf
= kcalloc(dev
->iamthif_mtu
,
631 sizeof(unsigned char), GFP_KERNEL
);
633 dev_dbg(&dev
->pdev
->dev
, "memory allocation for ME message buffer failed.\n");
637 dev
->iamthif_msg_buf
= msg_buf
;
639 if (!mei_connect(dev
, &dev
->iamthif_cl
)) {
640 dev_dbg(&dev
->pdev
->dev
, "Failed to connect to AMTHI client\n");
641 dev
->iamthif_cl
.state
= MEI_FILE_DISCONNECTED
;
642 dev
->iamthif_cl
.host_client_id
= 0;
644 dev
->iamthif_cl
.timer_count
= CONNECT_TIMEOUT
;
649 * mei_alloc_file_private - allocates a private file structure and sets it up.
650 * @file: the file structure
652 * returns The allocated file or NULL on failure
654 struct mei_cl
*mei_cl_allocate(struct mei_device
*dev
)
658 cl
= kmalloc(sizeof(struct mei_cl
), GFP_KERNEL
);
662 mei_cl_init(cl
, dev
);
670 * mei_disconnect_host_client - sends disconnect message to fw from host client.
672 * @dev: the device structure
673 * @cl: private data of the file object
675 * Locking: called under "dev->device_lock" lock
677 * returns 0 on success, <0 on failure.
679 int mei_disconnect_host_client(struct mei_device
*dev
, struct mei_cl
*cl
)
682 long timeout
= 15; /* 15 seconds */
683 struct mei_cl_cb
*cb
;
688 if (cl
->state
!= MEI_FILE_DISCONNECTING
)
691 cb
= kzalloc(sizeof(struct mei_cl_cb
), GFP_KERNEL
);
695 INIT_LIST_HEAD(&cb
->cb_list
);
696 cb
->file_private
= cl
;
697 cb
->major_file_operations
= MEI_CLOSE
;
698 if (dev
->mei_host_buffer_is_empty
) {
699 dev
->mei_host_buffer_is_empty
= false;
700 if (mei_disconnect(dev
, cl
)) {
701 mdelay(10); /* Wait for hardware disconnection ready */
702 list_add_tail(&cb
->cb_list
,
703 &dev
->ctrl_rd_list
.mei_cb
.cb_list
);
706 dev_dbg(&dev
->pdev
->dev
, "failed to call mei_disconnect.\n");
710 dev_dbg(&dev
->pdev
->dev
, "add disconnect cb to control write list\n");
711 list_add_tail(&cb
->cb_list
,
712 &dev
->ctrl_wr_list
.mei_cb
.cb_list
);
714 mutex_unlock(&dev
->device_lock
);
716 err
= wait_event_timeout(dev
->wait_recvd_msg
,
717 (MEI_FILE_DISCONNECTED
== cl
->state
),
720 mutex_lock(&dev
->device_lock
);
721 if (MEI_FILE_DISCONNECTED
== cl
->state
) {
723 dev_dbg(&dev
->pdev
->dev
, "successfully disconnected from FW client.\n");
726 if (MEI_FILE_DISCONNECTED
!= cl
->state
)
727 dev_dbg(&dev
->pdev
->dev
, "wrong status client disconnect.\n");
730 dev_dbg(&dev
->pdev
->dev
,
731 "wait failed disconnect err=%08x\n",
734 dev_dbg(&dev
->pdev
->dev
, "failed to disconnect from FW client.\n");
737 mei_io_list_flush(&dev
->ctrl_rd_list
, cl
);
738 mei_io_list_flush(&dev
->ctrl_wr_list
, cl
);
740 mei_free_cb_private(cb
);
745 * mei_remove_client_from_file_list -
746 * removes file private data from device file list
748 * @dev: the device structure
749 * @host_client_id: host client id to be removed
751 void mei_remove_client_from_file_list(struct mei_device
*dev
,
754 struct mei_cl
*cl_pos
= NULL
;
755 struct mei_cl
*cl_next
= NULL
;
756 list_for_each_entry_safe(cl_pos
, cl_next
, &dev
->file_list
, link
) {
757 if (host_client_id
== cl_pos
->host_client_id
) {
758 dev_dbg(&dev
->pdev
->dev
, "remove host client = %d, ME client = %d\n",
759 cl_pos
->host_client_id
,
760 cl_pos
->me_client_id
);
761 list_del_init(&cl_pos
->link
);