hbm.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280
  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/export.h>
  17. #include <linux/sched.h>
  18. #include <linux/wait.h>
  19. #include <linux/pm_runtime.h>
  20. #include <linux/slab.h>
  21. #include <linux/mei.h>
  22. #include "mei_dev.h"
  23. #include "hbm.h"
  24. #include "client.h"
  25. static const char *mei_hbm_status_str(enum mei_hbm_status status)
  26. {
  27. #define MEI_HBM_STATUS(status) case MEI_HBMS_##status: return #status
  28. switch (status) {
  29. MEI_HBM_STATUS(SUCCESS);
  30. MEI_HBM_STATUS(CLIENT_NOT_FOUND);
  31. MEI_HBM_STATUS(ALREADY_EXISTS);
  32. MEI_HBM_STATUS(REJECTED);
  33. MEI_HBM_STATUS(INVALID_PARAMETER);
  34. MEI_HBM_STATUS(NOT_ALLOWED);
  35. MEI_HBM_STATUS(ALREADY_STARTED);
  36. MEI_HBM_STATUS(NOT_STARTED);
  37. default: return "unknown";
  38. }
  39. #undef MEI_HBM_STATUS
  40. };
  41. static const char *mei_cl_conn_status_str(enum mei_cl_connect_status status)
  42. {
  43. #define MEI_CL_CS(status) case MEI_CL_CONN_##status: return #status
  44. switch (status) {
  45. MEI_CL_CS(SUCCESS);
  46. MEI_CL_CS(NOT_FOUND);
  47. MEI_CL_CS(ALREADY_STARTED);
  48. MEI_CL_CS(OUT_OF_RESOURCES);
  49. MEI_CL_CS(MESSAGE_SMALL);
  50. MEI_CL_CS(NOT_ALLOWED);
  51. default: return "unknown";
  52. }
  53. #undef MEI_CL_CCS
  54. }
  55. const char *mei_hbm_state_str(enum mei_hbm_state state)
  56. {
  57. #define MEI_HBM_STATE(state) case MEI_HBM_##state: return #state
  58. switch (state) {
  59. MEI_HBM_STATE(IDLE);
  60. MEI_HBM_STATE(STARTING);
  61. MEI_HBM_STATE(STARTED);
  62. MEI_HBM_STATE(ENUM_CLIENTS);
  63. MEI_HBM_STATE(CLIENT_PROPERTIES);
  64. MEI_HBM_STATE(STOPPED);
  65. default:
  66. return "unknown";
  67. }
  68. #undef MEI_HBM_STATE
  69. }
  70. /**
  71. * mei_cl_conn_status_to_errno - convert client connect response
  72. * status to error code
  73. *
  74. * @status: client connect response status
  75. *
  76. * Return: corresponding error code
  77. */
  78. static int mei_cl_conn_status_to_errno(enum mei_cl_connect_status status)
  79. {
  80. switch (status) {
  81. case MEI_CL_CONN_SUCCESS: return 0;
  82. case MEI_CL_CONN_NOT_FOUND: return -ENOTTY;
  83. case MEI_CL_CONN_ALREADY_STARTED: return -EBUSY;
  84. case MEI_CL_CONN_OUT_OF_RESOURCES: return -EBUSY;
  85. case MEI_CL_CONN_MESSAGE_SMALL: return -EINVAL;
  86. case MEI_CL_CONN_NOT_ALLOWED: return -EBUSY;
  87. default: return -EINVAL;
  88. }
  89. }
  90. /**
  91. * mei_hbm_write_message - wrapper for sending hbm messages.
  92. *
  93. * @dev: mei device
  94. * @hdr: mei header
  95. * @data: payload
  96. */
  97. static inline int mei_hbm_write_message(struct mei_device *dev,
  98. struct mei_msg_hdr *hdr,
  99. const void *data)
  100. {
  101. return mei_write_message(dev, hdr, sizeof(*hdr), data, hdr->length);
  102. }
  103. /**
  104. * mei_hbm_idle - set hbm to idle state
  105. *
  106. * @dev: the device structure
  107. */
  108. void mei_hbm_idle(struct mei_device *dev)
  109. {
  110. dev->init_clients_timer = 0;
  111. dev->hbm_state = MEI_HBM_IDLE;
  112. }
  113. /**
  114. * mei_hbm_reset - reset hbm counters and book keeping data structurs
  115. *
  116. * @dev: the device structure
  117. */
  118. void mei_hbm_reset(struct mei_device *dev)
  119. {
  120. mei_me_cl_rm_all(dev);
  121. mei_hbm_idle(dev);
  122. }
  123. /**
  124. * mei_hbm_hdr - construct hbm header
  125. *
  126. * @hdr: hbm header
  127. * @length: payload length
  128. */
  129. static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length)
  130. {
  131. hdr->host_addr = 0;
  132. hdr->me_addr = 0;
  133. hdr->length = length;
  134. hdr->msg_complete = 1;
  135. hdr->dma_ring = 0;
  136. hdr->reserved = 0;
  137. hdr->internal = 0;
  138. }
  139. /**
  140. * mei_hbm_cl_hdr - construct client hbm header
  141. *
  142. * @cl: client
  143. * @hbm_cmd: host bus message command
  144. * @buf: buffer for cl header
  145. * @len: buffer length
  146. */
  147. static inline
  148. void mei_hbm_cl_hdr(struct mei_cl *cl, u8 hbm_cmd, void *buf, size_t len)
  149. {
  150. struct mei_hbm_cl_cmd *cmd = buf;
  151. memset(cmd, 0, len);
  152. cmd->hbm_cmd = hbm_cmd;
  153. cmd->host_addr = mei_cl_host_addr(cl);
  154. cmd->me_addr = mei_cl_me_id(cl);
  155. }
  156. /**
  157. * mei_hbm_cl_write - write simple hbm client message
  158. *
  159. * @dev: the device structure
  160. * @cl: client
  161. * @hbm_cmd: host bus message command
  162. * @buf: message buffer
  163. * @len: buffer length
  164. *
  165. * Return: 0 on success, <0 on failure.
  166. */
  167. static inline int mei_hbm_cl_write(struct mei_device *dev, struct mei_cl *cl,
  168. u8 hbm_cmd, void *buf, size_t len)
  169. {
  170. struct mei_msg_hdr mei_hdr;
  171. mei_hbm_hdr(&mei_hdr, len);
  172. mei_hbm_cl_hdr(cl, hbm_cmd, buf, len);
  173. return mei_hbm_write_message(dev, &mei_hdr, buf);
  174. }
  175. /**
  176. * mei_hbm_cl_addr_equal - check if the client's and
  177. * the message address match
  178. *
  179. * @cl: client
  180. * @cmd: hbm client message
  181. *
  182. * Return: true if addresses are the same
  183. */
  184. static inline
  185. bool mei_hbm_cl_addr_equal(struct mei_cl *cl, struct mei_hbm_cl_cmd *cmd)
  186. {
  187. return mei_cl_host_addr(cl) == cmd->host_addr &&
  188. mei_cl_me_id(cl) == cmd->me_addr;
  189. }
  190. /**
  191. * mei_hbm_cl_find_by_cmd - find recipient client
  192. *
  193. * @dev: the device structure
  194. * @buf: a buffer with hbm cl command
  195. *
  196. * Return: the recipient client or NULL if not found
  197. */
  198. static inline
  199. struct mei_cl *mei_hbm_cl_find_by_cmd(struct mei_device *dev, void *buf)
  200. {
  201. struct mei_hbm_cl_cmd *cmd = (struct mei_hbm_cl_cmd *)buf;
  202. struct mei_cl *cl;
  203. list_for_each_entry(cl, &dev->file_list, link)
  204. if (mei_hbm_cl_addr_equal(cl, cmd))
  205. return cl;
  206. return NULL;
  207. }
  208. /**
  209. * mei_hbm_start_wait - wait for start response message.
  210. *
  211. * @dev: the device structure
  212. *
  213. * Return: 0 on success and < 0 on failure
  214. */
  215. int mei_hbm_start_wait(struct mei_device *dev)
  216. {
  217. int ret;
  218. if (dev->hbm_state > MEI_HBM_STARTING)
  219. return 0;
  220. mutex_unlock(&dev->device_lock);
  221. ret = wait_event_timeout(dev->wait_hbm_start,
  222. dev->hbm_state != MEI_HBM_STARTING,
  223. mei_secs_to_jiffies(MEI_HBM_TIMEOUT));
  224. mutex_lock(&dev->device_lock);
  225. if (ret == 0 && (dev->hbm_state <= MEI_HBM_STARTING)) {
  226. dev->hbm_state = MEI_HBM_IDLE;
  227. dev_err(dev->dev, "waiting for mei start failed\n");
  228. return -ETIME;
  229. }
  230. return 0;
  231. }
  232. /**
  233. * mei_hbm_start_req - sends start request message.
  234. *
  235. * @dev: the device structure
  236. *
  237. * Return: 0 on success and < 0 on failure
  238. */
  239. int mei_hbm_start_req(struct mei_device *dev)
  240. {
  241. struct mei_msg_hdr mei_hdr;
  242. struct hbm_host_version_request start_req;
  243. const size_t len = sizeof(struct hbm_host_version_request);
  244. int ret;
  245. mei_hbm_reset(dev);
  246. mei_hbm_hdr(&mei_hdr, len);
  247. /* host start message */
  248. memset(&start_req, 0, len);
  249. start_req.hbm_cmd = HOST_START_REQ_CMD;
  250. start_req.host_version.major_version = HBM_MAJOR_VERSION;
  251. start_req.host_version.minor_version = HBM_MINOR_VERSION;
  252. dev->hbm_state = MEI_HBM_IDLE;
  253. ret = mei_hbm_write_message(dev, &mei_hdr, &start_req);
  254. if (ret) {
  255. dev_err(dev->dev, "version message write failed: ret = %d\n",
  256. ret);
  257. return ret;
  258. }
  259. dev->hbm_state = MEI_HBM_STARTING;
  260. dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
  261. mei_schedule_stall_timer(dev);
  262. return 0;
  263. }
  264. /**
  265. * mei_hbm_enum_clients_req - sends enumeration client request message.
  266. *
  267. * @dev: the device structure
  268. *
  269. * Return: 0 on success and < 0 on failure
  270. */
  271. static int mei_hbm_enum_clients_req(struct mei_device *dev)
  272. {
  273. struct mei_msg_hdr mei_hdr;
  274. struct hbm_host_enum_request enum_req;
  275. const size_t len = sizeof(struct hbm_host_enum_request);
  276. int ret;
  277. /* enumerate clients */
  278. mei_hbm_hdr(&mei_hdr, len);
  279. memset(&enum_req, 0, len);
  280. enum_req.hbm_cmd = HOST_ENUM_REQ_CMD;
  281. enum_req.flags |= dev->hbm_f_dc_supported ?
  282. MEI_HBM_ENUM_F_ALLOW_ADD : 0;
  283. enum_req.flags |= dev->hbm_f_ie_supported ?
  284. MEI_HBM_ENUM_F_IMMEDIATE_ENUM : 0;
  285. ret = mei_hbm_write_message(dev, &mei_hdr, &enum_req);
  286. if (ret) {
  287. dev_err(dev->dev, "enumeration request write failed: ret = %d.\n",
  288. ret);
  289. return ret;
  290. }
  291. dev->hbm_state = MEI_HBM_ENUM_CLIENTS;
  292. dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
  293. mei_schedule_stall_timer(dev);
  294. return 0;
  295. }
  296. /**
  297. * mei_hbm_me_cl_add - add new me client to the list
  298. *
  299. * @dev: the device structure
  300. * @res: hbm property response
  301. *
  302. * Return: 0 on success and -ENOMEM on allocation failure
  303. */
  304. static int mei_hbm_me_cl_add(struct mei_device *dev,
  305. struct hbm_props_response *res)
  306. {
  307. struct mei_me_client *me_cl;
  308. const uuid_le *uuid = &res->client_properties.protocol_name;
  309. mei_me_cl_rm_by_uuid(dev, uuid);
  310. me_cl = kzalloc(sizeof(struct mei_me_client), GFP_KERNEL);
  311. if (!me_cl)
  312. return -ENOMEM;
  313. mei_me_cl_init(me_cl);
  314. me_cl->props = res->client_properties;
  315. me_cl->client_id = res->me_addr;
  316. me_cl->tx_flow_ctrl_creds = 0;
  317. mei_me_cl_add(dev, me_cl);
  318. return 0;
  319. }
  320. /**
  321. * mei_hbm_add_cl_resp - send response to fw on client add request
  322. *
  323. * @dev: the device structure
  324. * @addr: me address
  325. * @status: response status
  326. *
  327. * Return: 0 on success and < 0 on failure
  328. */
  329. static int mei_hbm_add_cl_resp(struct mei_device *dev, u8 addr, u8 status)
  330. {
  331. struct mei_msg_hdr mei_hdr;
  332. struct hbm_add_client_response resp;
  333. const size_t len = sizeof(struct hbm_add_client_response);
  334. int ret;
  335. dev_dbg(dev->dev, "adding client response\n");
  336. mei_hbm_hdr(&mei_hdr, len);
  337. memset(&resp, 0, sizeof(struct hbm_add_client_response));
  338. resp.hbm_cmd = MEI_HBM_ADD_CLIENT_RES_CMD;
  339. resp.me_addr = addr;
  340. resp.status = status;
  341. ret = mei_hbm_write_message(dev, &mei_hdr, &resp);
  342. if (ret)
  343. dev_err(dev->dev, "add client response write failed: ret = %d\n",
  344. ret);
  345. return ret;
  346. }
  347. /**
  348. * mei_hbm_fw_add_cl_req - request from the fw to add a client
  349. *
  350. * @dev: the device structure
  351. * @req: add client request
  352. *
  353. * Return: 0 on success and < 0 on failure
  354. */
  355. static int mei_hbm_fw_add_cl_req(struct mei_device *dev,
  356. struct hbm_add_client_request *req)
  357. {
  358. int ret;
  359. u8 status = MEI_HBMS_SUCCESS;
  360. BUILD_BUG_ON(sizeof(struct hbm_add_client_request) !=
  361. sizeof(struct hbm_props_response));
  362. ret = mei_hbm_me_cl_add(dev, (struct hbm_props_response *)req);
  363. if (ret)
  364. status = !MEI_HBMS_SUCCESS;
  365. if (dev->dev_state == MEI_DEV_ENABLED)
  366. schedule_work(&dev->bus_rescan_work);
  367. return mei_hbm_add_cl_resp(dev, req->me_addr, status);
  368. }
  369. /**
  370. * mei_hbm_cl_notify_req - send notification request
  371. *
  372. * @dev: the device structure
  373. * @cl: a client to disconnect from
  374. * @start: true for start false for stop
  375. *
  376. * Return: 0 on success and -EIO on write failure
  377. */
  378. int mei_hbm_cl_notify_req(struct mei_device *dev,
  379. struct mei_cl *cl, u8 start)
  380. {
  381. struct mei_msg_hdr mei_hdr;
  382. struct hbm_notification_request req;
  383. const size_t len = sizeof(struct hbm_notification_request);
  384. int ret;
  385. mei_hbm_hdr(&mei_hdr, len);
  386. mei_hbm_cl_hdr(cl, MEI_HBM_NOTIFY_REQ_CMD, &req, len);
  387. req.start = start;
  388. ret = mei_hbm_write_message(dev, &mei_hdr, &req);
  389. if (ret)
  390. dev_err(dev->dev, "notify request failed: ret = %d\n", ret);
  391. return ret;
  392. }
  393. /**
  394. * notify_res_to_fop - convert notification response to the proper
  395. * notification FOP
  396. *
  397. * @cmd: client notification start response command
  398. *
  399. * Return: MEI_FOP_NOTIFY_START or MEI_FOP_NOTIFY_STOP;
  400. */
  401. static inline enum mei_cb_file_ops notify_res_to_fop(struct mei_hbm_cl_cmd *cmd)
  402. {
  403. struct hbm_notification_response *rs =
  404. (struct hbm_notification_response *)cmd;
  405. return mei_cl_notify_req2fop(rs->start);
  406. }
  407. /**
  408. * mei_hbm_cl_notify_start_res - update the client state according
  409. * notify start response
  410. *
  411. * @dev: the device structure
  412. * @cl: mei host client
  413. * @cmd: client notification start response command
  414. */
  415. static void mei_hbm_cl_notify_start_res(struct mei_device *dev,
  416. struct mei_cl *cl,
  417. struct mei_hbm_cl_cmd *cmd)
  418. {
  419. struct hbm_notification_response *rs =
  420. (struct hbm_notification_response *)cmd;
  421. cl_dbg(dev, cl, "hbm: notify start response status=%d\n", rs->status);
  422. if (rs->status == MEI_HBMS_SUCCESS ||
  423. rs->status == MEI_HBMS_ALREADY_STARTED) {
  424. cl->notify_en = true;
  425. cl->status = 0;
  426. } else {
  427. cl->status = -EINVAL;
  428. }
  429. }
  430. /**
  431. * mei_hbm_cl_notify_stop_res - update the client state according
  432. * notify stop response
  433. *
  434. * @dev: the device structure
  435. * @cl: mei host client
  436. * @cmd: client notification stop response command
  437. */
  438. static void mei_hbm_cl_notify_stop_res(struct mei_device *dev,
  439. struct mei_cl *cl,
  440. struct mei_hbm_cl_cmd *cmd)
  441. {
  442. struct hbm_notification_response *rs =
  443. (struct hbm_notification_response *)cmd;
  444. cl_dbg(dev, cl, "hbm: notify stop response status=%d\n", rs->status);
  445. if (rs->status == MEI_HBMS_SUCCESS ||
  446. rs->status == MEI_HBMS_NOT_STARTED) {
  447. cl->notify_en = false;
  448. cl->status = 0;
  449. } else {
  450. /* TODO: spec is not clear yet about other possible issues */
  451. cl->status = -EINVAL;
  452. }
  453. }
  454. /**
  455. * mei_hbm_cl_notify - signal notification event
  456. *
  457. * @dev: the device structure
  458. * @cmd: notification client message
  459. */
  460. static void mei_hbm_cl_notify(struct mei_device *dev,
  461. struct mei_hbm_cl_cmd *cmd)
  462. {
  463. struct mei_cl *cl;
  464. cl = mei_hbm_cl_find_by_cmd(dev, cmd);
  465. if (cl)
  466. mei_cl_notify(cl);
  467. }
  468. /**
  469. * mei_hbm_prop_req - request property for a single client
  470. *
  471. * @dev: the device structure
  472. * @start_idx: client index to start search
  473. *
  474. * Return: 0 on success and < 0 on failure
  475. */
  476. static int mei_hbm_prop_req(struct mei_device *dev, unsigned long start_idx)
  477. {
  478. struct mei_msg_hdr mei_hdr;
  479. struct hbm_props_request prop_req;
  480. const size_t len = sizeof(struct hbm_props_request);
  481. unsigned long addr;
  482. int ret;
  483. addr = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX, start_idx);
  484. /* We got all client properties */
  485. if (addr == MEI_CLIENTS_MAX) {
  486. dev->hbm_state = MEI_HBM_STARTED;
  487. mei_host_client_init(dev);
  488. return 0;
  489. }
  490. mei_hbm_hdr(&mei_hdr, len);
  491. memset(&prop_req, 0, sizeof(struct hbm_props_request));
  492. prop_req.hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
  493. prop_req.me_addr = addr;
  494. ret = mei_hbm_write_message(dev, &mei_hdr, &prop_req);
  495. if (ret) {
  496. dev_err(dev->dev, "properties request write failed: ret = %d\n",
  497. ret);
  498. return ret;
  499. }
  500. dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
  501. mei_schedule_stall_timer(dev);
  502. return 0;
  503. }
  504. /**
  505. * mei_hbm_pg - sends pg command
  506. *
  507. * @dev: the device structure
  508. * @pg_cmd: the pg command code
  509. *
  510. * Return: -EIO on write failure
  511. * -EOPNOTSUPP if the operation is not supported by the protocol
  512. */
  513. int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
  514. {
  515. struct mei_msg_hdr mei_hdr;
  516. struct hbm_power_gate req;
  517. const size_t len = sizeof(struct hbm_power_gate);
  518. int ret;
  519. if (!dev->hbm_f_pg_supported)
  520. return -EOPNOTSUPP;
  521. mei_hbm_hdr(&mei_hdr, len);
  522. memset(&req, 0, len);
  523. req.hbm_cmd = pg_cmd;
  524. ret = mei_hbm_write_message(dev, &mei_hdr, &req);
  525. if (ret)
  526. dev_err(dev->dev, "power gate command write failed.\n");
  527. return ret;
  528. }
  529. EXPORT_SYMBOL_GPL(mei_hbm_pg);
  530. /**
  531. * mei_hbm_stop_req - send stop request message
  532. *
  533. * @dev: mei device
  534. *
  535. * Return: -EIO on write failure
  536. */
  537. static int mei_hbm_stop_req(struct mei_device *dev)
  538. {
  539. struct mei_msg_hdr mei_hdr;
  540. struct hbm_host_stop_request req;
  541. const size_t len = sizeof(struct hbm_host_stop_request);
  542. mei_hbm_hdr(&mei_hdr, len);
  543. memset(&req, 0, len);
  544. req.hbm_cmd = HOST_STOP_REQ_CMD;
  545. req.reason = DRIVER_STOP_REQUEST;
  546. return mei_hbm_write_message(dev, &mei_hdr, &req);
  547. }
  548. /**
  549. * mei_hbm_cl_flow_control_req - sends flow control request.
  550. *
  551. * @dev: the device structure
  552. * @cl: client info
  553. *
  554. * Return: -EIO on write failure
  555. */
  556. int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
  557. {
  558. struct hbm_flow_control req;
  559. cl_dbg(dev, cl, "sending flow control\n");
  560. return mei_hbm_cl_write(dev, cl, MEI_FLOW_CONTROL_CMD,
  561. &req, sizeof(req));
  562. }
  563. /**
  564. * mei_hbm_add_single_tx_flow_ctrl_creds - adds single buffer credentials.
  565. *
  566. * @dev: the device structure
  567. * @fctrl: flow control response bus message
  568. *
  569. * Return: 0 on success, < 0 otherwise
  570. */
  571. static int mei_hbm_add_single_tx_flow_ctrl_creds(struct mei_device *dev,
  572. struct hbm_flow_control *fctrl)
  573. {
  574. struct mei_me_client *me_cl;
  575. int rets;
  576. me_cl = mei_me_cl_by_id(dev, fctrl->me_addr);
  577. if (!me_cl) {
  578. dev_err(dev->dev, "no such me client %d\n", fctrl->me_addr);
  579. return -ENOENT;
  580. }
  581. if (WARN_ON(me_cl->props.single_recv_buf == 0)) {
  582. rets = -EINVAL;
  583. goto out;
  584. }
  585. me_cl->tx_flow_ctrl_creds++;
  586. dev_dbg(dev->dev, "recv flow ctrl msg ME %d (single) creds = %d.\n",
  587. fctrl->me_addr, me_cl->tx_flow_ctrl_creds);
  588. rets = 0;
  589. out:
  590. mei_me_cl_put(me_cl);
  591. return rets;
  592. }
  593. /**
  594. * mei_hbm_cl_flow_control_res - flow control response from me
  595. *
  596. * @dev: the device structure
  597. * @fctrl: flow control response bus message
  598. */
  599. static void mei_hbm_cl_tx_flow_ctrl_creds_res(struct mei_device *dev,
  600. struct hbm_flow_control *fctrl)
  601. {
  602. struct mei_cl *cl;
  603. if (!fctrl->host_addr) {
  604. /* single receive buffer */
  605. mei_hbm_add_single_tx_flow_ctrl_creds(dev, fctrl);
  606. return;
  607. }
  608. cl = mei_hbm_cl_find_by_cmd(dev, fctrl);
  609. if (cl) {
  610. cl->tx_flow_ctrl_creds++;
  611. cl_dbg(dev, cl, "flow control creds = %d.\n",
  612. cl->tx_flow_ctrl_creds);
  613. }
  614. }
  615. /**
  616. * mei_hbm_cl_disconnect_req - sends disconnect message to fw.
  617. *
  618. * @dev: the device structure
  619. * @cl: a client to disconnect from
  620. *
  621. * Return: -EIO on write failure
  622. */
  623. int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
  624. {
  625. struct hbm_client_connect_request req;
  626. return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_REQ_CMD,
  627. &req, sizeof(req));
  628. }
  629. /**
  630. * mei_hbm_cl_disconnect_rsp - sends disconnect respose to the FW
  631. *
  632. * @dev: the device structure
  633. * @cl: a client to disconnect from
  634. *
  635. * Return: -EIO on write failure
  636. */
  637. int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl)
  638. {
  639. struct hbm_client_connect_response resp;
  640. return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_RES_CMD,
  641. &resp, sizeof(resp));
  642. }
  643. /**
  644. * mei_hbm_cl_disconnect_res - update the client state according
  645. * disconnect response
  646. *
  647. * @dev: the device structure
  648. * @cl: mei host client
  649. * @cmd: disconnect client response host bus message
  650. */
  651. static void mei_hbm_cl_disconnect_res(struct mei_device *dev, struct mei_cl *cl,
  652. struct mei_hbm_cl_cmd *cmd)
  653. {
  654. struct hbm_client_connect_response *rs =
  655. (struct hbm_client_connect_response *)cmd;
  656. cl_dbg(dev, cl, "hbm: disconnect response status=%d\n", rs->status);
  657. if (rs->status == MEI_CL_DISCONN_SUCCESS)
  658. cl->state = MEI_FILE_DISCONNECT_REPLY;
  659. cl->status = 0;
  660. }
  661. /**
  662. * mei_hbm_cl_connect_req - send connection request to specific me client
  663. *
  664. * @dev: the device structure
  665. * @cl: a client to connect to
  666. *
  667. * Return: -EIO on write failure
  668. */
  669. int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
  670. {
  671. struct hbm_client_connect_request req;
  672. return mei_hbm_cl_write(dev, cl, CLIENT_CONNECT_REQ_CMD,
  673. &req, sizeof(req));
  674. }
  675. /**
  676. * mei_hbm_cl_connect_res - update the client state according
  677. * connection response
  678. *
  679. * @dev: the device structure
  680. * @cl: mei host client
  681. * @cmd: connect client response host bus message
  682. */
  683. static void mei_hbm_cl_connect_res(struct mei_device *dev, struct mei_cl *cl,
  684. struct mei_hbm_cl_cmd *cmd)
  685. {
  686. struct hbm_client_connect_response *rs =
  687. (struct hbm_client_connect_response *)cmd;
  688. cl_dbg(dev, cl, "hbm: connect response status=%s\n",
  689. mei_cl_conn_status_str(rs->status));
  690. if (rs->status == MEI_CL_CONN_SUCCESS)
  691. cl->state = MEI_FILE_CONNECTED;
  692. else {
  693. cl->state = MEI_FILE_DISCONNECT_REPLY;
  694. if (rs->status == MEI_CL_CONN_NOT_FOUND) {
  695. mei_me_cl_del(dev, cl->me_cl);
  696. if (dev->dev_state == MEI_DEV_ENABLED)
  697. schedule_work(&dev->bus_rescan_work);
  698. }
  699. }
  700. cl->status = mei_cl_conn_status_to_errno(rs->status);
  701. }
  702. /**
  703. * mei_hbm_cl_res - process hbm response received on behalf
  704. * an client
  705. *
  706. * @dev: the device structure
  707. * @rs: hbm client message
  708. * @fop_type: file operation type
  709. */
  710. static void mei_hbm_cl_res(struct mei_device *dev,
  711. struct mei_hbm_cl_cmd *rs,
  712. enum mei_cb_file_ops fop_type)
  713. {
  714. struct mei_cl *cl;
  715. struct mei_cl_cb *cb, *next;
  716. cl = NULL;
  717. list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list, list) {
  718. cl = cb->cl;
  719. if (cb->fop_type != fop_type)
  720. continue;
  721. if (mei_hbm_cl_addr_equal(cl, rs)) {
  722. list_del_init(&cb->list);
  723. break;
  724. }
  725. }
  726. if (!cl)
  727. return;
  728. switch (fop_type) {
  729. case MEI_FOP_CONNECT:
  730. mei_hbm_cl_connect_res(dev, cl, rs);
  731. break;
  732. case MEI_FOP_DISCONNECT:
  733. mei_hbm_cl_disconnect_res(dev, cl, rs);
  734. break;
  735. case MEI_FOP_NOTIFY_START:
  736. mei_hbm_cl_notify_start_res(dev, cl, rs);
  737. break;
  738. case MEI_FOP_NOTIFY_STOP:
  739. mei_hbm_cl_notify_stop_res(dev, cl, rs);
  740. break;
  741. default:
  742. return;
  743. }
  744. cl->timer_count = 0;
  745. wake_up(&cl->wait);
  746. }
  747. /**
  748. * mei_hbm_fw_disconnect_req - disconnect request initiated by ME firmware
  749. * host sends disconnect response
  750. *
  751. * @dev: the device structure.
  752. * @disconnect_req: disconnect request bus message from the me
  753. *
  754. * Return: -ENOMEM on allocation failure
  755. */
  756. static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
  757. struct hbm_client_connect_request *disconnect_req)
  758. {
  759. struct mei_cl *cl;
  760. struct mei_cl_cb *cb;
  761. cl = mei_hbm_cl_find_by_cmd(dev, disconnect_req);
  762. if (cl) {
  763. cl_warn(dev, cl, "fw disconnect request received\n");
  764. cl->state = MEI_FILE_DISCONNECTING;
  765. cl->timer_count = 0;
  766. cb = mei_cl_enqueue_ctrl_wr_cb(cl, 0, MEI_FOP_DISCONNECT_RSP,
  767. NULL);
  768. if (!cb)
  769. return -ENOMEM;
  770. }
  771. return 0;
  772. }
  773. /**
  774. * mei_hbm_pg_enter_res - PG enter response received
  775. *
  776. * @dev: the device structure.
  777. *
  778. * Return: 0 on success, -EPROTO on state mismatch
  779. */
  780. static int mei_hbm_pg_enter_res(struct mei_device *dev)
  781. {
  782. if (mei_pg_state(dev) != MEI_PG_OFF ||
  783. dev->pg_event != MEI_PG_EVENT_WAIT) {
  784. dev_err(dev->dev, "hbm: pg entry response: state mismatch [%s, %d]\n",
  785. mei_pg_state_str(mei_pg_state(dev)), dev->pg_event);
  786. return -EPROTO;
  787. }
  788. dev->pg_event = MEI_PG_EVENT_RECEIVED;
  789. wake_up(&dev->wait_pg);
  790. return 0;
  791. }
  792. /**
  793. * mei_hbm_pg_resume - process with PG resume
  794. *
  795. * @dev: the device structure.
  796. */
  797. void mei_hbm_pg_resume(struct mei_device *dev)
  798. {
  799. pm_request_resume(dev->dev);
  800. }
  801. EXPORT_SYMBOL_GPL(mei_hbm_pg_resume);
  802. /**
  803. * mei_hbm_pg_exit_res - PG exit response received
  804. *
  805. * @dev: the device structure.
  806. *
  807. * Return: 0 on success, -EPROTO on state mismatch
  808. */
  809. static int mei_hbm_pg_exit_res(struct mei_device *dev)
  810. {
  811. if (mei_pg_state(dev) != MEI_PG_ON ||
  812. (dev->pg_event != MEI_PG_EVENT_WAIT &&
  813. dev->pg_event != MEI_PG_EVENT_IDLE)) {
  814. dev_err(dev->dev, "hbm: pg exit response: state mismatch [%s, %d]\n",
  815. mei_pg_state_str(mei_pg_state(dev)), dev->pg_event);
  816. return -EPROTO;
  817. }
  818. switch (dev->pg_event) {
  819. case MEI_PG_EVENT_WAIT:
  820. dev->pg_event = MEI_PG_EVENT_RECEIVED;
  821. wake_up(&dev->wait_pg);
  822. break;
  823. case MEI_PG_EVENT_IDLE:
  824. /*
  825. * If the driver is not waiting on this then
  826. * this is HW initiated exit from PG.
  827. * Start runtime pm resume sequence to exit from PG.
  828. */
  829. dev->pg_event = MEI_PG_EVENT_RECEIVED;
  830. mei_hbm_pg_resume(dev);
  831. break;
  832. default:
  833. WARN(1, "hbm: pg exit response: unexpected pg event = %d\n",
  834. dev->pg_event);
  835. return -EPROTO;
  836. }
  837. return 0;
  838. }
  839. /**
  840. * mei_hbm_config_features - check what hbm features and commands
  841. * are supported by the fw
  842. *
  843. * @dev: the device structure
  844. */
  845. static void mei_hbm_config_features(struct mei_device *dev)
  846. {
  847. /* Power Gating Isolation Support */
  848. dev->hbm_f_pg_supported = 0;
  849. if (dev->version.major_version > HBM_MAJOR_VERSION_PGI)
  850. dev->hbm_f_pg_supported = 1;
  851. if (dev->version.major_version == HBM_MAJOR_VERSION_PGI &&
  852. dev->version.minor_version >= HBM_MINOR_VERSION_PGI)
  853. dev->hbm_f_pg_supported = 1;
  854. if (dev->version.major_version >= HBM_MAJOR_VERSION_DC)
  855. dev->hbm_f_dc_supported = 1;
  856. if (dev->version.major_version >= HBM_MAJOR_VERSION_IE)
  857. dev->hbm_f_ie_supported = 1;
  858. /* disconnect on connect timeout instead of link reset */
  859. if (dev->version.major_version >= HBM_MAJOR_VERSION_DOT)
  860. dev->hbm_f_dot_supported = 1;
  861. /* Notification Event Support */
  862. if (dev->version.major_version >= HBM_MAJOR_VERSION_EV)
  863. dev->hbm_f_ev_supported = 1;
  864. /* Fixed Address Client Support */
  865. if (dev->version.major_version >= HBM_MAJOR_VERSION_FA)
  866. dev->hbm_f_fa_supported = 1;
  867. /* OS ver message Support */
  868. if (dev->version.major_version >= HBM_MAJOR_VERSION_OS)
  869. dev->hbm_f_os_supported = 1;
  870. /* DMA Ring Support */
  871. if (dev->version.major_version > HBM_MAJOR_VERSION_DR ||
  872. (dev->version.major_version == HBM_MAJOR_VERSION_DR &&
  873. dev->version.minor_version >= HBM_MINOR_VERSION_DR))
  874. dev->hbm_f_dr_supported = 1;
  875. }
  876. /**
  877. * mei_hbm_version_is_supported - checks whether the driver can
  878. * support the hbm version of the device
  879. *
  880. * @dev: the device structure
  881. * Return: true if driver can support hbm version of the device
  882. */
  883. bool mei_hbm_version_is_supported(struct mei_device *dev)
  884. {
  885. return (dev->version.major_version < HBM_MAJOR_VERSION) ||
  886. (dev->version.major_version == HBM_MAJOR_VERSION &&
  887. dev->version.minor_version <= HBM_MINOR_VERSION);
  888. }
  889. /**
  890. * mei_hbm_dispatch - bottom half read routine after ISR to
  891. * handle the read bus message cmd processing.
  892. *
  893. * @dev: the device structure
  894. * @hdr: header of bus message
  895. *
  896. * Return: 0 on success and < 0 on failure
  897. */
  898. int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
  899. {
  900. struct mei_bus_message *mei_msg;
  901. struct hbm_host_version_response *version_res;
  902. struct hbm_props_response *props_res;
  903. struct hbm_host_enum_response *enum_res;
  904. struct hbm_add_client_request *add_cl_req;
  905. int ret;
  906. struct mei_hbm_cl_cmd *cl_cmd;
  907. struct hbm_client_connect_request *disconnect_req;
  908. struct hbm_flow_control *fctrl;
  909. /* read the message to our buffer */
  910. BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
  911. mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
  912. mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
  913. cl_cmd = (struct mei_hbm_cl_cmd *)mei_msg;
  914. /* ignore spurious message and prevent reset nesting
  915. * hbm is put to idle during system reset
  916. */
  917. if (dev->hbm_state == MEI_HBM_IDLE) {
  918. dev_dbg(dev->dev, "hbm: state is idle ignore spurious messages\n");
  919. return 0;
  920. }
  921. switch (mei_msg->hbm_cmd) {
  922. case HOST_START_RES_CMD:
  923. dev_dbg(dev->dev, "hbm: start: response message received.\n");
  924. dev->init_clients_timer = 0;
  925. version_res = (struct hbm_host_version_response *)mei_msg;
  926. dev_dbg(dev->dev, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n",
  927. HBM_MAJOR_VERSION, HBM_MINOR_VERSION,
  928. version_res->me_max_version.major_version,
  929. version_res->me_max_version.minor_version);
  930. if (version_res->host_version_supported) {
  931. dev->version.major_version = HBM_MAJOR_VERSION;
  932. dev->version.minor_version = HBM_MINOR_VERSION;
  933. } else {
  934. dev->version.major_version =
  935. version_res->me_max_version.major_version;
  936. dev->version.minor_version =
  937. version_res->me_max_version.minor_version;
  938. }
  939. if (!mei_hbm_version_is_supported(dev)) {
  940. dev_warn(dev->dev, "hbm: start: version mismatch - stopping the driver.\n");
  941. dev->hbm_state = MEI_HBM_STOPPED;
  942. if (mei_hbm_stop_req(dev)) {
  943. dev_err(dev->dev, "hbm: start: failed to send stop request\n");
  944. return -EIO;
  945. }
  946. break;
  947. }
  948. mei_hbm_config_features(dev);
  949. if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
  950. dev->hbm_state != MEI_HBM_STARTING) {
  951. dev_err(dev->dev, "hbm: start: state mismatch, [%d, %d]\n",
  952. dev->dev_state, dev->hbm_state);
  953. return -EPROTO;
  954. }
  955. if (mei_hbm_enum_clients_req(dev)) {
  956. dev_err(dev->dev, "hbm: start: failed to send enumeration request\n");
  957. return -EIO;
  958. }
  959. wake_up(&dev->wait_hbm_start);
  960. break;
  961. case CLIENT_CONNECT_RES_CMD:
  962. dev_dbg(dev->dev, "hbm: client connect response: message received.\n");
  963. mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_CONNECT);
  964. break;
  965. case CLIENT_DISCONNECT_RES_CMD:
  966. dev_dbg(dev->dev, "hbm: client disconnect response: message received.\n");
  967. mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_DISCONNECT);
  968. break;
  969. case MEI_FLOW_CONTROL_CMD:
  970. dev_dbg(dev->dev, "hbm: client flow control response: message received.\n");
  971. fctrl = (struct hbm_flow_control *)mei_msg;
  972. mei_hbm_cl_tx_flow_ctrl_creds_res(dev, fctrl);
  973. break;
  974. case MEI_PG_ISOLATION_ENTRY_RES_CMD:
  975. dev_dbg(dev->dev, "hbm: power gate isolation entry response received\n");
  976. ret = mei_hbm_pg_enter_res(dev);
  977. if (ret)
  978. return ret;
  979. break;
  980. case MEI_PG_ISOLATION_EXIT_REQ_CMD:
  981. dev_dbg(dev->dev, "hbm: power gate isolation exit request received\n");
  982. ret = mei_hbm_pg_exit_res(dev);
  983. if (ret)
  984. return ret;
  985. break;
  986. case HOST_CLIENT_PROPERTIES_RES_CMD:
  987. dev_dbg(dev->dev, "hbm: properties response: message received.\n");
  988. dev->init_clients_timer = 0;
  989. if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
  990. dev->hbm_state != MEI_HBM_CLIENT_PROPERTIES) {
  991. dev_err(dev->dev, "hbm: properties response: state mismatch, [%d, %d]\n",
  992. dev->dev_state, dev->hbm_state);
  993. return -EPROTO;
  994. }
  995. props_res = (struct hbm_props_response *)mei_msg;
  996. if (props_res->status == MEI_HBMS_CLIENT_NOT_FOUND) {
  997. dev_dbg(dev->dev, "hbm: properties response: %d CLIENT_NOT_FOUND\n",
  998. props_res->me_addr);
  999. } else if (props_res->status) {
  1000. dev_err(dev->dev, "hbm: properties response: wrong status = %d %s\n",
  1001. props_res->status,
  1002. mei_hbm_status_str(props_res->status));
  1003. return -EPROTO;
  1004. } else {
  1005. mei_hbm_me_cl_add(dev, props_res);
  1006. }
  1007. /* request property for the next client */
  1008. if (mei_hbm_prop_req(dev, props_res->me_addr + 1))
  1009. return -EIO;
  1010. break;
  1011. case HOST_ENUM_RES_CMD:
  1012. dev_dbg(dev->dev, "hbm: enumeration response: message received\n");
  1013. dev->init_clients_timer = 0;
  1014. enum_res = (struct hbm_host_enum_response *) mei_msg;
  1015. BUILD_BUG_ON(sizeof(dev->me_clients_map)
  1016. < sizeof(enum_res->valid_addresses));
  1017. memcpy(dev->me_clients_map, enum_res->valid_addresses,
  1018. sizeof(enum_res->valid_addresses));
  1019. if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
  1020. dev->hbm_state != MEI_HBM_ENUM_CLIENTS) {
  1021. dev_err(dev->dev, "hbm: enumeration response: state mismatch, [%d, %d]\n",
  1022. dev->dev_state, dev->hbm_state);
  1023. return -EPROTO;
  1024. }
  1025. dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
  1026. /* first property request */
  1027. if (mei_hbm_prop_req(dev, 0))
  1028. return -EIO;
  1029. break;
  1030. case HOST_STOP_RES_CMD:
  1031. dev_dbg(dev->dev, "hbm: stop response: message received\n");
  1032. dev->init_clients_timer = 0;
  1033. if (dev->hbm_state != MEI_HBM_STOPPED) {
  1034. dev_err(dev->dev, "hbm: stop response: state mismatch, [%d, %d]\n",
  1035. dev->dev_state, dev->hbm_state);
  1036. return -EPROTO;
  1037. }
  1038. dev->dev_state = MEI_DEV_POWER_DOWN;
  1039. dev_info(dev->dev, "hbm: stop response: resetting.\n");
  1040. /* force the reset */
  1041. return -EPROTO;
  1042. break;
  1043. case CLIENT_DISCONNECT_REQ_CMD:
  1044. dev_dbg(dev->dev, "hbm: disconnect request: message received\n");
  1045. disconnect_req = (struct hbm_client_connect_request *)mei_msg;
  1046. mei_hbm_fw_disconnect_req(dev, disconnect_req);
  1047. break;
  1048. case ME_STOP_REQ_CMD:
  1049. dev_dbg(dev->dev, "hbm: stop request: message received\n");
  1050. dev->hbm_state = MEI_HBM_STOPPED;
  1051. if (mei_hbm_stop_req(dev)) {
  1052. dev_err(dev->dev, "hbm: stop request: failed to send stop request\n");
  1053. return -EIO;
  1054. }
  1055. break;
  1056. case MEI_HBM_ADD_CLIENT_REQ_CMD:
  1057. dev_dbg(dev->dev, "hbm: add client request received\n");
  1058. /*
  1059. * after the host receives the enum_resp
  1060. * message clients may be added or removed
  1061. */
  1062. if (dev->hbm_state <= MEI_HBM_ENUM_CLIENTS ||
  1063. dev->hbm_state >= MEI_HBM_STOPPED) {
  1064. dev_err(dev->dev, "hbm: add client: state mismatch, [%d, %d]\n",
  1065. dev->dev_state, dev->hbm_state);
  1066. return -EPROTO;
  1067. }
  1068. add_cl_req = (struct hbm_add_client_request *)mei_msg;
  1069. ret = mei_hbm_fw_add_cl_req(dev, add_cl_req);
  1070. if (ret) {
  1071. dev_err(dev->dev, "hbm: add client: failed to send response %d\n",
  1072. ret);
  1073. return -EIO;
  1074. }
  1075. dev_dbg(dev->dev, "hbm: add client request processed\n");
  1076. break;
  1077. case MEI_HBM_NOTIFY_RES_CMD:
  1078. dev_dbg(dev->dev, "hbm: notify response received\n");
  1079. mei_hbm_cl_res(dev, cl_cmd, notify_res_to_fop(cl_cmd));
  1080. break;
  1081. case MEI_HBM_NOTIFICATION_CMD:
  1082. dev_dbg(dev->dev, "hbm: notification\n");
  1083. mei_hbm_cl_notify(dev, cl_cmd);
  1084. break;
  1085. default:
  1086. BUG();
  1087. break;
  1088. }
  1089. return 0;
  1090. }