ipa_qmi.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2018-2022 Linaro Ltd.
  4. */
  5. #include <linux/types.h>
  6. #include <linux/string.h>
  7. #include <linux/slab.h>
  8. #include <linux/qrtr.h>
  9. #include <linux/soc/qcom/qmi.h>
  10. #include "ipa.h"
  11. #include "ipa_endpoint.h"
  12. #include "ipa_mem.h"
  13. #include "ipa_table.h"
  14. #include "ipa_modem.h"
  15. #include "ipa_qmi_msg.h"
  16. /**
  17. * DOC: AP/Modem QMI Handshake
  18. *
  19. * The AP and modem perform a "handshake" at initialization time to ensure
  20. * both sides know when everything is ready to begin operating. The AP
  21. * driver (this code) uses two QMI handles (endpoints) for this; a client
  22. * using a service on the modem, and server to service modem requests (and
  23. * to supply an indication message from the AP). Once the handshake is
  24. * complete, the AP and modem may begin IPA operation. This occurs
  25. * only when the AP IPA driver, modem IPA driver, and IPA microcontroller
  26. * are ready.
  27. *
  28. * The QMI service on the modem expects to receive an INIT_DRIVER request from
  29. * the AP, which contains parameters used by the modem during initialization.
  30. * The AP sends this request as soon as it is knows the modem side service
  31. * is available. The modem responds to this request, and if this response
  32. * contains a success result, the AP knows the modem IPA driver is ready.
  33. *
  34. * The modem is responsible for loading firmware on the IPA microcontroller.
  35. * This occurs only during the initial modem boot. The modem sends a
  36. * separate DRIVER_INIT_COMPLETE request to the AP to report that the
  37. * microcontroller is ready. The AP may assume the microcontroller is
  38. * ready and remain so (even if the modem reboots) once it has received
  39. * and responded to this request.
  40. *
  41. * There is one final exchange involved in the handshake. It is required
  42. * on the initial modem boot, but optional (but in practice does occur) on
  43. * subsequent boots. The modem expects to receive a final INIT_COMPLETE
  44. * indication message from the AP when it is about to begin its normal
  45. * operation. The AP will only send this message after it has received
  46. * and responded to an INDICATION_REGISTER request from the modem.
  47. *
  48. * So in summary:
  49. * - Whenever the AP learns the modem has booted and its IPA QMI service
  50. * is available, it sends an INIT_DRIVER request to the modem. The
  51. * modem supplies a success response when it is ready to operate.
  52. * - On the initial boot, the modem sets up the IPA microcontroller, and
  53. * sends a DRIVER_INIT_COMPLETE request to the AP when this is done.
  54. * - When the modem is ready to receive an INIT_COMPLETE indication from
  55. * the AP, it sends an INDICATION_REGISTER request to the AP.
  56. * - On the initial modem boot, everything is ready when:
  57. * - AP has received a success response from its INIT_DRIVER request
  58. * - AP has responded to a DRIVER_INIT_COMPLETE request
  59. * - AP has responded to an INDICATION_REGISTER request from the modem
  60. * - AP has sent an INIT_COMPLETE indication to the modem
  61. * - On subsequent modem boots, everything is ready when:
  62. * - AP has received a success response from its INIT_DRIVER request
  63. * - AP has responded to a DRIVER_INIT_COMPLETE request
  64. * - The INDICATION_REGISTER request and INIT_COMPLETE indication are
  65. * optional for non-initial modem boots, and have no bearing on the
  66. * determination of when things are "ready"
  67. */
  68. #define IPA_HOST_SERVICE_SVC_ID 0x31
  69. #define IPA_HOST_SVC_VERS 1
  70. #define IPA_HOST_SERVICE_INS_ID 1
  71. #define IPA_MODEM_SERVICE_SVC_ID 0x31
  72. #define IPA_MODEM_SERVICE_INS_ID 2
  73. #define IPA_MODEM_SVC_VERS 1
  74. #define QMI_INIT_DRIVER_TIMEOUT 60000 /* A minute in milliseconds */
  75. /* Send an INIT_COMPLETE indication message to the modem */
  76. static void ipa_server_init_complete(struct ipa_qmi *ipa_qmi)
  77. {
  78. struct ipa *ipa = container_of(ipa_qmi, struct ipa, qmi);
  79. struct qmi_handle *qmi = &ipa_qmi->server_handle;
  80. struct sockaddr_qrtr *sq = &ipa_qmi->modem_sq;
  81. struct ipa_init_complete_ind ind = { };
  82. int ret;
  83. ind.status.result = QMI_RESULT_SUCCESS_V01;
  84. ind.status.error = QMI_ERR_NONE_V01;
  85. ret = qmi_send_indication(qmi, sq, IPA_QMI_INIT_COMPLETE,
  86. IPA_QMI_INIT_COMPLETE_IND_SZ,
  87. ipa_init_complete_ind_ei, &ind);
  88. if (ret)
  89. dev_err(&ipa->pdev->dev,
  90. "error %d sending init complete indication\n", ret);
  91. else
  92. ipa_qmi->indication_sent = true;
  93. }
  94. /* If requested (and not already sent) send the INIT_COMPLETE indication */
  95. static void ipa_qmi_indication(struct ipa_qmi *ipa_qmi)
  96. {
  97. if (!ipa_qmi->indication_requested)
  98. return;
  99. if (ipa_qmi->indication_sent)
  100. return;
  101. ipa_server_init_complete(ipa_qmi);
  102. }
  103. /* Determine whether everything is ready to start normal operation.
  104. * We know everything (else) is ready when we know the IPA driver on
  105. * the modem is ready, and the microcontroller is ready.
  106. *
  107. * When the modem boots (or reboots), the handshake sequence starts
  108. * with the AP sending the modem an INIT_DRIVER request. Within
  109. * that request, the uc_loaded flag will be zero (false) for an
  110. * initial boot, non-zero (true) for a subsequent (SSR) boot.
  111. */
  112. static void ipa_qmi_ready(struct ipa_qmi *ipa_qmi)
  113. {
  114. struct ipa *ipa;
  115. int ret;
  116. /* We aren't ready until the modem and microcontroller are */
  117. if (!ipa_qmi->modem_ready || !ipa_qmi->uc_ready)
  118. return;
  119. /* Send the indication message if it was requested */
  120. ipa_qmi_indication(ipa_qmi);
  121. /* The initial boot requires us to send the indication. */
  122. if (ipa_qmi->initial_boot) {
  123. if (!ipa_qmi->indication_sent)
  124. return;
  125. /* The initial modem boot completed successfully */
  126. ipa_qmi->initial_boot = false;
  127. }
  128. /* We're ready. Start up normal operation */
  129. ipa = container_of(ipa_qmi, struct ipa, qmi);
  130. ret = ipa_modem_start(ipa);
  131. if (ret)
  132. dev_err(&ipa->pdev->dev, "error %d starting modem\n", ret);
  133. }
  134. /* All QMI clients from the modem node are gone (modem shut down or crashed). */
  135. static void ipa_server_bye(struct qmi_handle *qmi, unsigned int node)
  136. {
  137. struct ipa_qmi *ipa_qmi;
  138. ipa_qmi = container_of(qmi, struct ipa_qmi, server_handle);
  139. /* The modem client and server go away at the same time */
  140. memset(&ipa_qmi->modem_sq, 0, sizeof(ipa_qmi->modem_sq));
  141. /* initial_boot doesn't change when modem reboots */
  142. /* uc_ready doesn't change when modem reboots */
  143. ipa_qmi->modem_ready = false;
  144. ipa_qmi->indication_requested = false;
  145. ipa_qmi->indication_sent = false;
  146. }
  147. static const struct qmi_ops ipa_server_ops = {
  148. .bye = ipa_server_bye,
  149. };
  150. /* Callback function to handle an INDICATION_REGISTER request message from the
  151. * modem. This informs the AP that the modem is now ready to receive the
  152. * INIT_COMPLETE indication message.
  153. */
  154. static void ipa_server_indication_register(struct qmi_handle *qmi,
  155. struct sockaddr_qrtr *sq,
  156. struct qmi_txn *txn,
  157. const void *decoded)
  158. {
  159. struct ipa_indication_register_rsp rsp = { };
  160. struct ipa_qmi *ipa_qmi;
  161. struct ipa *ipa;
  162. int ret;
  163. ipa_qmi = container_of(qmi, struct ipa_qmi, server_handle);
  164. ipa = container_of(ipa_qmi, struct ipa, qmi);
  165. rsp.rsp.result = QMI_RESULT_SUCCESS_V01;
  166. rsp.rsp.error = QMI_ERR_NONE_V01;
  167. ret = qmi_send_response(qmi, sq, txn, IPA_QMI_INDICATION_REGISTER,
  168. IPA_QMI_INDICATION_REGISTER_RSP_SZ,
  169. ipa_indication_register_rsp_ei, &rsp);
  170. if (!ret) {
  171. ipa_qmi->indication_requested = true;
  172. ipa_qmi_ready(ipa_qmi); /* We might be ready now */
  173. } else {
  174. dev_err(&ipa->pdev->dev,
  175. "error %d sending register indication response\n", ret);
  176. }
  177. }
  178. /* Respond to a DRIVER_INIT_COMPLETE request message from the modem. */
  179. static void ipa_server_driver_init_complete(struct qmi_handle *qmi,
  180. struct sockaddr_qrtr *sq,
  181. struct qmi_txn *txn,
  182. const void *decoded)
  183. {
  184. struct ipa_driver_init_complete_rsp rsp = { };
  185. struct ipa_qmi *ipa_qmi;
  186. struct ipa *ipa;
  187. int ret;
  188. ipa_qmi = container_of(qmi, struct ipa_qmi, server_handle);
  189. ipa = container_of(ipa_qmi, struct ipa, qmi);
  190. rsp.rsp.result = QMI_RESULT_SUCCESS_V01;
  191. rsp.rsp.error = QMI_ERR_NONE_V01;
  192. ret = qmi_send_response(qmi, sq, txn, IPA_QMI_DRIVER_INIT_COMPLETE,
  193. IPA_QMI_DRIVER_INIT_COMPLETE_RSP_SZ,
  194. ipa_driver_init_complete_rsp_ei, &rsp);
  195. if (!ret) {
  196. ipa_qmi->uc_ready = true;
  197. ipa_qmi_ready(ipa_qmi); /* We might be ready now */
  198. } else {
  199. dev_err(&ipa->pdev->dev,
  200. "error %d sending init complete response\n", ret);
  201. }
  202. }
  203. /* The server handles two request message types sent by the modem. */
  204. static const struct qmi_msg_handler ipa_server_msg_handlers[] = {
  205. {
  206. .type = QMI_REQUEST,
  207. .msg_id = IPA_QMI_INDICATION_REGISTER,
  208. .ei = ipa_indication_register_req_ei,
  209. .decoded_size = IPA_QMI_INDICATION_REGISTER_REQ_SZ,
  210. .fn = ipa_server_indication_register,
  211. },
  212. {
  213. .type = QMI_REQUEST,
  214. .msg_id = IPA_QMI_DRIVER_INIT_COMPLETE,
  215. .ei = ipa_driver_init_complete_req_ei,
  216. .decoded_size = IPA_QMI_DRIVER_INIT_COMPLETE_REQ_SZ,
  217. .fn = ipa_server_driver_init_complete,
  218. },
  219. { },
  220. };
  221. /* Handle an INIT_DRIVER response message from the modem. */
  222. static void ipa_client_init_driver(struct qmi_handle *qmi,
  223. struct sockaddr_qrtr *sq,
  224. struct qmi_txn *txn, const void *decoded)
  225. {
  226. txn->result = 0; /* IPA_QMI_INIT_DRIVER request was successful */
  227. complete(&txn->completion);
  228. }
  229. /* The client handles one response message type sent by the modem. */
  230. static const struct qmi_msg_handler ipa_client_msg_handlers[] = {
  231. {
  232. .type = QMI_RESPONSE,
  233. .msg_id = IPA_QMI_INIT_DRIVER,
  234. .ei = ipa_init_modem_driver_rsp_ei,
  235. .decoded_size = IPA_QMI_INIT_DRIVER_RSP_SZ,
  236. .fn = ipa_client_init_driver,
  237. },
  238. { },
  239. };
  240. /* Return a pointer to an init modem driver request structure, which contains
  241. * configuration parameters for the modem. The modem may be started multiple
  242. * times, but generally these parameters don't change so we can reuse the
  243. * request structure once it's initialized. The only exception is the
  244. * skip_uc_load field, which will be set only after the microcontroller has
  245. * reported it has completed its initialization.
  246. */
  247. static const struct ipa_init_modem_driver_req *
  248. init_modem_driver_req(struct ipa_qmi *ipa_qmi)
  249. {
  250. struct ipa *ipa = container_of(ipa_qmi, struct ipa, qmi);
  251. static struct ipa_init_modem_driver_req req;
  252. const struct ipa_mem *mem;
  253. /* The microcontroller is initialized on the first boot */
  254. req.skip_uc_load_valid = 1;
  255. req.skip_uc_load = ipa->uc_loaded ? 1 : 0;
  256. /* We only have to initialize most of it once */
  257. if (req.platform_type_valid)
  258. return &req;
  259. req.platform_type_valid = 1;
  260. req.platform_type = IPA_QMI_PLATFORM_TYPE_MSM_ANDROID;
  261. mem = ipa_mem_find(ipa, IPA_MEM_MODEM_HEADER);
  262. if (mem->size) {
  263. req.hdr_tbl_info_valid = 1;
  264. req.hdr_tbl_info.start = ipa->mem_offset + mem->offset;
  265. req.hdr_tbl_info.end = req.hdr_tbl_info.start + mem->size - 1;
  266. }
  267. mem = ipa_mem_find(ipa, IPA_MEM_V4_ROUTE);
  268. req.v4_route_tbl_info_valid = 1;
  269. req.v4_route_tbl_info.start = ipa->mem_offset + mem->offset;
  270. req.v4_route_tbl_info.end = IPA_ROUTE_MODEM_COUNT - 1;
  271. mem = ipa_mem_find(ipa, IPA_MEM_V6_ROUTE);
  272. req.v6_route_tbl_info_valid = 1;
  273. req.v6_route_tbl_info.start = ipa->mem_offset + mem->offset;
  274. req.v6_route_tbl_info.end = IPA_ROUTE_MODEM_COUNT - 1;
  275. mem = ipa_mem_find(ipa, IPA_MEM_V4_FILTER);
  276. req.v4_filter_tbl_start_valid = 1;
  277. req.v4_filter_tbl_start = ipa->mem_offset + mem->offset;
  278. mem = ipa_mem_find(ipa, IPA_MEM_V6_FILTER);
  279. req.v6_filter_tbl_start_valid = 1;
  280. req.v6_filter_tbl_start = ipa->mem_offset + mem->offset;
  281. mem = ipa_mem_find(ipa, IPA_MEM_MODEM);
  282. if (mem->size) {
  283. req.modem_mem_info_valid = 1;
  284. req.modem_mem_info.start = ipa->mem_offset + mem->offset;
  285. req.modem_mem_info.size = mem->size;
  286. }
  287. req.ctrl_comm_dest_end_pt_valid = 1;
  288. req.ctrl_comm_dest_end_pt =
  289. ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->endpoint_id;
  290. /* skip_uc_load_valid and skip_uc_load are set above */
  291. mem = ipa_mem_find(ipa, IPA_MEM_MODEM_PROC_CTX);
  292. if (mem->size) {
  293. req.hdr_proc_ctx_tbl_info_valid = 1;
  294. req.hdr_proc_ctx_tbl_info.start =
  295. ipa->mem_offset + mem->offset;
  296. req.hdr_proc_ctx_tbl_info.end =
  297. req.hdr_proc_ctx_tbl_info.start + mem->size - 1;
  298. }
  299. /* Nothing to report for the compression table (zip_tbl_info) */
  300. mem = ipa_mem_find(ipa, IPA_MEM_V4_ROUTE_HASHED);
  301. if (mem->size) {
  302. req.v4_hash_route_tbl_info_valid = 1;
  303. req.v4_hash_route_tbl_info.start =
  304. ipa->mem_offset + mem->offset;
  305. req.v4_hash_route_tbl_info.end = IPA_ROUTE_MODEM_COUNT - 1;
  306. }
  307. mem = ipa_mem_find(ipa, IPA_MEM_V6_ROUTE_HASHED);
  308. if (mem->size) {
  309. req.v6_hash_route_tbl_info_valid = 1;
  310. req.v6_hash_route_tbl_info.start =
  311. ipa->mem_offset + mem->offset;
  312. req.v6_hash_route_tbl_info.end = IPA_ROUTE_MODEM_COUNT - 1;
  313. }
  314. mem = ipa_mem_find(ipa, IPA_MEM_V4_FILTER_HASHED);
  315. if (mem->size) {
  316. req.v4_hash_filter_tbl_start_valid = 1;
  317. req.v4_hash_filter_tbl_start = ipa->mem_offset + mem->offset;
  318. }
  319. mem = ipa_mem_find(ipa, IPA_MEM_V6_FILTER_HASHED);
  320. if (mem->size) {
  321. req.v6_hash_filter_tbl_start_valid = 1;
  322. req.v6_hash_filter_tbl_start = ipa->mem_offset + mem->offset;
  323. }
  324. /* The stats fields are only valid for IPA v4.0+ */
  325. if (ipa->version >= IPA_VERSION_4_0) {
  326. mem = ipa_mem_find(ipa, IPA_MEM_STATS_QUOTA_MODEM);
  327. if (mem->size) {
  328. req.hw_stats_quota_base_addr_valid = 1;
  329. req.hw_stats_quota_base_addr =
  330. ipa->mem_offset + mem->offset;
  331. req.hw_stats_quota_size_valid = 1;
  332. req.hw_stats_quota_size = ipa->mem_offset + mem->size;
  333. }
  334. /* If the DROP stats region is defined, include it */
  335. mem = ipa_mem_find(ipa, IPA_MEM_STATS_DROP);
  336. if (mem && mem->size) {
  337. req.hw_stats_drop_base_addr_valid = 1;
  338. req.hw_stats_drop_base_addr =
  339. ipa->mem_offset + mem->offset;
  340. req.hw_stats_drop_size_valid = 1;
  341. req.hw_stats_drop_size = ipa->mem_offset + mem->size;
  342. }
  343. }
  344. return &req;
  345. }
  346. /* Send an INIT_DRIVER request to the modem, and wait for it to complete. */
  347. static void ipa_client_init_driver_work(struct work_struct *work)
  348. {
  349. unsigned long timeout = msecs_to_jiffies(QMI_INIT_DRIVER_TIMEOUT);
  350. const struct ipa_init_modem_driver_req *req;
  351. struct ipa_qmi *ipa_qmi;
  352. struct qmi_handle *qmi;
  353. struct qmi_txn txn;
  354. struct device *dev;
  355. struct ipa *ipa;
  356. int ret;
  357. ipa_qmi = container_of(work, struct ipa_qmi, init_driver_work);
  358. qmi = &ipa_qmi->client_handle;
  359. ipa = container_of(ipa_qmi, struct ipa, qmi);
  360. dev = &ipa->pdev->dev;
  361. ret = qmi_txn_init(qmi, &txn, NULL, NULL);
  362. if (ret < 0) {
  363. dev_err(dev, "error %d preparing init driver request\n", ret);
  364. return;
  365. }
  366. /* Send the request, and if successful wait for its response */
  367. req = init_modem_driver_req(ipa_qmi);
  368. ret = qmi_send_request(qmi, &ipa_qmi->modem_sq, &txn,
  369. IPA_QMI_INIT_DRIVER, IPA_QMI_INIT_DRIVER_REQ_SZ,
  370. ipa_init_modem_driver_req_ei, req);
  371. if (ret)
  372. dev_err(dev, "error %d sending init driver request\n", ret);
  373. else if ((ret = qmi_txn_wait(&txn, timeout)))
  374. dev_err(dev, "error %d awaiting init driver response\n", ret);
  375. if (!ret) {
  376. ipa_qmi->modem_ready = true;
  377. ipa_qmi_ready(ipa_qmi); /* We might be ready now */
  378. } else {
  379. /* If any error occurs we need to cancel the transaction */
  380. qmi_txn_cancel(&txn);
  381. }
  382. }
  383. /* The modem server is now available. We will send an INIT_DRIVER request
  384. * to the modem, but can't wait for it to complete in this callback thread.
  385. * Schedule a worker on the global workqueue to do that for us.
  386. */
  387. static int
  388. ipa_client_new_server(struct qmi_handle *qmi, struct qmi_service *svc)
  389. {
  390. struct ipa_qmi *ipa_qmi;
  391. ipa_qmi = container_of(qmi, struct ipa_qmi, client_handle);
  392. ipa_qmi->modem_sq.sq_family = AF_QIPCRTR;
  393. ipa_qmi->modem_sq.sq_node = svc->node;
  394. ipa_qmi->modem_sq.sq_port = svc->port;
  395. schedule_work(&ipa_qmi->init_driver_work);
  396. return 0;
  397. }
  398. static const struct qmi_ops ipa_client_ops = {
  399. .new_server = ipa_client_new_server,
  400. };
  401. /* Set up for QMI message exchange */
  402. int ipa_qmi_setup(struct ipa *ipa)
  403. {
  404. struct ipa_qmi *ipa_qmi = &ipa->qmi;
  405. int ret;
  406. ipa_qmi->initial_boot = true;
  407. /* The server handle is used to handle the DRIVER_INIT_COMPLETE
  408. * request on the first modem boot. It also receives the
  409. * INDICATION_REGISTER request on the first boot and (optionally)
  410. * subsequent boots. The INIT_COMPLETE indication message is
  411. * sent over the server handle if requested.
  412. */
  413. ret = qmi_handle_init(&ipa_qmi->server_handle,
  414. IPA_QMI_SERVER_MAX_RCV_SZ, &ipa_server_ops,
  415. ipa_server_msg_handlers);
  416. if (ret)
  417. return ret;
  418. ret = qmi_add_server(&ipa_qmi->server_handle, IPA_HOST_SERVICE_SVC_ID,
  419. IPA_HOST_SVC_VERS, IPA_HOST_SERVICE_INS_ID);
  420. if (ret)
  421. goto err_server_handle_release;
  422. /* The client handle is only used for sending an INIT_DRIVER request
  423. * to the modem, and receiving its response message.
  424. */
  425. ret = qmi_handle_init(&ipa_qmi->client_handle,
  426. IPA_QMI_CLIENT_MAX_RCV_SZ, &ipa_client_ops,
  427. ipa_client_msg_handlers);
  428. if (ret)
  429. goto err_server_handle_release;
  430. /* We need this ready before the service lookup is added */
  431. INIT_WORK(&ipa_qmi->init_driver_work, ipa_client_init_driver_work);
  432. ret = qmi_add_lookup(&ipa_qmi->client_handle, IPA_MODEM_SERVICE_SVC_ID,
  433. IPA_MODEM_SVC_VERS, IPA_MODEM_SERVICE_INS_ID);
  434. if (ret)
  435. goto err_client_handle_release;
  436. return 0;
  437. err_client_handle_release:
  438. /* Releasing the handle also removes registered lookups */
  439. qmi_handle_release(&ipa_qmi->client_handle);
  440. memset(&ipa_qmi->client_handle, 0, sizeof(ipa_qmi->client_handle));
  441. err_server_handle_release:
  442. /* Releasing the handle also removes registered services */
  443. qmi_handle_release(&ipa_qmi->server_handle);
  444. memset(&ipa_qmi->server_handle, 0, sizeof(ipa_qmi->server_handle));
  445. return ret;
  446. }
  447. /* Tear down IPA QMI handles */
  448. void ipa_qmi_teardown(struct ipa *ipa)
  449. {
  450. cancel_work_sync(&ipa->qmi.init_driver_work);
  451. qmi_handle_release(&ipa->qmi.client_handle);
  452. memset(&ipa->qmi.client_handle, 0, sizeof(ipa->qmi.client_handle));
  453. qmi_handle_release(&ipa->qmi.server_handle);
  454. memset(&ipa->qmi.server_handle, 0, sizeof(ipa->qmi.server_handle));
  455. }