blob: 14becc0d55632123193f3ec9cc819f68f321a3ee [file] [log] [blame]
Oren Weilfb7d8792011-05-15 13:43:42 +03001/*
2 *
3 * Intel Management Engine Interface (Intel MEI) Linux driver
Tomas Winkler733ba912012-02-09 19:25:53 +02004 * Copyright (c) 2003-2012, Intel Corporation.
Oren Weilfb7d8792011-05-15 13:43:42 +03005 *
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
18#include <linux/pci.h>
19#include <linux/kthread.h>
20#include <linux/interrupt.h>
21#include <linux/fs.h>
22#include <linux/jiffies.h>
23
24#include "mei_dev.h"
Tomas Winkler4f3afe12012-05-09 16:38:59 +030025#include <linux/mei.h>
Oren Weilfb7d8792011-05-15 13:43:42 +030026#include "hw.h"
27#include "interface.h"
28
29
30/**
31 * mei_interrupt_quick_handler - The ISR of the MEI device
32 *
33 * @irq: The irq number
34 * @dev_id: pointer to the device structure
35 *
36 * returns irqreturn_t
37 */
38irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id)
39{
40 struct mei_device *dev = (struct mei_device *) dev_id;
41 u32 csr_reg = mei_hcsr_read(dev);
42
43 if ((csr_reg & H_IS) != H_IS)
44 return IRQ_NONE;
45
46 /* clear H_IS bit in H_CSR */
47 mei_reg_write(dev, H_CSR, csr_reg);
48
49 return IRQ_WAKE_THREAD;
50}
51
52/**
53 * _mei_cmpl - processes completed operation.
54 *
55 * @cl: private data of the file object.
56 * @cb_pos: callback block.
57 */
58static void _mei_cmpl(struct mei_cl *cl, struct mei_cl_cb *cb_pos)
59{
Tomas Winkler4b8960b2012-11-11 17:38:00 +020060 if (cb_pos->fop_type == MEI_FOP_WRITE) {
Tomas Winkler601a1ef2012-10-09 16:50:20 +020061 mei_io_cb_free(cb_pos);
Oren Weilfb7d8792011-05-15 13:43:42 +030062 cb_pos = NULL;
63 cl->writing_state = MEI_WRITE_COMPLETE;
64 if (waitqueue_active(&cl->tx_wait))
65 wake_up_interruptible(&cl->tx_wait);
66
Tomas Winkler4b8960b2012-11-11 17:38:00 +020067 } else if (cb_pos->fop_type == MEI_FOP_READ &&
Oren Weilfb7d8792011-05-15 13:43:42 +030068 MEI_READING == cl->reading_state) {
69 cl->reading_state = MEI_READ_COMPLETE;
70 if (waitqueue_active(&cl->rx_wait))
71 wake_up_interruptible(&cl->rx_wait);
72
73 }
74}
75
76/**
Oren Weilfb7d8792011-05-15 13:43:42 +030077 * _mei_irq_thread_state_ok - checks if mei header matches file private data
78 *
79 * @cl: private data of the file object
80 * @mei_hdr: header of mei client message
81 *
82 * returns !=0 if matches, 0 if no match.
83 */
84static int _mei_irq_thread_state_ok(struct mei_cl *cl,
85 struct mei_msg_hdr *mei_hdr)
86{
87 return (cl->host_client_id == mei_hdr->host_addr &&
88 cl->me_client_id == mei_hdr->me_addr &&
89 cl->state == MEI_FILE_CONNECTED &&
90 MEI_READ_COMPLETE != cl->reading_state);
91}
92
93/**
94 * mei_irq_thread_read_client_message - bottom half read routine after ISR to
95 * handle the read mei client message data processing.
96 *
97 * @complete_list: An instance of our list structure
98 * @dev: the device structure
99 * @mei_hdr: header of mei client message
100 *
101 * returns 0 on success, <0 on failure.
102 */
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200103static int mei_irq_thread_read_client_message(struct mei_cl_cb *complete_list,
Oren Weilfb7d8792011-05-15 13:43:42 +0300104 struct mei_device *dev,
105 struct mei_msg_hdr *mei_hdr)
106{
107 struct mei_cl *cl;
108 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
Tomas Winkler479bc592011-06-16 00:46:03 +0300109 unsigned char *buffer = NULL;
Oren Weilfb7d8792011-05-15 13:43:42 +0300110
111 dev_dbg(&dev->pdev->dev, "start client msg\n");
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200112 if (list_empty(&dev->read_list.list))
Oren Weilfb7d8792011-05-15 13:43:42 +0300113 goto quit;
114
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200115 list_for_each_entry_safe(cb_pos, cb_next, &dev->read_list.list, list) {
Tomas Winklerdb3ed432012-11-11 17:37:59 +0200116 cl = cb_pos->cl;
Oren Weilfb7d8792011-05-15 13:43:42 +0300117 if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
118 cl->reading_state = MEI_READING;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200119 buffer = cb_pos->response_buffer.data + cb_pos->buf_idx;
Oren Weilfb7d8792011-05-15 13:43:42 +0300120
121 if (cb_pos->response_buffer.size <
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200122 mei_hdr->length + cb_pos->buf_idx) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300123 dev_dbg(&dev->pdev->dev, "message overflow.\n");
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200124 list_del(&cb_pos->list);
Oren Weilfb7d8792011-05-15 13:43:42 +0300125 return -ENOMEM;
126 }
127 if (buffer)
128 mei_read_slots(dev, buffer, mei_hdr->length);
129
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200130 cb_pos->buf_idx += mei_hdr->length;
Oren Weilfb7d8792011-05-15 13:43:42 +0300131 if (mei_hdr->msg_complete) {
132 cl->status = 0;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200133 list_del(&cb_pos->list);
Oren Weilfb7d8792011-05-15 13:43:42 +0300134 dev_dbg(&dev->pdev->dev,
Tomas Winklera4136b42012-09-11 00:43:22 +0300135 "completed read H cl = %d, ME cl = %d, length = %lu\n",
Oren Weilfb7d8792011-05-15 13:43:42 +0300136 cl->host_client_id,
137 cl->me_client_id,
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200138 cb_pos->buf_idx);
139
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200140 list_add_tail(&cb_pos->list,
141 &complete_list->list);
Oren Weilfb7d8792011-05-15 13:43:42 +0300142 }
143
144 break;
145 }
146
147 }
148
149quit:
150 dev_dbg(&dev->pdev->dev, "message read\n");
151 if (!buffer) {
Tomas Winkleredf1eed2012-02-09 19:25:54 +0200152 mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
Oren Weilfb7d8792011-05-15 13:43:42 +0300153 dev_dbg(&dev->pdev->dev, "discarding message, header =%08x.\n",
154 *(u32 *) dev->rd_msg_buf);
155 }
156
157 return 0;
158}
159
160/**
Oren Weilfb7d8792011-05-15 13:43:42 +0300161 * _mei_irq_thread_close - processes close related operation.
162 *
163 * @dev: the device structure.
164 * @slots: free slots.
165 * @cb_pos: callback block.
166 * @cl: private data of the file object.
167 * @cmpl_list: complete list.
168 *
169 * returns 0, OK; otherwise, error.
170 */
171static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
172 struct mei_cl_cb *cb_pos,
173 struct mei_cl *cl,
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200174 struct mei_cl_cb *cmpl_list)
Oren Weilfb7d8792011-05-15 13:43:42 +0300175{
Tomas Winklerb45f3cc2012-07-04 19:24:53 +0300176 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
Tomas Winkleraeba4a02012-11-11 17:38:04 +0200177 sizeof(struct hbm_client_connect_request)))
Oren Weilfb7d8792011-05-15 13:43:42 +0300178 return -EBADMSG;
Tomas Winklerb45f3cc2012-07-04 19:24:53 +0300179
Tomas Winkleraeba4a02012-11-11 17:38:04 +0200180 *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
Tomas Winklerb45f3cc2012-07-04 19:24:53 +0300181
182 if (mei_disconnect(dev, cl)) {
183 cl->status = 0;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200184 cb_pos->buf_idx = 0;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200185 list_move_tail(&cb_pos->list, &cmpl_list->list);
Tomas Winklerb45f3cc2012-07-04 19:24:53 +0300186 return -EMSGSIZE;
187 } else {
188 cl->state = MEI_FILE_DISCONNECTING;
189 cl->status = 0;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200190 cb_pos->buf_idx = 0;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200191 list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
Tomas Winklerb45f3cc2012-07-04 19:24:53 +0300192 cl->timer_count = MEI_CONNECT_TIMEOUT;
Oren Weilfb7d8792011-05-15 13:43:42 +0300193 }
194
195 return 0;
196}
197
198/**
199 * is_treat_specially_client - checks if the message belongs
200 * to the file private data.
201 *
202 * @cl: private data of the file object
203 * @rs: connect response bus message
204 *
205 */
206static bool is_treat_specially_client(struct mei_cl *cl,
207 struct hbm_client_connect_response *rs)
208{
209
210 if (cl->host_client_id == rs->host_addr &&
211 cl->me_client_id == rs->me_addr) {
212 if (!rs->status) {
213 cl->state = MEI_FILE_CONNECTED;
214 cl->status = 0;
215
216 } else {
217 cl->state = MEI_FILE_DISCONNECTED;
218 cl->status = -ENODEV;
219 }
220 cl->timer_count = 0;
221
222 return true;
223 }
224 return false;
225}
226
227/**
228 * mei_client_connect_response - connects to response irq routine
229 *
230 * @dev: the device structure
231 * @rs: connect response bus message
232 */
233static void mei_client_connect_response(struct mei_device *dev,
234 struct hbm_client_connect_response *rs)
235{
236
237 struct mei_cl *cl;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200238 struct mei_cl_cb *pos = NULL, *next = NULL;
Oren Weilfb7d8792011-05-15 13:43:42 +0300239
240 dev_dbg(&dev->pdev->dev,
241 "connect_response:\n"
242 "ME Client = %d\n"
243 "Host Client = %d\n"
244 "Status = %d\n",
245 rs->me_addr,
246 rs->host_addr,
247 rs->status);
248
249 /* if WD or iamthif client treat specially */
250
251 if (is_treat_specially_client(&(dev->wd_cl), rs)) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300252 dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n");
Tomas Winkler70cd5332011-12-22 18:50:50 +0200253 mei_watchdog_register(dev);
Oren Weil9ce178e2011-09-07 09:03:09 +0300254
Tomas Winkler70cd5332011-12-22 18:50:50 +0200255 /* next step in the state maching */
Tomas Winkler19838fb2012-11-01 21:17:15 +0200256 mei_amthif_host_init(dev);
Oren Weilfb7d8792011-05-15 13:43:42 +0300257 return;
258 }
259
260 if (is_treat_specially_client(&(dev->iamthif_cl), rs)) {
261 dev->iamthif_state = MEI_IAMTHIF_IDLE;
262 return;
263 }
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200264 list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200265
Tomas Winklerdb3ed432012-11-11 17:37:59 +0200266 cl = pos->cl;
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200267 if (!cl) {
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200268 list_del(&pos->list);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200269 return;
270 }
Tomas Winkler4b8960b2012-11-11 17:38:00 +0200271 if (pos->fop_type == MEI_FOP_IOCTL) {
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200272 if (is_treat_specially_client(cl, rs)) {
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200273 list_del(&pos->list);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200274 cl->status = 0;
275 cl->timer_count = 0;
276 break;
Oren Weilfb7d8792011-05-15 13:43:42 +0300277 }
278 }
279 }
280}
281
282/**
283 * mei_client_disconnect_response - disconnects from response irq routine
284 *
285 * @dev: the device structure
286 * @rs: disconnect response bus message
287 */
288static void mei_client_disconnect_response(struct mei_device *dev,
289 struct hbm_client_connect_response *rs)
290{
291 struct mei_cl *cl;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200292 struct mei_cl_cb *pos = NULL, *next = NULL;
Oren Weilfb7d8792011-05-15 13:43:42 +0300293
294 dev_dbg(&dev->pdev->dev,
295 "disconnect_response:\n"
296 "ME Client = %d\n"
297 "Host Client = %d\n"
298 "Status = %d\n",
299 rs->me_addr,
300 rs->host_addr,
301 rs->status);
302
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200303 list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
Tomas Winklerdb3ed432012-11-11 17:37:59 +0200304 cl = pos->cl;
Oren Weilfb7d8792011-05-15 13:43:42 +0300305
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200306 if (!cl) {
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200307 list_del(&pos->list);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200308 return;
309 }
Oren Weilfb7d8792011-05-15 13:43:42 +0300310
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200311 dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n");
312 if (cl->host_client_id == rs->host_addr &&
313 cl->me_client_id == rs->me_addr) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300314
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200315 list_del(&pos->list);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200316 if (!rs->status)
317 cl->state = MEI_FILE_DISCONNECTED;
Oren Weilfb7d8792011-05-15 13:43:42 +0300318
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200319 cl->status = 0;
320 cl->timer_count = 0;
321 break;
Oren Weilfb7d8792011-05-15 13:43:42 +0300322 }
323 }
324}
325
326/**
327 * same_flow_addr - tells if they have the same address.
328 *
329 * @file: private data of the file object.
330 * @flow: flow control.
331 *
332 * returns !=0, same; 0,not.
333 */
334static int same_flow_addr(struct mei_cl *cl, struct hbm_flow_control *flow)
335{
336 return (cl->host_client_id == flow->host_addr &&
337 cl->me_client_id == flow->me_addr);
338}
339
340/**
341 * add_single_flow_creds - adds single buffer credentials.
342 *
343 * @file: private data ot the file object.
344 * @flow: flow control.
345 */
346static void add_single_flow_creds(struct mei_device *dev,
347 struct hbm_flow_control *flow)
348{
349 struct mei_me_client *client;
350 int i;
351
Tomas Winklercf9673d2011-06-06 10:44:33 +0300352 for (i = 0; i < dev->me_clients_num; i++) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300353 client = &dev->me_clients[i];
354 if (client && flow->me_addr == client->client_id) {
355 if (client->props.single_recv_buf) {
356 client->mei_flow_ctrl_creds++;
357 dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
358 flow->me_addr);
359 dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
360 client->mei_flow_ctrl_creds);
361 } else {
362 BUG(); /* error in flow control */
363 }
364 }
365 }
366}
367
368/**
369 * mei_client_flow_control_response - flow control response irq routine
370 *
371 * @dev: the device structure
372 * @flow_control: flow control response bus message
373 */
374static void mei_client_flow_control_response(struct mei_device *dev,
375 struct hbm_flow_control *flow_control)
376{
377 struct mei_cl *cl_pos = NULL;
378 struct mei_cl *cl_next = NULL;
379
380 if (!flow_control->host_addr) {
381 /* single receive buffer */
382 add_single_flow_creds(dev, flow_control);
383 } else {
384 /* normal connection */
385 list_for_each_entry_safe(cl_pos, cl_next,
386 &dev->file_list, link) {
387 dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in file_list\n");
388
389 dev_dbg(&dev->pdev->dev, "cl of host client %d ME client %d.\n",
390 cl_pos->host_client_id,
391 cl_pos->me_client_id);
392 dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
393 flow_control->host_addr,
394 flow_control->me_addr);
395 if (same_flow_addr(cl_pos, flow_control)) {
396 dev_dbg(&dev->pdev->dev, "recv ctrl msg for host %d ME %d.\n",
397 flow_control->host_addr,
398 flow_control->me_addr);
399 cl_pos->mei_flow_ctrl_creds++;
400 dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
401 cl_pos->mei_flow_ctrl_creds);
402 break;
403 }
404 }
405 }
406}
407
408/**
409 * same_disconn_addr - tells if they have the same address
410 *
411 * @file: private data of the file object.
412 * @disconn: disconnection request.
413 *
414 * returns !=0, same; 0,not.
415 */
416static int same_disconn_addr(struct mei_cl *cl,
Tomas Winkleraeba4a02012-11-11 17:38:04 +0200417 struct hbm_client_connect_request *req)
Oren Weilfb7d8792011-05-15 13:43:42 +0300418{
Tomas Winkleraeba4a02012-11-11 17:38:04 +0200419 return (cl->host_client_id == req->host_addr &&
420 cl->me_client_id == req->me_addr);
Oren Weilfb7d8792011-05-15 13:43:42 +0300421}
422
423/**
424 * mei_client_disconnect_request - disconnects from request irq routine
425 *
426 * @dev: the device structure.
427 * @disconnect_req: disconnect request bus message.
428 */
429static void mei_client_disconnect_request(struct mei_device *dev,
Tomas Winkleraeba4a02012-11-11 17:38:04 +0200430 struct hbm_client_connect_request *disconnect_req)
Oren Weilfb7d8792011-05-15 13:43:42 +0300431{
Oren Weilfb7d8792011-05-15 13:43:42 +0300432 struct hbm_client_connect_response *disconnect_res;
Tomas Winkler5bd64712012-11-18 15:13:14 +0200433 struct mei_cl *pos, *next;
434 const size_t len = sizeof(struct hbm_client_connect_response);
Oren Weilfb7d8792011-05-15 13:43:42 +0300435
Tomas Winkler5bd64712012-11-18 15:13:14 +0200436 list_for_each_entry_safe(pos, next, &dev->file_list, link) {
437 if (same_disconn_addr(pos, disconnect_req)) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300438 dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
439 disconnect_req->host_addr,
440 disconnect_req->me_addr);
Tomas Winkler5bd64712012-11-18 15:13:14 +0200441 pos->state = MEI_FILE_DISCONNECTED;
442 pos->timer_count = 0;
443 if (pos == &dev->wd_cl)
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300444 dev->wd_pending = false;
Tomas Winkler5bd64712012-11-18 15:13:14 +0200445 else if (pos == &dev->iamthif_cl)
Oren Weilfb7d8792011-05-15 13:43:42 +0300446 dev->iamthif_timer = 0;
447
448 /* prepare disconnect response */
Tomas Winkler5bd64712012-11-18 15:13:14 +0200449 (void)mei_hbm_hdr(&dev->ext_msg_buf[0], len);
Oren Weilfb7d8792011-05-15 13:43:42 +0300450 disconnect_res =
451 (struct hbm_client_connect_response *)
452 &dev->ext_msg_buf[1];
Tomas Winkler1ca7e782012-02-26 23:18:57 +0200453 disconnect_res->hbm_cmd = CLIENT_DISCONNECT_RES_CMD;
Tomas Winkler5bd64712012-11-18 15:13:14 +0200454 disconnect_res->host_addr = pos->host_client_id;
455 disconnect_res->me_addr = pos->me_client_id;
Oren Weilfb7d8792011-05-15 13:43:42 +0300456 disconnect_res->status = 0;
457 dev->extra_write_index = 2;
458 break;
459 }
460 }
461}
462
Oren Weilfb7d8792011-05-15 13:43:42 +0300463/**
464 * mei_irq_thread_read_bus_message - bottom half read routine after ISR to
465 * handle the read bus message cmd processing.
466 *
467 * @dev: the device structure
468 * @mei_hdr: header of bus message
469 */
470static void mei_irq_thread_read_bus_message(struct mei_device *dev,
471 struct mei_msg_hdr *mei_hdr)
472{
473 struct mei_bus_message *mei_msg;
474 struct hbm_host_version_response *version_res;
475 struct hbm_client_connect_response *connect_res;
476 struct hbm_client_connect_response *disconnect_res;
Tomas Winkleraeba4a02012-11-11 17:38:04 +0200477 struct hbm_client_connect_request *disconnect_req;
Oren Weilfb7d8792011-05-15 13:43:42 +0300478 struct hbm_flow_control *flow_control;
479 struct hbm_props_response *props_res;
480 struct hbm_host_enum_response *enum_res;
Tomas Winkler5bd64712012-11-18 15:13:14 +0200481 struct hbm_host_stop_request *stop_req;
Oren Weilabc51b62011-09-21 16:45:30 +0300482 int res;
Oren Weilfb7d8792011-05-15 13:43:42 +0300483
Oren Weilfb7d8792011-05-15 13:43:42 +0300484
485 /* read the message to our buffer */
Oren Weilfb7d8792011-05-15 13:43:42 +0300486 BUG_ON(mei_hdr->length >= sizeof(dev->rd_msg_buf));
Tomas Winkleredf1eed2012-02-09 19:25:54 +0200487 mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
488 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
Oren Weilfb7d8792011-05-15 13:43:42 +0300489
Tomas Winkler1ca7e782012-02-26 23:18:57 +0200490 switch (mei_msg->hbm_cmd) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300491 case HOST_START_RES_CMD:
492 version_res = (struct hbm_host_version_response *) mei_msg;
493 if (version_res->host_version_supported) {
494 dev->version.major_version = HBM_MAJOR_VERSION;
495 dev->version.minor_version = HBM_MINOR_VERSION;
Tomas Winklerb210d752012-08-07 00:03:56 +0300496 if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
Oren Weilfb7d8792011-05-15 13:43:42 +0300497 dev->init_clients_state == MEI_START_MESSAGE) {
498 dev->init_clients_timer = 0;
Tomas Winklerc95efb72011-05-25 17:28:21 +0300499 mei_host_enum_clients_message(dev);
Oren Weilfb7d8792011-05-15 13:43:42 +0300500 } else {
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300501 dev->recvd_msg = false;
Oren Weilfb7d8792011-05-15 13:43:42 +0300502 dev_dbg(&dev->pdev->dev, "IMEI reset due to received host start response bus message.\n");
503 mei_reset(dev, 1);
504 return;
505 }
506 } else {
Tomas Winkler5bd64712012-11-18 15:13:14 +0200507 u32 *buf = dev->wr_msg_buf;
508 const size_t len = sizeof(struct hbm_host_stop_request);
509
Oren Weilfb7d8792011-05-15 13:43:42 +0300510 dev->version = version_res->me_max_version;
Tomas Winkler5bd64712012-11-18 15:13:14 +0200511
Oren Weilfb7d8792011-05-15 13:43:42 +0300512 /* send stop message */
Tomas Winkler5bd64712012-11-18 15:13:14 +0200513 mei_hdr = mei_hbm_hdr(&buf[0], len);
514 stop_req = (struct hbm_host_stop_request *)&buf[1];
515 memset(stop_req, 0, len);
516 stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
517 stop_req->reason = DRIVER_STOP_REQUEST;
Oren Weilfb7d8792011-05-15 13:43:42 +0300518
Oren Weilfb7d8792011-05-15 13:43:42 +0300519 mei_write_message(dev, mei_hdr,
Tomas Winkler5bd64712012-11-18 15:13:14 +0200520 (unsigned char *)stop_req, len);
Oren Weilfb7d8792011-05-15 13:43:42 +0300521 dev_dbg(&dev->pdev->dev, "version mismatch.\n");
522 return;
523 }
524
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300525 dev->recvd_msg = true;
Oren Weilfb7d8792011-05-15 13:43:42 +0300526 dev_dbg(&dev->pdev->dev, "host start response message received.\n");
527 break;
528
529 case CLIENT_CONNECT_RES_CMD:
Tomas Winkler5bd64712012-11-18 15:13:14 +0200530 connect_res = (struct hbm_client_connect_response *) mei_msg;
Oren Weilfb7d8792011-05-15 13:43:42 +0300531 mei_client_connect_response(dev, connect_res);
532 dev_dbg(&dev->pdev->dev, "client connect response message received.\n");
533 wake_up(&dev->wait_recvd_msg);
534 break;
535
536 case CLIENT_DISCONNECT_RES_CMD:
Tomas Winkler5bd64712012-11-18 15:13:14 +0200537 disconnect_res = (struct hbm_client_connect_response *) mei_msg;
Tomas Winkler441ab502011-12-13 23:39:34 +0200538 mei_client_disconnect_response(dev, disconnect_res);
Oren Weilfb7d8792011-05-15 13:43:42 +0300539 dev_dbg(&dev->pdev->dev, "client disconnect response message received.\n");
540 wake_up(&dev->wait_recvd_msg);
541 break;
542
543 case MEI_FLOW_CONTROL_CMD:
544 flow_control = (struct hbm_flow_control *) mei_msg;
545 mei_client_flow_control_response(dev, flow_control);
546 dev_dbg(&dev->pdev->dev, "client flow control response message received.\n");
547 break;
548
549 case HOST_CLIENT_PROPERTIES_RES_CMD:
550 props_res = (struct hbm_props_response *)mei_msg;
551 if (props_res->status || !dev->me_clients) {
552 dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message wrong status.\n");
553 mei_reset(dev, 1);
554 return;
555 }
Tomas Winkler441ab502011-12-13 23:39:34 +0200556 if (dev->me_clients[dev->me_client_presentation_num]
Oren Weilfb7d8792011-05-15 13:43:42 +0300557 .client_id == props_res->address) {
558
559 dev->me_clients[dev->me_client_presentation_num].props
560 = props_res->client_properties;
561
Tomas Winklerb210d752012-08-07 00:03:56 +0300562 if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
Oren Weilfb7d8792011-05-15 13:43:42 +0300563 dev->init_clients_state ==
564 MEI_CLIENT_PROPERTIES_MESSAGE) {
565 dev->me_client_index++;
566 dev->me_client_presentation_num++;
Oren Weilabc51b62011-09-21 16:45:30 +0300567
Justin P. Mattock5f9092f32012-03-12 07:18:09 -0700568 /** Send Client Properties request **/
Oren Weilabc51b62011-09-21 16:45:30 +0300569 res = mei_host_client_properties(dev);
570 if (res < 0) {
571 dev_dbg(&dev->pdev->dev, "mei_host_client_properties() failed");
572 return;
573 } else if (!res) {
574 /*
575 * No more clients to send to.
576 * Clear Map for indicating now ME clients
577 * with associated host client
578 */
579 bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX);
580 dev->open_handle_count = 0;
581
582 /*
583 * Reserving the first three client IDs
584 * Client Id 0 - Reserved for MEI Bus Message communications
585 * Client Id 1 - Reserved for Watchdog
586 * Client ID 2 - Reserved for AMTHI
587 */
588 bitmap_set(dev->host_clients_map, 0, 3);
Tomas Winklerb210d752012-08-07 00:03:56 +0300589 dev->dev_state = MEI_DEV_ENABLED;
Oren Weilabc51b62011-09-21 16:45:30 +0300590
591 /* if wd initialization fails, initialization the AMTHI client,
592 * otherwise the AMTHI client will be initialized after the WD client connect response
593 * will be received
594 */
595 if (mei_wd_host_init(dev))
Tomas Winkler19838fb2012-11-01 21:17:15 +0200596 mei_amthif_host_init(dev);
Oren Weilabc51b62011-09-21 16:45:30 +0300597 }
598
Oren Weilfb7d8792011-05-15 13:43:42 +0300599 } else {
600 dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message");
601 mei_reset(dev, 1);
602 return;
603 }
604 } else {
605 dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message for wrong client ID\n");
606 mei_reset(dev, 1);
607 return;
608 }
609 break;
610
611 case HOST_ENUM_RES_CMD:
612 enum_res = (struct hbm_host_enum_response *) mei_msg;
613 memcpy(dev->me_clients_map, enum_res->valid_addresses, 32);
Tomas Winklerb210d752012-08-07 00:03:56 +0300614 if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
Oren Weilfb7d8792011-05-15 13:43:42 +0300615 dev->init_clients_state == MEI_ENUM_CLIENTS_MESSAGE) {
616 dev->init_clients_timer = 0;
617 dev->me_client_presentation_num = 0;
618 dev->me_client_index = 0;
Tomas Winklerc95efb72011-05-25 17:28:21 +0300619 mei_allocate_me_clients_storage(dev);
Oren Weilfb7d8792011-05-15 13:43:42 +0300620 dev->init_clients_state =
621 MEI_CLIENT_PROPERTIES_MESSAGE;
Tomas Winklerc95efb72011-05-25 17:28:21 +0300622 mei_host_client_properties(dev);
Oren Weilfb7d8792011-05-15 13:43:42 +0300623 } else {
624 dev_dbg(&dev->pdev->dev, "reset due to received host enumeration clients response bus message.\n");
625 mei_reset(dev, 1);
626 return;
627 }
628 break;
629
630 case HOST_STOP_RES_CMD:
Tomas Winklerb210d752012-08-07 00:03:56 +0300631 dev->dev_state = MEI_DEV_DISABLED;
Oren Weilfb7d8792011-05-15 13:43:42 +0300632 dev_dbg(&dev->pdev->dev, "resetting because of FW stop response.\n");
633 mei_reset(dev, 1);
634 break;
635
636 case CLIENT_DISCONNECT_REQ_CMD:
637 /* search for client */
Tomas Winkleraeba4a02012-11-11 17:38:04 +0200638 disconnect_req = (struct hbm_client_connect_request *)mei_msg;
Oren Weilfb7d8792011-05-15 13:43:42 +0300639 mei_client_disconnect_request(dev, disconnect_req);
640 break;
641
642 case ME_STOP_REQ_CMD:
Tomas Winkler5bd64712012-11-18 15:13:14 +0200643 {
644 /* prepare stop request: sent in next interrupt event */
645
646 u32 *buf = dev->ext_msg_buf;
647 const size_t len = sizeof(struct hbm_host_stop_request);
648
649 mei_hdr = mei_hbm_hdr(&buf[0], len);
650 stop_req = (struct hbm_host_stop_request *)&buf[1];
651 memset(stop_req, 0, len);
652 stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
653 stop_req->reason = DRIVER_STOP_REQUEST;
654
Oren Weilfb7d8792011-05-15 13:43:42 +0300655 dev->extra_write_index = 2;
656 break;
Tomas Winkler5bd64712012-11-18 15:13:14 +0200657 }
Oren Weilfb7d8792011-05-15 13:43:42 +0300658 default:
659 BUG();
660 break;
661
662 }
663}
664
665
666/**
667 * _mei_hb_read - processes read related operation.
668 *
669 * @dev: the device structure.
670 * @slots: free slots.
671 * @cb_pos: callback block.
672 * @cl: private data of the file object.
673 * @cmpl_list: complete list.
674 *
675 * returns 0, OK; otherwise, error.
676 */
677static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
678 struct mei_cl_cb *cb_pos,
679 struct mei_cl *cl,
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200680 struct mei_cl_cb *cmpl_list)
Oren Weilfb7d8792011-05-15 13:43:42 +0300681{
Tomas Winkler1e69d642012-05-29 16:39:12 +0300682 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
Oren Weilfb7d8792011-05-15 13:43:42 +0300683 sizeof(struct hbm_flow_control))) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300684 /* return the cancel routine */
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200685 list_del(&cb_pos->list);
Oren Weilfb7d8792011-05-15 13:43:42 +0300686 return -EBADMSG;
687 }
688
Tomas Winkler7bdf72d2012-07-04 19:24:52 +0300689 *slots -= mei_data2slots(sizeof(struct hbm_flow_control));
690
Tomas Winkler1ccb7b62012-03-14 14:39:42 +0200691 if (mei_send_flow_control(dev, cl)) {
692 cl->status = -ENODEV;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200693 cb_pos->buf_idx = 0;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200694 list_move_tail(&cb_pos->list, &cmpl_list->list);
Tomas Winkler1ccb7b62012-03-14 14:39:42 +0200695 return -ENODEV;
696 }
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200697 list_move_tail(&cb_pos->list, &dev->read_list.list);
Tomas Winkler1ccb7b62012-03-14 14:39:42 +0200698
Oren Weilfb7d8792011-05-15 13:43:42 +0300699 return 0;
700}
701
702
703/**
704 * _mei_irq_thread_ioctl - processes ioctl related operation.
705 *
706 * @dev: the device structure.
707 * @slots: free slots.
708 * @cb_pos: callback block.
709 * @cl: private data of the file object.
710 * @cmpl_list: complete list.
711 *
712 * returns 0, OK; otherwise, error.
713 */
714static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
715 struct mei_cl_cb *cb_pos,
716 struct mei_cl *cl,
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200717 struct mei_cl_cb *cmpl_list)
Oren Weilfb7d8792011-05-15 13:43:42 +0300718{
Tomas Winklerb45f3cc2012-07-04 19:24:53 +0300719 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
Oren Weilfb7d8792011-05-15 13:43:42 +0300720 sizeof(struct hbm_client_connect_request))) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300721 /* return the cancel routine */
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200722 list_del(&cb_pos->list);
Oren Weilfb7d8792011-05-15 13:43:42 +0300723 return -EBADMSG;
724 }
725
Tomas Winklerb45f3cc2012-07-04 19:24:53 +0300726 cl->state = MEI_FILE_CONNECTING;
727 *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
728 if (mei_connect(dev, cl)) {
729 cl->status = -ENODEV;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200730 cb_pos->buf_idx = 0;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200731 list_del(&cb_pos->list);
Tomas Winklerb45f3cc2012-07-04 19:24:53 +0300732 return -ENODEV;
733 } else {
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200734 list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
Tomas Winklerb45f3cc2012-07-04 19:24:53 +0300735 cl->timer_count = MEI_CONNECT_TIMEOUT;
736 }
Oren Weilfb7d8792011-05-15 13:43:42 +0300737 return 0;
738}
739
740/**
741 * _mei_irq_thread_cmpl - processes completed and no-iamthif operation.
742 *
743 * @dev: the device structure.
744 * @slots: free slots.
745 * @cb_pos: callback block.
746 * @cl: private data of the file object.
747 * @cmpl_list: complete list.
748 *
749 * returns 0, OK; otherwise, error.
750 */
751static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
752 struct mei_cl_cb *cb_pos,
753 struct mei_cl *cl,
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200754 struct mei_cl_cb *cmpl_list)
Oren Weilfb7d8792011-05-15 13:43:42 +0300755{
756 struct mei_msg_hdr *mei_hdr;
757
758 if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200759 (cb_pos->request_buffer.size - cb_pos->buf_idx))) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300760 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
761 mei_hdr->host_addr = cl->host_client_id;
762 mei_hdr->me_addr = cl->me_client_id;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200763 mei_hdr->length = cb_pos->request_buffer.size - cb_pos->buf_idx;
Oren Weilfb7d8792011-05-15 13:43:42 +0300764 mei_hdr->msg_complete = 1;
765 mei_hdr->reserved = 0;
766 dev_dbg(&dev->pdev->dev, "cb_pos->request_buffer.size =%d"
767 "mei_hdr->msg_complete = %d\n",
768 cb_pos->request_buffer.size,
769 mei_hdr->msg_complete);
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200770 dev_dbg(&dev->pdev->dev, "cb_pos->buf_idx =%lu\n",
771 cb_pos->buf_idx);
Oren Weilfb7d8792011-05-15 13:43:42 +0300772 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
773 mei_hdr->length);
Tomas Winkler7bdf72d2012-07-04 19:24:52 +0300774 *slots -= mei_data2slots(mei_hdr->length);
Tomas Winkler1ccb7b62012-03-14 14:39:42 +0200775 if (mei_write_message(dev, mei_hdr,
Oren Weilfb7d8792011-05-15 13:43:42 +0300776 (unsigned char *)
777 (cb_pos->request_buffer.data +
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200778 cb_pos->buf_idx),
Oren Weilfb7d8792011-05-15 13:43:42 +0300779 mei_hdr->length)) {
780 cl->status = -ENODEV;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200781 list_move_tail(&cb_pos->list, &cmpl_list->list);
Oren Weilfb7d8792011-05-15 13:43:42 +0300782 return -ENODEV;
783 } else {
784 if (mei_flow_ctrl_reduce(dev, cl))
785 return -ENODEV;
786 cl->status = 0;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200787 cb_pos->buf_idx += mei_hdr->length;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200788 list_move_tail(&cb_pos->list, &dev->write_waiting_list.list);
Oren Weilfb7d8792011-05-15 13:43:42 +0300789 }
Tomas Winkler24aadc82012-06-25 23:46:27 +0300790 } else if (*slots == dev->hbuf_depth) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300791 /* buffer is still empty */
792 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
793 mei_hdr->host_addr = cl->host_client_id;
794 mei_hdr->me_addr = cl->me_client_id;
795 mei_hdr->length =
796 (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
797 mei_hdr->msg_complete = 0;
798 mei_hdr->reserved = 0;
Tomas Winkler7bdf72d2012-07-04 19:24:52 +0300799 *slots -= mei_data2slots(mei_hdr->length);
Tomas Winkler1ccb7b62012-03-14 14:39:42 +0200800 if (mei_write_message(dev, mei_hdr,
Oren Weilfb7d8792011-05-15 13:43:42 +0300801 (unsigned char *)
802 (cb_pos->request_buffer.data +
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200803 cb_pos->buf_idx),
Oren Weilfb7d8792011-05-15 13:43:42 +0300804 mei_hdr->length)) {
805 cl->status = -ENODEV;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200806 list_move_tail(&cb_pos->list, &cmpl_list->list);
Oren Weilfb7d8792011-05-15 13:43:42 +0300807 return -ENODEV;
808 } else {
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200809 cb_pos->buf_idx += mei_hdr->length;
Oren Weilfb7d8792011-05-15 13:43:42 +0300810 dev_dbg(&dev->pdev->dev,
811 "cb_pos->request_buffer.size =%d"
812 " mei_hdr->msg_complete = %d\n",
813 cb_pos->request_buffer.size,
814 mei_hdr->msg_complete);
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200815 dev_dbg(&dev->pdev->dev, "cb_pos->buf_idx =%lu\n",
816 cb_pos->buf_idx);
Oren Weilfb7d8792011-05-15 13:43:42 +0300817 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
818 mei_hdr->length);
819 }
820 return -EMSGSIZE;
821 } else {
822 return -EBADMSG;
823 }
824
825 return 0;
826}
827
828/**
Oren Weilfb7d8792011-05-15 13:43:42 +0300829 * mei_irq_thread_read_handler - bottom half read routine after ISR to
830 * handle the read processing.
831 *
832 * @cmpl_list: An instance of our list structure
833 * @dev: the device structure
834 * @slots: slots to read.
835 *
836 * returns 0 on success, <0 on failure.
837 */
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200838static int mei_irq_thread_read_handler(struct mei_cl_cb *cmpl_list,
Oren Weilfb7d8792011-05-15 13:43:42 +0300839 struct mei_device *dev,
840 s32 *slots)
841{
842 struct mei_msg_hdr *mei_hdr;
843 struct mei_cl *cl_pos = NULL;
844 struct mei_cl *cl_next = NULL;
845 int ret = 0;
846
847 if (!dev->rd_msg_hdr) {
848 dev->rd_msg_hdr = mei_mecbrw_read(dev);
849 dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
850 (*slots)--;
851 dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
852 }
853 mei_hdr = (struct mei_msg_hdr *) &dev->rd_msg_hdr;
854 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", mei_hdr->length);
855
856 if (mei_hdr->reserved || !dev->rd_msg_hdr) {
857 dev_dbg(&dev->pdev->dev, "corrupted message header.\n");
858 ret = -EBADMSG;
859 goto end;
860 }
861
862 if (mei_hdr->host_addr || mei_hdr->me_addr) {
863 list_for_each_entry_safe(cl_pos, cl_next,
864 &dev->file_list, link) {
865 dev_dbg(&dev->pdev->dev,
866 "list_for_each_entry_safe read host"
867 " client = %d, ME client = %d\n",
868 cl_pos->host_client_id,
869 cl_pos->me_client_id);
870 if (cl_pos->host_client_id == mei_hdr->host_addr &&
871 cl_pos->me_client_id == mei_hdr->me_addr)
872 break;
873 }
874
875 if (&cl_pos->link == &dev->file_list) {
876 dev_dbg(&dev->pdev->dev, "corrupted message header\n");
877 ret = -EBADMSG;
878 goto end;
879 }
880 }
881 if (((*slots) * sizeof(u32)) < mei_hdr->length) {
882 dev_dbg(&dev->pdev->dev,
883 "we can't read the message slots =%08x.\n",
884 *slots);
885 /* we can't read the message */
886 ret = -ERANGE;
887 goto end;
888 }
889
890 /* decide where to read the message too */
891 if (!mei_hdr->host_addr) {
892 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_bus_message.\n");
893 mei_irq_thread_read_bus_message(dev, mei_hdr);
894 dev_dbg(&dev->pdev->dev, "end mei_irq_thread_read_bus_message.\n");
895 } else if (mei_hdr->host_addr == dev->iamthif_cl.host_client_id &&
896 (MEI_FILE_CONNECTED == dev->iamthif_cl.state) &&
897 (dev->iamthif_state == MEI_IAMTHIF_READING)) {
898 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_iamthif_message.\n");
899 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
900 mei_hdr->length);
Tomas Winkler19838fb2012-11-01 21:17:15 +0200901
902 ret = mei_amthif_irq_read_message(cmpl_list, dev, mei_hdr);
Oren Weilfb7d8792011-05-15 13:43:42 +0300903 if (ret)
904 goto end;
905
906 } else {
907 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_client_message.\n");
908 ret = mei_irq_thread_read_client_message(cmpl_list,
909 dev, mei_hdr);
910 if (ret)
911 goto end;
912
913 }
914
915 /* reset the number of slots and header */
916 *slots = mei_count_full_read_slots(dev);
917 dev->rd_msg_hdr = 0;
918
919 if (*slots == -EOVERFLOW) {
920 /* overflow - reset */
921 dev_dbg(&dev->pdev->dev, "resetting due to slots overflow.\n");
922 /* set the event since message has been read */
923 ret = -ERANGE;
924 goto end;
925 }
926end:
927 return ret;
928}
929
930
931/**
932 * mei_irq_thread_write_handler - bottom half write routine after
933 * ISR to handle the write processing.
934 *
935 * @cmpl_list: An instance of our list structure
936 * @dev: the device structure
937 * @slots: slots to write.
938 *
939 * returns 0 on success, <0 on failure.
940 */
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200941static int mei_irq_thread_write_handler(struct mei_cl_cb *cmpl_list,
942 struct mei_device *dev, s32 *slots)
Oren Weilfb7d8792011-05-15 13:43:42 +0300943{
944
945 struct mei_cl *cl;
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200946 struct mei_cl_cb *pos = NULL, *next = NULL;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200947 struct mei_cl_cb *list;
Oren Weilfb7d8792011-05-15 13:43:42 +0300948 int ret;
949
Tomas Winkler726917f2012-06-25 23:46:28 +0300950 if (!mei_hbuf_is_empty(dev)) {
Oren Weilfb7d8792011-05-15 13:43:42 +0300951 dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n");
952 return 0;
953 }
Tomas Winkler726917f2012-06-25 23:46:28 +0300954 *slots = mei_hbuf_empty_slots(dev);
Tomas Winkler7d5e0e52012-06-19 09:13:36 +0300955 if (*slots <= 0)
956 return -EMSGSIZE;
957
Oren Weilfb7d8792011-05-15 13:43:42 +0300958 /* complete all waiting for write CB */
959 dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n");
960
961 list = &dev->write_waiting_list;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200962 list_for_each_entry_safe(pos, next, &list->list, list) {
Tomas Winklerdb3ed432012-11-11 17:37:59 +0200963 cl = pos->cl;
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200964 if (cl == NULL)
965 continue;
Oren Weilfb7d8792011-05-15 13:43:42 +0300966
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200967 cl->status = 0;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200968 list_del(&pos->list);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200969 if (MEI_WRITING == cl->writing_state &&
Tomas Winkler4b8960b2012-11-11 17:38:00 +0200970 pos->fop_type == MEI_FOP_WRITE &&
971 cl != &dev->iamthif_cl) {
Tomas Winkler483136e2012-07-04 19:24:54 +0300972 dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n");
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200973 cl->writing_state = MEI_WRITE_COMPLETE;
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200974 list_add_tail(&pos->list, &cmpl_list->list);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200975 }
976 if (cl == &dev->iamthif_cl) {
977 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
978 if (dev->iamthif_flow_control_pending) {
Tomas Winkler19838fb2012-11-01 21:17:15 +0200979 ret = mei_amthif_irq_read(dev, slots);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200980 if (ret)
981 return ret;
982 }
Oren Weilfb7d8792011-05-15 13:43:42 +0300983 }
984 }
985
Tomas Winklerc216fde2012-08-16 19:39:43 +0300986 if (dev->wd_state == MEI_WD_STOPPING) {
987 dev->wd_state = MEI_WD_IDLE;
Oren Weilfb7d8792011-05-15 13:43:42 +0300988 wake_up_interruptible(&dev->wait_stop_wd);
Oren Weilfb7d8792011-05-15 13:43:42 +0300989 }
990
991 if (dev->extra_write_index) {
992 dev_dbg(&dev->pdev->dev, "extra_write_index =%d.\n",
993 dev->extra_write_index);
994 mei_write_message(dev,
995 (struct mei_msg_hdr *) &dev->ext_msg_buf[0],
996 (unsigned char *) &dev->ext_msg_buf[1],
997 (dev->extra_write_index - 1) * sizeof(u32));
998 *slots -= dev->extra_write_index;
999 dev->extra_write_index = 0;
1000 }
Tomas Winklerb210d752012-08-07 00:03:56 +03001001 if (dev->dev_state == MEI_DEV_ENABLED) {
Oren Weilfb7d8792011-05-15 13:43:42 +03001002 if (dev->wd_pending &&
Tomas Winkler483136e2012-07-04 19:24:54 +03001003 mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
Oren Weilfb7d8792011-05-15 13:43:42 +03001004 if (mei_wd_send(dev))
1005 dev_dbg(&dev->pdev->dev, "wd send failed.\n");
Tomas Winkler483136e2012-07-04 19:24:54 +03001006 else if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
1007 return -ENODEV;
Oren Weilfb7d8792011-05-15 13:43:42 +03001008
Tomas Winklereb9af0a2011-05-25 17:28:22 +03001009 dev->wd_pending = false;
Oren Weilfb7d8792011-05-15 13:43:42 +03001010
Tomas Winklerc216fde2012-08-16 19:39:43 +03001011 if (dev->wd_state == MEI_WD_RUNNING)
Tomas Winkler248ffdf2012-08-16 19:39:42 +03001012 *slots -= mei_data2slots(MEI_WD_START_MSG_SIZE);
Tomas Winklerd242a0a2012-07-04 19:24:50 +03001013 else
Tomas Winkler248ffdf2012-08-16 19:39:42 +03001014 *slots -= mei_data2slots(MEI_WD_STOP_MSG_SIZE);
Oren Weilfb7d8792011-05-15 13:43:42 +03001015 }
1016 }
Oren Weilfb7d8792011-05-15 13:43:42 +03001017
1018 /* complete control write list CB */
Tomas Winklerc8372092011-11-27 21:43:33 +02001019 dev_dbg(&dev->pdev->dev, "complete control write list cb.\n");
Tomas Winklerfb601ad2012-10-15 12:06:48 +02001020 list_for_each_entry_safe(pos, next, &dev->ctrl_wr_list.list, list) {
Tomas Winklerdb3ed432012-11-11 17:37:59 +02001021 cl = pos->cl;
Tomas Winklerc8372092011-11-27 21:43:33 +02001022 if (!cl) {
Tomas Winklerfb601ad2012-10-15 12:06:48 +02001023 list_del(&pos->list);
Tomas Winklerc8372092011-11-27 21:43:33 +02001024 return -ENODEV;
Oren Weilfb7d8792011-05-15 13:43:42 +03001025 }
Tomas Winkler4b8960b2012-11-11 17:38:00 +02001026 switch (pos->fop_type) {
1027 case MEI_FOP_CLOSE:
Tomas Winklerc8372092011-11-27 21:43:33 +02001028 /* send disconnect message */
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001029 ret = _mei_irq_thread_close(dev, slots, pos, cl, cmpl_list);
Tomas Winklerc8372092011-11-27 21:43:33 +02001030 if (ret)
1031 return ret;
1032
1033 break;
Tomas Winkler4b8960b2012-11-11 17:38:00 +02001034 case MEI_FOP_READ:
Tomas Winklerc8372092011-11-27 21:43:33 +02001035 /* send flow control message */
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001036 ret = _mei_irq_thread_read(dev, slots, pos, cl, cmpl_list);
Tomas Winklerc8372092011-11-27 21:43:33 +02001037 if (ret)
1038 return ret;
1039
1040 break;
Tomas Winkler4b8960b2012-11-11 17:38:00 +02001041 case MEI_FOP_IOCTL:
Tomas Winklerc8372092011-11-27 21:43:33 +02001042 /* connect message */
Natalia Ovsyanikove8cd29d2011-12-05 00:16:54 +02001043 if (mei_other_client_is_connecting(dev, cl))
Tomas Winklerc8372092011-11-27 21:43:33 +02001044 continue;
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001045 ret = _mei_irq_thread_ioctl(dev, slots, pos, cl, cmpl_list);
Tomas Winklerc8372092011-11-27 21:43:33 +02001046 if (ret)
1047 return ret;
1048
1049 break;
1050
1051 default:
1052 BUG();
1053 }
1054
Oren Weilfb7d8792011-05-15 13:43:42 +03001055 }
1056 /* complete write list CB */
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001057 dev_dbg(&dev->pdev->dev, "complete write list cb.\n");
Tomas Winklerfb601ad2012-10-15 12:06:48 +02001058 list_for_each_entry_safe(pos, next, &dev->write_list.list, list) {
Tomas Winklerdb3ed432012-11-11 17:37:59 +02001059 cl = pos->cl;
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001060 if (cl == NULL)
1061 continue;
Oren Weilfb7d8792011-05-15 13:43:42 +03001062
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001063 if (cl != &dev->iamthif_cl) {
Tomas Winklerd2041152012-06-19 09:13:34 +03001064 if (mei_flow_ctrl_creds(dev, cl) <= 0) {
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001065 dev_dbg(&dev->pdev->dev,
Tomas Winkler483136e2012-07-04 19:24:54 +03001066 "No flow control credentials for client %d, not sending.\n",
1067 cl->host_client_id);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001068 continue;
Oren Weilfb7d8792011-05-15 13:43:42 +03001069 }
Tomas Winkler483136e2012-07-04 19:24:54 +03001070 ret = _mei_irq_thread_cmpl(dev, slots, pos,
1071 cl, cmpl_list);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001072 if (ret)
1073 return ret;
1074
1075 } else if (cl == &dev->iamthif_cl) {
1076 /* IAMTHIF IOCTL */
1077 dev_dbg(&dev->pdev->dev, "complete amthi write cb.\n");
Tomas Winklerd2041152012-06-19 09:13:34 +03001078 if (mei_flow_ctrl_creds(dev, cl) <= 0) {
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001079 dev_dbg(&dev->pdev->dev,
Tomas Winkler483136e2012-07-04 19:24:54 +03001080 "No flow control credentials for amthi client %d.\n",
1081 cl->host_client_id);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001082 continue;
1083 }
Tomas Winkler19838fb2012-11-01 21:17:15 +02001084 ret = mei_amthif_irq_process_completed(dev, slots, pos,
1085 cl, cmpl_list);
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001086 if (ret)
1087 return ret;
Oren Weilfb7d8792011-05-15 13:43:42 +03001088
1089 }
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001090
Oren Weilfb7d8792011-05-15 13:43:42 +03001091 }
1092 return 0;
1093}
1094
1095
1096
1097/**
1098 * mei_timer - timer function.
1099 *
1100 * @work: pointer to the work_struct structure
1101 *
1102 * NOTE: This function is called by timer interrupt work
1103 */
Oren Weila61c6532011-09-07 09:03:13 +03001104void mei_timer(struct work_struct *work)
Oren Weilfb7d8792011-05-15 13:43:42 +03001105{
1106 unsigned long timeout;
1107 struct mei_cl *cl_pos = NULL;
1108 struct mei_cl *cl_next = NULL;
Oren Weilfb7d8792011-05-15 13:43:42 +03001109 struct mei_cl_cb *cb_pos = NULL;
1110 struct mei_cl_cb *cb_next = NULL;
1111
1112 struct mei_device *dev = container_of(work,
Oren Weila61c6532011-09-07 09:03:13 +03001113 struct mei_device, timer_work.work);
Oren Weilfb7d8792011-05-15 13:43:42 +03001114
1115
1116 mutex_lock(&dev->device_lock);
Tomas Winklerb210d752012-08-07 00:03:56 +03001117 if (dev->dev_state != MEI_DEV_ENABLED) {
1118 if (dev->dev_state == MEI_DEV_INIT_CLIENTS) {
Oren Weilfb7d8792011-05-15 13:43:42 +03001119 if (dev->init_clients_timer) {
1120 if (--dev->init_clients_timer == 0) {
1121 dev_dbg(&dev->pdev->dev, "IMEI reset due to init clients timeout ,init clients state = %d.\n",
1122 dev->init_clients_state);
1123 mei_reset(dev, 1);
1124 }
1125 }
1126 }
1127 goto out;
1128 }
1129 /*** connect/disconnect timeouts ***/
1130 list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
1131 if (cl_pos->timer_count) {
1132 if (--cl_pos->timer_count == 0) {
1133 dev_dbg(&dev->pdev->dev, "HECI reset due to connect/disconnect timeout.\n");
1134 mei_reset(dev, 1);
1135 goto out;
1136 }
1137 }
1138 }
1139
Oren Weilfb7d8792011-05-15 13:43:42 +03001140 if (dev->iamthif_stall_timer) {
1141 if (--dev->iamthif_stall_timer == 0) {
Masanari Iida32de21f2012-01-25 23:14:56 +09001142 dev_dbg(&dev->pdev->dev, "resetting because of hang to amthi.\n");
Oren Weilfb7d8792011-05-15 13:43:42 +03001143 mei_reset(dev, 1);
1144 dev->iamthif_msg_buf_size = 0;
1145 dev->iamthif_msg_buf_index = 0;
Tomas Winklereb9af0a2011-05-25 17:28:22 +03001146 dev->iamthif_canceled = false;
1147 dev->iamthif_ioctl = true;
Oren Weilfb7d8792011-05-15 13:43:42 +03001148 dev->iamthif_state = MEI_IAMTHIF_IDLE;
1149 dev->iamthif_timer = 0;
1150
Tomas Winkler601a1ef2012-10-09 16:50:20 +02001151 mei_io_cb_free(dev->iamthif_current_cb);
1152 dev->iamthif_current_cb = NULL;
Oren Weilfb7d8792011-05-15 13:43:42 +03001153
1154 dev->iamthif_file_object = NULL;
Tomas Winkler19838fb2012-11-01 21:17:15 +02001155 mei_amthif_run_next_cmd(dev);
Oren Weilfb7d8792011-05-15 13:43:42 +03001156 }
1157 }
1158
1159 if (dev->iamthif_timer) {
1160
1161 timeout = dev->iamthif_timer +
Tomas Winkler3870c322012-11-01 21:17:14 +02001162 mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
Oren Weilfb7d8792011-05-15 13:43:42 +03001163
1164 dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
1165 dev->iamthif_timer);
1166 dev_dbg(&dev->pdev->dev, "timeout = %ld\n", timeout);
1167 dev_dbg(&dev->pdev->dev, "jiffies = %ld\n", jiffies);
1168 if (time_after(jiffies, timeout)) {
1169 /*
1170 * User didn't read the AMTHI data on time (15sec)
1171 * freeing AMTHI for other requests
1172 */
1173
1174 dev_dbg(&dev->pdev->dev, "freeing AMTHI for other requests\n");
1175
Tomas Winklere773efc2012-11-11 17:37:58 +02001176 list_for_each_entry_safe(cb_pos, cb_next,
1177 &dev->amthif_rd_complete_list.list, list) {
Oren Weilfb7d8792011-05-15 13:43:42 +03001178
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001179 cl_pos = cb_pos->file_object->private_data;
Oren Weilfb7d8792011-05-15 13:43:42 +03001180
Tomas Winklerb7cd2d92011-11-27 21:43:34 +02001181 /* Finding the AMTHI entry. */
1182 if (cl_pos == &dev->iamthif_cl)
Tomas Winklerfb601ad2012-10-15 12:06:48 +02001183 list_del(&cb_pos->list);
Oren Weilfb7d8792011-05-15 13:43:42 +03001184 }
Tomas Winkler601a1ef2012-10-09 16:50:20 +02001185 mei_io_cb_free(dev->iamthif_current_cb);
1186 dev->iamthif_current_cb = NULL;
Oren Weilfb7d8792011-05-15 13:43:42 +03001187
1188 dev->iamthif_file_object->private_data = NULL;
1189 dev->iamthif_file_object = NULL;
Oren Weilfb7d8792011-05-15 13:43:42 +03001190 dev->iamthif_timer = 0;
Tomas Winkler19838fb2012-11-01 21:17:15 +02001191 mei_amthif_run_next_cmd(dev);
Oren Weilfb7d8792011-05-15 13:43:42 +03001192
1193 }
1194 }
1195out:
Tomas Winkler441ab502011-12-13 23:39:34 +02001196 schedule_delayed_work(&dev->timer_work, 2 * HZ);
1197 mutex_unlock(&dev->device_lock);
Oren Weilfb7d8792011-05-15 13:43:42 +03001198}
1199
1200/**
1201 * mei_interrupt_thread_handler - function called after ISR to handle the interrupt
1202 * processing.
1203 *
1204 * @irq: The irq number
1205 * @dev_id: pointer to the device structure
1206 *
1207 * returns irqreturn_t
1208 *
1209 */
1210irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
1211{
1212 struct mei_device *dev = (struct mei_device *) dev_id;
Tomas Winklerfb601ad2012-10-15 12:06:48 +02001213 struct mei_cl_cb complete_list;
Oren Weilfb7d8792011-05-15 13:43:42 +03001214 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
1215 struct mei_cl *cl;
1216 s32 slots;
1217 int rets;
1218 bool bus_message_received;
1219
1220
1221 dev_dbg(&dev->pdev->dev, "function called after ISR to handle the interrupt processing.\n");
1222 /* initialize our complete list */
1223 mutex_lock(&dev->device_lock);
Tomas Winkler0288c7c2011-06-06 10:44:34 +03001224 mei_io_list_init(&complete_list);
Oren Weilfb7d8792011-05-15 13:43:42 +03001225 dev->host_hw_state = mei_hcsr_read(dev);
Tomas Winkler4f61a7a2011-07-14 20:11:25 +03001226
1227 /* Ack the interrupt here
Justin P. Mattock5f9092f32012-03-12 07:18:09 -07001228 * In case of MSI we don't go through the quick handler */
Tomas Winkler4f61a7a2011-07-14 20:11:25 +03001229 if (pci_dev_msi_enabled(dev->pdev))
1230 mei_reg_write(dev, H_CSR, dev->host_hw_state);
1231
Oren Weilfb7d8792011-05-15 13:43:42 +03001232 dev->me_hw_state = mei_mecsr_read(dev);
1233
1234 /* check if ME wants a reset */
1235 if ((dev->me_hw_state & ME_RDY_HRA) == 0 &&
Tomas Winklerb210d752012-08-07 00:03:56 +03001236 dev->dev_state != MEI_DEV_RESETING &&
1237 dev->dev_state != MEI_DEV_INITIALIZING) {
Oren Weilfb7d8792011-05-15 13:43:42 +03001238 dev_dbg(&dev->pdev->dev, "FW not ready.\n");
1239 mei_reset(dev, 1);
1240 mutex_unlock(&dev->device_lock);
1241 return IRQ_HANDLED;
1242 }
1243
1244 /* check if we need to start the dev */
1245 if ((dev->host_hw_state & H_RDY) == 0) {
1246 if ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA) {
1247 dev_dbg(&dev->pdev->dev, "we need to start the dev.\n");
1248 dev->host_hw_state |= (H_IE | H_IG | H_RDY);
1249 mei_hcsr_set(dev);
Tomas Winklerb210d752012-08-07 00:03:56 +03001250 dev->dev_state = MEI_DEV_INIT_CLIENTS;
Oren Weilfb7d8792011-05-15 13:43:42 +03001251 dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n");
1252 /* link is established
1253 * start sending messages.
1254 */
Tomas Winklerc95efb72011-05-25 17:28:21 +03001255 mei_host_start_message(dev);
Oren Weilfb7d8792011-05-15 13:43:42 +03001256 mutex_unlock(&dev->device_lock);
1257 return IRQ_HANDLED;
1258 } else {
1259 dev_dbg(&dev->pdev->dev, "FW not ready.\n");
1260 mutex_unlock(&dev->device_lock);
1261 return IRQ_HANDLED;
1262 }
1263 }
Justin P. Mattock5f9092f32012-03-12 07:18:09 -07001264 /* check slots available for reading */
Oren Weilfb7d8792011-05-15 13:43:42 +03001265 slots = mei_count_full_read_slots(dev);
1266 dev_dbg(&dev->pdev->dev, "slots =%08x extra_write_index =%08x.\n",
1267 slots, dev->extra_write_index);
1268 while (slots > 0 && !dev->extra_write_index) {
1269 dev_dbg(&dev->pdev->dev, "slots =%08x extra_write_index =%08x.\n",
1270 slots, dev->extra_write_index);
1271 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_handler.\n");
1272 rets = mei_irq_thread_read_handler(&complete_list, dev, &slots);
1273 if (rets)
1274 goto end;
1275 }
1276 rets = mei_irq_thread_write_handler(&complete_list, dev, &slots);
1277end:
1278 dev_dbg(&dev->pdev->dev, "end of bottom half function.\n");
1279 dev->host_hw_state = mei_hcsr_read(dev);
Tomas Winkler726917f2012-06-25 23:46:28 +03001280 dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
Oren Weilfb7d8792011-05-15 13:43:42 +03001281
1282 bus_message_received = false;
1283 if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) {
1284 dev_dbg(&dev->pdev->dev, "received waiting bus message\n");
1285 bus_message_received = true;
1286 }
1287 mutex_unlock(&dev->device_lock);
1288 if (bus_message_received) {
1289 dev_dbg(&dev->pdev->dev, "wake up dev->wait_recvd_msg\n");
1290 wake_up_interruptible(&dev->wait_recvd_msg);
1291 bus_message_received = false;
1292 }
Tomas Winklerfb601ad2012-10-15 12:06:48 +02001293 if (list_empty(&complete_list.list))
Oren Weilfb7d8792011-05-15 13:43:42 +03001294 return IRQ_HANDLED;
1295
1296
Tomas Winklerfb601ad2012-10-15 12:06:48 +02001297 list_for_each_entry_safe(cb_pos, cb_next, &complete_list.list, list) {
Tomas Winklerdb3ed432012-11-11 17:37:59 +02001298 cl = cb_pos->cl;
Tomas Winklerfb601ad2012-10-15 12:06:48 +02001299 list_del(&cb_pos->list);
Oren Weilfb7d8792011-05-15 13:43:42 +03001300 if (cl) {
1301 if (cl != &dev->iamthif_cl) {
1302 dev_dbg(&dev->pdev->dev, "completing call back.\n");
1303 _mei_cmpl(cl, cb_pos);
1304 cb_pos = NULL;
1305 } else if (cl == &dev->iamthif_cl) {
Tomas Winkler19838fb2012-11-01 21:17:15 +02001306 mei_amthif_complete(dev, cb_pos);
Oren Weilfb7d8792011-05-15 13:43:42 +03001307 }
1308 }
1309 }
1310 return IRQ_HANDLED;
1311}