msm_vidc_debug.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #define CREATE_TRACE_POINTS
  6. #include "msm_vidc_debug.h"
  7. #include "msm_vidc_driver.h"
  8. #include "msm_vidc_dt.h"
  9. #include "msm_vidc.h"
  10. #include "msm_vidc_core.h"
  11. #include "msm_vidc_inst.h"
  12. #include "msm_vidc_internal.h"
  13. #include "msm_vidc_events.h"
  14. extern struct msm_vidc_core *g_core;
  15. #define MAX_SSR_STRING_LEN 64
  16. #define MAX_DEBUG_LEVEL_STRING_LEN 15
  17. #define MSM_VIDC_MIN_STATS_DELAY_MS 200
  18. #define MSM_VIDC_MAX_STATS_DELAY_MS 10000
  19. unsigned int msm_vidc_debug = VIDC_ERR | VIDC_PRINTK | FW_ERROR | FW_FATAL | FW_PRINTK;
  20. static int debug_level_set(const char *val,
  21. const struct kernel_param *kp)
  22. {
  23. struct msm_vidc_core *core = NULL;
  24. unsigned int dvalue;
  25. int ret;
  26. if (!kp || !kp->arg || !val) {
  27. d_vpr_e("%s: Invalid params\n", __func__);
  28. return -EINVAL;
  29. }
  30. core = *(struct msm_vidc_core **)kp->arg;
  31. if (!core || !core->capabilities) {
  32. d_vpr_e("%s: Invalid core/capabilities\n", __func__);
  33. return -EINVAL;
  34. }
  35. ret = kstrtouint(val, 0, &dvalue);
  36. if (ret)
  37. return ret;
  38. msm_vidc_debug = dvalue;
  39. /* check only driver logmask */
  40. if ((dvalue & 0xFF) > (VIDC_ERR | VIDC_HIGH)) {
  41. core->capabilities[HW_RESPONSE_TIMEOUT].value = 2 * HW_RESPONSE_TIMEOUT_VALUE;
  42. core->capabilities[SW_PC_DELAY].value = 2 * SW_PC_DELAY_VALUE;
  43. core->capabilities[FW_UNLOAD_DELAY].value = 2 * FW_UNLOAD_DELAY_VALUE;
  44. } else {
  45. /* reset timeout values, if user reduces the logging */
  46. core->capabilities[HW_RESPONSE_TIMEOUT].value = HW_RESPONSE_TIMEOUT_VALUE;
  47. core->capabilities[SW_PC_DELAY].value = SW_PC_DELAY_VALUE;
  48. core->capabilities[FW_UNLOAD_DELAY].value = FW_UNLOAD_DELAY_VALUE;
  49. }
  50. d_vpr_h("timeout updated: hw_response %u, sw_pc %u, fw_unload %u, debug_level %#x\n",
  51. core->capabilities[HW_RESPONSE_TIMEOUT].value,
  52. core->capabilities[SW_PC_DELAY].value,
  53. core->capabilities[FW_UNLOAD_DELAY].value,
  54. msm_vidc_debug);
  55. return 0;
  56. }
  57. static int debug_level_get(char *buffer, const struct kernel_param *kp)
  58. {
  59. return scnprintf(buffer, PAGE_SIZE, "%#x", msm_vidc_debug);
  60. }
  61. static const struct kernel_param_ops msm_vidc_debug_fops = {
  62. .set = debug_level_set,
  63. .get = debug_level_get,
  64. };
  65. module_param_cb(msm_vidc_debug, &msm_vidc_debug_fops, &g_core, 0644);
  66. bool msm_vidc_lossless_encode = !true;
  67. EXPORT_SYMBOL(msm_vidc_lossless_encode);
  68. bool msm_vidc_syscache_disable = !true;
  69. EXPORT_SYMBOL(msm_vidc_syscache_disable);
  70. int msm_vidc_clock_voting = !1;
  71. int msm_vidc_ddr_bw = !1;
  72. int msm_vidc_llc_bw = !1;
  73. bool msm_vidc_fw_dump = !true;
  74. EXPORT_SYMBOL(msm_vidc_fw_dump);
  75. unsigned int msm_vidc_enable_bugon = !1;
  76. EXPORT_SYMBOL(msm_vidc_enable_bugon);
  77. #define MAX_DBG_BUF_SIZE 4096
  78. struct core_inst_pair {
  79. struct msm_vidc_core *core;
  80. struct msm_vidc_inst *inst;
  81. };
  82. /* debug fs support */
  83. static inline void tic(struct msm_vidc_inst *i, enum profiling_points p,
  84. char *b)
  85. {
  86. if (!i->debug.pdata[p].name[0])
  87. memcpy(i->debug.pdata[p].name, b, 64);
  88. if (i->debug.pdata[p].sampling) {
  89. i->debug.pdata[p].start = ktime_get_ns() / 1000 / 1000;
  90. i->debug.pdata[p].sampling = false;
  91. }
  92. }
  93. static inline void toc(struct msm_vidc_inst *i, enum profiling_points p)
  94. {
  95. if (!i->debug.pdata[p].sampling) {
  96. i->debug.pdata[p].stop = ktime_get_ns() / 1000 / 1000;
  97. i->debug.pdata[p].cumulative += i->debug.pdata[p].stop -
  98. i->debug.pdata[p].start;
  99. i->debug.pdata[p].sampling = true;
  100. }
  101. }
  102. void msm_vidc_show_stats(void *inst)
  103. {
  104. int x;
  105. struct msm_vidc_inst *i = (struct msm_vidc_inst *) inst;
  106. if (!i) {
  107. d_vpr_e("%s: invalid params\n", __func__);
  108. return;
  109. }
  110. for (x = 0; x < MAX_PROFILING_POINTS; x++) {
  111. if (i->debug.pdata[x].name[0]) {
  112. if (i->debug.samples) {
  113. i_vpr_p(i, "%s averaged %d ms/sample\n",
  114. i->debug.pdata[x].name,
  115. i->debug.pdata[x].cumulative /
  116. i->debug.samples);
  117. }
  118. i_vpr_p(i, "%s Samples: %d\n",
  119. i->debug.pdata[x].name, i->debug.samples);
  120. }
  121. }
  122. }
  123. static u32 write_str(char *buffer,
  124. size_t size, const char *fmt, ...)
  125. {
  126. va_list args;
  127. u32 len;
  128. va_start(args, fmt);
  129. len = vscnprintf(buffer, size, fmt, args);
  130. va_end(args);
  131. return len;
  132. }
  133. static ssize_t core_info_read(struct file* file, char __user* buf,
  134. size_t count, loff_t* ppos)
  135. {
  136. struct msm_vidc_core *core = file->private_data;
  137. char* dbuf, * cur, * end;
  138. ssize_t len = 0;
  139. if (!core || !core->dt) {
  140. d_vpr_e("%s: invalid params %pK\n", __func__, core);
  141. return 0;
  142. }
  143. dbuf = kzalloc(MAX_DBG_BUF_SIZE, GFP_KERNEL);
  144. if (!dbuf) {
  145. d_vpr_e("%s: Allocation failed!\n", __func__);
  146. return -ENOMEM;
  147. }
  148. cur = dbuf;
  149. end = cur + MAX_DBG_BUF_SIZE;
  150. cur += write_str(cur, end - cur, "Core state: %d\n", core->state);
  151. cur += write_str(cur, end - cur,
  152. "FW version : %s\n", core->fw_version);
  153. cur += write_str(cur, end - cur,
  154. "register_base: 0x%x\n", core->dt->register_base);
  155. cur += write_str(cur, end - cur,
  156. "register_size: %u\n", core->dt->register_size);
  157. cur += write_str(cur, end - cur, "irq: %u\n", core->dt->irq);
  158. len = simple_read_from_buffer(buf, count, ppos,
  159. dbuf, cur - dbuf);
  160. kfree(dbuf);
  161. return len;
  162. }
  163. static const struct file_operations core_info_fops = {
  164. .open = simple_open,
  165. .read = core_info_read,
  166. };
  167. static ssize_t stats_delay_write_ms(struct file *filp, const char __user *buf,
  168. size_t count, loff_t *ppos)
  169. {
  170. int rc = 0;
  171. struct msm_vidc_core *core = filp->private_data;
  172. char kbuf[MAX_DEBUG_LEVEL_STRING_LEN] = {0};
  173. u32 delay_ms = 0;
  174. /* filter partial writes and invalid commands */
  175. if (*ppos != 0 || count >= sizeof(kbuf) || count == 0) {
  176. d_vpr_e("returning error - pos %d, count %d\n", *ppos, count);
  177. rc = -EINVAL;
  178. }
  179. rc = simple_write_to_buffer(kbuf, sizeof(kbuf) - 1, ppos, buf, count);
  180. if (rc < 0) {
  181. d_vpr_e("%s: User memory fault\n", __func__);
  182. rc = -EFAULT;
  183. goto exit;
  184. }
  185. rc = kstrtoint(kbuf, 0, &delay_ms);
  186. if (rc) {
  187. d_vpr_e("returning error err %d\n", rc);
  188. rc = -EINVAL;
  189. goto exit;
  190. }
  191. delay_ms = clamp_t(u32, delay_ms, MSM_VIDC_MIN_STATS_DELAY_MS, MSM_VIDC_MAX_STATS_DELAY_MS);
  192. core->capabilities[STATS_TIMEOUT_MS].value = delay_ms;
  193. d_vpr_h("Stats delay is updated to - %d ms\n", delay_ms);
  194. exit:
  195. return rc;
  196. }
  197. static ssize_t stats_delay_read_ms(struct file *file, char __user *buf,
  198. size_t count, loff_t *ppos)
  199. {
  200. size_t len;
  201. char kbuf[MAX_DEBUG_LEVEL_STRING_LEN];
  202. struct msm_vidc_core *core = file->private_data;
  203. len = scnprintf(kbuf, sizeof(kbuf), "%u\n", core->capabilities[STATS_TIMEOUT_MS].value);
  204. return simple_read_from_buffer(buf, count, ppos, kbuf, len);
  205. }
  206. static const struct file_operations stats_delay_fops = {
  207. .open = simple_open,
  208. .write = stats_delay_write_ms,
  209. .read = stats_delay_read_ms,
  210. };
  211. static ssize_t trigger_ssr_write(struct file* filp, const char __user* buf,
  212. size_t count, loff_t* ppos)
  213. {
  214. unsigned long ssr_trigger_val = 0;
  215. int rc = 0;
  216. struct msm_vidc_core* core = filp->private_data;
  217. size_t size = MAX_SSR_STRING_LEN;
  218. char kbuf[MAX_SSR_STRING_LEN + 1] = { 0 };
  219. if (!buf)
  220. return -EINVAL;
  221. if (!count)
  222. goto exit;
  223. if (count < size)
  224. size = count;
  225. if (copy_from_user(kbuf, buf, size)) {
  226. d_vpr_e("%s: User memory fault\n", __func__);
  227. rc = -EFAULT;
  228. goto exit;
  229. }
  230. rc = kstrtoul(kbuf, 0, &ssr_trigger_val);
  231. if (rc) {
  232. d_vpr_e("returning error err %d\n", rc);
  233. rc = -EINVAL;
  234. }
  235. else {
  236. msm_vidc_trigger_ssr(core, ssr_trigger_val);
  237. rc = count;
  238. }
  239. exit:
  240. return rc;
  241. }
  242. static const struct file_operations ssr_fops = {
  243. .open = simple_open,
  244. .write = trigger_ssr_write,
  245. };
  246. struct dentry* msm_vidc_debugfs_init_drv()
  247. {
  248. struct dentry *dir = NULL;
  249. dir = debugfs_create_dir("msm_vidc", NULL);
  250. if (IS_ERR_OR_NULL(dir)) {
  251. dir = NULL;
  252. goto failed_create_dir;
  253. }
  254. debugfs_create_u32("core_clock_voting", 0644, dir,
  255. &msm_vidc_clock_voting);
  256. debugfs_create_u32("ddr_bw_kbps", 0644, dir,
  257. &msm_vidc_ddr_bw);
  258. debugfs_create_u32("llc_bw_kbps", 0644, dir,
  259. &msm_vidc_llc_bw);
  260. debugfs_create_bool("disable_video_syscache", 0644, dir,
  261. &msm_vidc_syscache_disable);
  262. debugfs_create_bool("lossless_encoding", 0644, dir,
  263. &msm_vidc_lossless_encode);
  264. debugfs_create_bool("msm_vidc_fw_dump", 0644, dir,
  265. &msm_vidc_fw_dump);
  266. debugfs_create_u32("enable_bugon", 0644, dir,
  267. &msm_vidc_enable_bugon);
  268. return dir;
  269. failed_create_dir:
  270. if (dir)
  271. debugfs_remove_recursive(dir);
  272. return NULL;
  273. }
  274. struct dentry *msm_vidc_debugfs_init_core(void *core_in)
  275. {
  276. struct dentry *dir = NULL;
  277. char debugfs_name[MAX_DEBUGFS_NAME];
  278. struct msm_vidc_core *core = (struct msm_vidc_core *) core_in;
  279. struct dentry *parent;
  280. if (!core || !core->debugfs_parent) {
  281. d_vpr_e("%s: invalid params\n", __func__);
  282. goto failed_create_dir;
  283. }
  284. parent = core->debugfs_parent;
  285. snprintf(debugfs_name, MAX_DEBUGFS_NAME, "core");
  286. dir = debugfs_create_dir(debugfs_name, parent);
  287. if (IS_ERR_OR_NULL(dir)) {
  288. dir = NULL;
  289. d_vpr_e("Failed to create debugfs for msm_vidc\n");
  290. goto failed_create_dir;
  291. }
  292. if (!debugfs_create_file("info", 0444, dir, core, &core_info_fops)) {
  293. d_vpr_e("debugfs_create_file: fail\n");
  294. goto failed_create_dir;
  295. }
  296. if (!debugfs_create_file("trigger_ssr", 0200,
  297. dir, core, &ssr_fops)) {
  298. d_vpr_e("debugfs_create_file: fail\n");
  299. goto failed_create_dir;
  300. }
  301. if (!debugfs_create_file("stats_delay_ms", 0644, dir, core, &stats_delay_fops)) {
  302. d_vpr_e("debugfs_create_file: fail\n");
  303. goto failed_create_dir;
  304. }
  305. failed_create_dir:
  306. return dir;
  307. }
  308. static int inst_info_open(struct inode *inode, struct file *file)
  309. {
  310. d_vpr_l("Open inode ptr: %pK\n", inode->i_private);
  311. file->private_data = inode->i_private;
  312. return 0;
  313. }
  314. static int publish_unreleased_reference(struct msm_vidc_inst *inst,
  315. char **dbuf, char *end)
  316. {
  317. return 0;
  318. }
  319. static ssize_t inst_info_read(struct file *file, char __user *buf,
  320. size_t count, loff_t *ppos)
  321. {
  322. struct core_inst_pair *idata = file->private_data;
  323. struct msm_vidc_core *core;
  324. struct msm_vidc_inst *inst;
  325. char *dbuf, *cur, *end;
  326. int i, j;
  327. ssize_t len = 0;
  328. struct v4l2_format *f;
  329. if (!idata || !idata->core || !idata->inst ||
  330. !idata->inst->capabilities) {
  331. d_vpr_e("%s: invalid params %pK\n", __func__, idata);
  332. return 0;
  333. }
  334. core = idata->core;
  335. inst = idata->inst;
  336. inst = get_inst(core, inst->session_id);
  337. if (!inst) {
  338. d_vpr_h("%s: instance has become obsolete", __func__);
  339. return 0;
  340. }
  341. dbuf = kzalloc(MAX_DBG_BUF_SIZE, GFP_KERNEL);
  342. if (!dbuf) {
  343. i_vpr_e(inst, "%s: Allocation failed!\n", __func__);
  344. len = -ENOMEM;
  345. goto failed_alloc;
  346. }
  347. cur = dbuf;
  348. end = cur + MAX_DBG_BUF_SIZE;
  349. f = &inst->fmts[OUTPUT_PORT];
  350. cur += write_str(cur, end - cur, "==============================\n");
  351. cur += write_str(cur, end - cur, "INSTANCE: %pK (%s)\n", inst,
  352. inst->domain == MSM_VIDC_ENCODER ? "Encoder" : "Decoder");
  353. cur += write_str(cur, end - cur, "==============================\n");
  354. cur += write_str(cur, end - cur, "core: %pK\n", inst->core);
  355. cur += write_str(cur, end - cur, "height: %d\n", f->fmt.pix_mp.height);
  356. cur += write_str(cur, end - cur, "width: %d\n", f->fmt.pix_mp.width);
  357. cur += write_str(cur, end - cur, "fps: %d\n",
  358. inst->capabilities->cap[FRAME_RATE].value >> 16);
  359. cur += write_str(cur, end - cur, "state: %d\n", inst->state);
  360. cur += write_str(cur, end - cur, "secure: %d\n",
  361. is_secure_session(inst));
  362. cur += write_str(cur, end - cur, "-----------Formats-------------\n");
  363. for (i = 0; i < MAX_PORT; i++) {
  364. if (i != INPUT_PORT && i != OUTPUT_PORT)
  365. continue;
  366. f = &inst->fmts[i];
  367. cur += write_str(cur, end - cur, "capability: %s\n",
  368. i == INPUT_PORT ? "Output" : "Capture");
  369. cur += write_str(cur, end - cur, "planes : %d\n",
  370. f->fmt.pix_mp.num_planes);
  371. cur += write_str(cur, end - cur,
  372. "type: %s\n", i == INPUT_PORT ?
  373. "Output" : "Capture");
  374. cur += write_str(cur, end - cur, "count: %u\n",
  375. inst->vb2q[i].num_buffers);
  376. for (j = 0; j < f->fmt.pix_mp.num_planes; j++)
  377. cur += write_str(cur, end - cur,
  378. "size for plane %d: %u\n",
  379. j, f->fmt.pix_mp.plane_fmt[j].sizeimage);
  380. cur += write_str(cur, end - cur, "\n");
  381. }
  382. cur += write_str(cur, end - cur, "-------------------------------\n");
  383. cur += write_str(cur, end - cur, "ETB Count: %d\n",
  384. inst->debug_count.etb);
  385. cur += write_str(cur, end - cur, "EBD Count: %d\n",
  386. inst->debug_count.ebd);
  387. cur += write_str(cur, end - cur, "FTB Count: %d\n",
  388. inst->debug_count.ftb);
  389. cur += write_str(cur, end - cur, "FBD Count: %d\n",
  390. inst->debug_count.fbd);
  391. publish_unreleased_reference(inst, &cur, end);
  392. len = simple_read_from_buffer(buf, count, ppos,
  393. dbuf, cur - dbuf);
  394. kfree(dbuf);
  395. failed_alloc:
  396. put_inst(inst);
  397. return len;
  398. }
  399. static int inst_info_release(struct inode *inode, struct file *file)
  400. {
  401. d_vpr_l("Release inode ptr: %pK\n", inode->i_private);
  402. file->private_data = NULL;
  403. return 0;
  404. }
  405. static const struct file_operations inst_info_fops = {
  406. .open = inst_info_open,
  407. .read = inst_info_read,
  408. .release = inst_info_release,
  409. };
  410. struct dentry *msm_vidc_debugfs_init_inst(void *instance, struct dentry *parent)
  411. {
  412. struct dentry *dir = NULL, *info = NULL;
  413. char debugfs_name[MAX_DEBUGFS_NAME];
  414. struct core_inst_pair *idata = NULL;
  415. struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
  416. if (!inst) {
  417. d_vpr_e("%s: invalid params\n", __func__);
  418. goto exit;
  419. }
  420. snprintf(debugfs_name, MAX_DEBUGFS_NAME, "inst_%d", inst->session_id);
  421. idata = kzalloc(sizeof(struct core_inst_pair), GFP_KERNEL);
  422. if (!idata) {
  423. i_vpr_e(inst, "%s: Allocation failed!\n", __func__);
  424. goto exit;
  425. }
  426. idata->core = inst->core;
  427. idata->inst = inst;
  428. dir = debugfs_create_dir(debugfs_name, parent);
  429. if (IS_ERR_OR_NULL(dir)) {
  430. dir = NULL;
  431. i_vpr_e(inst,
  432. "%s: Failed to create debugfs for msm_vidc\n",
  433. __func__);
  434. goto failed_create_dir;
  435. }
  436. info = debugfs_create_file("info", 0444, dir,
  437. idata, &inst_info_fops);
  438. if (IS_ERR_OR_NULL(info)) {
  439. i_vpr_e(inst, "%s: debugfs_create_file: fail\n",
  440. __func__);
  441. goto failed_create_file;
  442. }
  443. dir->d_inode->i_private = info->d_inode->i_private;
  444. inst->debug.pdata[FRAME_PROCESSING].sampling = true;
  445. return dir;
  446. failed_create_file:
  447. debugfs_remove_recursive(dir);
  448. dir = NULL;
  449. failed_create_dir:
  450. kfree(idata);
  451. exit:
  452. return dir;
  453. }
  454. void msm_vidc_debugfs_deinit_inst(void *instance)
  455. {
  456. struct dentry *dentry = NULL;
  457. struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
  458. if (!inst || !inst->debugfs_root)
  459. return;
  460. dentry = inst->debugfs_root;
  461. if (dentry->d_inode) {
  462. i_vpr_l(inst, "%s: Destroy %pK\n",
  463. __func__, dentry->d_inode->i_private);
  464. kfree(dentry->d_inode->i_private);
  465. dentry->d_inode->i_private = NULL;
  466. }
  467. debugfs_remove_recursive(dentry);
  468. inst->debugfs_root = NULL;
  469. }
  470. void msm_vidc_debugfs_update(void *instance,
  471. enum msm_vidc_debugfs_event e)
  472. {
  473. struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
  474. struct msm_vidc_debug *d;
  475. char a[64] = "Frame processing";
  476. if (!inst) {
  477. d_vpr_e("%s: invalid params\n", __func__);
  478. return;
  479. }
  480. d = &inst->debug;
  481. switch (e) {
  482. case MSM_VIDC_DEBUGFS_EVENT_ETB:
  483. inst->debug_count.etb++;
  484. if (inst->debug_count.ebd &&
  485. inst->debug_count.ftb > inst->debug_count.fbd) {
  486. d->pdata[FRAME_PROCESSING].name[0] = '\0';
  487. tic(inst, FRAME_PROCESSING, a);
  488. }
  489. break;
  490. case MSM_VIDC_DEBUGFS_EVENT_EBD:
  491. inst->debug_count.ebd++;
  492. if (inst->debug_count.ebd &&
  493. inst->debug_count.ebd == inst->debug_count.etb) {
  494. toc(inst, FRAME_PROCESSING);
  495. i_vpr_p(inst, "EBD: FW needs input buffers\n");
  496. }
  497. if (inst->debug_count.ftb == inst->debug_count.fbd)
  498. i_vpr_p(inst, "EBD: FW needs output buffers\n");
  499. break;
  500. case MSM_VIDC_DEBUGFS_EVENT_FTB:
  501. inst->debug_count.ftb++;
  502. if (inst->debug_count.ebd &&
  503. inst->debug_count.etb > inst->debug_count.ebd) {
  504. d->pdata[FRAME_PROCESSING].name[0] = '\0';
  505. tic(inst, FRAME_PROCESSING, a);
  506. }
  507. break;
  508. case MSM_VIDC_DEBUGFS_EVENT_FBD:
  509. inst->debug_count.fbd++;
  510. inst->debug.samples++;
  511. if (inst->debug_count.fbd &&
  512. inst->debug_count.fbd == inst->debug_count.ftb) {
  513. toc(inst, FRAME_PROCESSING);
  514. i_vpr_p(inst, "FBD: FW needs output buffers\n");
  515. }
  516. if (inst->debug_count.etb == inst->debug_count.ebd)
  517. i_vpr_p(inst, "FBD: FW needs input buffers\n");
  518. break;
  519. default:
  520. i_vpr_e(inst, "invalid event in debugfs: %d\n", e);
  521. break;
  522. }
  523. }
  524. int msm_vidc_check_ratelimit(void)
  525. {
  526. static DEFINE_RATELIMIT_STATE(_rs,
  527. VIDC_DBG_SESSION_RATELIMIT_INTERVAL,
  528. VIDC_DBG_SESSION_RATELIMIT_BURST);
  529. return __ratelimit(&_rs);
  530. }