Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Intel Management Engine Interface (Intel MEI) Linux driver |
Tomas Winkler | 733ba91 | 2012-02-09 19:25:53 +0200 | [diff] [blame] | 4 | * Copyright (c) 2003-2012, Intel Corporation. |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 5 | * |
| 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. |
| 9 | * |
| 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 |
| 13 | * more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <linux/pci.h> |
| 18 | #include <linux/sched.h> |
| 19 | #include <linux/wait.h> |
| 20 | #include <linux/delay.h> |
| 21 | |
| 22 | #include "mei_dev.h" |
| 23 | #include "hw.h" |
| 24 | #include "interface.h" |
Tomas Winkler | 4f3afe1 | 2012-05-09 16:38:59 +0300 | [diff] [blame] | 25 | #include <linux/mei.h> |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 26 | |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 27 | const char *mei_dev_state_str(int state) |
| 28 | { |
| 29 | #define MEI_DEV_STATE(state) case MEI_DEV_##state: return #state |
| 30 | switch (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); |
| 39 | default: |
| 40 | return "unkown"; |
| 41 | } |
| 42 | #undef MEI_DEV_STATE |
| 43 | } |
| 44 | |
| 45 | |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 46 | /** |
Tomas Winkler | 0288c7c | 2011-06-06 10:44:34 +0300 | [diff] [blame] | 47 | * mei_io_list_flush - removes list entry belonging to cl. |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 48 | * |
| 49 | * @list: An instance of our list structure |
| 50 | * @cl: private data of the file object |
| 51 | */ |
Tomas Winkler | fb601ad | 2012-10-15 12:06:48 +0200 | [diff] [blame] | 52 | void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 53 | { |
Tomas Winkler | 3a5352f | 2011-12-04 16:16:27 +0200 | [diff] [blame] | 54 | struct mei_cl_cb *pos; |
| 55 | struct mei_cl_cb *next; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 56 | |
Tomas Winkler | fb601ad | 2012-10-15 12:06:48 +0200 | [diff] [blame] | 57 | list_for_each_entry_safe(pos, next, &list->list, list) { |
Tomas Winkler | 3a5352f | 2011-12-04 16:16:27 +0200 | [diff] [blame] | 58 | if (pos->file_private) { |
Tomas Winkler | 0288c7c | 2011-06-06 10:44:34 +0300 | [diff] [blame] | 59 | struct mei_cl *cl_tmp; |
Tomas Winkler | b7cd2d9 | 2011-11-27 21:43:34 +0200 | [diff] [blame] | 60 | cl_tmp = (struct mei_cl *)pos->file_private; |
Tomas Winkler | 0288c7c | 2011-06-06 10:44:34 +0300 | [diff] [blame] | 61 | if (mei_cl_cmp_id(cl, cl_tmp)) |
Tomas Winkler | fb601ad | 2012-10-15 12:06:48 +0200 | [diff] [blame] | 62 | list_del(&pos->list); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | } |
Tomas Winkler | 0288c7c | 2011-06-06 10:44:34 +0300 | [diff] [blame] | 66 | /** |
| 67 | * mei_cl_flush_queues - flushes queue lists belonging to cl. |
| 68 | * |
| 69 | * @dev: the device structure |
| 70 | * @cl: private data of the file object |
| 71 | */ |
| 72 | int mei_cl_flush_queues(struct mei_cl *cl) |
| 73 | { |
| 74 | if (!cl || !cl->dev) |
| 75 | return -EINVAL; |
| 76 | |
| 77 | dev_dbg(&cl->dev->pdev->dev, "remove list entry belonging to cl\n"); |
| 78 | mei_io_list_flush(&cl->dev->read_list, cl); |
| 79 | mei_io_list_flush(&cl->dev->write_list, cl); |
| 80 | mei_io_list_flush(&cl->dev->write_waiting_list, cl); |
| 81 | mei_io_list_flush(&cl->dev->ctrl_wr_list, cl); |
| 82 | mei_io_list_flush(&cl->dev->ctrl_rd_list, cl); |
| 83 | mei_io_list_flush(&cl->dev->amthi_cmd_list, cl); |
| 84 | mei_io_list_flush(&cl->dev->amthi_read_complete_list, cl); |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 89 | |
| 90 | /** |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 91 | * init_mei_device - allocates and initializes the mei device structure |
| 92 | * |
| 93 | * @pdev: The pci device structure |
| 94 | * |
| 95 | * returns The mei_device_device pointer on success, NULL on failure. |
| 96 | */ |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 97 | struct mei_device *mei_device_init(struct pci_dev *pdev) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 98 | { |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 99 | struct mei_device *dev; |
| 100 | |
| 101 | dev = kzalloc(sizeof(struct mei_device), GFP_KERNEL); |
| 102 | if (!dev) |
| 103 | return NULL; |
| 104 | |
| 105 | /* setup our list array */ |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 106 | INIT_LIST_HEAD(&dev->file_list); |
| 107 | INIT_LIST_HEAD(&dev->wd_cl.link); |
| 108 | INIT_LIST_HEAD(&dev->iamthif_cl.link); |
| 109 | mutex_init(&dev->device_lock); |
| 110 | init_waitqueue_head(&dev->wait_recvd_msg); |
| 111 | init_waitqueue_head(&dev->wait_stop_wd); |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 112 | dev->dev_state = MEI_DEV_INITIALIZING; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 113 | dev->iamthif_state = MEI_IAMTHIF_IDLE; |
Oren Weil | 9ce178e | 2011-09-07 09:03:09 +0300 | [diff] [blame] | 114 | dev->wd_interface_reg = false; |
Tomas Winkler | 0288c7c | 2011-06-06 10:44:34 +0300 | [diff] [blame] | 115 | |
| 116 | |
| 117 | mei_io_list_init(&dev->read_list); |
| 118 | mei_io_list_init(&dev->write_list); |
| 119 | mei_io_list_init(&dev->write_waiting_list); |
| 120 | mei_io_list_init(&dev->ctrl_wr_list); |
| 121 | mei_io_list_init(&dev->ctrl_rd_list); |
| 122 | mei_io_list_init(&dev->amthi_cmd_list); |
| 123 | mei_io_list_init(&dev->amthi_read_complete_list); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 124 | dev->pdev = pdev; |
| 125 | return dev; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * mei_hw_init - initializes host and fw to start work. |
| 130 | * |
| 131 | * @dev: the device structure |
| 132 | * |
| 133 | * returns 0 on success, <0 on failure. |
| 134 | */ |
| 135 | int mei_hw_init(struct mei_device *dev) |
| 136 | { |
| 137 | int err = 0; |
| 138 | int ret; |
| 139 | |
| 140 | mutex_lock(&dev->device_lock); |
| 141 | |
| 142 | dev->host_hw_state = mei_hcsr_read(dev); |
| 143 | dev->me_hw_state = mei_mecsr_read(dev); |
| 144 | dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, mestate = 0x%08x.\n", |
| 145 | dev->host_hw_state, dev->me_hw_state); |
| 146 | |
| 147 | /* acknowledge interrupt and stop interupts */ |
| 148 | if ((dev->host_hw_state & H_IS) == H_IS) |
| 149 | mei_reg_write(dev, H_CSR, dev->host_hw_state); |
| 150 | |
Tomas Winkler | 24aadc8 | 2012-06-25 23:46:27 +0300 | [diff] [blame] | 151 | /* Doesn't change in runtime */ |
| 152 | dev->hbuf_depth = (dev->host_hw_state & H_CBD) >> 24; |
| 153 | |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 154 | dev->recvd_msg = false; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 155 | dev_dbg(&dev->pdev->dev, "reset in start the mei device.\n"); |
| 156 | |
| 157 | mei_reset(dev, 1); |
| 158 | |
| 159 | dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n", |
| 160 | dev->host_hw_state, dev->me_hw_state); |
| 161 | |
| 162 | /* wait for ME to turn on ME_RDY */ |
| 163 | if (!dev->recvd_msg) { |
| 164 | mutex_unlock(&dev->device_lock); |
| 165 | err = wait_event_interruptible_timeout(dev->wait_recvd_msg, |
Tomas Winkler | 3870c32 | 2012-11-01 21:17:14 +0200 | [diff] [blame] | 166 | dev->recvd_msg, |
| 167 | mei_secs_to_jiffies(MEI_INTEROP_TIMEOUT)); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 168 | mutex_lock(&dev->device_lock); |
| 169 | } |
| 170 | |
Tomas Winkler | a534bb6 | 2011-06-13 16:39:31 +0300 | [diff] [blame] | 171 | if (err <= 0 && !dev->recvd_msg) { |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 172 | dev->dev_state = MEI_DEV_DISABLED; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 173 | dev_dbg(&dev->pdev->dev, |
| 174 | "wait_event_interruptible_timeout failed" |
| 175 | "on wait for ME to turn on ME_RDY.\n"); |
| 176 | ret = -ENODEV; |
| 177 | goto out; |
| 178 | } |
| 179 | |
| 180 | if (!(((dev->host_hw_state & H_RDY) == H_RDY) && |
| 181 | ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA))) { |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 182 | dev->dev_state = MEI_DEV_DISABLED; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 183 | dev_dbg(&dev->pdev->dev, |
| 184 | "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n", |
| 185 | dev->host_hw_state, dev->me_hw_state); |
| 186 | |
Dan Carpenter | 8eb73c6 | 2011-06-09 10:18:23 +0300 | [diff] [blame] | 187 | if (!(dev->host_hw_state & H_RDY)) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 188 | dev_dbg(&dev->pdev->dev, "host turn off H_RDY.\n"); |
| 189 | |
Dan Carpenter | 8eb73c6 | 2011-06-09 10:18:23 +0300 | [diff] [blame] | 190 | if (!(dev->me_hw_state & ME_RDY_HRA)) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 191 | dev_dbg(&dev->pdev->dev, "ME turn off ME_RDY.\n"); |
| 192 | |
Tomas Winkler | d39a464 | 2012-03-19 17:58:42 +0200 | [diff] [blame] | 193 | dev_err(&dev->pdev->dev, "link layer initialization failed.\n"); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 194 | ret = -ENODEV; |
| 195 | goto out; |
| 196 | } |
| 197 | |
| 198 | if (dev->version.major_version != HBM_MAJOR_VERSION || |
| 199 | dev->version.minor_version != HBM_MINOR_VERSION) { |
| 200 | dev_dbg(&dev->pdev->dev, "MEI start failed.\n"); |
| 201 | ret = -ENODEV; |
| 202 | goto out; |
| 203 | } |
| 204 | |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 205 | dev->recvd_msg = false; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 206 | dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n", |
| 207 | dev->host_hw_state, dev->me_hw_state); |
| 208 | dev_dbg(&dev->pdev->dev, "ME turn on ME_RDY and host turn on H_RDY.\n"); |
| 209 | dev_dbg(&dev->pdev->dev, "link layer has been established.\n"); |
| 210 | dev_dbg(&dev->pdev->dev, "MEI start success.\n"); |
| 211 | ret = 0; |
| 212 | |
| 213 | out: |
| 214 | mutex_unlock(&dev->device_lock); |
| 215 | return ret; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * mei_hw_reset - resets fw via mei csr register. |
| 220 | * |
| 221 | * @dev: the device structure |
| 222 | * @interrupts_enabled: if interrupt should be enabled after reset. |
| 223 | */ |
| 224 | static void mei_hw_reset(struct mei_device *dev, int interrupts_enabled) |
| 225 | { |
| 226 | dev->host_hw_state |= (H_RST | H_IG); |
| 227 | |
| 228 | if (interrupts_enabled) |
| 229 | mei_enable_interrupts(dev); |
| 230 | else |
| 231 | mei_disable_interrupts(dev); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * mei_reset - resets host and fw. |
| 236 | * |
| 237 | * @dev: the device structure |
| 238 | * @interrupts_enabled: if interrupt should be enabled after reset. |
| 239 | */ |
| 240 | void mei_reset(struct mei_device *dev, int interrupts_enabled) |
| 241 | { |
| 242 | struct mei_cl *cl_pos = NULL; |
| 243 | struct mei_cl *cl_next = NULL; |
| 244 | struct mei_cl_cb *cb_pos = NULL; |
| 245 | struct mei_cl_cb *cb_next = NULL; |
| 246 | bool unexpected; |
| 247 | |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 248 | if (dev->dev_state == MEI_DEV_RECOVERING_FROM_RESET) { |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 249 | dev->need_reset = true; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 250 | return; |
| 251 | } |
| 252 | |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 253 | unexpected = (dev->dev_state != MEI_DEV_INITIALIZING && |
| 254 | dev->dev_state != MEI_DEV_DISABLED && |
| 255 | dev->dev_state != MEI_DEV_POWER_DOWN && |
| 256 | dev->dev_state != MEI_DEV_POWER_UP); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 257 | |
| 258 | dev->host_hw_state = mei_hcsr_read(dev); |
| 259 | |
| 260 | dev_dbg(&dev->pdev->dev, "before reset host_hw_state = 0x%08x.\n", |
| 261 | dev->host_hw_state); |
| 262 | |
| 263 | mei_hw_reset(dev, interrupts_enabled); |
| 264 | |
| 265 | dev->host_hw_state &= ~H_RST; |
| 266 | dev->host_hw_state |= H_IG; |
| 267 | |
| 268 | mei_hcsr_set(dev); |
| 269 | |
| 270 | dev_dbg(&dev->pdev->dev, "currently saved host_hw_state = 0x%08x.\n", |
| 271 | dev->host_hw_state); |
| 272 | |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 273 | dev->need_reset = false; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 274 | |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 275 | if (dev->dev_state != MEI_DEV_INITIALIZING) { |
| 276 | if (dev->dev_state != MEI_DEV_DISABLED && |
| 277 | dev->dev_state != MEI_DEV_POWER_DOWN) |
| 278 | dev->dev_state = MEI_DEV_RESETING; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 279 | |
| 280 | list_for_each_entry_safe(cl_pos, |
| 281 | cl_next, &dev->file_list, link) { |
| 282 | cl_pos->state = MEI_FILE_DISCONNECTED; |
| 283 | cl_pos->mei_flow_ctrl_creds = 0; |
| 284 | cl_pos->read_cb = NULL; |
| 285 | cl_pos->timer_count = 0; |
| 286 | } |
| 287 | /* remove entry if already in list */ |
| 288 | dev_dbg(&dev->pdev->dev, "list del iamthif and wd file list.\n"); |
| 289 | mei_remove_client_from_file_list(dev, |
| 290 | dev->wd_cl.host_client_id); |
| 291 | |
| 292 | mei_remove_client_from_file_list(dev, |
| 293 | dev->iamthif_cl.host_client_id); |
| 294 | |
Tomas Winkler | 19838fb | 2012-11-01 21:17:15 +0200 | [diff] [blame^] | 295 | mei_amthif_reset_params(dev); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 296 | dev->extra_write_index = 0; |
| 297 | } |
| 298 | |
Tomas Winkler | cf9673d | 2011-06-06 10:44:33 +0300 | [diff] [blame] | 299 | dev->me_clients_num = 0; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 300 | dev->rd_msg_hdr = 0; |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 301 | dev->wd_pending = false; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 302 | |
| 303 | /* update the state of the registers after reset */ |
| 304 | dev->host_hw_state = mei_hcsr_read(dev); |
| 305 | dev->me_hw_state = mei_mecsr_read(dev); |
| 306 | |
| 307 | dev_dbg(&dev->pdev->dev, "after reset host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n", |
| 308 | dev->host_hw_state, dev->me_hw_state); |
| 309 | |
| 310 | if (unexpected) |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 311 | dev_warn(&dev->pdev->dev, "unexpected reset: dev_state = %s\n", |
| 312 | mei_dev_state_str(dev->dev_state)); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 313 | |
| 314 | /* Wake up all readings so they can be interrupted */ |
| 315 | list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) { |
| 316 | if (waitqueue_active(&cl_pos->rx_wait)) { |
| 317 | dev_dbg(&dev->pdev->dev, "Waking up client!\n"); |
| 318 | wake_up_interruptible(&cl_pos->rx_wait); |
| 319 | } |
| 320 | } |
| 321 | /* remove all waiting requests */ |
Tomas Winkler | fb601ad | 2012-10-15 12:06:48 +0200 | [diff] [blame] | 322 | list_for_each_entry_safe(cb_pos, cb_next, &dev->write_list.list, list) { |
| 323 | list_del(&cb_pos->list); |
Tomas Winkler | 601a1ef | 2012-10-09 16:50:20 +0200 | [diff] [blame] | 324 | mei_io_cb_free(cb_pos); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | |
| 328 | |
| 329 | |
| 330 | /** |
| 331 | * host_start_message - mei host sends start message. |
| 332 | * |
| 333 | * @dev: the device structure |
| 334 | * |
| 335 | * returns none. |
| 336 | */ |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 337 | void mei_host_start_message(struct mei_device *dev) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 338 | { |
| 339 | struct mei_msg_hdr *mei_hdr; |
| 340 | struct hbm_host_version_request *host_start_req; |
| 341 | |
| 342 | /* host start message */ |
| 343 | mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; |
| 344 | mei_hdr->host_addr = 0; |
| 345 | mei_hdr->me_addr = 0; |
| 346 | mei_hdr->length = sizeof(struct hbm_host_version_request); |
| 347 | mei_hdr->msg_complete = 1; |
| 348 | mei_hdr->reserved = 0; |
| 349 | |
| 350 | host_start_req = |
| 351 | (struct hbm_host_version_request *) &dev->wr_msg_buf[1]; |
| 352 | memset(host_start_req, 0, sizeof(struct hbm_host_version_request)); |
Tomas Winkler | 1ca7e78 | 2012-02-26 23:18:57 +0200 | [diff] [blame] | 353 | host_start_req->hbm_cmd = HOST_START_REQ_CMD; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 354 | host_start_req->host_version.major_version = HBM_MAJOR_VERSION; |
| 355 | host_start_req->host_version.minor_version = HBM_MINOR_VERSION; |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 356 | dev->recvd_msg = false; |
Tomas Winkler | 1ccb7b6 | 2012-03-14 14:39:42 +0200 | [diff] [blame] | 357 | if (mei_write_message(dev, mei_hdr, (unsigned char *)host_start_req, |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 358 | mei_hdr->length)) { |
| 359 | dev_dbg(&dev->pdev->dev, "write send version message to FW fail.\n"); |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 360 | dev->dev_state = MEI_DEV_RESETING; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 361 | mei_reset(dev, 1); |
| 362 | } |
| 363 | dev->init_clients_state = MEI_START_MESSAGE; |
Tomas Winkler | 3870c32 | 2012-11-01 21:17:14 +0200 | [diff] [blame] | 364 | dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 365 | return ; |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * host_enum_clients_message - host sends enumeration client request message. |
| 370 | * |
| 371 | * @dev: the device structure |
| 372 | * |
| 373 | * returns none. |
| 374 | */ |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 375 | void mei_host_enum_clients_message(struct mei_device *dev) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 376 | { |
| 377 | struct mei_msg_hdr *mei_hdr; |
| 378 | struct hbm_host_enum_request *host_enum_req; |
| 379 | mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; |
| 380 | /* enumerate clients */ |
| 381 | mei_hdr->host_addr = 0; |
| 382 | mei_hdr->me_addr = 0; |
| 383 | mei_hdr->length = sizeof(struct hbm_host_enum_request); |
| 384 | mei_hdr->msg_complete = 1; |
| 385 | mei_hdr->reserved = 0; |
| 386 | |
| 387 | host_enum_req = (struct hbm_host_enum_request *) &dev->wr_msg_buf[1]; |
| 388 | memset(host_enum_req, 0, sizeof(struct hbm_host_enum_request)); |
Tomas Winkler | 1ca7e78 | 2012-02-26 23:18:57 +0200 | [diff] [blame] | 389 | host_enum_req->hbm_cmd = HOST_ENUM_REQ_CMD; |
Tomas Winkler | 1ccb7b6 | 2012-03-14 14:39:42 +0200 | [diff] [blame] | 390 | if (mei_write_message(dev, mei_hdr, (unsigned char *)host_enum_req, |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 391 | mei_hdr->length)) { |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 392 | dev->dev_state = MEI_DEV_RESETING; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 393 | dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n"); |
| 394 | mei_reset(dev, 1); |
| 395 | } |
| 396 | dev->init_clients_state = MEI_ENUM_CLIENTS_MESSAGE; |
Tomas Winkler | 3870c32 | 2012-11-01 21:17:14 +0200 | [diff] [blame] | 397 | dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT; |
Tomas Winkler | 1ccb7b6 | 2012-03-14 14:39:42 +0200 | [diff] [blame] | 398 | return; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | |
| 402 | /** |
| 403 | * allocate_me_clients_storage - allocates storage for me clients |
| 404 | * |
| 405 | * @dev: the device structure |
| 406 | * |
| 407 | * returns none. |
| 408 | */ |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 409 | void mei_allocate_me_clients_storage(struct mei_device *dev) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 410 | { |
| 411 | struct mei_me_client *clients; |
| 412 | int b; |
| 413 | |
| 414 | /* count how many ME clients we have */ |
| 415 | for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX) |
Tomas Winkler | cf9673d | 2011-06-06 10:44:33 +0300 | [diff] [blame] | 416 | dev->me_clients_num++; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 417 | |
Tomas Winkler | cf9673d | 2011-06-06 10:44:33 +0300 | [diff] [blame] | 418 | if (dev->me_clients_num <= 0) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 419 | return ; |
| 420 | |
| 421 | |
| 422 | if (dev->me_clients != NULL) { |
| 423 | kfree(dev->me_clients); |
| 424 | dev->me_clients = NULL; |
| 425 | } |
| 426 | dev_dbg(&dev->pdev->dev, "memory allocation for ME clients size=%zd.\n", |
Tomas Winkler | cf9673d | 2011-06-06 10:44:33 +0300 | [diff] [blame] | 427 | dev->me_clients_num * sizeof(struct mei_me_client)); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 428 | /* allocate storage for ME clients representation */ |
Tomas Winkler | cf9673d | 2011-06-06 10:44:33 +0300 | [diff] [blame] | 429 | clients = kcalloc(dev->me_clients_num, |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 430 | sizeof(struct mei_me_client), GFP_KERNEL); |
| 431 | if (!clients) { |
| 432 | dev_dbg(&dev->pdev->dev, "memory allocation for ME clients failed.\n"); |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 433 | dev->dev_state = MEI_DEV_RESETING; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 434 | mei_reset(dev, 1); |
| 435 | return ; |
| 436 | } |
| 437 | dev->me_clients = clients; |
| 438 | return ; |
| 439 | } |
| 440 | /** |
| 441 | * host_client_properties - reads properties for client |
| 442 | * |
| 443 | * @dev: the device structure |
| 444 | * |
Oren Weil | abc51b6 | 2011-09-21 16:45:30 +0300 | [diff] [blame] | 445 | * returns: |
| 446 | * < 0 - Error. |
| 447 | * = 0 - no more clients. |
| 448 | * = 1 - still have clients to send properties request. |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 449 | */ |
Oren Weil | abc51b6 | 2011-09-21 16:45:30 +0300 | [diff] [blame] | 450 | int mei_host_client_properties(struct mei_device *dev) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 451 | { |
| 452 | struct mei_msg_hdr *mei_header; |
| 453 | struct hbm_props_request *host_cli_req; |
| 454 | int b; |
| 455 | u8 client_num = dev->me_client_presentation_num; |
| 456 | |
| 457 | b = dev->me_client_index; |
| 458 | b = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX, b); |
| 459 | if (b < MEI_CLIENTS_MAX) { |
| 460 | dev->me_clients[client_num].client_id = b; |
| 461 | dev->me_clients[client_num].mei_flow_ctrl_creds = 0; |
| 462 | mei_header = (struct mei_msg_hdr *)&dev->wr_msg_buf[0]; |
| 463 | mei_header->host_addr = 0; |
| 464 | mei_header->me_addr = 0; |
| 465 | mei_header->length = sizeof(struct hbm_props_request); |
| 466 | mei_header->msg_complete = 1; |
| 467 | mei_header->reserved = 0; |
| 468 | |
| 469 | host_cli_req = (struct hbm_props_request *)&dev->wr_msg_buf[1]; |
| 470 | |
| 471 | memset(host_cli_req, 0, sizeof(struct hbm_props_request)); |
| 472 | |
Tomas Winkler | 1ca7e78 | 2012-02-26 23:18:57 +0200 | [diff] [blame] | 473 | host_cli_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 474 | host_cli_req->address = b; |
| 475 | |
Tomas Winkler | 1ccb7b6 | 2012-03-14 14:39:42 +0200 | [diff] [blame] | 476 | if (mei_write_message(dev, mei_header, |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 477 | (unsigned char *)host_cli_req, |
| 478 | mei_header->length)) { |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 479 | dev->dev_state = MEI_DEV_RESETING; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 480 | dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n"); |
| 481 | mei_reset(dev, 1); |
Oren Weil | abc51b6 | 2011-09-21 16:45:30 +0300 | [diff] [blame] | 482 | return -EIO; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 483 | } |
| 484 | |
Tomas Winkler | 3870c32 | 2012-11-01 21:17:14 +0200 | [diff] [blame] | 485 | dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 486 | dev->me_client_index = b; |
Oren Weil | abc51b6 | 2011-09-21 16:45:30 +0300 | [diff] [blame] | 487 | return 1; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 488 | } |
| 489 | |
Oren Weil | abc51b6 | 2011-09-21 16:45:30 +0300 | [diff] [blame] | 490 | return 0; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | /** |
| 494 | * mei_init_file_private - initializes private file structure. |
| 495 | * |
| 496 | * @priv: private file structure to be initialized |
| 497 | * @file: the file structure |
| 498 | */ |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 499 | void mei_cl_init(struct mei_cl *priv, struct mei_device *dev) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 500 | { |
| 501 | memset(priv, 0, sizeof(struct mei_cl)); |
| 502 | init_waitqueue_head(&priv->wait); |
| 503 | init_waitqueue_head(&priv->rx_wait); |
| 504 | init_waitqueue_head(&priv->tx_wait); |
| 505 | INIT_LIST_HEAD(&priv->link); |
| 506 | priv->reading_state = MEI_IDLE; |
| 507 | priv->writing_state = MEI_IDLE; |
| 508 | priv->dev = dev; |
| 509 | } |
| 510 | |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 511 | int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 512 | { |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 513 | int i, res = -ENOENT; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 514 | |
Tomas Winkler | cf9673d | 2011-06-06 10:44:33 +0300 | [diff] [blame] | 515 | for (i = 0; i < dev->me_clients_num; ++i) |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 516 | if (uuid_le_cmp(*cuuid, |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 517 | dev->me_clients[i].props.protocol_name) == 0) { |
| 518 | res = i; |
| 519 | break; |
| 520 | } |
| 521 | |
| 522 | return res; |
| 523 | } |
| 524 | |
| 525 | |
| 526 | /** |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 527 | * mei_me_cl_update_filext - searches for ME client guid |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 528 | * sets client_id in mei_file_private if found |
| 529 | * @dev: the device structure |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 530 | * @cl: private file structure to set client_id in |
| 531 | * @cuuid: searched uuid of ME client |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 532 | * @client_id: id of host client to be set in file private structure |
| 533 | * |
| 534 | * returns ME client index |
| 535 | */ |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 536 | int mei_me_cl_update_filext(struct mei_device *dev, struct mei_cl *cl, |
| 537 | const uuid_le *cuuid, u8 host_cl_id) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 538 | { |
| 539 | int i; |
| 540 | |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 541 | if (!dev || !cl || !cuuid) |
| 542 | return -EINVAL; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 543 | |
| 544 | /* check for valid client id */ |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 545 | i = mei_me_cl_by_uuid(dev, cuuid); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 546 | if (i >= 0) { |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 547 | cl->me_client_id = dev->me_clients[i].client_id; |
| 548 | cl->state = MEI_FILE_CONNECTING; |
| 549 | cl->host_client_id = host_cl_id; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 550 | |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 551 | list_add_tail(&cl->link, &dev->file_list); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 552 | return (u8)i; |
| 553 | } |
| 554 | |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 555 | return -ENOENT; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | /** |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 559 | * mei_alloc_file_private - allocates a private file structure and sets it up. |
| 560 | * @file: the file structure |
| 561 | * |
| 562 | * returns The allocated file or NULL on failure |
| 563 | */ |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 564 | struct mei_cl *mei_cl_allocate(struct mei_device *dev) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 565 | { |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 566 | struct mei_cl *cl; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 567 | |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 568 | cl = kmalloc(sizeof(struct mei_cl), GFP_KERNEL); |
| 569 | if (!cl) |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 570 | return NULL; |
| 571 | |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 572 | mei_cl_init(cl, dev); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 573 | |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 574 | return cl; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | |
| 578 | |
| 579 | /** |
| 580 | * mei_disconnect_host_client - sends disconnect message to fw from host client. |
| 581 | * |
| 582 | * @dev: the device structure |
| 583 | * @cl: private data of the file object |
| 584 | * |
| 585 | * Locking: called under "dev->device_lock" lock |
| 586 | * |
| 587 | * returns 0 on success, <0 on failure. |
| 588 | */ |
| 589 | int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl) |
| 590 | { |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 591 | struct mei_cl_cb *cb; |
Tomas Winkler | 3870c32 | 2012-11-01 21:17:14 +0200 | [diff] [blame] | 592 | int rets, err; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 593 | |
| 594 | if (!dev || !cl) |
| 595 | return -ENODEV; |
| 596 | |
| 597 | if (cl->state != MEI_FILE_DISCONNECTING) |
| 598 | return 0; |
| 599 | |
Tomas Winkler | 664df38 | 2012-10-11 16:35:08 +0200 | [diff] [blame] | 600 | cb = mei_io_cb_init(cl, NULL); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 601 | if (!cb) |
| 602 | return -ENOMEM; |
| 603 | |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 604 | cb->major_file_operations = MEI_CLOSE; |
| 605 | if (dev->mei_host_buffer_is_empty) { |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 606 | dev->mei_host_buffer_is_empty = false; |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 607 | if (mei_disconnect(dev, cl)) { |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 608 | rets = -ENODEV; |
| 609 | dev_dbg(&dev->pdev->dev, "failed to call mei_disconnect.\n"); |
| 610 | goto free; |
| 611 | } |
Tomas Winkler | 1ccb7b6 | 2012-03-14 14:39:42 +0200 | [diff] [blame] | 612 | mdelay(10); /* Wait for hardware disconnection ready */ |
Tomas Winkler | fb601ad | 2012-10-15 12:06:48 +0200 | [diff] [blame] | 613 | list_add_tail(&cb->list, &dev->ctrl_rd_list.list); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 614 | } else { |
| 615 | dev_dbg(&dev->pdev->dev, "add disconnect cb to control write list\n"); |
Tomas Winkler | fb601ad | 2012-10-15 12:06:48 +0200 | [diff] [blame] | 616 | list_add_tail(&cb->list, &dev->ctrl_wr_list.list); |
| 617 | |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 618 | } |
| 619 | mutex_unlock(&dev->device_lock); |
| 620 | |
| 621 | err = wait_event_timeout(dev->wait_recvd_msg, |
Tomas Winkler | 3870c32 | 2012-11-01 21:17:14 +0200 | [diff] [blame] | 622 | MEI_FILE_DISCONNECTED == cl->state, |
| 623 | mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT)); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 624 | |
| 625 | mutex_lock(&dev->device_lock); |
| 626 | if (MEI_FILE_DISCONNECTED == cl->state) { |
| 627 | rets = 0; |
| 628 | dev_dbg(&dev->pdev->dev, "successfully disconnected from FW client.\n"); |
| 629 | } else { |
| 630 | rets = -ENODEV; |
| 631 | if (MEI_FILE_DISCONNECTED != cl->state) |
| 632 | dev_dbg(&dev->pdev->dev, "wrong status client disconnect.\n"); |
| 633 | |
| 634 | if (err) |
| 635 | dev_dbg(&dev->pdev->dev, |
| 636 | "wait failed disconnect err=%08x\n", |
| 637 | err); |
| 638 | |
| 639 | dev_dbg(&dev->pdev->dev, "failed to disconnect from FW client.\n"); |
| 640 | } |
| 641 | |
Tomas Winkler | 0288c7c | 2011-06-06 10:44:34 +0300 | [diff] [blame] | 642 | mei_io_list_flush(&dev->ctrl_rd_list, cl); |
| 643 | mei_io_list_flush(&dev->ctrl_wr_list, cl); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 644 | free: |
Tomas Winkler | 601a1ef | 2012-10-09 16:50:20 +0200 | [diff] [blame] | 645 | mei_io_cb_free(cb); |
Oren Weil | 91f01c6 | 2011-05-15 13:43:44 +0300 | [diff] [blame] | 646 | return rets; |
| 647 | } |
| 648 | |
| 649 | /** |
| 650 | * mei_remove_client_from_file_list - |
| 651 | * removes file private data from device file list |
| 652 | * |
| 653 | * @dev: the device structure |
| 654 | * @host_client_id: host client id to be removed |
| 655 | */ |
| 656 | void mei_remove_client_from_file_list(struct mei_device *dev, |
| 657 | u8 host_client_id) |
| 658 | { |
| 659 | struct mei_cl *cl_pos = NULL; |
| 660 | struct mei_cl *cl_next = NULL; |
| 661 | list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) { |
| 662 | if (host_client_id == cl_pos->host_client_id) { |
| 663 | dev_dbg(&dev->pdev->dev, "remove host client = %d, ME client = %d\n", |
| 664 | cl_pos->host_client_id, |
| 665 | cl_pos->me_client_id); |
| 666 | list_del_init(&cl_pos->link); |
| 667 | break; |
| 668 | } |
| 669 | } |
| 670 | } |