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