interrupt.c 14.0 KB
Newer Older
O
Oren Weil 已提交
1 2 3
/*
 *
 * Intel Management Engine Interface (Intel MEI) Linux driver
4
 * Copyright (c) 2003-2012, Intel Corporation.
O
Oren Weil 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 */


18
#include <linux/export.h>
O
Oren Weil 已提交
19 20 21 22
#include <linux/kthread.h>
#include <linux/interrupt.h>
#include <linux/fs.h>
#include <linux/jiffies.h>
23
#include <linux/slab.h>
O
Oren Weil 已提交
24

25
#include <linux/mei.h>
26 27

#include "mei_dev.h"
28
#include "hbm.h"
T
Tomas Winkler 已提交
29
#include "client.h"
O
Oren Weil 已提交
30 31


32
/**
33
 * mei_irq_compl_handler - dispatch complete handlers
34 35
 *	for the completed callbacks
 *
36 37
 * @dev: mei device
 * @compl_list: list of completed cbs
38 39 40 41 42 43 44 45
 */
void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *compl_list)
{
	struct mei_cl_cb *cb, *next;
	struct mei_cl *cl;

	list_for_each_entry_safe(cb, next, &compl_list->list, list) {
		cl = cb->cl;
46
		list_del_init(&cb->list);
47

48
		dev_dbg(dev->dev, "completing call back.\n");
49 50 51
		if (cl == &dev->iamthif_cl)
			mei_amthif_complete(dev, cb);
		else
52
			mei_cl_complete(cl, cb);
53 54
	}
}
55
EXPORT_SYMBOL_GPL(mei_irq_compl_handler);
56

O
Oren Weil 已提交
57
/**
58
 * mei_cl_hbm_equal - check if hbm is addressed to the client
O
Oren Weil 已提交
59
 *
60
 * @cl: host client
O
Oren Weil 已提交
61 62
 * @mei_hdr: header of mei client message
 *
63
 * Return: true if matches, false otherwise
O
Oren Weil 已提交
64
 */
65 66
static inline int mei_cl_hbm_equal(struct mei_cl *cl,
			struct mei_msg_hdr *mei_hdr)
O
Oren Weil 已提交
67
{
68 69 70 71
	return cl->host_client_id == mei_hdr->host_addr &&
		cl->me_client_id == mei_hdr->me_addr;
}
/**
72
 * mei_cl_is_reading - checks if the client is in reading state
73 74 75
 *
 * @cl: mei client
 *
76
 * Return: true if the client is reading
77
 */
78
static bool mei_cl_is_reading(struct mei_cl *cl)
79
{
80
	return cl->state == MEI_FILE_CONNECTED &&
81
		cl->reading_state != MEI_READ_COMPLETE;
O
Oren Weil 已提交
82 83 84
}

/**
A
Alexander Usyskin 已提交
85
 * mei_cl_irq_read_msg - process client message
O
Oren Weil 已提交
86
 *
87
 * @cl: reading client
O
Oren Weil 已提交
88
 * @mei_hdr: header of mei client message
89
 * @complete_list: completion list
O
Oren Weil 已提交
90
 *
91
 * Return: always 0
O
Oren Weil 已提交
92
 */
93
static int mei_cl_irq_read_msg(struct mei_cl *cl,
94 95
			       struct mei_msg_hdr *mei_hdr,
			       struct mei_cl_cb *complete_list)
O
Oren Weil 已提交
96
{
97 98
	struct mei_device *dev = cl->dev;
	struct mei_cl_cb *cb;
99
	unsigned char *buffer = NULL;
O
Oren Weil 已提交
100

101 102 103 104
	list_for_each_entry(cb, &dev->read_list.list, list) {
		if (cl == cb->cl)
			break;
	}
105

106 107 108 109
	if (&cb->list == &dev->read_list.list) {
		dev_err(dev->dev, "no reader found\n");
		goto out;
	}
110

111 112 113 114 115
	if (!mei_cl_is_reading(cl)) {
		cl_err(dev, cl, "cl is not reading state=%d reading state=%d\n",
			cl->state, cl->reading_state);
		goto out;
	}
116

117
	cl->reading_state = MEI_READING;
O
Oren Weil 已提交
118

119 120 121 122 123 124 125
	if (cb->response_buffer.size == 0 ||
	    cb->response_buffer.data == NULL) {
		cl_err(dev, cl, "response buffer is not allocated.\n");
		list_move_tail(&cb->list, &complete_list->list);
		cb->status = -ENOMEM;
		goto out;
	}
126

127 128 129 130 131 132 133 134 135 136 137
	if (cb->response_buffer.size < mei_hdr->length + cb->buf_idx) {
		cl_dbg(dev, cl, "message overflow. size %d len %d idx %ld\n",
			cb->response_buffer.size, mei_hdr->length, cb->buf_idx);
		buffer = krealloc(cb->response_buffer.data,
				  mei_hdr->length + cb->buf_idx,
				  GFP_KERNEL);

		if (!buffer) {
			cb->status = -ENOMEM;
			list_move_tail(&cb->list, &complete_list->list);
			goto out;
138
		}
139 140
		cb->response_buffer.data = buffer;
		cb->response_buffer.size = mei_hdr->length + cb->buf_idx;
O
Oren Weil 已提交
141 142
	}

143 144 145 146 147 148 149 150 151 152 153
	buffer = cb->response_buffer.data + cb->buf_idx;
	mei_read_slots(dev, buffer, mei_hdr->length);

	cb->buf_idx += mei_hdr->length;
	if (mei_hdr->msg_complete) {
		cl_dbg(dev, cl, "completed read length = %lu\n",
			cb->buf_idx);
		list_move_tail(&cb->list, &complete_list->list);
	}

out:
O
Oren Weil 已提交
154
	if (!buffer) {
155 156
		/* assume that mei_hdr->length <= MEI_RD_MSG_BUF_SIZE */
		BUG_ON(mei_hdr->length > MEI_RD_MSG_BUF_SIZE);
157
		mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
158
		dev_dbg(dev->dev, "discarding message " MEI_HDR_FMT "\n",
159
				MEI_HDR_PRM(mei_hdr));
O
Oren Weil 已提交
160 161 162 163 164
	}

	return 0;
}

T
Tomas Winkler 已提交
165 166 167 168 169 170 171
/**
 * mei_cl_irq_disconnect_rsp - send disconnection response message
 *
 * @cl: client
 * @cb: callback block.
 * @cmpl_list: complete list.
 *
172
 * Return: 0, OK; otherwise, error.
T
Tomas Winkler 已提交
173 174
 */
static int mei_cl_irq_disconnect_rsp(struct mei_cl *cl, struct mei_cl_cb *cb,
175
				     struct mei_cl_cb *cmpl_list)
T
Tomas Winkler 已提交
176 177
{
	struct mei_device *dev = cl->dev;
178 179
	u32 msg_slots;
	int slots;
T
Tomas Winkler 已提交
180 181
	int ret;

182 183
	slots = mei_hbuf_empty_slots(dev);
	msg_slots = mei_data2slots(sizeof(struct hbm_client_connect_response));
T
Tomas Winkler 已提交
184

185
	if (slots < msg_slots)
T
Tomas Winkler 已提交
186 187 188 189 190 191
		return -EMSGSIZE;

	ret = mei_hbm_cl_disconnect_rsp(dev, cl);

	cl->state = MEI_FILE_DISCONNECTED;
	cl->status = 0;
192
	list_del(&cb->list);
T
Tomas Winkler 已提交
193 194 195 196 197 198 199
	mei_io_cb_free(cb);

	return ret;
}



O
Oren Weil 已提交
200
/**
201
 * mei_cl_irq_disconnect - processes close related operation from
202
 *	interrupt thread context - send disconnect request
O
Oren Weil 已提交
203
 *
204 205
 * @cl: client
 * @cb: callback block.
O
Oren Weil 已提交
206 207
 * @cmpl_list: complete list.
 *
208
 * Return: 0, OK; otherwise, error.
O
Oren Weil 已提交
209
 */
210
static int mei_cl_irq_disconnect(struct mei_cl *cl, struct mei_cl_cb *cb,
211
			    struct mei_cl_cb *cmpl_list)
O
Oren Weil 已提交
212
{
213
	struct mei_device *dev = cl->dev;
214 215
	u32 msg_slots;
	int slots;
216

217 218
	msg_slots = mei_data2slots(sizeof(struct hbm_client_connect_request));
	slots = mei_hbuf_empty_slots(dev);
O
Oren Weil 已提交
219

220
	if (slots < msg_slots)
T
Tomas Winkler 已提交
221 222
		return -EMSGSIZE;

223
	if (mei_hbm_cl_disconnect_req(dev, cl)) {
224
		cl->status = 0;
225 226
		cb->buf_idx = 0;
		list_move_tail(&cb->list, &cmpl_list->list);
T
Tomas Winkler 已提交
227
		return -EIO;
O
Oren Weil 已提交
228 229
	}

T
Tomas Winkler 已提交
230 231
	cl->state = MEI_FILE_DISCONNECTING;
	cl->status = 0;
232 233
	cb->buf_idx = 0;
	list_move_tail(&cb->list, &dev->ctrl_rd_list.list);
T
Tomas Winkler 已提交
234 235
	cl->timer_count = MEI_CONNECT_TIMEOUT;

O
Oren Weil 已提交
236 237 238 239 240
	return 0;
}


/**
A
Alexander Usyskin 已提交
241
 * mei_cl_irq_read - processes client read related operation from the
242
 *	interrupt thread context - request for flow control credits
O
Oren Weil 已提交
243
 *
244 245
 * @cl: client
 * @cb: callback block.
O
Oren Weil 已提交
246 247
 * @cmpl_list: complete list.
 *
248
 * Return: 0, OK; otherwise, error.
O
Oren Weil 已提交
249
 */
250
static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
251
			   struct mei_cl_cb *cmpl_list)
O
Oren Weil 已提交
252
{
253
	struct mei_device *dev = cl->dev;
254 255
	u32 msg_slots;
	int slots;
256 257
	int ret;

258 259
	msg_slots = mei_data2slots(sizeof(struct hbm_flow_control));
	slots = mei_hbuf_empty_slots(dev);
260

261
	if (slots < msg_slots)
T
Tomas Winkler 已提交
262
		return -EMSGSIZE;
263

264 265 266
	ret = mei_hbm_cl_flow_control_req(dev, cl);
	if (ret) {
		cl->status = ret;
267 268
		cb->buf_idx = 0;
		list_move_tail(&cb->list, &cmpl_list->list);
269
		return ret;
270
	}
271

272
	list_move_tail(&cb->list, &dev->read_list.list);
273

O
Oren Weil 已提交
274 275 276 277 278
	return 0;
}


/**
279
 * mei_cl_irq_connect - send connect request in irq_thread context
O
Oren Weil 已提交
280
 *
281 282
 * @cl: client
 * @cb: callback block.
O
Oren Weil 已提交
283 284
 * @cmpl_list: complete list.
 *
285
 * Return: 0, OK; otherwise, error.
O
Oren Weil 已提交
286
 */
287
static int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb,
288
			      struct mei_cl_cb *cmpl_list)
O
Oren Weil 已提交
289
{
290
	struct mei_device *dev = cl->dev;
291 292
	u32 msg_slots;
	int slots;
293
	int ret;
294

295 296
	msg_slots = mei_data2slots(sizeof(struct hbm_client_connect_request));
	slots = mei_hbuf_empty_slots(dev);
T
Tomas Winkler 已提交
297

298 299 300
	if (mei_cl_is_other_connecting(cl))
		return 0;

301
	if (slots < msg_slots)
T
Tomas Winkler 已提交
302 303
		return -EMSGSIZE;

304
	cl->state = MEI_FILE_CONNECTING;
T
Tomas Winkler 已提交
305

306 307 308
	ret = mei_hbm_cl_connect_req(dev, cl);
	if (ret) {
		cl->status = ret;
309 310
		cb->buf_idx = 0;
		list_del(&cb->list);
311
		return ret;
312
	}
313 314 315

	list_move_tail(&cb->list, &dev->ctrl_rd_list.list);
	cl->timer_count = MEI_CONNECT_TIMEOUT;
O
Oren Weil 已提交
316 317 318 319 320
	return 0;
}


/**
321
 * mei_irq_read_handler - bottom half read routine after ISR to
O
Oren Weil 已提交
322 323 324
 * handle the read processing.
 *
 * @dev: the device structure
325
 * @cmpl_list: An instance of our list structure
O
Oren Weil 已提交
326 327
 * @slots: slots to read.
 *
328
 * Return: 0 on success, <0 on failure.
O
Oren Weil 已提交
329
 */
330 331
int mei_irq_read_handler(struct mei_device *dev,
		struct mei_cl_cb *cmpl_list, s32 *slots)
O
Oren Weil 已提交
332 333
{
	struct mei_msg_hdr *mei_hdr;
T
Tomas Winkler 已提交
334 335
	struct mei_cl *cl;
	int ret;
O
Oren Weil 已提交
336 337

	if (!dev->rd_msg_hdr) {
338
		dev->rd_msg_hdr = mei_read_hdr(dev);
O
Oren Weil 已提交
339
		(*slots)--;
340
		dev_dbg(dev->dev, "slots =%08x.\n", *slots);
O
Oren Weil 已提交
341 342
	}
	mei_hdr = (struct mei_msg_hdr *) &dev->rd_msg_hdr;
343
	dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM(mei_hdr));
O
Oren Weil 已提交
344 345

	if (mei_hdr->reserved || !dev->rd_msg_hdr) {
346
		dev_err(dev->dev, "corrupted message header 0x%08X\n",
T
Tomas Winkler 已提交
347
				dev->rd_msg_hdr);
O
Oren Weil 已提交
348 349 350 351
		ret = -EBADMSG;
		goto end;
	}

T
Tomas Winkler 已提交
352
	if (mei_slots2data(*slots) < mei_hdr->length) {
353
		dev_err(dev->dev, "less data available than length=%08x.\n",
O
Oren Weil 已提交
354 355
				*slots);
		/* we can't read the message */
356
		ret = -ENODATA;
O
Oren Weil 已提交
357 358 359
		goto end;
	}

T
Tomas Winkler 已提交
360 361
	/*  HBM message */
	if (mei_hdr->host_addr == 0 && mei_hdr->me_addr == 0) {
362 363
		ret = mei_hbm_dispatch(dev, mei_hdr);
		if (ret) {
364
			dev_dbg(dev->dev, "mei_hbm_dispatch failed ret = %d\n",
365 366 367
					ret);
			goto end;
		}
T
Tomas Winkler 已提交
368 369
		goto reset_slots;
	}
370

371
	/* find recipient cl */
T
Tomas Winkler 已提交
372 373 374 375 376 377 378
	list_for_each_entry(cl, &dev->file_list, link) {
		if (mei_cl_hbm_equal(cl, mei_hdr)) {
			cl_dbg(dev, cl, "got a message\n");
			break;
		}
	}

379
	/* if no recipient cl was found we assume corrupted header */
T
Tomas Winkler 已提交
380
	if (&cl->link == &dev->file_list) {
381
		dev_err(dev->dev, "no destination client found 0x%08X\n",
T
Tomas Winkler 已提交
382 383 384 385 386
				dev->rd_msg_hdr);
		ret = -EBADMSG;
		goto end;
	}

387 388
	if (cl == &dev->iamthif_cl) {
		ret = mei_amthif_irq_read_msg(cl, mei_hdr, cmpl_list);
O
Oren Weil 已提交
389
	} else {
390
		ret = mei_cl_irq_read_msg(cl, mei_hdr, cmpl_list);
O
Oren Weil 已提交
391 392
	}

393

T
Tomas Winkler 已提交
394
reset_slots:
O
Oren Weil 已提交
395 396 397 398 399 400
	/* reset the number of slots and header */
	*slots = mei_count_full_read_slots(dev);
	dev->rd_msg_hdr = 0;

	if (*slots == -EOVERFLOW) {
		/* overflow - reset */
401
		dev_err(dev->dev, "resetting due to slots overflow.\n");
O
Oren Weil 已提交
402 403 404 405 406 407 408
		/* set the event since message has been read */
		ret = -ERANGE;
		goto end;
	}
end:
	return ret;
}
409
EXPORT_SYMBOL_GPL(mei_irq_read_handler);
O
Oren Weil 已提交
410 411 412


/**
413 414
 * mei_irq_write_handler -  dispatch write requests
 *  after irq received
O
Oren Weil 已提交
415 416
 *
 * @dev: the device structure
417
 * @cmpl_list: An instance of our list structure
O
Oren Weil 已提交
418
 *
419
 * Return: 0 on success, <0 on failure.
O
Oren Weil 已提交
420
 */
T
Tomas Winkler 已提交
421
int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
O
Oren Weil 已提交
422 423 424
{

	struct mei_cl *cl;
425
	struct mei_cl_cb *cb, *next;
426
	struct mei_cl_cb *list;
427
	s32 slots;
O
Oren Weil 已提交
428 429
	int ret;

430 431

	if (!mei_hbuf_acquire(dev))
O
Oren Weil 已提交
432
		return 0;
433

434 435
	slots = mei_hbuf_empty_slots(dev);
	if (slots <= 0)
436 437
		return -EMSGSIZE;

O
Oren Weil 已提交
438
	/* complete all waiting for write CB */
439
	dev_dbg(dev->dev, "complete all waiting for write cb.\n");
O
Oren Weil 已提交
440 441

	list = &dev->write_waiting_list;
442 443
	list_for_each_entry_safe(cb, next, &list->list, list) {
		cl = cb->cl;
444 445

		cl->status = 0;
446 447 448
		cl_dbg(dev, cl, "MEI WRITE COMPLETE\n");
		cl->writing_state = MEI_WRITE_COMPLETE;
		list_move_tail(&cb->list, &cmpl_list->list);
O
Oren Weil 已提交
449 450
	}

451 452
	if (dev->wd_state == MEI_WD_STOPPING) {
		dev->wd_state = MEI_WD_IDLE;
453
		wake_up(&dev->wait_stop_wd);
O
Oren Weil 已提交
454 455
	}

456
	if (mei_cl_is_connected(&dev->wd_cl)) {
O
Oren Weil 已提交
457
		if (dev->wd_pending &&
T
Tomas Winkler 已提交
458
		    mei_cl_flow_ctrl_creds(&dev->wd_cl) > 0) {
459 460 461
			ret = mei_wd_send(dev);
			if (ret)
				return ret;
462
			dev->wd_pending = false;
O
Oren Weil 已提交
463 464 465 466
		}
	}

	/* complete control write list CB */
467
	dev_dbg(dev->dev, "complete control write list cb.\n");
468 469 470
	list_for_each_entry_safe(cb, next, &dev->ctrl_wr_list.list, list) {
		cl = cb->cl;
		switch (cb->fop_type) {
471
		case MEI_FOP_DISCONNECT:
472
			/* send disconnect message */
473
			ret = mei_cl_irq_disconnect(cl, cb, cmpl_list);
474 475
			if (ret)
				return ret;
O
Oren Weil 已提交
476

477
			break;
478
		case MEI_FOP_READ:
479
			/* send flow control message */
480
			ret = mei_cl_irq_read(cl, cb, cmpl_list);
481 482
			if (ret)
				return ret;
O
Oren Weil 已提交
483

484
			break;
485
		case MEI_FOP_CONNECT:
486
			/* connect message */
487
			ret = mei_cl_irq_connect(cl, cb, cmpl_list);
488 489
			if (ret)
				return ret;
O
Oren Weil 已提交
490

491
			break;
T
Tomas Winkler 已提交
492 493
		case MEI_FOP_DISCONNECT_RSP:
			/* send disconnect resp */
494
			ret = mei_cl_irq_disconnect_rsp(cl, cb, cmpl_list);
T
Tomas Winkler 已提交
495 496
			if (ret)
				return ret;
497
			break;
498 499
		default:
			BUG();
O
Oren Weil 已提交
500
		}
501

O
Oren Weil 已提交
502 503
	}
	/* complete  write list CB */
504
	dev_dbg(dev->dev, "complete write list cb.\n");
505 506
	list_for_each_entry_safe(cb, next, &dev->write_list.list, list) {
		cl = cb->cl;
507
		if (cl == &dev->iamthif_cl)
508
			ret = mei_amthif_irq_write(cl, cb, cmpl_list);
509
		else
510
			ret = mei_cl_irq_write(cl, cb, cmpl_list);
511 512
		if (ret)
			return ret;
O
Oren Weil 已提交
513 514 515
	}
	return 0;
}
516
EXPORT_SYMBOL_GPL(mei_irq_write_handler);
O
Oren Weil 已提交
517 518 519 520 521 522 523 524 525



/**
 * mei_timer - timer function.
 *
 * @work: pointer to the work_struct structure
 *
 */
526
void mei_timer(struct work_struct *work)
O
Oren Weil 已提交
527 528
{
	unsigned long timeout;
529
	struct mei_cl *cl;
O
Oren Weil 已提交
530 531

	struct mei_device *dev = container_of(work,
532
					struct mei_device, timer_work.work);
O
Oren Weil 已提交
533 534 535


	mutex_lock(&dev->device_lock);
536 537 538 539 540 541 542

	/* Catch interrupt stalls during HBM init handshake */
	if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
	    dev->hbm_state != MEI_HBM_IDLE) {

		if (dev->init_clients_timer) {
			if (--dev->init_clients_timer == 0) {
543
				dev_err(dev->dev, "timer: init clients timeout hbm_state = %d.\n",
544
					dev->hbm_state);
545
				mei_reset(dev);
546
				goto out;
O
Oren Weil 已提交
547 548 549
			}
		}
	}
550 551 552 553

	if (dev->dev_state != MEI_DEV_ENABLED)
		goto out;

O
Oren Weil 已提交
554
	/*** connect/disconnect timeouts ***/
555 556 557
	list_for_each_entry(cl, &dev->file_list, link) {
		if (cl->timer_count) {
			if (--cl->timer_count == 0) {
558
				dev_err(dev->dev, "timer: connect/disconnect timeout.\n");
559
				mei_reset(dev);
O
Oren Weil 已提交
560 561 562 563 564
				goto out;
			}
		}
	}

565 566 567
	if (!mei_cl_is_connected(&dev->iamthif_cl))
		goto out;

O
Oren Weil 已提交
568 569
	if (dev->iamthif_stall_timer) {
		if (--dev->iamthif_stall_timer == 0) {
570
			dev_err(dev->dev, "timer: amthif  hanged.\n");
571
			mei_reset(dev);
O
Oren Weil 已提交
572 573
			dev->iamthif_msg_buf_size = 0;
			dev->iamthif_msg_buf_index = 0;
574
			dev->iamthif_canceled = false;
O
Oren Weil 已提交
575 576 577
			dev->iamthif_state = MEI_IAMTHIF_IDLE;
			dev->iamthif_timer = 0;

578 579
			mei_io_cb_free(dev->iamthif_current_cb);
			dev->iamthif_current_cb = NULL;
O
Oren Weil 已提交
580 581

			dev->iamthif_file_object = NULL;
582
			mei_amthif_run_next_cmd(dev);
O
Oren Weil 已提交
583 584 585 586 587 588
		}
	}

	if (dev->iamthif_timer) {

		timeout = dev->iamthif_timer +
589
			mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
O
Oren Weil 已提交
590

591
		dev_dbg(dev->dev, "dev->iamthif_timer = %ld\n",
O
Oren Weil 已提交
592
				dev->iamthif_timer);
593 594
		dev_dbg(dev->dev, "timeout = %ld\n", timeout);
		dev_dbg(dev->dev, "jiffies = %ld\n", jiffies);
O
Oren Weil 已提交
595 596 597 598 599 600
		if (time_after(jiffies, timeout)) {
			/*
			 * User didn't read the AMTHI data on time (15sec)
			 * freeing AMTHI for other requests
			 */

601
			dev_dbg(dev->dev, "freeing AMTHI for other requests\n");
O
Oren Weil 已提交
602

603 604
			mei_io_list_flush(&dev->amthif_rd_complete_list,
				&dev->iamthif_cl);
605 606
			mei_io_cb_free(dev->iamthif_current_cb);
			dev->iamthif_current_cb = NULL;
O
Oren Weil 已提交
607 608 609 610

			dev->iamthif_file_object->private_data = NULL;
			dev->iamthif_file_object = NULL;
			dev->iamthif_timer = 0;
611
			mei_amthif_run_next_cmd(dev);
O
Oren Weil 已提交
612 613 614 615

		}
	}
out:
616 617
	if (dev->dev_state != MEI_DEV_DISABLED)
		schedule_delayed_work(&dev->timer_work, 2 * HZ);
618
	mutex_unlock(&dev->device_lock);
O
Oren Weil 已提交
619
}