hbm.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  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/sched.h>
  18. #include <linux/wait.h>
  19. #include <linux/mei.h>
  20. #include "mei_dev.h"
  21. #include "hbm.h"
  22. #include "hw-me.h"
  23. /**
  24. * mei_hbm_me_cl_allocate - allocates storage for me clients
  25. *
  26. * @dev: the device structure
  27. *
  28. * returns none.
  29. */
  30. static void mei_hbm_me_cl_allocate(struct mei_device *dev)
  31. {
  32. struct mei_me_client *clients;
  33. int b;
  34. /* count how many ME clients we have */
  35. for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX)
  36. dev->me_clients_num++;
  37. if (dev->me_clients_num <= 0)
  38. return;
  39. kfree(dev->me_clients);
  40. dev->me_clients = NULL;
  41. dev_dbg(&dev->pdev->dev, "memory allocation for ME clients size=%zd.\n",
  42. dev->me_clients_num * sizeof(struct mei_me_client));
  43. /* allocate storage for ME clients representation */
  44. clients = kcalloc(dev->me_clients_num,
  45. sizeof(struct mei_me_client), GFP_KERNEL);
  46. if (!clients) {
  47. dev_err(&dev->pdev->dev, "memory allocation for ME clients failed.\n");
  48. dev->dev_state = MEI_DEV_RESETING;
  49. mei_reset(dev, 1);
  50. return;
  51. }
  52. dev->me_clients = clients;
  53. return;
  54. }
  55. /**
  56. * mei_hbm_cl_hdr - construct client hbm header
  57. * @cl: - client
  58. * @hbm_cmd: host bus message command
  59. * @buf: buffer for cl header
  60. * @len: buffer length
  61. */
  62. static inline
  63. void mei_hbm_cl_hdr(struct mei_cl *cl, u8 hbm_cmd, void *buf, size_t len)
  64. {
  65. struct mei_hbm_cl_cmd *cmd = buf;
  66. memset(cmd, 0, len);
  67. cmd->hbm_cmd = hbm_cmd;
  68. cmd->host_addr = cl->host_client_id;
  69. cmd->me_addr = cl->me_client_id;
  70. }
  71. /**
  72. * same_disconn_addr - tells if they have the same address
  73. *
  74. * @file: private data of the file object.
  75. * @disconn: disconnection request.
  76. *
  77. * returns true if addres are same
  78. */
  79. static inline
  80. bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf)
  81. {
  82. struct mei_hbm_cl_cmd *cmd = buf;
  83. return cl->host_client_id == cmd->host_addr &&
  84. cl->me_client_id == cmd->me_addr;
  85. }
  86. /**
  87. * is_treat_specially_client - checks if the message belongs
  88. * to the file private data.
  89. *
  90. * @cl: private data of the file object
  91. * @rs: connect response bus message
  92. *
  93. */
  94. static bool is_treat_specially_client(struct mei_cl *cl,
  95. struct hbm_client_connect_response *rs)
  96. {
  97. if (mei_hbm_cl_addr_equal(cl, rs)) {
  98. if (!rs->status) {
  99. cl->state = MEI_FILE_CONNECTED;
  100. cl->status = 0;
  101. } else {
  102. cl->state = MEI_FILE_DISCONNECTED;
  103. cl->status = -ENODEV;
  104. }
  105. cl->timer_count = 0;
  106. return true;
  107. }
  108. return false;
  109. }
  110. int mei_hbm_start_wait(struct mei_device *dev)
  111. {
  112. int ret;
  113. if (dev->hbm_state > MEI_HBM_START)
  114. return 0;
  115. mutex_unlock(&dev->device_lock);
  116. ret = wait_event_interruptible_timeout(dev->wait_recvd_msg,
  117. dev->hbm_state == MEI_HBM_IDLE ||
  118. dev->hbm_state > MEI_HBM_START,
  119. mei_secs_to_jiffies(MEI_INTEROP_TIMEOUT));
  120. mutex_lock(&dev->device_lock);
  121. if (ret <= 0 && (dev->hbm_state <= MEI_HBM_START)) {
  122. dev->hbm_state = MEI_HBM_IDLE;
  123. dev_err(&dev->pdev->dev, "wating for mei start failed\n");
  124. return -ETIMEDOUT;
  125. }
  126. return 0;
  127. }
  128. /**
  129. * mei_hbm_start_req - sends start request message.
  130. *
  131. * @dev: the device structure
  132. */
  133. int mei_hbm_start_req(struct mei_device *dev)
  134. {
  135. struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
  136. struct hbm_host_version_request *start_req;
  137. const size_t len = sizeof(struct hbm_host_version_request);
  138. mei_hbm_hdr(mei_hdr, len);
  139. /* host start message */
  140. start_req = (struct hbm_host_version_request *)dev->wr_msg.data;
  141. memset(start_req, 0, len);
  142. start_req->hbm_cmd = HOST_START_REQ_CMD;
  143. start_req->host_version.major_version = HBM_MAJOR_VERSION;
  144. start_req->host_version.minor_version = HBM_MINOR_VERSION;
  145. dev->hbm_state = MEI_HBM_IDLE;
  146. if (mei_write_message(dev, mei_hdr, dev->wr_msg.data)) {
  147. dev_err(&dev->pdev->dev, "version message writet failed\n");
  148. dev->dev_state = MEI_DEV_RESETING;
  149. mei_reset(dev, 1);
  150. return -ENODEV;
  151. }
  152. dev->hbm_state = MEI_HBM_START;
  153. dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
  154. return 0;
  155. }
  156. /*
  157. * mei_hbm_enum_clients_req - sends enumeration client request message.
  158. *
  159. * @dev: the device structure
  160. *
  161. * returns none.
  162. */
  163. static void mei_hbm_enum_clients_req(struct mei_device *dev)
  164. {
  165. struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
  166. struct hbm_host_enum_request *enum_req;
  167. const size_t len = sizeof(struct hbm_host_enum_request);
  168. /* enumerate clients */
  169. mei_hbm_hdr(mei_hdr, len);
  170. enum_req = (struct hbm_host_enum_request *)dev->wr_msg.data;
  171. memset(enum_req, 0, len);
  172. enum_req->hbm_cmd = HOST_ENUM_REQ_CMD;
  173. if (mei_write_message(dev, mei_hdr, dev->wr_msg.data)) {
  174. dev->dev_state = MEI_DEV_RESETING;
  175. dev_err(&dev->pdev->dev, "enumeration request write failed.\n");
  176. mei_reset(dev, 1);
  177. }
  178. dev->hbm_state = MEI_HBM_ENUM_CLIENTS;
  179. dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
  180. return;
  181. }
  182. /**
  183. * mei_hbm_prop_requsest - request property for a single client
  184. *
  185. * @dev: the device structure
  186. *
  187. * returns none.
  188. */
  189. static int mei_hbm_prop_req(struct mei_device *dev)
  190. {
  191. struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
  192. struct hbm_props_request *prop_req;
  193. const size_t len = sizeof(struct hbm_props_request);
  194. unsigned long next_client_index;
  195. u8 client_num;
  196. client_num = dev->me_client_presentation_num;
  197. next_client_index = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX,
  198. dev->me_client_index);
  199. /* We got all client properties */
  200. if (next_client_index == MEI_CLIENTS_MAX) {
  201. dev->hbm_state = MEI_HBM_STARTED;
  202. schedule_work(&dev->init_work);
  203. return 0;
  204. }
  205. dev->me_clients[client_num].client_id = next_client_index;
  206. dev->me_clients[client_num].mei_flow_ctrl_creds = 0;
  207. mei_hbm_hdr(mei_hdr, len);
  208. prop_req = (struct hbm_props_request *)dev->wr_msg.data;
  209. memset(prop_req, 0, sizeof(struct hbm_props_request));
  210. prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
  211. prop_req->address = next_client_index;
  212. if (mei_write_message(dev, mei_hdr, dev->wr_msg.data)) {
  213. dev->dev_state = MEI_DEV_RESETING;
  214. dev_err(&dev->pdev->dev, "properties request write failed\n");
  215. mei_reset(dev, 1);
  216. return -EIO;
  217. }
  218. dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
  219. dev->me_client_index = next_client_index;
  220. return 0;
  221. }
  222. /**
  223. * mei_hbm_stop_req_prepare - perpare stop request message
  224. *
  225. * @dev - mei device
  226. * @mei_hdr - mei message header
  227. * @data - hbm message body buffer
  228. */
  229. static void mei_hbm_stop_req_prepare(struct mei_device *dev,
  230. struct mei_msg_hdr *mei_hdr, unsigned char *data)
  231. {
  232. struct hbm_host_stop_request *req =
  233. (struct hbm_host_stop_request *)data;
  234. const size_t len = sizeof(struct hbm_host_stop_request);
  235. mei_hbm_hdr(mei_hdr, len);
  236. memset(req, 0, len);
  237. req->hbm_cmd = HOST_STOP_REQ_CMD;
  238. req->reason = DRIVER_STOP_REQUEST;
  239. }
  240. /**
  241. * mei_hbm_cl_flow_control_req - sends flow control requst.
  242. *
  243. * @dev: the device structure
  244. * @cl: client info
  245. *
  246. * This function returns -EIO on write failure
  247. */
  248. int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
  249. {
  250. struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
  251. const size_t len = sizeof(struct hbm_flow_control);
  252. mei_hbm_hdr(mei_hdr, len);
  253. mei_hbm_cl_hdr(cl, MEI_FLOW_CONTROL_CMD, dev->wr_msg.data, len);
  254. dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n",
  255. cl->host_client_id, cl->me_client_id);
  256. return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
  257. }
  258. /**
  259. * add_single_flow_creds - adds single buffer credentials.
  260. *
  261. * @file: private data ot the file object.
  262. * @flow: flow control.
  263. */
  264. static void mei_hbm_add_single_flow_creds(struct mei_device *dev,
  265. struct hbm_flow_control *flow)
  266. {
  267. struct mei_me_client *client;
  268. int i;
  269. for (i = 0; i < dev->me_clients_num; i++) {
  270. client = &dev->me_clients[i];
  271. if (client && flow->me_addr == client->client_id) {
  272. if (client->props.single_recv_buf) {
  273. client->mei_flow_ctrl_creds++;
  274. dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
  275. flow->me_addr);
  276. dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
  277. client->mei_flow_ctrl_creds);
  278. } else {
  279. BUG(); /* error in flow control */
  280. }
  281. }
  282. }
  283. }
  284. /**
  285. * mei_hbm_cl_flow_control_res - flow control response from me
  286. *
  287. * @dev: the device structure
  288. * @flow_control: flow control response bus message
  289. */
  290. static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
  291. struct hbm_flow_control *flow_control)
  292. {
  293. struct mei_cl *cl = NULL;
  294. struct mei_cl *next = NULL;
  295. if (!flow_control->host_addr) {
  296. /* single receive buffer */
  297. mei_hbm_add_single_flow_creds(dev, flow_control);
  298. return;
  299. }
  300. /* normal connection */
  301. list_for_each_entry_safe(cl, next, &dev->file_list, link) {
  302. if (mei_hbm_cl_addr_equal(cl, flow_control)) {
  303. cl->mei_flow_ctrl_creds++;
  304. dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
  305. flow_control->host_addr, flow_control->me_addr);
  306. dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
  307. cl->mei_flow_ctrl_creds);
  308. break;
  309. }
  310. }
  311. }
  312. /**
  313. * mei_hbm_cl_disconnect_req - sends disconnect message to fw.
  314. *
  315. * @dev: the device structure
  316. * @cl: a client to disconnect from
  317. *
  318. * This function returns -EIO on write failure
  319. */
  320. int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
  321. {
  322. struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
  323. const size_t len = sizeof(struct hbm_client_connect_request);
  324. mei_hbm_hdr(mei_hdr, len);
  325. mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_REQ_CMD, dev->wr_msg.data, len);
  326. return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
  327. }
  328. /**
  329. * mei_hbm_cl_disconnect_res - disconnect response from ME
  330. *
  331. * @dev: the device structure
  332. * @rs: disconnect response bus message
  333. */
  334. static void mei_hbm_cl_disconnect_res(struct mei_device *dev,
  335. struct hbm_client_connect_response *rs)
  336. {
  337. struct mei_cl *cl;
  338. struct mei_cl_cb *pos = NULL, *next = NULL;
  339. dev_dbg(&dev->pdev->dev,
  340. "disconnect_response:\n"
  341. "ME Client = %d\n"
  342. "Host Client = %d\n"
  343. "Status = %d\n",
  344. rs->me_addr,
  345. rs->host_addr,
  346. rs->status);
  347. list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
  348. cl = pos->cl;
  349. if (!cl) {
  350. list_del(&pos->list);
  351. return;
  352. }
  353. dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n");
  354. if (mei_hbm_cl_addr_equal(cl, rs)) {
  355. list_del(&pos->list);
  356. if (!rs->status)
  357. cl->state = MEI_FILE_DISCONNECTED;
  358. cl->status = 0;
  359. cl->timer_count = 0;
  360. break;
  361. }
  362. }
  363. }
  364. /**
  365. * mei_hbm_cl_connect_req - send connection request to specific me client
  366. *
  367. * @dev: the device structure
  368. * @cl: a client to connect to
  369. *
  370. * returns -EIO on write failure
  371. */
  372. int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
  373. {
  374. struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
  375. const size_t len = sizeof(struct hbm_client_connect_request);
  376. mei_hbm_hdr(mei_hdr, len);
  377. mei_hbm_cl_hdr(cl, CLIENT_CONNECT_REQ_CMD, dev->wr_msg.data, len);
  378. return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
  379. }
  380. /**
  381. * mei_hbm_cl_connect_res - connect resposne from the ME
  382. *
  383. * @dev: the device structure
  384. * @rs: connect response bus message
  385. */
  386. static void mei_hbm_cl_connect_res(struct mei_device *dev,
  387. struct hbm_client_connect_response *rs)
  388. {
  389. struct mei_cl *cl;
  390. struct mei_cl_cb *pos = NULL, *next = NULL;
  391. dev_dbg(&dev->pdev->dev,
  392. "connect_response:\n"
  393. "ME Client = %d\n"
  394. "Host Client = %d\n"
  395. "Status = %d\n",
  396. rs->me_addr,
  397. rs->host_addr,
  398. rs->status);
  399. /* if WD or iamthif client treat specially */
  400. if (is_treat_specially_client(&dev->wd_cl, rs)) {
  401. dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n");
  402. mei_watchdog_register(dev);
  403. return;
  404. }
  405. if (is_treat_specially_client(&dev->iamthif_cl, rs)) {
  406. dev->iamthif_state = MEI_IAMTHIF_IDLE;
  407. return;
  408. }
  409. list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
  410. cl = pos->cl;
  411. if (!cl) {
  412. list_del(&pos->list);
  413. return;
  414. }
  415. if (pos->fop_type == MEI_FOP_IOCTL) {
  416. if (is_treat_specially_client(cl, rs)) {
  417. list_del(&pos->list);
  418. cl->status = 0;
  419. cl->timer_count = 0;
  420. break;
  421. }
  422. }
  423. }
  424. }
  425. /**
  426. * mei_client_disconnect_request - disconnect request initiated by me
  427. * host sends disoconnect response
  428. *
  429. * @dev: the device structure.
  430. * @disconnect_req: disconnect request bus message from the me
  431. */
  432. static void mei_hbm_fw_disconnect_req(struct mei_device *dev,
  433. struct hbm_client_connect_request *disconnect_req)
  434. {
  435. struct mei_cl *cl, *next;
  436. const size_t len = sizeof(struct hbm_client_connect_response);
  437. list_for_each_entry_safe(cl, next, &dev->file_list, link) {
  438. if (mei_hbm_cl_addr_equal(cl, disconnect_req)) {
  439. dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
  440. disconnect_req->host_addr,
  441. disconnect_req->me_addr);
  442. cl->state = MEI_FILE_DISCONNECTED;
  443. cl->timer_count = 0;
  444. if (cl == &dev->wd_cl)
  445. dev->wd_pending = false;
  446. else if (cl == &dev->iamthif_cl)
  447. dev->iamthif_timer = 0;
  448. /* prepare disconnect response */
  449. mei_hbm_hdr(&dev->wr_ext_msg.hdr, len);
  450. mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_RES_CMD,
  451. dev->wr_ext_msg.data, len);
  452. break;
  453. }
  454. }
  455. }
  456. /**
  457. * mei_hbm_dispatch - bottom half read routine after ISR to
  458. * handle the read bus message cmd processing.
  459. *
  460. * @dev: the device structure
  461. * @mei_hdr: header of bus message
  462. */
  463. void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
  464. {
  465. struct mei_bus_message *mei_msg;
  466. struct mei_me_client *me_client;
  467. struct hbm_host_version_response *version_res;
  468. struct hbm_client_connect_response *connect_res;
  469. struct hbm_client_connect_response *disconnect_res;
  470. struct hbm_client_connect_request *disconnect_req;
  471. struct hbm_flow_control *flow_control;
  472. struct hbm_props_response *props_res;
  473. struct hbm_host_enum_response *enum_res;
  474. /* read the message to our buffer */
  475. BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
  476. mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
  477. mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
  478. switch (mei_msg->hbm_cmd) {
  479. case HOST_START_RES_CMD:
  480. version_res = (struct hbm_host_version_response *)mei_msg;
  481. if (!version_res->host_version_supported) {
  482. dev->version = version_res->me_max_version;
  483. dev_dbg(&dev->pdev->dev, "version mismatch.\n");
  484. dev->hbm_state = MEI_HBM_STOP;
  485. mei_hbm_stop_req_prepare(dev, &dev->wr_msg.hdr,
  486. dev->wr_msg.data);
  487. mei_write_message(dev, &dev->wr_msg.hdr,
  488. dev->wr_msg.data);
  489. return;
  490. }
  491. dev->version.major_version = HBM_MAJOR_VERSION;
  492. dev->version.minor_version = HBM_MINOR_VERSION;
  493. if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
  494. dev->hbm_state == MEI_HBM_START) {
  495. dev->init_clients_timer = 0;
  496. mei_hbm_enum_clients_req(dev);
  497. } else {
  498. dev_err(&dev->pdev->dev, "reset: wrong host start response\n");
  499. mei_reset(dev, 1);
  500. return;
  501. }
  502. wake_up_interruptible(&dev->wait_recvd_msg);
  503. dev_dbg(&dev->pdev->dev, "host start response message received.\n");
  504. break;
  505. case CLIENT_CONNECT_RES_CMD:
  506. connect_res = (struct hbm_client_connect_response *) mei_msg;
  507. mei_hbm_cl_connect_res(dev, connect_res);
  508. dev_dbg(&dev->pdev->dev, "client connect response message received.\n");
  509. wake_up(&dev->wait_recvd_msg);
  510. break;
  511. case CLIENT_DISCONNECT_RES_CMD:
  512. disconnect_res = (struct hbm_client_connect_response *) mei_msg;
  513. mei_hbm_cl_disconnect_res(dev, disconnect_res);
  514. dev_dbg(&dev->pdev->dev, "client disconnect response message received.\n");
  515. wake_up(&dev->wait_recvd_msg);
  516. break;
  517. case MEI_FLOW_CONTROL_CMD:
  518. flow_control = (struct hbm_flow_control *) mei_msg;
  519. mei_hbm_cl_flow_control_res(dev, flow_control);
  520. dev_dbg(&dev->pdev->dev, "client flow control response message received.\n");
  521. break;
  522. case HOST_CLIENT_PROPERTIES_RES_CMD:
  523. props_res = (struct hbm_props_response *)mei_msg;
  524. me_client = &dev->me_clients[dev->me_client_presentation_num];
  525. if (props_res->status || !dev->me_clients) {
  526. dev_err(&dev->pdev->dev, "reset: properties response hbm wrong status.\n");
  527. mei_reset(dev, 1);
  528. return;
  529. }
  530. if (me_client->client_id != props_res->address) {
  531. dev_err(&dev->pdev->dev, "reset: host properties response address mismatch\n");
  532. mei_reset(dev, 1);
  533. return;
  534. }
  535. if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
  536. dev->hbm_state != MEI_HBM_CLIENT_PROPERTIES) {
  537. dev_err(&dev->pdev->dev, "reset: unexpected properties response\n");
  538. mei_reset(dev, 1);
  539. return;
  540. }
  541. me_client->props = props_res->client_properties;
  542. dev->me_client_index++;
  543. dev->me_client_presentation_num++;
  544. /* request property for the next client */
  545. mei_hbm_prop_req(dev);
  546. break;
  547. case HOST_ENUM_RES_CMD:
  548. enum_res = (struct hbm_host_enum_response *) mei_msg;
  549. memcpy(dev->me_clients_map, enum_res->valid_addresses, 32);
  550. if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
  551. dev->hbm_state == MEI_HBM_ENUM_CLIENTS) {
  552. dev->init_clients_timer = 0;
  553. dev->me_client_presentation_num = 0;
  554. dev->me_client_index = 0;
  555. mei_hbm_me_cl_allocate(dev);
  556. dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
  557. /* first property reqeust */
  558. mei_hbm_prop_req(dev);
  559. } else {
  560. dev_err(&dev->pdev->dev, "reset: unexpected enumeration response hbm.\n");
  561. mei_reset(dev, 1);
  562. return;
  563. }
  564. break;
  565. case HOST_STOP_RES_CMD:
  566. if (dev->hbm_state != MEI_HBM_STOP)
  567. dev_err(&dev->pdev->dev, "unexpected stop response hbm.\n");
  568. dev->dev_state = MEI_DEV_DISABLED;
  569. dev_info(&dev->pdev->dev, "reset: FW stop response.\n");
  570. mei_reset(dev, 1);
  571. break;
  572. case CLIENT_DISCONNECT_REQ_CMD:
  573. /* search for client */
  574. disconnect_req = (struct hbm_client_connect_request *)mei_msg;
  575. mei_hbm_fw_disconnect_req(dev, disconnect_req);
  576. break;
  577. case ME_STOP_REQ_CMD:
  578. dev->hbm_state = MEI_HBM_STOP;
  579. mei_hbm_stop_req_prepare(dev, &dev->wr_ext_msg.hdr,
  580. dev->wr_ext_msg.data);
  581. break;
  582. default:
  583. BUG();
  584. break;
  585. }
  586. }