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