interrupt.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. /*
  2. *
  3. * Intel Management Engine Interface (Intel MEI) Linux driver
  4. * Copyright (c) 2003-2012, Intel Corporation.
  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. #include <linux/pci.h>
  17. #include <linux/kthread.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/fs.h>
  20. #include <linux/jiffies.h>
  21. #include "mei_dev.h"
  22. #include <linux/mei.h>
  23. #include "hw.h"
  24. #include "interface.h"
  25. /**
  26. * mei_interrupt_quick_handler - The ISR of the MEI device
  27. *
  28. * @irq: The irq number
  29. * @dev_id: pointer to the device structure
  30. *
  31. * returns irqreturn_t
  32. */
  33. irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id)
  34. {
  35. struct mei_device *dev = (struct mei_device *) dev_id;
  36. u32 csr_reg = mei_hcsr_read(dev);
  37. if ((csr_reg & H_IS) != H_IS)
  38. return IRQ_NONE;
  39. /* clear H_IS bit in H_CSR */
  40. mei_reg_write(dev, H_CSR, csr_reg);
  41. return IRQ_WAKE_THREAD;
  42. }
  43. /**
  44. * _mei_cmpl - processes completed operation.
  45. *
  46. * @cl: private data of the file object.
  47. * @cb_pos: callback block.
  48. */
  49. static void _mei_cmpl(struct mei_cl *cl, struct mei_cl_cb *cb_pos)
  50. {
  51. if (cb_pos->fop_type == MEI_FOP_WRITE) {
  52. mei_io_cb_free(cb_pos);
  53. cb_pos = NULL;
  54. cl->writing_state = MEI_WRITE_COMPLETE;
  55. if (waitqueue_active(&cl->tx_wait))
  56. wake_up_interruptible(&cl->tx_wait);
  57. } else if (cb_pos->fop_type == MEI_FOP_READ &&
  58. MEI_READING == cl->reading_state) {
  59. cl->reading_state = MEI_READ_COMPLETE;
  60. if (waitqueue_active(&cl->rx_wait))
  61. wake_up_interruptible(&cl->rx_wait);
  62. }
  63. }
  64. /**
  65. * _mei_irq_thread_state_ok - checks if mei header matches file private data
  66. *
  67. * @cl: private data of the file object
  68. * @mei_hdr: header of mei client message
  69. *
  70. * returns !=0 if matches, 0 if no match.
  71. */
  72. static int _mei_irq_thread_state_ok(struct mei_cl *cl,
  73. struct mei_msg_hdr *mei_hdr)
  74. {
  75. return (cl->host_client_id == mei_hdr->host_addr &&
  76. cl->me_client_id == mei_hdr->me_addr &&
  77. cl->state == MEI_FILE_CONNECTED &&
  78. MEI_READ_COMPLETE != cl->reading_state);
  79. }
  80. /**
  81. * mei_irq_thread_read_client_message - bottom half read routine after ISR to
  82. * handle the read mei client message data processing.
  83. *
  84. * @complete_list: An instance of our list structure
  85. * @dev: the device structure
  86. * @mei_hdr: header of mei client message
  87. *
  88. * returns 0 on success, <0 on failure.
  89. */
  90. static int mei_irq_thread_read_client_message(struct mei_cl_cb *complete_list,
  91. struct mei_device *dev,
  92. struct mei_msg_hdr *mei_hdr)
  93. {
  94. struct mei_cl *cl;
  95. struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
  96. unsigned char *buffer = NULL;
  97. dev_dbg(&dev->pdev->dev, "start client msg\n");
  98. if (list_empty(&dev->read_list.list))
  99. goto quit;
  100. list_for_each_entry_safe(cb_pos, cb_next, &dev->read_list.list, list) {
  101. cl = cb_pos->cl;
  102. if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
  103. cl->reading_state = MEI_READING;
  104. buffer = cb_pos->response_buffer.data + cb_pos->buf_idx;
  105. if (cb_pos->response_buffer.size <
  106. mei_hdr->length + cb_pos->buf_idx) {
  107. dev_dbg(&dev->pdev->dev, "message overflow.\n");
  108. list_del(&cb_pos->list);
  109. return -ENOMEM;
  110. }
  111. if (buffer)
  112. mei_read_slots(dev, buffer, mei_hdr->length);
  113. cb_pos->buf_idx += mei_hdr->length;
  114. if (mei_hdr->msg_complete) {
  115. cl->status = 0;
  116. list_del(&cb_pos->list);
  117. dev_dbg(&dev->pdev->dev,
  118. "completed read H cl = %d, ME cl = %d, length = %lu\n",
  119. cl->host_client_id,
  120. cl->me_client_id,
  121. cb_pos->buf_idx);
  122. list_add_tail(&cb_pos->list,
  123. &complete_list->list);
  124. }
  125. break;
  126. }
  127. }
  128. quit:
  129. dev_dbg(&dev->pdev->dev, "message read\n");
  130. if (!buffer) {
  131. mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
  132. dev_dbg(&dev->pdev->dev, "discarding message, header =%08x.\n",
  133. *(u32 *) dev->rd_msg_buf);
  134. }
  135. return 0;
  136. }
  137. /**
  138. * _mei_irq_thread_close - processes close related operation.
  139. *
  140. * @dev: the device structure.
  141. * @slots: free slots.
  142. * @cb_pos: callback block.
  143. * @cl: private data of the file object.
  144. * @cmpl_list: complete list.
  145. *
  146. * returns 0, OK; otherwise, error.
  147. */
  148. static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
  149. struct mei_cl_cb *cb_pos,
  150. struct mei_cl *cl,
  151. struct mei_cl_cb *cmpl_list)
  152. {
  153. if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
  154. sizeof(struct hbm_client_connect_request)))
  155. return -EBADMSG;
  156. *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
  157. if (mei_disconnect(dev, cl)) {
  158. cl->status = 0;
  159. cb_pos->buf_idx = 0;
  160. list_move_tail(&cb_pos->list, &cmpl_list->list);
  161. return -EMSGSIZE;
  162. } else {
  163. cl->state = MEI_FILE_DISCONNECTING;
  164. cl->status = 0;
  165. cb_pos->buf_idx = 0;
  166. list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
  167. cl->timer_count = MEI_CONNECT_TIMEOUT;
  168. }
  169. return 0;
  170. }
  171. /**
  172. * is_treat_specially_client - checks if the message belongs
  173. * to the file private data.
  174. *
  175. * @cl: private data of the file object
  176. * @rs: connect response bus message
  177. *
  178. */
  179. static bool is_treat_specially_client(struct mei_cl *cl,
  180. struct hbm_client_connect_response *rs)
  181. {
  182. if (cl->host_client_id == rs->host_addr &&
  183. cl->me_client_id == rs->me_addr) {
  184. if (!rs->status) {
  185. cl->state = MEI_FILE_CONNECTED;
  186. cl->status = 0;
  187. } else {
  188. cl->state = MEI_FILE_DISCONNECTED;
  189. cl->status = -ENODEV;
  190. }
  191. cl->timer_count = 0;
  192. return true;
  193. }
  194. return false;
  195. }
  196. /**
  197. * mei_client_connect_response - connects to response irq routine
  198. *
  199. * @dev: the device structure
  200. * @rs: connect response bus message
  201. */
  202. static void mei_client_connect_response(struct mei_device *dev,
  203. struct hbm_client_connect_response *rs)
  204. {
  205. struct mei_cl *cl;
  206. struct mei_cl_cb *pos = NULL, *next = NULL;
  207. dev_dbg(&dev->pdev->dev,
  208. "connect_response:\n"
  209. "ME Client = %d\n"
  210. "Host Client = %d\n"
  211. "Status = %d\n",
  212. rs->me_addr,
  213. rs->host_addr,
  214. rs->status);
  215. /* if WD or iamthif client treat specially */
  216. if (is_treat_specially_client(&(dev->wd_cl), rs)) {
  217. dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n");
  218. mei_watchdog_register(dev);
  219. return;
  220. }
  221. if (is_treat_specially_client(&(dev->iamthif_cl), rs)) {
  222. dev->iamthif_state = MEI_IAMTHIF_IDLE;
  223. return;
  224. }
  225. list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
  226. cl = pos->cl;
  227. if (!cl) {
  228. list_del(&pos->list);
  229. return;
  230. }
  231. if (pos->fop_type == MEI_FOP_IOCTL) {
  232. if (is_treat_specially_client(cl, rs)) {
  233. list_del(&pos->list);
  234. cl->status = 0;
  235. cl->timer_count = 0;
  236. break;
  237. }
  238. }
  239. }
  240. }
  241. /**
  242. * mei_client_disconnect_response - disconnects from response irq routine
  243. *
  244. * @dev: the device structure
  245. * @rs: disconnect response bus message
  246. */
  247. static void mei_client_disconnect_response(struct mei_device *dev,
  248. struct hbm_client_connect_response *rs)
  249. {
  250. struct mei_cl *cl;
  251. struct mei_cl_cb *pos = NULL, *next = NULL;
  252. dev_dbg(&dev->pdev->dev,
  253. "disconnect_response:\n"
  254. "ME Client = %d\n"
  255. "Host Client = %d\n"
  256. "Status = %d\n",
  257. rs->me_addr,
  258. rs->host_addr,
  259. rs->status);
  260. list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
  261. cl = pos->cl;
  262. if (!cl) {
  263. list_del(&pos->list);
  264. return;
  265. }
  266. dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n");
  267. if (cl->host_client_id == rs->host_addr &&
  268. cl->me_client_id == rs->me_addr) {
  269. list_del(&pos->list);
  270. if (!rs->status)
  271. cl->state = MEI_FILE_DISCONNECTED;
  272. cl->status = 0;
  273. cl->timer_count = 0;
  274. break;
  275. }
  276. }
  277. }
  278. /**
  279. * same_flow_addr - tells if they have the same address.
  280. *
  281. * @file: private data of the file object.
  282. * @flow: flow control.
  283. *
  284. * returns !=0, same; 0,not.
  285. */
  286. static int same_flow_addr(struct mei_cl *cl, struct hbm_flow_control *flow)
  287. {
  288. return (cl->host_client_id == flow->host_addr &&
  289. cl->me_client_id == flow->me_addr);
  290. }
  291. /**
  292. * add_single_flow_creds - adds single buffer credentials.
  293. *
  294. * @file: private data ot the file object.
  295. * @flow: flow control.
  296. */
  297. static void add_single_flow_creds(struct mei_device *dev,
  298. struct hbm_flow_control *flow)
  299. {
  300. struct mei_me_client *client;
  301. int i;
  302. for (i = 0; i < dev->me_clients_num; i++) {
  303. client = &dev->me_clients[i];
  304. if (client && flow->me_addr == client->client_id) {
  305. if (client->props.single_recv_buf) {
  306. client->mei_flow_ctrl_creds++;
  307. dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
  308. flow->me_addr);
  309. dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
  310. client->mei_flow_ctrl_creds);
  311. } else {
  312. BUG(); /* error in flow control */
  313. }
  314. }
  315. }
  316. }
  317. /**
  318. * mei_client_flow_control_response - flow control response irq routine
  319. *
  320. * @dev: the device structure
  321. * @flow_control: flow control response bus message
  322. */
  323. static void mei_client_flow_control_response(struct mei_device *dev,
  324. struct hbm_flow_control *flow_control)
  325. {
  326. struct mei_cl *cl_pos = NULL;
  327. struct mei_cl *cl_next = NULL;
  328. if (!flow_control->host_addr) {
  329. /* single receive buffer */
  330. add_single_flow_creds(dev, flow_control);
  331. } else {
  332. /* normal connection */
  333. list_for_each_entry_safe(cl_pos, cl_next,
  334. &dev->file_list, link) {
  335. dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in file_list\n");
  336. dev_dbg(&dev->pdev->dev, "cl of host client %d ME client %d.\n",
  337. cl_pos->host_client_id,
  338. cl_pos->me_client_id);
  339. dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
  340. flow_control->host_addr,
  341. flow_control->me_addr);
  342. if (same_flow_addr(cl_pos, flow_control)) {
  343. dev_dbg(&dev->pdev->dev, "recv ctrl msg for host %d ME %d.\n",
  344. flow_control->host_addr,
  345. flow_control->me_addr);
  346. cl_pos->mei_flow_ctrl_creds++;
  347. dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
  348. cl_pos->mei_flow_ctrl_creds);
  349. break;
  350. }
  351. }
  352. }
  353. }
  354. /**
  355. * same_disconn_addr - tells if they have the same address
  356. *
  357. * @file: private data of the file object.
  358. * @disconn: disconnection request.
  359. *
  360. * returns !=0, same; 0,not.
  361. */
  362. static int same_disconn_addr(struct mei_cl *cl,
  363. struct hbm_client_connect_request *req)
  364. {
  365. return (cl->host_client_id == req->host_addr &&
  366. cl->me_client_id == req->me_addr);
  367. }
  368. /**
  369. * mei_client_disconnect_request - disconnects from request irq routine
  370. *
  371. * @dev: the device structure.
  372. * @disconnect_req: disconnect request bus message.
  373. */
  374. static void mei_client_disconnect_request(struct mei_device *dev,
  375. struct hbm_client_connect_request *disconnect_req)
  376. {
  377. struct hbm_client_connect_response *disconnect_res;
  378. struct mei_cl *pos, *next;
  379. const size_t len = sizeof(struct hbm_client_connect_response);
  380. list_for_each_entry_safe(pos, next, &dev->file_list, link) {
  381. if (same_disconn_addr(pos, disconnect_req)) {
  382. dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
  383. disconnect_req->host_addr,
  384. disconnect_req->me_addr);
  385. pos->state = MEI_FILE_DISCONNECTED;
  386. pos->timer_count = 0;
  387. if (pos == &dev->wd_cl)
  388. dev->wd_pending = false;
  389. else if (pos == &dev->iamthif_cl)
  390. dev->iamthif_timer = 0;
  391. /* prepare disconnect response */
  392. (void)mei_hbm_hdr((u32 *)&dev->wr_ext_msg.hdr, len);
  393. disconnect_res =
  394. (struct hbm_client_connect_response *)
  395. &dev->wr_ext_msg.data;
  396. disconnect_res->hbm_cmd = CLIENT_DISCONNECT_RES_CMD;
  397. disconnect_res->host_addr = pos->host_client_id;
  398. disconnect_res->me_addr = pos->me_client_id;
  399. disconnect_res->status = 0;
  400. break;
  401. }
  402. }
  403. }
  404. /**
  405. * mei_irq_thread_read_bus_message - bottom half read routine after ISR to
  406. * handle the read bus message cmd processing.
  407. *
  408. * @dev: the device structure
  409. * @mei_hdr: header of bus message
  410. */
  411. static void mei_irq_thread_read_bus_message(struct mei_device *dev,
  412. struct mei_msg_hdr *mei_hdr)
  413. {
  414. struct mei_bus_message *mei_msg;
  415. struct mei_me_client *me_client;
  416. struct hbm_host_version_response *version_res;
  417. struct hbm_client_connect_response *connect_res;
  418. struct hbm_client_connect_response *disconnect_res;
  419. struct hbm_client_connect_request *disconnect_req;
  420. struct hbm_flow_control *flow_control;
  421. struct hbm_props_response *props_res;
  422. struct hbm_host_enum_response *enum_res;
  423. struct hbm_host_stop_request *stop_req;
  424. /* read the message to our buffer */
  425. BUG_ON(mei_hdr->length >= sizeof(dev->rd_msg_buf));
  426. mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
  427. mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
  428. switch (mei_msg->hbm_cmd) {
  429. case HOST_START_RES_CMD:
  430. version_res = (struct hbm_host_version_response *) mei_msg;
  431. if (version_res->host_version_supported) {
  432. dev->version.major_version = HBM_MAJOR_VERSION;
  433. dev->version.minor_version = HBM_MINOR_VERSION;
  434. if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
  435. dev->init_clients_state == MEI_START_MESSAGE) {
  436. dev->init_clients_timer = 0;
  437. mei_host_enum_clients_message(dev);
  438. } else {
  439. dev->recvd_msg = false;
  440. dev_dbg(&dev->pdev->dev, "IMEI reset due to received host start response bus message.\n");
  441. mei_reset(dev, 1);
  442. return;
  443. }
  444. } else {
  445. u32 *buf = dev->wr_msg_buf;
  446. const size_t len = sizeof(struct hbm_host_stop_request);
  447. dev->version = version_res->me_max_version;
  448. /* send stop message */
  449. mei_hdr = mei_hbm_hdr(&buf[0], len);
  450. stop_req = (struct hbm_host_stop_request *)&buf[1];
  451. memset(stop_req, 0, len);
  452. stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
  453. stop_req->reason = DRIVER_STOP_REQUEST;
  454. mei_write_message(dev, mei_hdr,
  455. (unsigned char *)stop_req, len);
  456. dev_dbg(&dev->pdev->dev, "version mismatch.\n");
  457. return;
  458. }
  459. dev->recvd_msg = true;
  460. dev_dbg(&dev->pdev->dev, "host start response message received.\n");
  461. break;
  462. case CLIENT_CONNECT_RES_CMD:
  463. connect_res = (struct hbm_client_connect_response *) mei_msg;
  464. mei_client_connect_response(dev, connect_res);
  465. dev_dbg(&dev->pdev->dev, "client connect response message received.\n");
  466. wake_up(&dev->wait_recvd_msg);
  467. break;
  468. case CLIENT_DISCONNECT_RES_CMD:
  469. disconnect_res = (struct hbm_client_connect_response *) mei_msg;
  470. mei_client_disconnect_response(dev, disconnect_res);
  471. dev_dbg(&dev->pdev->dev, "client disconnect response message received.\n");
  472. wake_up(&dev->wait_recvd_msg);
  473. break;
  474. case MEI_FLOW_CONTROL_CMD:
  475. flow_control = (struct hbm_flow_control *) mei_msg;
  476. mei_client_flow_control_response(dev, flow_control);
  477. dev_dbg(&dev->pdev->dev, "client flow control response message received.\n");
  478. break;
  479. case HOST_CLIENT_PROPERTIES_RES_CMD:
  480. props_res = (struct hbm_props_response *)mei_msg;
  481. me_client = &dev->me_clients[dev->me_client_presentation_num];
  482. if (props_res->status || !dev->me_clients) {
  483. dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message wrong status.\n");
  484. mei_reset(dev, 1);
  485. return;
  486. }
  487. if (me_client->client_id != props_res->address) {
  488. dev_err(&dev->pdev->dev,
  489. "Host client properties reply mismatch\n");
  490. mei_reset(dev, 1);
  491. return;
  492. }
  493. if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
  494. dev->init_clients_state != MEI_CLIENT_PROPERTIES_MESSAGE) {
  495. dev_err(&dev->pdev->dev,
  496. "Unexpected client properties reply\n");
  497. mei_reset(dev, 1);
  498. return;
  499. }
  500. me_client->props = props_res->client_properties;
  501. dev->me_client_index++;
  502. dev->me_client_presentation_num++;
  503. mei_host_client_enumerate(dev);
  504. break;
  505. case HOST_ENUM_RES_CMD:
  506. enum_res = (struct hbm_host_enum_response *) mei_msg;
  507. memcpy(dev->me_clients_map, enum_res->valid_addresses, 32);
  508. if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
  509. dev->init_clients_state == MEI_ENUM_CLIENTS_MESSAGE) {
  510. dev->init_clients_timer = 0;
  511. dev->me_client_presentation_num = 0;
  512. dev->me_client_index = 0;
  513. mei_allocate_me_clients_storage(dev);
  514. dev->init_clients_state =
  515. MEI_CLIENT_PROPERTIES_MESSAGE;
  516. mei_host_client_enumerate(dev);
  517. } else {
  518. dev_dbg(&dev->pdev->dev, "reset due to received host enumeration clients response bus message.\n");
  519. mei_reset(dev, 1);
  520. return;
  521. }
  522. break;
  523. case HOST_STOP_RES_CMD:
  524. dev->dev_state = MEI_DEV_DISABLED;
  525. dev_dbg(&dev->pdev->dev, "resetting because of FW stop response.\n");
  526. mei_reset(dev, 1);
  527. break;
  528. case CLIENT_DISCONNECT_REQ_CMD:
  529. /* search for client */
  530. disconnect_req = (struct hbm_client_connect_request *)mei_msg;
  531. mei_client_disconnect_request(dev, disconnect_req);
  532. break;
  533. case ME_STOP_REQ_CMD:
  534. {
  535. /* prepare stop request: sent in next interrupt event */
  536. const size_t len = sizeof(struct hbm_host_stop_request);
  537. mei_hdr = mei_hbm_hdr((u32 *)&dev->wr_ext_msg.hdr, len);
  538. stop_req = (struct hbm_host_stop_request *)&dev->wr_ext_msg.data;
  539. memset(stop_req, 0, len);
  540. stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
  541. stop_req->reason = DRIVER_STOP_REQUEST;
  542. break;
  543. }
  544. default:
  545. BUG();
  546. break;
  547. }
  548. }
  549. /**
  550. * _mei_hb_read - processes read related operation.
  551. *
  552. * @dev: the device structure.
  553. * @slots: free slots.
  554. * @cb_pos: callback block.
  555. * @cl: private data of the file object.
  556. * @cmpl_list: complete list.
  557. *
  558. * returns 0, OK; otherwise, error.
  559. */
  560. static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
  561. struct mei_cl_cb *cb_pos,
  562. struct mei_cl *cl,
  563. struct mei_cl_cb *cmpl_list)
  564. {
  565. if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
  566. sizeof(struct hbm_flow_control))) {
  567. /* return the cancel routine */
  568. list_del(&cb_pos->list);
  569. return -EBADMSG;
  570. }
  571. *slots -= mei_data2slots(sizeof(struct hbm_flow_control));
  572. if (mei_send_flow_control(dev, cl)) {
  573. cl->status = -ENODEV;
  574. cb_pos->buf_idx = 0;
  575. list_move_tail(&cb_pos->list, &cmpl_list->list);
  576. return -ENODEV;
  577. }
  578. list_move_tail(&cb_pos->list, &dev->read_list.list);
  579. return 0;
  580. }
  581. /**
  582. * _mei_irq_thread_ioctl - processes ioctl related operation.
  583. *
  584. * @dev: the device structure.
  585. * @slots: free slots.
  586. * @cb_pos: callback block.
  587. * @cl: private data of the file object.
  588. * @cmpl_list: complete list.
  589. *
  590. * returns 0, OK; otherwise, error.
  591. */
  592. static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
  593. struct mei_cl_cb *cb_pos,
  594. struct mei_cl *cl,
  595. struct mei_cl_cb *cmpl_list)
  596. {
  597. if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
  598. sizeof(struct hbm_client_connect_request))) {
  599. /* return the cancel routine */
  600. list_del(&cb_pos->list);
  601. return -EBADMSG;
  602. }
  603. cl->state = MEI_FILE_CONNECTING;
  604. *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
  605. if (mei_connect(dev, cl)) {
  606. cl->status = -ENODEV;
  607. cb_pos->buf_idx = 0;
  608. list_del(&cb_pos->list);
  609. return -ENODEV;
  610. } else {
  611. list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
  612. cl->timer_count = MEI_CONNECT_TIMEOUT;
  613. }
  614. return 0;
  615. }
  616. /**
  617. * mei_irq_thread_write_complete - write messages to device.
  618. *
  619. * @dev: the device structure.
  620. * @slots: free slots.
  621. * @cb: callback block.
  622. * @cmpl_list: complete list.
  623. *
  624. * returns 0, OK; otherwise, error.
  625. */
  626. static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,
  627. struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list)
  628. {
  629. struct mei_msg_hdr *mei_hdr;
  630. struct mei_cl *cl = cb->cl;
  631. size_t len = cb->request_buffer.size - cb->buf_idx;
  632. size_t msg_slots = mei_data2slots(len);
  633. mei_hdr = (struct mei_msg_hdr *)&dev->wr_msg_buf[0];
  634. mei_hdr->host_addr = cl->host_client_id;
  635. mei_hdr->me_addr = cl->me_client_id;
  636. mei_hdr->reserved = 0;
  637. if (*slots >= msg_slots) {
  638. mei_hdr->length = len;
  639. mei_hdr->msg_complete = 1;
  640. /* Split the message only if we can write the whole host buffer */
  641. } else if (*slots == dev->hbuf_depth) {
  642. msg_slots = *slots;
  643. len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
  644. mei_hdr->length = len;
  645. mei_hdr->msg_complete = 0;
  646. } else {
  647. /* wait for next time the host buffer is empty */
  648. return 0;
  649. }
  650. dev_dbg(&dev->pdev->dev, "buf: size = %d idx = %lu\n",
  651. cb->request_buffer.size, cb->buf_idx);
  652. dev_dbg(&dev->pdev->dev, "msg: len = %d complete = %d\n",
  653. mei_hdr->length, mei_hdr->msg_complete);
  654. *slots -= msg_slots;
  655. if (mei_write_message(dev, mei_hdr,
  656. cb->request_buffer.data + cb->buf_idx, len)) {
  657. cl->status = -ENODEV;
  658. list_move_tail(&cb->list, &cmpl_list->list);
  659. return -ENODEV;
  660. }
  661. if (mei_flow_ctrl_reduce(dev, cl))
  662. return -ENODEV;
  663. cl->status = 0;
  664. cb->buf_idx += mei_hdr->length;
  665. if (mei_hdr->msg_complete)
  666. list_move_tail(&cb->list, &dev->write_waiting_list.list);
  667. return 0;
  668. }
  669. /**
  670. * mei_irq_thread_read_handler - bottom half read routine after ISR to
  671. * handle the read processing.
  672. *
  673. * @cmpl_list: An instance of our list structure
  674. * @dev: the device structure
  675. * @slots: slots to read.
  676. *
  677. * returns 0 on success, <0 on failure.
  678. */
  679. static int mei_irq_thread_read_handler(struct mei_cl_cb *cmpl_list,
  680. struct mei_device *dev,
  681. s32 *slots)
  682. {
  683. struct mei_msg_hdr *mei_hdr;
  684. struct mei_cl *cl_pos = NULL;
  685. struct mei_cl *cl_next = NULL;
  686. int ret = 0;
  687. if (!dev->rd_msg_hdr) {
  688. dev->rd_msg_hdr = mei_mecbrw_read(dev);
  689. dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
  690. (*slots)--;
  691. dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
  692. }
  693. mei_hdr = (struct mei_msg_hdr *) &dev->rd_msg_hdr;
  694. dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", mei_hdr->length);
  695. if (mei_hdr->reserved || !dev->rd_msg_hdr) {
  696. dev_dbg(&dev->pdev->dev, "corrupted message header.\n");
  697. ret = -EBADMSG;
  698. goto end;
  699. }
  700. if (mei_hdr->host_addr || mei_hdr->me_addr) {
  701. list_for_each_entry_safe(cl_pos, cl_next,
  702. &dev->file_list, link) {
  703. dev_dbg(&dev->pdev->dev,
  704. "list_for_each_entry_safe read host"
  705. " client = %d, ME client = %d\n",
  706. cl_pos->host_client_id,
  707. cl_pos->me_client_id);
  708. if (cl_pos->host_client_id == mei_hdr->host_addr &&
  709. cl_pos->me_client_id == mei_hdr->me_addr)
  710. break;
  711. }
  712. if (&cl_pos->link == &dev->file_list) {
  713. dev_dbg(&dev->pdev->dev, "corrupted message header\n");
  714. ret = -EBADMSG;
  715. goto end;
  716. }
  717. }
  718. if (((*slots) * sizeof(u32)) < mei_hdr->length) {
  719. dev_dbg(&dev->pdev->dev,
  720. "we can't read the message slots =%08x.\n",
  721. *slots);
  722. /* we can't read the message */
  723. ret = -ERANGE;
  724. goto end;
  725. }
  726. /* decide where to read the message too */
  727. if (!mei_hdr->host_addr) {
  728. dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_bus_message.\n");
  729. mei_irq_thread_read_bus_message(dev, mei_hdr);
  730. dev_dbg(&dev->pdev->dev, "end mei_irq_thread_read_bus_message.\n");
  731. } else if (mei_hdr->host_addr == dev->iamthif_cl.host_client_id &&
  732. (MEI_FILE_CONNECTED == dev->iamthif_cl.state) &&
  733. (dev->iamthif_state == MEI_IAMTHIF_READING)) {
  734. dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_iamthif_message.\n");
  735. dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
  736. mei_hdr->length);
  737. ret = mei_amthif_irq_read_message(cmpl_list, dev, mei_hdr);
  738. if (ret)
  739. goto end;
  740. } else {
  741. dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_client_message.\n");
  742. ret = mei_irq_thread_read_client_message(cmpl_list,
  743. dev, mei_hdr);
  744. if (ret)
  745. goto end;
  746. }
  747. /* reset the number of slots and header */
  748. *slots = mei_count_full_read_slots(dev);
  749. dev->rd_msg_hdr = 0;
  750. if (*slots == -EOVERFLOW) {
  751. /* overflow - reset */
  752. dev_dbg(&dev->pdev->dev, "resetting due to slots overflow.\n");
  753. /* set the event since message has been read */
  754. ret = -ERANGE;
  755. goto end;
  756. }
  757. end:
  758. return ret;
  759. }
  760. /**
  761. * mei_irq_thread_write_handler - bottom half write routine after
  762. * ISR to handle the write processing.
  763. *
  764. * @dev: the device structure
  765. * @cmpl_list: An instance of our list structure
  766. *
  767. * returns 0 on success, <0 on failure.
  768. */
  769. static int mei_irq_thread_write_handler(struct mei_device *dev,
  770. struct mei_cl_cb *cmpl_list)
  771. {
  772. struct mei_cl *cl;
  773. struct mei_cl_cb *pos = NULL, *next = NULL;
  774. struct mei_cl_cb *list;
  775. s32 slots;
  776. int ret;
  777. if (!mei_hbuf_is_empty(dev)) {
  778. dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n");
  779. return 0;
  780. }
  781. slots = mei_hbuf_empty_slots(dev);
  782. if (slots <= 0)
  783. return -EMSGSIZE;
  784. /* complete all waiting for write CB */
  785. dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n");
  786. list = &dev->write_waiting_list;
  787. list_for_each_entry_safe(pos, next, &list->list, list) {
  788. cl = pos->cl;
  789. if (cl == NULL)
  790. continue;
  791. cl->status = 0;
  792. list_del(&pos->list);
  793. if (MEI_WRITING == cl->writing_state &&
  794. pos->fop_type == MEI_FOP_WRITE &&
  795. cl != &dev->iamthif_cl) {
  796. dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n");
  797. cl->writing_state = MEI_WRITE_COMPLETE;
  798. list_add_tail(&pos->list, &cmpl_list->list);
  799. }
  800. if (cl == &dev->iamthif_cl) {
  801. dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
  802. if (dev->iamthif_flow_control_pending) {
  803. ret = mei_amthif_irq_read(dev, &slots);
  804. if (ret)
  805. return ret;
  806. }
  807. }
  808. }
  809. if (dev->wd_state == MEI_WD_STOPPING) {
  810. dev->wd_state = MEI_WD_IDLE;
  811. wake_up_interruptible(&dev->wait_stop_wd);
  812. }
  813. if (dev->wr_ext_msg.hdr.length) {
  814. mei_write_message(dev, &dev->wr_ext_msg.hdr,
  815. dev->wr_ext_msg.data, dev->wr_ext_msg.hdr.length);
  816. slots -= mei_data2slots(dev->wr_ext_msg.hdr.length);
  817. dev->wr_ext_msg.hdr.length = 0;
  818. }
  819. if (dev->dev_state == MEI_DEV_ENABLED) {
  820. if (dev->wd_pending &&
  821. mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
  822. if (mei_wd_send(dev))
  823. dev_dbg(&dev->pdev->dev, "wd send failed.\n");
  824. else if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
  825. return -ENODEV;
  826. dev->wd_pending = false;
  827. if (dev->wd_state == MEI_WD_RUNNING)
  828. slots -= mei_data2slots(MEI_WD_START_MSG_SIZE);
  829. else
  830. slots -= mei_data2slots(MEI_WD_STOP_MSG_SIZE);
  831. }
  832. }
  833. /* complete control write list CB */
  834. dev_dbg(&dev->pdev->dev, "complete control write list cb.\n");
  835. list_for_each_entry_safe(pos, next, &dev->ctrl_wr_list.list, list) {
  836. cl = pos->cl;
  837. if (!cl) {
  838. list_del(&pos->list);
  839. return -ENODEV;
  840. }
  841. switch (pos->fop_type) {
  842. case MEI_FOP_CLOSE:
  843. /* send disconnect message */
  844. ret = _mei_irq_thread_close(dev, &slots, pos,
  845. cl, cmpl_list);
  846. if (ret)
  847. return ret;
  848. break;
  849. case MEI_FOP_READ:
  850. /* send flow control message */
  851. ret = _mei_irq_thread_read(dev, &slots, pos,
  852. cl, cmpl_list);
  853. if (ret)
  854. return ret;
  855. break;
  856. case MEI_FOP_IOCTL:
  857. /* connect message */
  858. if (mei_other_client_is_connecting(dev, cl))
  859. continue;
  860. ret = _mei_irq_thread_ioctl(dev, &slots, pos,
  861. cl, cmpl_list);
  862. if (ret)
  863. return ret;
  864. break;
  865. default:
  866. BUG();
  867. }
  868. }
  869. /* complete write list CB */
  870. dev_dbg(&dev->pdev->dev, "complete write list cb.\n");
  871. list_for_each_entry_safe(pos, next, &dev->write_list.list, list) {
  872. cl = pos->cl;
  873. if (cl == NULL)
  874. continue;
  875. if (mei_flow_ctrl_creds(dev, cl) <= 0) {
  876. dev_dbg(&dev->pdev->dev,
  877. "No flow control credentials for client %d, not sending.\n",
  878. cl->host_client_id);
  879. continue;
  880. }
  881. if (cl == &dev->iamthif_cl)
  882. ret = mei_amthif_irq_write_complete(dev, &slots,
  883. pos, cmpl_list);
  884. else
  885. ret = mei_irq_thread_write_complete(dev, &slots, pos,
  886. cmpl_list);
  887. if (ret)
  888. return ret;
  889. }
  890. return 0;
  891. }
  892. /**
  893. * mei_timer - timer function.
  894. *
  895. * @work: pointer to the work_struct structure
  896. *
  897. * NOTE: This function is called by timer interrupt work
  898. */
  899. void mei_timer(struct work_struct *work)
  900. {
  901. unsigned long timeout;
  902. struct mei_cl *cl_pos = NULL;
  903. struct mei_cl *cl_next = NULL;
  904. struct mei_cl_cb *cb_pos = NULL;
  905. struct mei_cl_cb *cb_next = NULL;
  906. struct mei_device *dev = container_of(work,
  907. struct mei_device, timer_work.work);
  908. mutex_lock(&dev->device_lock);
  909. if (dev->dev_state != MEI_DEV_ENABLED) {
  910. if (dev->dev_state == MEI_DEV_INIT_CLIENTS) {
  911. if (dev->init_clients_timer) {
  912. if (--dev->init_clients_timer == 0) {
  913. dev_dbg(&dev->pdev->dev, "IMEI reset due to init clients timeout ,init clients state = %d.\n",
  914. dev->init_clients_state);
  915. mei_reset(dev, 1);
  916. }
  917. }
  918. }
  919. goto out;
  920. }
  921. /*** connect/disconnect timeouts ***/
  922. list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
  923. if (cl_pos->timer_count) {
  924. if (--cl_pos->timer_count == 0) {
  925. dev_dbg(&dev->pdev->dev, "HECI reset due to connect/disconnect timeout.\n");
  926. mei_reset(dev, 1);
  927. goto out;
  928. }
  929. }
  930. }
  931. if (dev->iamthif_stall_timer) {
  932. if (--dev->iamthif_stall_timer == 0) {
  933. dev_dbg(&dev->pdev->dev, "resetting because of hang to amthi.\n");
  934. mei_reset(dev, 1);
  935. dev->iamthif_msg_buf_size = 0;
  936. dev->iamthif_msg_buf_index = 0;
  937. dev->iamthif_canceled = false;
  938. dev->iamthif_ioctl = true;
  939. dev->iamthif_state = MEI_IAMTHIF_IDLE;
  940. dev->iamthif_timer = 0;
  941. mei_io_cb_free(dev->iamthif_current_cb);
  942. dev->iamthif_current_cb = NULL;
  943. dev->iamthif_file_object = NULL;
  944. mei_amthif_run_next_cmd(dev);
  945. }
  946. }
  947. if (dev->iamthif_timer) {
  948. timeout = dev->iamthif_timer +
  949. mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
  950. dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
  951. dev->iamthif_timer);
  952. dev_dbg(&dev->pdev->dev, "timeout = %ld\n", timeout);
  953. dev_dbg(&dev->pdev->dev, "jiffies = %ld\n", jiffies);
  954. if (time_after(jiffies, timeout)) {
  955. /*
  956. * User didn't read the AMTHI data on time (15sec)
  957. * freeing AMTHI for other requests
  958. */
  959. dev_dbg(&dev->pdev->dev, "freeing AMTHI for other requests\n");
  960. list_for_each_entry_safe(cb_pos, cb_next,
  961. &dev->amthif_rd_complete_list.list, list) {
  962. cl_pos = cb_pos->file_object->private_data;
  963. /* Finding the AMTHI entry. */
  964. if (cl_pos == &dev->iamthif_cl)
  965. list_del(&cb_pos->list);
  966. }
  967. mei_io_cb_free(dev->iamthif_current_cb);
  968. dev->iamthif_current_cb = NULL;
  969. dev->iamthif_file_object->private_data = NULL;
  970. dev->iamthif_file_object = NULL;
  971. dev->iamthif_timer = 0;
  972. mei_amthif_run_next_cmd(dev);
  973. }
  974. }
  975. out:
  976. schedule_delayed_work(&dev->timer_work, 2 * HZ);
  977. mutex_unlock(&dev->device_lock);
  978. }
  979. /**
  980. * mei_interrupt_thread_handler - function called after ISR to handle the interrupt
  981. * processing.
  982. *
  983. * @irq: The irq number
  984. * @dev_id: pointer to the device structure
  985. *
  986. * returns irqreturn_t
  987. *
  988. */
  989. irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
  990. {
  991. struct mei_device *dev = (struct mei_device *) dev_id;
  992. struct mei_cl_cb complete_list;
  993. struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
  994. struct mei_cl *cl;
  995. s32 slots;
  996. int rets;
  997. bool bus_message_received;
  998. dev_dbg(&dev->pdev->dev, "function called after ISR to handle the interrupt processing.\n");
  999. /* initialize our complete list */
  1000. mutex_lock(&dev->device_lock);
  1001. mei_io_list_init(&complete_list);
  1002. dev->host_hw_state = mei_hcsr_read(dev);
  1003. /* Ack the interrupt here
  1004. * In case of MSI we don't go through the quick handler */
  1005. if (pci_dev_msi_enabled(dev->pdev))
  1006. mei_reg_write(dev, H_CSR, dev->host_hw_state);
  1007. dev->me_hw_state = mei_mecsr_read(dev);
  1008. /* check if ME wants a reset */
  1009. if ((dev->me_hw_state & ME_RDY_HRA) == 0 &&
  1010. dev->dev_state != MEI_DEV_RESETING &&
  1011. dev->dev_state != MEI_DEV_INITIALIZING) {
  1012. dev_dbg(&dev->pdev->dev, "FW not ready.\n");
  1013. mei_reset(dev, 1);
  1014. mutex_unlock(&dev->device_lock);
  1015. return IRQ_HANDLED;
  1016. }
  1017. /* check if we need to start the dev */
  1018. if ((dev->host_hw_state & H_RDY) == 0) {
  1019. if ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA) {
  1020. dev_dbg(&dev->pdev->dev, "we need to start the dev.\n");
  1021. dev->host_hw_state |= (H_IE | H_IG | H_RDY);
  1022. mei_hcsr_set(dev);
  1023. dev->dev_state = MEI_DEV_INIT_CLIENTS;
  1024. dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n");
  1025. /* link is established
  1026. * start sending messages.
  1027. */
  1028. mei_host_start_message(dev);
  1029. mutex_unlock(&dev->device_lock);
  1030. return IRQ_HANDLED;
  1031. } else {
  1032. dev_dbg(&dev->pdev->dev, "FW not ready.\n");
  1033. mutex_unlock(&dev->device_lock);
  1034. return IRQ_HANDLED;
  1035. }
  1036. }
  1037. /* check slots available for reading */
  1038. slots = mei_count_full_read_slots(dev);
  1039. while (slots > 0) {
  1040. /* we have urgent data to send so break the read */
  1041. if (dev->wr_ext_msg.hdr.length)
  1042. break;
  1043. dev_dbg(&dev->pdev->dev, "slots =%08x\n", slots);
  1044. dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_handler.\n");
  1045. rets = mei_irq_thread_read_handler(&complete_list, dev, &slots);
  1046. if (rets)
  1047. goto end;
  1048. }
  1049. rets = mei_irq_thread_write_handler(dev, &complete_list);
  1050. end:
  1051. dev_dbg(&dev->pdev->dev, "end of bottom half function.\n");
  1052. dev->host_hw_state = mei_hcsr_read(dev);
  1053. dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
  1054. bus_message_received = false;
  1055. if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) {
  1056. dev_dbg(&dev->pdev->dev, "received waiting bus message\n");
  1057. bus_message_received = true;
  1058. }
  1059. mutex_unlock(&dev->device_lock);
  1060. if (bus_message_received) {
  1061. dev_dbg(&dev->pdev->dev, "wake up dev->wait_recvd_msg\n");
  1062. wake_up_interruptible(&dev->wait_recvd_msg);
  1063. bus_message_received = false;
  1064. }
  1065. if (list_empty(&complete_list.list))
  1066. return IRQ_HANDLED;
  1067. list_for_each_entry_safe(cb_pos, cb_next, &complete_list.list, list) {
  1068. cl = cb_pos->cl;
  1069. list_del(&cb_pos->list);
  1070. if (cl) {
  1071. if (cl != &dev->iamthif_cl) {
  1072. dev_dbg(&dev->pdev->dev, "completing call back.\n");
  1073. _mei_cmpl(cl, cb_pos);
  1074. cb_pos = NULL;
  1075. } else if (cl == &dev->iamthif_cl) {
  1076. mei_amthif_complete(dev, cb_pos);
  1077. }
  1078. }
  1079. }
  1080. return IRQ_HANDLED;
  1081. }