ipa_pm_ut.c 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/ipa.h>
  6. #include "../ipa_v3/ipa_pm.h"
  7. #include "../ipa_v3/ipa_i.h"
  8. #include "ipa_ut_framework.h"
  9. #include <linux/delay.h>
  10. struct callback_param {
  11. struct completion complete;
  12. enum ipa_pm_cb_event evt;
  13. };
  14. static int ipa_pm_ut_setup(void **ppriv)
  15. {
  16. int i;
  17. int vote;
  18. IPA_UT_DBG("Start Setup\n");
  19. /* decrement UT vote */
  20. IPA_ACTIVE_CLIENTS_DEC_SPECIAL("IPA_UT");
  21. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  22. if (vote) {
  23. IPA_UT_ERR("clock vote is not zero %d\n", vote);
  24. IPA_UT_TEST_FAIL_REPORT("clock is voted");
  25. IPA_ACTIVE_CLIENTS_INC_SPECIAL("IPA_UT");
  26. return -EINVAL;
  27. }
  28. /*decouple PM from RPM */
  29. ipa3_ctx->enable_clock_scaling = false;
  30. for (i = 0; i < IPA_PM_MAX_CLIENTS; i++) {
  31. ipa_pm_deactivate_sync(i);
  32. ipa_pm_deregister(i);
  33. }
  34. ipa_pm_destroy();
  35. return 0;
  36. }
  37. static int ipa_pm_ut_teardown(void *priv)
  38. {
  39. IPA_UT_DBG("Start Teardown\n");
  40. IPA_UT_ERR("WARNING: IPA_PM HAS BEEN DESTROYED, REBOOT TO RE_INIT\n");
  41. /* undo UT vote */
  42. IPA_ACTIVE_CLIENTS_INC_SPECIAL("IPA_UT");
  43. return 0;
  44. }
  45. /* pass completion struct as the user data/callback params */
  46. static void ipa_pm_call_back(void *user_data, enum ipa_pm_cb_event evt)
  47. {
  48. struct callback_param *param;
  49. param = (struct callback_param *) user_data;
  50. param->evt = evt;
  51. if (evt == IPA_PM_CLIENT_ACTIVATED) {
  52. IPA_UT_DBG("Activate callback called\n");
  53. complete_all(&param->complete);
  54. } else if (evt == IPA_PM_REQUEST_WAKEUP) {
  55. IPA_UT_DBG("Request Wakeup callback called\n");
  56. complete_all(&param->complete);
  57. } else
  58. IPA_UT_ERR("invalid callback - callback #%d\n", evt);
  59. }
  60. static int clean_up(int n, ...)
  61. {
  62. va_list args;
  63. int i, hdl, rc = 0;
  64. va_start(args, n);
  65. IPA_UT_DBG("n = %d\n", n);
  66. IPA_UT_DBG("Clean up Started");
  67. for (i = 0; i < n; i++) {
  68. hdl = va_arg(args, int);
  69. rc = ipa_pm_deactivate_sync(hdl);
  70. if (rc) {
  71. IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
  72. IPA_UT_TEST_FAIL_REPORT("deactivate failed");
  73. return -EFAULT;
  74. }
  75. rc = ipa_pm_deregister(hdl);
  76. if (rc) {
  77. IPA_UT_ERR("fail to deregister client - rc = %d\n", rc);
  78. IPA_UT_TEST_FAIL_REPORT("deregister failed");
  79. return -EFAULT;
  80. }
  81. }
  82. va_end(args);
  83. rc = ipa_pm_destroy();
  84. if (rc) {
  85. IPA_UT_ERR("fail to destroy pm - rc = %d\n", rc);
  86. IPA_UT_TEST_FAIL_REPORT("destroy failed");
  87. return -EFAULT;
  88. }
  89. return 0;
  90. }
  91. /* test 1 */
  92. static int ipa_pm_ut_single_registration(void *priv)
  93. {
  94. int rc = 0;
  95. int hdl, vote;
  96. struct callback_param user_data;
  97. struct ipa_pm_init_params init_params = {
  98. .threshold_size = 2,
  99. .default_threshold = {600, 1000}
  100. };
  101. struct ipa_pm_register_params register_params = {
  102. .name = "USB",
  103. .group = IPA_PM_GROUP_DEFAULT,
  104. .skip_clk_vote = 0,
  105. .callback = ipa_pm_call_back,
  106. .user_data = &user_data
  107. };
  108. user_data.evt = IPA_PM_CB_EVENT_MAX;
  109. rc = ipa_pm_init(&init_params);
  110. if (rc) {
  111. IPA_UT_ERR("Fail to init ipa_pm rc = %d\n", rc);
  112. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  113. return -EFAULT;
  114. }
  115. init_completion(&user_data.complete);
  116. rc = ipa_pm_register(&register_params, &hdl);
  117. if (rc) {
  118. IPA_UT_ERR("fail to register client rc = %d\n", rc);
  119. IPA_UT_TEST_FAIL_REPORT("fail to register");
  120. return -EFAULT;
  121. }
  122. rc = ipa_pm_activate(hdl);
  123. if (rc != -EINPROGRESS) {
  124. IPA_UT_ERR("fail to queue work - rc = %d\n", rc);
  125. IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
  126. return -EFAULT;
  127. }
  128. if (!wait_for_completion_timeout(&user_data.complete,
  129. msecs_to_jiffies(2000))) {
  130. IPA_UT_ERR("timeout waiting for activate_callback\n");
  131. IPA_UT_TEST_FAIL_REPORT("activate callback not called");
  132. return -ETIME;
  133. }
  134. if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
  135. IPA_UT_ERR("Callback = %d\n", user_data.evt);
  136. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  137. return -EFAULT;
  138. }
  139. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  140. if (vote != 1) {
  141. IPA_UT_ERR("clock vote is at %d\n", vote);
  142. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  143. return -EINVAL;
  144. }
  145. rc = ipa_pm_deregister(hdl);
  146. if (rc == 0) {
  147. IPA_UT_ERR("deregister succeeded while it should not\n");
  148. IPA_UT_TEST_FAIL_REPORT("deregister should not succeed");
  149. return -EFAULT;
  150. }
  151. rc = ipa_pm_deferred_deactivate(hdl);
  152. if (rc) {
  153. IPA_UT_ERR("fail to deferred deactivate client - rc = %d\n"
  154. , rc);
  155. IPA_UT_TEST_FAIL_REPORT("fail to deferred deactivate client");
  156. return -EFAULT;
  157. }
  158. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  159. if (vote != 1) {
  160. IPA_UT_ERR("clock vote is at %d\n", vote);
  161. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  162. return -EINVAL;
  163. }
  164. msleep(2000);
  165. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  166. if (vote != 0) {
  167. IPA_UT_ERR("clock vote is at %d\n", vote);
  168. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  169. return -EINVAL;
  170. }
  171. rc = ipa_pm_deregister(hdl);
  172. if (rc) {
  173. IPA_UT_ERR("fail to deregister client - rc = %d\n", rc);
  174. IPA_UT_TEST_FAIL_REPORT("fail to deregister client");
  175. return -EFAULT;
  176. }
  177. rc = ipa_pm_activate(hdl);
  178. if (rc == 0) {
  179. IPA_UT_ERR("activate succeeded while it should not\n");
  180. IPA_UT_TEST_FAIL_REPORT("activate should not succeed");
  181. return -EFAULT;
  182. }
  183. rc = ipa_pm_destroy();
  184. if (rc) {
  185. IPA_UT_ERR("terminate failed - rc = %d\n", rc);
  186. IPA_UT_TEST_FAIL_REPORT("terminate_failed");
  187. }
  188. return 0;
  189. }
  190. /* test 2 */
  191. static int ipa_pm_ut_double_register_activate(void *priv)
  192. {
  193. int rc = 0;
  194. int hdl, hdl_test, vote;
  195. struct callback_param user_data;
  196. struct ipa_pm_init_params init_params = {
  197. .threshold_size = 2,
  198. .default_threshold = {600, 1000}
  199. };
  200. struct ipa_pm_register_params register_params = {
  201. .name = "USB",
  202. .group = IPA_PM_GROUP_DEFAULT,
  203. .skip_clk_vote = 0,
  204. .callback = ipa_pm_call_back,
  205. .user_data = &user_data
  206. };
  207. user_data.evt = IPA_PM_CB_EVENT_MAX;
  208. rc = ipa_pm_init(&init_params);
  209. if (rc) {
  210. IPA_UT_ERR("Fail to init ipa_pm rc = %d\n", rc);
  211. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  212. return -EFAULT;
  213. }
  214. init_completion(&user_data.complete);
  215. rc = ipa_pm_register(&register_params, &hdl);
  216. if (rc) {
  217. IPA_UT_ERR("fail to register client rc = %d\n", rc);
  218. IPA_UT_TEST_FAIL_REPORT("fail to register");
  219. return -EFAULT;
  220. }
  221. rc = ipa_pm_register(&register_params, &hdl_test);
  222. if (rc != -EEXIST) {
  223. IPA_UT_ERR("registered client with same name rc = %d\n", rc);
  224. IPA_UT_TEST_FAIL_REPORT("did not to fail register");
  225. return -EFAULT;
  226. }
  227. rc = ipa_pm_activate(hdl);
  228. if (rc != -EINPROGRESS) {
  229. IPA_UT_ERR("fail to queue work - rc = %d\n", rc);
  230. IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
  231. return -EFAULT;
  232. }
  233. /* It is possible that previous activation already completed. */
  234. rc = ipa_pm_activate(hdl);
  235. if (rc != -EINPROGRESS && rc != 0) {
  236. IPA_UT_ERR("second time activation failed - rc = %d\n", rc);
  237. IPA_UT_TEST_FAIL_REPORT("second time activation failed");
  238. return -EFAULT;
  239. }
  240. if (!wait_for_completion_timeout(&user_data.complete,
  241. msecs_to_jiffies(2000))) {
  242. IPA_UT_ERR("timeout waiting for activate_callback\n");
  243. IPA_UT_TEST_FAIL_REPORT("activate callback not called");
  244. return -ETIME;
  245. }
  246. if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
  247. IPA_UT_ERR("Callback = %d\n", user_data.evt);
  248. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  249. return -EFAULT;
  250. }
  251. rc = ipa_pm_activate(hdl);
  252. if (rc) {
  253. IPA_UT_ERR("fail to do nothing on 2nd activate = %d\n", rc);
  254. IPA_UT_TEST_FAIL_REPORT("fail to not reactivate");
  255. return -EFAULT;
  256. }
  257. msleep(2000);
  258. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  259. if (vote != 1) {
  260. IPA_UT_ERR("clock vote is at %d\n", vote);
  261. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  262. return -EINVAL;
  263. }
  264. rc = ipa_pm_deactivate_sync(hdl);
  265. if (rc) {
  266. IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
  267. IPA_UT_TEST_FAIL_REPORT("fail to deactivate client");
  268. return -EFAULT;
  269. }
  270. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  271. if (vote != 0) {
  272. IPA_UT_ERR("clock vote is at %d\n", vote);
  273. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  274. return -EINVAL;
  275. }
  276. rc = clean_up(1, hdl);
  277. return rc;
  278. }
  279. /* test 3 */
  280. static int ipa_pm_ut_deferred_deactivate(void *priv)
  281. {
  282. int rc = 0;
  283. int hdl, vote;
  284. struct callback_param user_data;
  285. struct ipa_pm_init_params init_params = {
  286. .threshold_size = 2,
  287. .default_threshold = {600, 1000}
  288. };
  289. struct ipa_pm_register_params register_params = {
  290. .name = "USB",
  291. .group = IPA_PM_GROUP_DEFAULT,
  292. .skip_clk_vote = 0,
  293. .callback = ipa_pm_call_back,
  294. .user_data = &user_data
  295. };
  296. user_data.evt = IPA_PM_CB_EVENT_MAX;
  297. rc = ipa_pm_init(&init_params);
  298. if (rc) {
  299. IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
  300. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  301. return -EFAULT;
  302. }
  303. init_completion(&user_data.complete);
  304. rc = ipa_pm_register(&register_params, &hdl);
  305. if (rc) {
  306. IPA_UT_ERR("fail to register client rc = %d\n", rc);
  307. IPA_UT_TEST_FAIL_REPORT("fail to register");
  308. return -EFAULT;
  309. }
  310. rc = ipa_pm_activate(hdl);
  311. if (rc != -EINPROGRESS) {
  312. IPA_UT_ERR("fail to queue work - rc = %d\n", rc);
  313. IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
  314. return -EFAULT;
  315. }
  316. if (!wait_for_completion_timeout(&user_data.complete,
  317. msecs_to_jiffies(2000))) {
  318. IPA_UT_ERR("timeout waiting for activate_callback\n");
  319. IPA_UT_TEST_FAIL_REPORT("activate callback not called");
  320. return -ETIME;
  321. }
  322. if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
  323. IPA_UT_ERR("Callback = %d\n", user_data.evt);
  324. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  325. return -EFAULT;
  326. }
  327. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  328. if (vote != 1) {
  329. IPA_UT_ERR("clock vote is at %d\n", vote);
  330. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  331. return -EINVAL;
  332. }
  333. rc = ipa_pm_deferred_deactivate(hdl);
  334. if (rc) {
  335. IPA_UT_ERR("fail to deffered deactivate client - rc = %d\n",
  336. rc);
  337. IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
  338. return -EFAULT;
  339. }
  340. rc = ipa_pm_activate(hdl);
  341. if (rc) {
  342. IPA_UT_ERR("fail to reactivate client - rc = %d\n", rc);
  343. IPA_UT_TEST_FAIL_REPORT("reactivate client failed");
  344. return -EFAULT;
  345. }
  346. msleep(2000);
  347. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  348. if (vote != 1) {
  349. IPA_UT_ERR("clock vote is at %d\n", vote);
  350. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  351. return -EINVAL;
  352. }
  353. rc = ipa_pm_deactivate_sync(hdl);
  354. if (rc) {
  355. IPA_UT_ERR("fail to deactivate_sync client - rc = %d\n", rc);
  356. IPA_UT_TEST_FAIL_REPORT("deactivate sync failed");
  357. return -EFAULT;
  358. }
  359. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  360. if (vote) {
  361. IPA_UT_ERR("clock vote is at %d\n", vote);
  362. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  363. return -EINVAL;
  364. }
  365. rc = clean_up(1, hdl);
  366. return rc;
  367. }
  368. /* test 4 */
  369. static int ipa_pm_ut_two_clients_activate(void *priv)
  370. {
  371. int rc = 0;
  372. int hdl_USB, hdl_WLAN, vote;
  373. u32 pipes;
  374. struct callback_param user_data_USB;
  375. struct callback_param user_data_WLAN;
  376. bool wait_for_completion;
  377. struct ipa_pm_init_params init_params = {
  378. .threshold_size = 2,
  379. .default_threshold = {600, 1000}
  380. };
  381. struct ipa_pm_register_params USB_params = {
  382. .name = "USB",
  383. .group = IPA_PM_GROUP_DEFAULT,
  384. .skip_clk_vote = 0,
  385. .callback = ipa_pm_call_back,
  386. .user_data = &user_data_USB
  387. };
  388. struct ipa_pm_register_params WLAN_params = {
  389. .name = "WLAN",
  390. .group = IPA_PM_GROUP_DEFAULT,
  391. .skip_clk_vote = 0,
  392. .callback = ipa_pm_call_back,
  393. .user_data = &user_data_WLAN
  394. };
  395. user_data_USB.evt = IPA_PM_CB_EVENT_MAX;
  396. user_data_WLAN.evt = IPA_PM_CB_EVENT_MAX;
  397. rc = ipa_pm_init(&init_params);
  398. if (rc) {
  399. IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
  400. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  401. return -EFAULT;
  402. }
  403. init_completion(&user_data_USB.complete);
  404. init_completion(&user_data_WLAN.complete);
  405. rc = ipa_pm_register(&USB_params, &hdl_USB);
  406. if (rc) {
  407. IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
  408. IPA_UT_TEST_FAIL_REPORT("fail to register");
  409. return -EFAULT;
  410. }
  411. rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
  412. if (rc) {
  413. IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
  414. IPA_UT_TEST_FAIL_REPORT("fail to register");
  415. return -EFAULT;
  416. }
  417. rc = ipa_pm_associate_ipa_cons_to_client(hdl_USB, IPA_CLIENT_USB_CONS);
  418. if (rc) {
  419. IPA_UT_ERR("fail to map client 1 rc = %d\n", rc);
  420. IPA_UT_TEST_FAIL_REPORT("fail to map client");
  421. return -EFAULT;
  422. }
  423. rc = ipa_pm_associate_ipa_cons_to_client(hdl_WLAN,
  424. IPA_CLIENT_WLAN1_CONS);
  425. if (rc) {
  426. IPA_UT_ERR("fail to map client 2 rc = %d\n", rc);
  427. IPA_UT_TEST_FAIL_REPORT("fail to map client");
  428. return -EFAULT;
  429. }
  430. rc = ipa_pm_associate_ipa_cons_to_client(hdl_WLAN,
  431. IPA_CLIENT_USB_DPL_CONS);
  432. if (rc) {
  433. IPA_UT_ERR("fail to map client 2 to multiplt pipes rc = %d\n",
  434. rc);
  435. IPA_UT_TEST_FAIL_REPORT("fail to map client");
  436. return -EFAULT;
  437. }
  438. rc = ipa_pm_activate(hdl_USB);
  439. if (rc != -EINPROGRESS) {
  440. IPA_UT_ERR("fail to queue work for client 1 - rc = %d\n", rc);
  441. IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
  442. return -EFAULT;
  443. }
  444. /* It could be that USB enabled clocks so WLAN will be activated
  445. * without delay.
  446. */
  447. rc = ipa_pm_activate(hdl_WLAN);
  448. if (rc != -EINPROGRESS && rc != 0) {
  449. IPA_UT_ERR("failed to activate WLAN - rc = %d\n", rc);
  450. IPA_UT_TEST_FAIL_REPORT("failed to activate WLAN");
  451. return -EFAULT;
  452. }
  453. wait_for_completion = !rc ? false : true;
  454. if (!wait_for_completion_timeout(&user_data_USB.complete,
  455. msecs_to_jiffies(2000))) {
  456. IPA_UT_ERR("timeout waiting for activate_callback 1\n");
  457. IPA_UT_TEST_FAIL_REPORT("activate callback not called");
  458. return -ETIME;
  459. }
  460. if (user_data_USB.evt != IPA_PM_CLIENT_ACTIVATED) {
  461. IPA_UT_ERR("Callback = %d\n", user_data_USB.evt);
  462. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  463. return -EFAULT;
  464. }
  465. if (wait_for_completion &&
  466. !wait_for_completion_timeout(&user_data_WLAN.complete,
  467. msecs_to_jiffies(2000))) {
  468. IPA_UT_ERR("timeout waiting for activate_callback 2\n");
  469. IPA_UT_TEST_FAIL_REPORT("activate callback not called");
  470. return -ETIME;
  471. }
  472. /* In case WLAN activated immediately, there will be no event */
  473. if (wait_for_completion &&
  474. user_data_WLAN.evt != IPA_PM_CLIENT_ACTIVATED) {
  475. IPA_UT_ERR("Callback = %d\n", user_data_WLAN.evt);
  476. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  477. return -EFAULT;
  478. }
  479. reinit_completion(&user_data_USB.complete);
  480. reinit_completion(&user_data_WLAN.complete);
  481. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  482. if (vote != 2) {
  483. IPA_UT_ERR("clock vote is at %d\n", vote);
  484. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  485. return -EINVAL;
  486. }
  487. rc = ipa_pm_deferred_deactivate(hdl_USB);
  488. if (rc) {
  489. IPA_UT_ERR("fail to deffered deactivate client 1 - rc = %d\n",
  490. rc);
  491. IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
  492. return -EFAULT;
  493. }
  494. msleep(2000);
  495. rc = ipa_pm_activate(hdl_USB);
  496. if (rc) {
  497. IPA_UT_ERR("no-block activate failed - rc = %d\n", rc);
  498. IPA_UT_TEST_FAIL_REPORT("no-block activate fail");
  499. return -EFAULT;
  500. }
  501. pipes = 1 << ipa_get_ep_mapping(IPA_CLIENT_USB_CONS);
  502. pipes |= 1 << ipa_get_ep_mapping(IPA_CLIENT_WLAN1_CONS);
  503. pipes |= 1 << ipa_get_ep_mapping(IPA_CLIENT_USB_DPL_CONS);
  504. IPA_UT_DBG("pipes = %d\n", pipes);
  505. rc = ipa_pm_handle_suspend(pipes);
  506. if (!wait_for_completion_timeout(&user_data_USB.complete,
  507. msecs_to_jiffies(2000))) {
  508. IPA_UT_ERR("timeout waiting for wakeup_callback 1\n");
  509. IPA_UT_TEST_FAIL_REPORT("wakeup callback not called");
  510. return -ETIME;
  511. }
  512. if (user_data_USB.evt != IPA_PM_REQUEST_WAKEUP) {
  513. IPA_UT_ERR("Callback = %d\n", user_data_USB.evt);
  514. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  515. return -EFAULT;
  516. }
  517. if (!wait_for_completion_timeout(&user_data_WLAN.complete,
  518. msecs_to_jiffies(2000))) {
  519. IPA_UT_ERR("timeout waiting for wakeup_callback 2\n");
  520. IPA_UT_TEST_FAIL_REPORT("wakeup callback not called");
  521. return -ETIME;
  522. }
  523. if (user_data_WLAN.evt != IPA_PM_REQUEST_WAKEUP) {
  524. IPA_UT_ERR("Callback = %d\n", user_data_WLAN.evt);
  525. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  526. return -EFAULT;
  527. }
  528. reinit_completion(&user_data_USB.complete);
  529. rc = ipa_pm_deactivate_sync(hdl_USB);
  530. if (rc) {
  531. IPA_UT_ERR("fail to deactivate_sync client 1 - rc = %d\n", rc);
  532. IPA_UT_TEST_FAIL_REPORT("fail to deactivate_sync");
  533. return -EFAULT;
  534. }
  535. rc = ipa_pm_activate(hdl_USB);
  536. if (rc) {
  537. IPA_UT_ERR("no-block activate failed - rc = %d\n", rc);
  538. IPA_UT_TEST_FAIL_REPORT("no-block activate fail");
  539. return -EFAULT;
  540. }
  541. pipes = 1 << ipa_get_ep_mapping(IPA_CLIENT_USB_CONS);
  542. rc = ipa_pm_handle_suspend(pipes);
  543. if (!wait_for_completion_timeout(&user_data_USB.complete,
  544. msecs_to_jiffies(2000))) {
  545. IPA_UT_ERR("timeout waiting for wakeup_callback 1\n");
  546. IPA_UT_TEST_FAIL_REPORT("wakeup callback not called");
  547. return -ETIME;
  548. }
  549. if (user_data_USB.evt != IPA_PM_REQUEST_WAKEUP) {
  550. IPA_UT_ERR("Callback = %d\n", user_data_USB.evt);
  551. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  552. return -EFAULT;
  553. }
  554. rc = clean_up(2, hdl_USB, hdl_WLAN);
  555. return rc;
  556. }
  557. /* test 5 */
  558. static int ipa_pm_ut_deactivate_all_deferred(void *priv)
  559. {
  560. int rc = 0;
  561. int hdl_USB, hdl_WLAN, hdl_MODEM, vote;
  562. struct callback_param user_data;
  563. struct ipa_pm_init_params init_params = {
  564. .threshold_size = 2,
  565. .default_threshold = {600, 1000}
  566. };
  567. struct ipa_pm_register_params USB_params = {
  568. .name = "USB",
  569. .group = IPA_PM_GROUP_DEFAULT,
  570. .skip_clk_vote = 0,
  571. .callback = ipa_pm_call_back,
  572. .user_data = &user_data
  573. };
  574. struct ipa_pm_register_params WLAN_params = {
  575. .name = "WLAN",
  576. .group = IPA_PM_GROUP_DEFAULT,
  577. .skip_clk_vote = 0,
  578. .callback = ipa_pm_call_back,
  579. };
  580. struct ipa_pm_register_params MODEM_params = {
  581. .name = "MODEM",
  582. .group = IPA_PM_GROUP_DEFAULT,
  583. .skip_clk_vote = 0,
  584. .callback = ipa_pm_call_back,
  585. };
  586. user_data.evt = IPA_PM_CB_EVENT_MAX;
  587. rc = ipa_pm_init(&init_params);
  588. if (rc) {
  589. IPA_UT_ERR("Fail to init ipa_pm - rce %d\n", rc);
  590. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  591. return -EFAULT;
  592. }
  593. init_completion(&user_data.complete);
  594. rc = ipa_pm_register(&USB_params, &hdl_USB);
  595. if (rc) {
  596. IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
  597. IPA_UT_TEST_FAIL_REPORT("fail to register");
  598. return -EFAULT;
  599. }
  600. rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
  601. if (rc) {
  602. IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
  603. IPA_UT_TEST_FAIL_REPORT("fail to register");
  604. return -EFAULT;
  605. }
  606. rc = ipa_pm_activate(hdl_USB);
  607. if (rc != -EINPROGRESS) {
  608. IPA_UT_ERR("fail to queue work for client 1 - rc = %d\n", rc);
  609. IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
  610. return -EFAULT;
  611. }
  612. rc = ipa_pm_activate_sync(hdl_WLAN);
  613. if (rc) {
  614. IPA_UT_ERR("fail to activate sync for client 2- rc = %d\n", rc);
  615. IPA_UT_TEST_FAIL_REPORT("activate sync failed");
  616. return -EFAULT;
  617. }
  618. if (!wait_for_completion_timeout(&user_data.complete,
  619. msecs_to_jiffies(2000))) {
  620. IPA_UT_ERR("timeout waiting for activate_callback 1\n");
  621. IPA_UT_TEST_FAIL_REPORT("activate callback not called");
  622. return -ETIME;
  623. }
  624. if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
  625. IPA_UT_ERR("Callback = %d\n", user_data.evt);
  626. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  627. return -EFAULT;
  628. }
  629. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  630. if (vote != 2) {
  631. IPA_UT_ERR("clock vote is at %d\n", vote);
  632. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  633. return -EINVAL;
  634. }
  635. rc = ipa_pm_register(&MODEM_params, &hdl_MODEM);
  636. if (rc) {
  637. IPA_UT_ERR("fail to register client 3 rc = %d\n", rc);
  638. IPA_UT_TEST_FAIL_REPORT("fail to register");
  639. return -EFAULT;
  640. }
  641. rc = ipa_pm_activate(hdl_MODEM);
  642. if (rc) {
  643. IPA_UT_ERR("fail to no-block activate - rc = %d\n", rc);
  644. IPA_UT_TEST_FAIL_REPORT("no-block-activate failed");
  645. return -EFAULT;
  646. }
  647. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  648. if (vote != 3) {
  649. IPA_UT_ERR("clock vote is at %d\n", vote);
  650. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  651. return -EINVAL;
  652. }
  653. rc = ipa_pm_deferred_deactivate(hdl_USB);
  654. if (rc) {
  655. IPA_UT_ERR("fail to deffered deactivate client 1 - rc = %d\n",
  656. rc);
  657. IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
  658. return -EFAULT;
  659. }
  660. rc = ipa_pm_deferred_deactivate(hdl_WLAN);
  661. if (rc) {
  662. IPA_UT_ERR("fail to deffered deactivate client 2 - rc = %d\n",
  663. rc);
  664. IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
  665. return -EFAULT;
  666. }
  667. rc = ipa_pm_deactivate_all_deferred();
  668. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  669. if (vote != 1) {
  670. IPA_UT_ERR("clock vote is at %d\n", vote);
  671. IPA_UT_TEST_FAIL_REPORT("deactivate_all_deferred failed");
  672. return -EINVAL;
  673. }
  674. msleep(2000);
  675. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  676. if (vote != 1) {
  677. IPA_UT_ERR("clock vote is at %d\n", vote);
  678. IPA_UT_TEST_FAIL_REPORT("clock vote went below 1");
  679. return -EINVAL;
  680. }
  681. rc = clean_up(3, hdl_USB, hdl_WLAN, hdl_MODEM);
  682. return rc;
  683. }
  684. /* test 5 */
  685. static int ipa_pm_ut_deactivate_after_activate(void *priv)
  686. {
  687. int rc = 0;
  688. int hdl, vote;
  689. struct callback_param user_data;
  690. struct ipa_pm_init_params init_params = {
  691. .threshold_size = 2,
  692. .default_threshold = {600, 1000}
  693. };
  694. struct ipa_pm_register_params USB_params = {
  695. .name = "USB",
  696. .group = IPA_PM_GROUP_DEFAULT,
  697. .skip_clk_vote = 0,
  698. .callback = ipa_pm_call_back,
  699. .user_data = &user_data
  700. };
  701. rc = ipa_pm_init(&init_params);
  702. if (rc) {
  703. IPA_UT_ERR("Fail to init ipa_pm - rce %d\n", rc);
  704. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  705. return -EFAULT;
  706. }
  707. init_completion(&user_data.complete);
  708. rc = ipa_pm_register(&USB_params, &hdl);
  709. if (rc) {
  710. IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
  711. IPA_UT_TEST_FAIL_REPORT("fail to register");
  712. return -EFAULT;
  713. }
  714. rc = ipa_pm_activate(hdl);
  715. if (rc != -EINPROGRESS) {
  716. IPA_UT_ERR("fail to queue work for client rc = %d\n", rc);
  717. IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
  718. return -EFAULT;
  719. }
  720. rc = ipa_pm_deferred_deactivate(hdl);
  721. if (rc) {
  722. IPA_UT_ERR("fail to deffered deactivate client - rc = %d\n",
  723. rc);
  724. IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
  725. return -EFAULT;
  726. }
  727. msleep(2000);
  728. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  729. if (vote) {
  730. IPA_UT_ERR("clock vote is at %d\n", vote);
  731. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  732. return -EINVAL;
  733. }
  734. rc = ipa_pm_activate(hdl);
  735. if (rc != -EINPROGRESS) {
  736. IPA_UT_ERR("fail to queue work for client rc = %d\n", rc);
  737. IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
  738. return -EFAULT;
  739. }
  740. rc = ipa_pm_deactivate_sync(hdl);
  741. if (rc) {
  742. IPA_UT_ERR("fail to deactivate sync client - rc = %d\n", rc);
  743. IPA_UT_TEST_FAIL_REPORT("deactivate sync fail");
  744. return -EFAULT;
  745. }
  746. msleep(2000);
  747. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  748. if (vote) {
  749. IPA_UT_ERR("clock vote is at %d\n", vote);
  750. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  751. return -EINVAL;
  752. }
  753. rc = clean_up(1, hdl);
  754. return rc;
  755. }
  756. /* test 6 */
  757. static int ipa_pm_ut_atomic_activate(void *priv)
  758. {
  759. int rc = 0;
  760. int hdl, vote;
  761. struct callback_param user_data;
  762. spinlock_t lock;
  763. unsigned long flags;
  764. struct ipa_pm_init_params init_params = {
  765. .threshold_size = 2,
  766. .default_threshold = {600, 1000}
  767. };
  768. struct ipa_pm_register_params register_params = {
  769. .name = "USB",
  770. .group = IPA_PM_GROUP_DEFAULT,
  771. .skip_clk_vote = 0,
  772. .callback = ipa_pm_call_back,
  773. .user_data = &user_data
  774. };
  775. user_data.evt = IPA_PM_CB_EVENT_MAX;
  776. spin_lock_init(&lock);
  777. rc = ipa_pm_init(&init_params);
  778. if (rc) {
  779. IPA_UT_ERR("Fail to init ipa_pm rc = %d\n", rc);
  780. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  781. return -EFAULT;
  782. }
  783. init_completion(&user_data.complete);
  784. rc = ipa_pm_register(&register_params, &hdl);
  785. if (rc) {
  786. IPA_UT_ERR("fail to register client rc = %d\n", rc);
  787. IPA_UT_TEST_FAIL_REPORT("fail to register");
  788. return -EFAULT;
  789. }
  790. spin_lock_irqsave(&lock, flags);
  791. rc = ipa_pm_activate(hdl);
  792. if (rc != -EINPROGRESS) {
  793. IPA_UT_ERR("fail to queue work - rc = %d\n", rc);
  794. IPA_UT_TEST_FAIL_REPORT("queue activate work failed");
  795. spin_unlock_irqrestore(&lock, flags);
  796. return -EFAULT;
  797. }
  798. spin_unlock_irqrestore(&lock, flags);
  799. if (!wait_for_completion_timeout(&user_data.complete,
  800. msecs_to_jiffies(2000))) {
  801. IPA_UT_ERR("timeout waiting for activate_callback\n");
  802. IPA_UT_TEST_FAIL_REPORT("activate callback not called");
  803. return -ETIME;
  804. }
  805. if (user_data.evt != IPA_PM_CLIENT_ACTIVATED) {
  806. IPA_UT_ERR("Callback = %d\n", user_data.evt);
  807. IPA_UT_TEST_FAIL_REPORT("wrong callback called");
  808. return -EFAULT;
  809. }
  810. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  811. if (vote != 1) {
  812. IPA_UT_ERR("clock vote is at %d\n", vote);
  813. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  814. return -EINVAL;
  815. }
  816. rc = clean_up(1, hdl);
  817. return rc;
  818. }
  819. /* test 7 */
  820. static int ipa_pm_ut_deactivate_loop(void *priv)
  821. {
  822. int rc = 0;
  823. int i, hdl_USB, hdl_WLAN, vote;
  824. struct ipa_pm_init_params init_params = {
  825. .threshold_size = 2,
  826. .default_threshold = {600, 1000}
  827. };
  828. struct ipa_pm_register_params USB_params = {
  829. .name = "USB",
  830. .group = IPA_PM_GROUP_DEFAULT,
  831. .skip_clk_vote = 0,
  832. .callback = ipa_pm_call_back,
  833. };
  834. struct ipa_pm_register_params WLAN_params = {
  835. .name = "WLAN",
  836. .group = IPA_PM_GROUP_DEFAULT,
  837. .skip_clk_vote = 0,
  838. .callback = ipa_pm_call_back,
  839. };
  840. rc = ipa_pm_init(&init_params);
  841. if (rc) {
  842. IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
  843. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  844. return -EFAULT;
  845. }
  846. rc = ipa_pm_register(&USB_params, &hdl_USB);
  847. if (rc) {
  848. IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
  849. IPA_UT_TEST_FAIL_REPORT("fail to register");
  850. return -EFAULT;
  851. }
  852. rc = ipa_pm_set_throughput(hdl_USB, 1200);
  853. if (rc) {
  854. IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
  855. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  856. return -EFAULT;
  857. }
  858. rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
  859. if (rc) {
  860. IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
  861. IPA_UT_TEST_FAIL_REPORT("fail to register");
  862. return -EFAULT;
  863. }
  864. rc = ipa_pm_set_throughput(hdl_WLAN, 800);
  865. if (rc) {
  866. IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
  867. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  868. return -EFAULT;
  869. }
  870. rc = ipa_pm_activate_sync(hdl_USB);
  871. if (rc) {
  872. IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
  873. IPA_UT_TEST_FAIL_REPORT("activate sync failed");
  874. return -EFAULT;
  875. }
  876. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  877. if (vote != 1) {
  878. IPA_UT_ERR("clock vote is at %d\n", vote);
  879. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  880. return -EINVAL;
  881. }
  882. rc = ipa_pm_activate(hdl_WLAN);
  883. if (rc) {
  884. IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
  885. rc);
  886. IPA_UT_TEST_FAIL_REPORT("activate no block failed");
  887. return -EFAULT;
  888. }
  889. msleep(2000);
  890. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  891. if (vote != 2) {
  892. IPA_UT_ERR("clock vote is at %d\n", vote);
  893. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  894. return -EINVAL;
  895. }
  896. rc = ipa_pm_deferred_deactivate(hdl_WLAN);
  897. if (rc) {
  898. IPA_UT_ERR("fail to deffered deactivate client 2 - rc = %d\n",
  899. rc);
  900. IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
  901. return -EFAULT;
  902. }
  903. for (i = 0; i < 50; i++) {
  904. IPA_UT_DBG("Loop iteration #%d\n", i);
  905. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  906. if (vote != 2) {
  907. IPA_UT_ERR("clock vote is at %d\n", vote);
  908. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  909. return -EINVAL;
  910. }
  911. rc = ipa_pm_activate(hdl_WLAN);
  912. if (rc) {
  913. IPA_UT_ERR("fail to undo deactivate for client 2");
  914. IPA_UT_ERR(" - rc = %d\n", rc);
  915. IPA_UT_TEST_FAIL_REPORT("undo deactivate failed");
  916. return -EFAULT;
  917. }
  918. rc = ipa_pm_deferred_deactivate(hdl_WLAN);
  919. if (rc) {
  920. IPA_UT_ERR("fail to deffered deactivate client");
  921. IPA_UT_ERR(" - rc = %d\n", rc);
  922. IPA_UT_TEST_FAIL_REPORT("deffered deactivate fail");
  923. return -EFAULT;
  924. }
  925. }
  926. msleep(2000);
  927. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  928. if (vote != 1) {
  929. IPA_UT_ERR("clock vote is at %d\n", vote);
  930. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  931. return -EINVAL;
  932. }
  933. rc = clean_up(2, hdl_USB, hdl_WLAN);
  934. return rc;
  935. }
  936. /*test 8*/
  937. static int ipa_pm_ut_set_perf_profile(void *priv)
  938. {
  939. int rc = 0;
  940. int hdl_USB, hdl_WLAN, vote, idx;
  941. struct ipa_pm_init_params init_params = {
  942. .threshold_size = 2,
  943. .default_threshold = {600, 1000}
  944. };
  945. struct ipa_pm_register_params USB_params = {
  946. .name = "USB",
  947. .group = IPA_PM_GROUP_DEFAULT,
  948. .skip_clk_vote = 0,
  949. .callback = ipa_pm_call_back,
  950. };
  951. struct ipa_pm_register_params WLAN_params = {
  952. .name = "WLAN",
  953. .group = IPA_PM_GROUP_DEFAULT,
  954. .skip_clk_vote = 0,
  955. .callback = ipa_pm_call_back,
  956. };
  957. rc = ipa_pm_init(&init_params);
  958. if (rc) {
  959. IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
  960. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  961. return -EFAULT;
  962. }
  963. rc = ipa_pm_register(&USB_params, &hdl_USB);
  964. if (rc) {
  965. IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
  966. IPA_UT_TEST_FAIL_REPORT("fail to register");
  967. return -EFAULT;
  968. }
  969. rc = ipa_pm_set_throughput(hdl_USB, 1200);
  970. if (rc) {
  971. IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
  972. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  973. return -EFAULT;
  974. }
  975. rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
  976. if (rc) {
  977. IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
  978. IPA_UT_TEST_FAIL_REPORT("fail to register");
  979. return -EFAULT;
  980. }
  981. rc = ipa_pm_set_throughput(hdl_WLAN, 800);
  982. if (rc) {
  983. IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
  984. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  985. return -EFAULT;
  986. }
  987. rc = ipa_pm_activate_sync(hdl_USB);
  988. if (rc) {
  989. IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
  990. IPA_UT_TEST_FAIL_REPORT("activate sync failed");
  991. return -EFAULT;
  992. }
  993. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  994. if (idx != 1) {
  995. IPA_UT_ERR("clock plan is at %d\n", idx);
  996. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  997. return -EINVAL;
  998. }
  999. rc = ipa_pm_activate(hdl_WLAN);
  1000. if (rc) {
  1001. IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
  1002. rc);
  1003. IPA_UT_TEST_FAIL_REPORT("activate no block failed");
  1004. return -EFAULT;
  1005. }
  1006. msleep(2000);
  1007. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1008. if (idx != 2) {
  1009. IPA_UT_ERR("clock plan is at %d\n", idx);
  1010. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1011. return -EINVAL;
  1012. }
  1013. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1014. if (vote != 2) {
  1015. IPA_UT_ERR("clock vote is at %d\n", vote);
  1016. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1017. return -EINVAL;
  1018. }
  1019. rc = ipa_pm_set_throughput(hdl_WLAN, 1200);
  1020. if (rc) {
  1021. IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
  1022. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1023. return -EFAULT;
  1024. }
  1025. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1026. if (idx != 3) {
  1027. IPA_UT_ERR("clock plan is at %d\n", idx);
  1028. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1029. return -EINVAL;
  1030. }
  1031. rc = clean_up(2, hdl_USB, hdl_WLAN);
  1032. return rc;
  1033. }
  1034. /*test 9*/
  1035. static int ipa_pm_ut_group_tput(void *priv)
  1036. {
  1037. int rc = 0;
  1038. int hdl_USB, hdl_WLAN, hdl_MODEM, vote, idx;
  1039. struct ipa_pm_init_params init_params = {
  1040. .threshold_size = 2,
  1041. .default_threshold = {600, 1000}
  1042. };
  1043. struct ipa_pm_register_params USB_params = {
  1044. .name = "USB",
  1045. .group = IPA_PM_GROUP_APPS,
  1046. .skip_clk_vote = 0,
  1047. .callback = ipa_pm_call_back,
  1048. };
  1049. struct ipa_pm_register_params WLAN_params = {
  1050. .name = "WLAN",
  1051. .group = IPA_PM_GROUP_APPS,
  1052. .skip_clk_vote = 0,
  1053. .callback = ipa_pm_call_back,
  1054. };
  1055. struct ipa_pm_register_params MODEM_params = {
  1056. .name = "MODEM",
  1057. .group = IPA_PM_GROUP_DEFAULT,
  1058. .skip_clk_vote = 0,
  1059. .callback = ipa_pm_call_back,
  1060. };
  1061. rc = ipa_pm_init(&init_params);
  1062. if (rc) {
  1063. IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
  1064. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  1065. return -EFAULT;
  1066. }
  1067. rc = ipa_pm_register(&USB_params, &hdl_USB);
  1068. if (rc) {
  1069. IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
  1070. IPA_UT_TEST_FAIL_REPORT("fail to register");
  1071. return -EFAULT;
  1072. }
  1073. rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
  1074. if (rc) {
  1075. IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
  1076. IPA_UT_TEST_FAIL_REPORT("fail to register");
  1077. return -EFAULT;
  1078. }
  1079. rc = ipa_pm_set_throughput(hdl_USB, 500);
  1080. if (rc) {
  1081. IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
  1082. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1083. return -EFAULT;
  1084. }
  1085. rc = ipa_pm_set_throughput(hdl_WLAN, 800);
  1086. if (rc) {
  1087. IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
  1088. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1089. return -EFAULT;
  1090. }
  1091. rc = ipa_pm_activate_sync(hdl_USB);
  1092. if (rc) {
  1093. IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
  1094. IPA_UT_TEST_FAIL_REPORT("activate sync failed");
  1095. return -EFAULT;
  1096. }
  1097. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1098. if (idx != 1) {
  1099. IPA_UT_ERR("clock plan is at %d\n", idx);
  1100. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1101. return -EINVAL;
  1102. }
  1103. rc = ipa_pm_activate(hdl_WLAN);
  1104. if (rc) {
  1105. IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
  1106. rc);
  1107. IPA_UT_TEST_FAIL_REPORT("activate no block failed");
  1108. return -EFAULT;
  1109. }
  1110. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1111. if (vote != 2) {
  1112. IPA_UT_ERR("clock vote is at %d\n", vote);
  1113. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1114. return -EINVAL;
  1115. }
  1116. msleep(2000);
  1117. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1118. if (idx != 1) {
  1119. IPA_UT_ERR("clock plan is at %d\n", idx);
  1120. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1121. return -EINVAL;
  1122. }
  1123. rc = ipa_pm_register(&MODEM_params, &hdl_MODEM);
  1124. if (rc) {
  1125. IPA_UT_ERR("fail to register client 3 rc = %d\n", rc);
  1126. IPA_UT_TEST_FAIL_REPORT("fail to register");
  1127. return -EFAULT;
  1128. }
  1129. rc = ipa_pm_set_throughput(hdl_MODEM, 1000);
  1130. if (rc) {
  1131. IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
  1132. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1133. return -EFAULT;
  1134. }
  1135. rc = ipa_pm_activate(hdl_MODEM);
  1136. if (rc) {
  1137. IPA_UT_ERR("fail to activate no block for client 3 - rc = %d\n",
  1138. rc);
  1139. IPA_UT_TEST_FAIL_REPORT("activate no block failed");
  1140. return -EFAULT;
  1141. }
  1142. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1143. if (vote != 3) {
  1144. IPA_UT_ERR("clock vote is at %d\n", vote);
  1145. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1146. return -EINVAL;
  1147. }
  1148. msleep(2000);
  1149. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1150. if (idx != 2) {
  1151. IPA_UT_ERR("clock plan is at %d\n", idx);
  1152. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1153. return -EINVAL;
  1154. }
  1155. rc = ipa_pm_deactivate_sync(hdl_WLAN);
  1156. if (rc) {
  1157. IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
  1158. IPA_UT_TEST_FAIL_REPORT("deactivate failed");
  1159. return -EFAULT;
  1160. }
  1161. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1162. if (vote != 2) {
  1163. IPA_UT_ERR("clock vote is at %d\n", vote);
  1164. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1165. return -EINVAL;
  1166. }
  1167. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1168. if (idx != 2) {
  1169. IPA_UT_ERR("clock plan is at %d\n", idx);
  1170. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1171. return -EINVAL;
  1172. }
  1173. rc = clean_up(3, hdl_USB, hdl_WLAN, hdl_MODEM);
  1174. return rc;
  1175. }
  1176. /*test 10*/
  1177. static int ipa_pm_ut_skip_clk_vote_tput(void *priv)
  1178. {
  1179. int rc = 0;
  1180. int hdl_USB, hdl_WLAN, hdl_MODEM, vote, idx;
  1181. struct ipa_pm_init_params init_params = {
  1182. .threshold_size = 2,
  1183. .default_threshold = {600, 1000}
  1184. };
  1185. struct ipa_pm_register_params USB_params = {
  1186. .name = "USB",
  1187. .group = IPA_PM_GROUP_DEFAULT,
  1188. .skip_clk_vote = 0,
  1189. .callback = ipa_pm_call_back,
  1190. };
  1191. struct ipa_pm_register_params WLAN_params = {
  1192. .name = "WLAN",
  1193. .group = IPA_PM_GROUP_MODEM,
  1194. .skip_clk_vote = 1,
  1195. .callback = ipa_pm_call_back,
  1196. };
  1197. struct ipa_pm_register_params MODEM_params = {
  1198. .name = "MODEM",
  1199. .group = IPA_PM_GROUP_MODEM,
  1200. .skip_clk_vote = 1,
  1201. .callback = ipa_pm_call_back,
  1202. };
  1203. rc = ipa_pm_init(&init_params);
  1204. if (rc) {
  1205. IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
  1206. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  1207. return -EFAULT;
  1208. }
  1209. rc = ipa_pm_register(&USB_params, &hdl_USB);
  1210. if (rc) {
  1211. IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
  1212. IPA_UT_TEST_FAIL_REPORT("fail to register");
  1213. return -EFAULT;
  1214. }
  1215. rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
  1216. if (rc) {
  1217. IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
  1218. IPA_UT_TEST_FAIL_REPORT("fail to register");
  1219. return -EFAULT;
  1220. }
  1221. rc = ipa_pm_set_throughput(hdl_USB, 1200);
  1222. if (rc) {
  1223. IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
  1224. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1225. return -EFAULT;
  1226. }
  1227. rc = ipa_pm_set_throughput(hdl_WLAN, 800);
  1228. if (rc) {
  1229. IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
  1230. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1231. return -EFAULT;
  1232. }
  1233. rc = ipa_pm_activate_sync(hdl_USB);
  1234. if (rc) {
  1235. IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
  1236. IPA_UT_TEST_FAIL_REPORT("activate sync failed");
  1237. return -EFAULT;
  1238. }
  1239. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1240. if (idx != 1) {
  1241. IPA_UT_ERR("clock plan is at %d\n", idx);
  1242. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1243. return -EINVAL;
  1244. }
  1245. rc = ipa_pm_activate(hdl_WLAN);
  1246. if (rc) {
  1247. IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
  1248. rc);
  1249. IPA_UT_TEST_FAIL_REPORT("activate no block failed");
  1250. return -EFAULT;
  1251. }
  1252. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1253. if (vote != 1) {
  1254. IPA_UT_ERR("clock vote is at %d\n", vote);
  1255. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1256. return -EINVAL;
  1257. }
  1258. msleep(2000);
  1259. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1260. if (idx != 2) {
  1261. IPA_UT_ERR("clock plan is at %d\n", idx);
  1262. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1263. return -EINVAL;
  1264. }
  1265. rc = ipa_pm_register(&MODEM_params, &hdl_MODEM);
  1266. if (rc) {
  1267. IPA_UT_ERR("fail to register client 3 rc = %d\n", rc);
  1268. IPA_UT_TEST_FAIL_REPORT("fail to register");
  1269. return -EFAULT;
  1270. }
  1271. rc = ipa_pm_set_throughput(hdl_MODEM, 2000);
  1272. if (rc) {
  1273. IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
  1274. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1275. return -EFAULT;
  1276. }
  1277. rc = ipa_pm_activate(hdl_MODEM);
  1278. if (rc) {
  1279. IPA_UT_ERR("fail to activate no block for client 3 - rc = %d\n",
  1280. rc);
  1281. IPA_UT_TEST_FAIL_REPORT("activate no block failed");
  1282. return -EFAULT;
  1283. }
  1284. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1285. if (vote != 1) {
  1286. IPA_UT_ERR("clock vote is at %d\n", vote);
  1287. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1288. return -EINVAL;
  1289. }
  1290. msleep(2000);
  1291. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1292. if (idx != 3) {
  1293. IPA_UT_ERR("clock plan is at %d\n", idx);
  1294. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1295. return -EINVAL;
  1296. }
  1297. rc = ipa_pm_deactivate_sync(hdl_USB);
  1298. if (rc) {
  1299. IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
  1300. IPA_UT_TEST_FAIL_REPORT("deactivate failed");
  1301. return -EFAULT;
  1302. }
  1303. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1304. if (vote != 0) {
  1305. IPA_UT_ERR("clock vote is at %d\n", vote);
  1306. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1307. return -EINVAL;
  1308. }
  1309. rc = clean_up(3, hdl_USB, hdl_WLAN, hdl_MODEM);
  1310. return rc;
  1311. }
  1312. /* Test 11 */
  1313. static int ipa_pm_ut_simple_exception(void *priv)
  1314. {
  1315. int rc = 0;
  1316. int hdl_USB, hdl_WLAN, hdl_MODEM, vote, idx;
  1317. struct ipa_pm_exception exceptions = {
  1318. .usecase = "USB",
  1319. .threshold = {1000, 1800},
  1320. };
  1321. struct ipa_pm_init_params init_params = {
  1322. .threshold_size = 2,
  1323. .default_threshold = {600, 1000},
  1324. .exception_size = 1,
  1325. .exceptions[0] = exceptions,
  1326. };
  1327. struct ipa_pm_register_params USB_params = {
  1328. .name = "USB",
  1329. .group = IPA_PM_GROUP_DEFAULT,
  1330. .skip_clk_vote = 0,
  1331. .callback = ipa_pm_call_back,
  1332. };
  1333. struct ipa_pm_register_params WLAN_params = {
  1334. .name = "WLAN",
  1335. .group = IPA_PM_GROUP_DEFAULT,
  1336. .skip_clk_vote = 0,
  1337. .callback = ipa_pm_call_back,
  1338. };
  1339. struct ipa_pm_register_params MODEM_params = {
  1340. .name = "MODEM",
  1341. .group = IPA_PM_GROUP_DEFAULT,
  1342. .skip_clk_vote = 0,
  1343. .callback = ipa_pm_call_back,
  1344. };
  1345. rc = ipa_pm_init(&init_params);
  1346. if (rc) {
  1347. IPA_UT_ERR("Fail to init ipa_pm - rc = %d\n", rc);
  1348. IPA_UT_TEST_FAIL_REPORT("fail to init params");
  1349. return -EFAULT;
  1350. }
  1351. rc = ipa_pm_register(&USB_params, &hdl_USB);
  1352. if (rc) {
  1353. IPA_UT_ERR("fail to register client 1 rc = %d\n", rc);
  1354. IPA_UT_TEST_FAIL_REPORT("fail to register");
  1355. return -EFAULT;
  1356. }
  1357. rc = ipa_pm_register(&WLAN_params, &hdl_WLAN);
  1358. if (rc) {
  1359. IPA_UT_ERR("fail to register client 2 rc = %d\n", rc);
  1360. IPA_UT_TEST_FAIL_REPORT("fail to register");
  1361. return -EFAULT;
  1362. }
  1363. rc = ipa_pm_set_throughput(hdl_USB, 1200);
  1364. if (rc) {
  1365. IPA_UT_ERR("fail to set tput for client 1 rc = %d\n", rc);
  1366. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1367. return -EFAULT;
  1368. }
  1369. rc = ipa_pm_set_throughput(hdl_WLAN, 2000);
  1370. if (rc) {
  1371. IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
  1372. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1373. return -EFAULT;
  1374. }
  1375. rc = ipa_pm_activate_sync(hdl_USB);
  1376. if (rc) {
  1377. IPA_UT_ERR("fail to activate sync for client 1- rc = %d\n", rc);
  1378. IPA_UT_TEST_FAIL_REPORT("activate sync failed");
  1379. return -EFAULT;
  1380. }
  1381. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1382. if (idx != 1) {
  1383. IPA_UT_ERR("clock plan is at %d\n", idx);
  1384. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1385. return -EINVAL;
  1386. }
  1387. rc = ipa_pm_activate(hdl_WLAN);
  1388. if (rc) {
  1389. IPA_UT_ERR("fail to activate no block for client 2 - rc = %d\n",
  1390. rc);
  1391. IPA_UT_TEST_FAIL_REPORT("activate no block failed");
  1392. return -EFAULT;
  1393. }
  1394. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1395. if (vote != 2) {
  1396. IPA_UT_ERR("clock vote is at %d\n", vote);
  1397. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1398. return -EINVAL;
  1399. }
  1400. msleep(2000);
  1401. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1402. if (idx != 2) {
  1403. IPA_UT_ERR("clock plan is at %d\n", idx);
  1404. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1405. return -EINVAL;
  1406. }
  1407. rc = ipa_pm_register(&MODEM_params, &hdl_MODEM);
  1408. if (rc) {
  1409. IPA_UT_ERR("fail to register client 3 rc = %d\n", rc);
  1410. IPA_UT_TEST_FAIL_REPORT("fail to register");
  1411. return -EFAULT;
  1412. }
  1413. rc = ipa_pm_set_throughput(hdl_MODEM, 800);
  1414. if (rc) {
  1415. IPA_UT_ERR("fail to set tput for client 2 rc = %d\n", rc);
  1416. IPA_UT_TEST_FAIL_REPORT("fail to set perf profile");
  1417. return -EFAULT;
  1418. }
  1419. rc = ipa_pm_activate(hdl_MODEM);
  1420. if (rc) {
  1421. IPA_UT_ERR("fail to activate no block for client 3 - rc = %d\n",
  1422. rc);
  1423. IPA_UT_TEST_FAIL_REPORT("activate no block failed");
  1424. return -EFAULT;
  1425. }
  1426. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1427. if (vote != 3) {
  1428. IPA_UT_ERR("clock vote is at %d\n", vote);
  1429. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1430. return -EINVAL;
  1431. }
  1432. msleep(2000);
  1433. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1434. if (idx != 3) {
  1435. IPA_UT_ERR("clock plan is at %d\n", idx);
  1436. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1437. return -EINVAL;
  1438. }
  1439. rc = ipa_pm_deactivate_sync(hdl_USB);
  1440. if (rc) {
  1441. IPA_UT_ERR("fail to deactivate client - rc = %d\n", rc);
  1442. IPA_UT_TEST_FAIL_REPORT("deactivate failed");
  1443. return -EFAULT;
  1444. }
  1445. vote = atomic_read(&ipa3_ctx->ipa3_active_clients.cnt);
  1446. if (vote != 2) {
  1447. IPA_UT_ERR("clock vote is at %d\n", vote);
  1448. IPA_UT_TEST_FAIL_REPORT("wrong clock vote");
  1449. return -EINVAL;
  1450. }
  1451. idx = ipa3_ctx->ipa3_active_clients.bus_vote_idx;
  1452. if (idx != 2) {
  1453. IPA_UT_ERR("clock plan is at %d\n", idx);
  1454. IPA_UT_TEST_FAIL_REPORT("wrong clock plan");
  1455. return -EINVAL;
  1456. }
  1457. rc = clean_up(3, hdl_USB, hdl_WLAN, hdl_MODEM);
  1458. return rc;
  1459. }
  1460. /* Suite definition block */
  1461. IPA_UT_DEFINE_SUITE_START(pm, "PM for IPA",
  1462. ipa_pm_ut_setup, ipa_pm_ut_teardown)
  1463. {
  1464. IPA_UT_ADD_TEST(single_registration,
  1465. "Single Registration/Basic Functions",
  1466. ipa_pm_ut_single_registration,
  1467. true, IPA_HW_v4_0, IPA_HW_MAX),
  1468. IPA_UT_ADD_TEST(double_register_activate,
  1469. "double register/activate",
  1470. ipa_pm_ut_double_register_activate,
  1471. true, IPA_HW_v4_0, IPA_HW_MAX),
  1472. IPA_UT_ADD_TEST(deferred_deactivate,
  1473. "Deferred_deactivate",
  1474. ipa_pm_ut_deferred_deactivate,
  1475. true, IPA_HW_v4_0, IPA_HW_MAX),
  1476. IPA_UT_ADD_TEST(two_clients_activate,
  1477. "Activate two clients",
  1478. ipa_pm_ut_two_clients_activate,
  1479. true, IPA_HW_v4_0, IPA_HW_MAX),
  1480. IPA_UT_ADD_TEST(deactivate_all_deferred,
  1481. "Deactivate all deferred",
  1482. ipa_pm_ut_deactivate_all_deferred,
  1483. true, IPA_HW_v4_0, IPA_HW_MAX),
  1484. IPA_UT_ADD_TEST(deactivate_after_activate,
  1485. "Deactivate after activate",
  1486. ipa_pm_ut_deactivate_after_activate,
  1487. true, IPA_HW_v4_0, IPA_HW_MAX),
  1488. IPA_UT_ADD_TEST(atomic_activate,
  1489. "Atomic activate",
  1490. ipa_pm_ut_atomic_activate,
  1491. true, IPA_HW_v4_0, IPA_HW_MAX),
  1492. IPA_UT_ADD_TEST(deactivate_loop,
  1493. "Deactivate Loop",
  1494. ipa_pm_ut_deactivate_loop,
  1495. true, IPA_HW_v4_0, IPA_HW_MAX),
  1496. IPA_UT_ADD_TEST(set_perf_profile,
  1497. "Set perf profile",
  1498. ipa_pm_ut_set_perf_profile,
  1499. true, IPA_HW_v4_0, IPA_HW_MAX),
  1500. IPA_UT_ADD_TEST(group_tput,
  1501. "Group throughputs",
  1502. ipa_pm_ut_group_tput,
  1503. true, IPA_HW_v4_0, IPA_HW_MAX),
  1504. IPA_UT_ADD_TEST(skip_clk_vote_tput,
  1505. "Skip clock vote and tput",
  1506. ipa_pm_ut_skip_clk_vote_tput,
  1507. true, IPA_HW_v4_0, IPA_HW_MAX),
  1508. IPA_UT_ADD_TEST(simple_exception,
  1509. "throughput while passing simple exception",
  1510. ipa_pm_ut_simple_exception,
  1511. true, IPA_HW_v4_0, IPA_HW_MAX),
  1512. } IPA_UT_DEFINE_SUITE_END(pm);