ivpu_job.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2020-2025 Intel Corporation
  4. */
  5. #include <drm/drm_file.h>
  6. #include <linux/bitfield.h>
  7. #include <linux/highmem.h>
  8. #include <linux/pci.h>
  9. #include <linux/pm_runtime.h>
  10. #include <linux/module.h>
  11. #include <uapi/drm/ivpu_accel.h>
  12. #include "ivpu_drv.h"
  13. #include "ivpu_fw.h"
  14. #include "ivpu_hw.h"
  15. #include "ivpu_ipc.h"
  16. #include "ivpu_job.h"
  17. #include "ivpu_jsm_msg.h"
  18. #include "ivpu_mmu.h"
  19. #include "ivpu_pm.h"
  20. #include "ivpu_trace.h"
  21. #include "vpu_boot_api.h"
  22. #define CMD_BUF_IDX 0
  23. #define JOB_MAX_BUFFER_COUNT 65535
  24. static void ivpu_cmdq_ring_db(struct ivpu_device *vdev, struct ivpu_cmdq *cmdq)
  25. {
  26. ivpu_hw_db_set(vdev, cmdq->db_id);
  27. }
  28. static int ivpu_preemption_buffers_create(struct ivpu_device *vdev,
  29. struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq)
  30. {
  31. if (ivpu_fw_preempt_buf_size(vdev) == 0)
  32. return 0;
  33. cmdq->primary_preempt_buf = ivpu_bo_create(vdev, &file_priv->ctx, &vdev->hw->ranges.user,
  34. vdev->fw->primary_preempt_buf_size,
  35. DRM_IVPU_BO_WC);
  36. if (!cmdq->primary_preempt_buf) {
  37. ivpu_err(vdev, "Failed to create primary preemption buffer\n");
  38. return -ENOMEM;
  39. }
  40. cmdq->secondary_preempt_buf = ivpu_bo_create(vdev, &file_priv->ctx, &vdev->hw->ranges.dma,
  41. vdev->fw->secondary_preempt_buf_size,
  42. DRM_IVPU_BO_WC);
  43. if (!cmdq->secondary_preempt_buf) {
  44. ivpu_err(vdev, "Failed to create secondary preemption buffer\n");
  45. goto err_free_primary;
  46. }
  47. return 0;
  48. err_free_primary:
  49. ivpu_bo_free(cmdq->primary_preempt_buf);
  50. cmdq->primary_preempt_buf = NULL;
  51. return -ENOMEM;
  52. }
  53. static void ivpu_preemption_buffers_free(struct ivpu_device *vdev,
  54. struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq)
  55. {
  56. if (cmdq->primary_preempt_buf)
  57. ivpu_bo_free(cmdq->primary_preempt_buf);
  58. if (cmdq->secondary_preempt_buf)
  59. ivpu_bo_free(cmdq->secondary_preempt_buf);
  60. }
  61. static int ivpu_preemption_job_init(struct ivpu_device *vdev, struct ivpu_file_priv *file_priv,
  62. struct ivpu_cmdq *cmdq, struct ivpu_job *job)
  63. {
  64. int ret;
  65. /* Use preemption buffer provided by the user space */
  66. if (job->primary_preempt_buf)
  67. return 0;
  68. if (!cmdq->primary_preempt_buf) {
  69. /* Allocate per command queue preemption buffers */
  70. ret = ivpu_preemption_buffers_create(vdev, file_priv, cmdq);
  71. if (ret)
  72. return ret;
  73. }
  74. /* Use preemption buffers allocated by the kernel */
  75. job->primary_preempt_buf = cmdq->primary_preempt_buf;
  76. job->secondary_preempt_buf = cmdq->secondary_preempt_buf;
  77. return 0;
  78. }
  79. static struct ivpu_cmdq *ivpu_cmdq_alloc(struct ivpu_file_priv *file_priv)
  80. {
  81. struct ivpu_device *vdev = file_priv->vdev;
  82. struct ivpu_cmdq *cmdq;
  83. cmdq = kzalloc_obj(*cmdq);
  84. if (!cmdq)
  85. return NULL;
  86. cmdq->mem = ivpu_bo_create_global(vdev, SZ_4K, DRM_IVPU_BO_WC | DRM_IVPU_BO_MAPPABLE);
  87. if (!cmdq->mem)
  88. goto err_free_cmdq;
  89. return cmdq;
  90. err_free_cmdq:
  91. kfree(cmdq);
  92. return NULL;
  93. }
  94. /**
  95. * ivpu_cmdq_get_entry_count - Calculate the number of entries in the command queue.
  96. * @cmdq: Pointer to the command queue structure.
  97. *
  98. * Returns the number of entries that can fit in the command queue memory.
  99. */
  100. static inline u32 ivpu_cmdq_get_entry_count(struct ivpu_cmdq *cmdq)
  101. {
  102. size_t size = ivpu_bo_size(cmdq->mem) - sizeof(struct vpu_job_queue_header);
  103. return size / sizeof(struct vpu_job_queue_entry);
  104. }
  105. /**
  106. * ivpu_cmdq_get_flags - Get command queue flags based on input flags and test mode.
  107. * @vdev: Pointer to the ivpu device structure.
  108. * @flags: Input flags to determine the command queue flags.
  109. *
  110. * Returns the calculated command queue flags, considering both the input flags
  111. * and the current test mode settings.
  112. */
  113. static u32 ivpu_cmdq_get_flags(struct ivpu_device *vdev, u32 flags)
  114. {
  115. u32 cmdq_flags = 0;
  116. if ((flags & DRM_IVPU_CMDQ_FLAG_TURBO) && (ivpu_hw_ip_gen(vdev) >= IVPU_HW_IP_40XX))
  117. cmdq_flags |= VPU_JOB_QUEUE_FLAGS_TURBO_MODE;
  118. /* Test mode can override the TURBO flag coming from the application */
  119. if (ivpu_test_mode & IVPU_TEST_MODE_TURBO_ENABLE)
  120. cmdq_flags |= VPU_JOB_QUEUE_FLAGS_TURBO_MODE;
  121. if (ivpu_test_mode & IVPU_TEST_MODE_TURBO_DISABLE)
  122. cmdq_flags &= ~VPU_JOB_QUEUE_FLAGS_TURBO_MODE;
  123. return cmdq_flags;
  124. }
  125. static void ivpu_cmdq_free(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq)
  126. {
  127. ivpu_preemption_buffers_free(file_priv->vdev, file_priv, cmdq);
  128. ivpu_bo_free(cmdq->mem);
  129. kfree(cmdq);
  130. }
  131. static struct ivpu_cmdq *ivpu_cmdq_create(struct ivpu_file_priv *file_priv, u8 priority, u32 flags)
  132. {
  133. struct ivpu_device *vdev = file_priv->vdev;
  134. struct ivpu_cmdq *cmdq = NULL;
  135. int ret;
  136. lockdep_assert_held(&file_priv->lock);
  137. cmdq = ivpu_cmdq_alloc(file_priv);
  138. if (!cmdq) {
  139. ivpu_err(vdev, "Failed to allocate command queue\n");
  140. return NULL;
  141. }
  142. ret = xa_alloc_cyclic(&file_priv->cmdq_xa, &cmdq->id, cmdq, file_priv->cmdq_limit,
  143. &file_priv->cmdq_id_next, GFP_KERNEL);
  144. if (ret < 0) {
  145. ivpu_err(vdev, "Failed to allocate command queue ID: %d\n", ret);
  146. goto err_free_cmdq;
  147. }
  148. cmdq->entry_count = ivpu_cmdq_get_entry_count(cmdq);
  149. cmdq->priority = priority;
  150. cmdq->jobq = (struct vpu_job_queue *)ivpu_bo_vaddr(cmdq->mem);
  151. cmdq->jobq->header.engine_idx = VPU_ENGINE_COMPUTE;
  152. cmdq->jobq->header.flags = ivpu_cmdq_get_flags(vdev, flags);
  153. ivpu_dbg(vdev, JOB, "Command queue %d created, ctx %d, flags 0x%08x\n",
  154. cmdq->id, file_priv->ctx.id, cmdq->jobq->header.flags);
  155. return cmdq;
  156. err_free_cmdq:
  157. ivpu_cmdq_free(file_priv, cmdq);
  158. return NULL;
  159. }
  160. static int ivpu_hws_cmdq_init(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq, u16 engine,
  161. u8 priority)
  162. {
  163. struct ivpu_device *vdev = file_priv->vdev;
  164. int ret;
  165. ret = ivpu_jsm_hws_create_cmdq(vdev, file_priv->ctx.id, file_priv->ctx.id, cmdq->id,
  166. task_pid_nr(current), engine,
  167. cmdq->mem->vpu_addr, ivpu_bo_size(cmdq->mem));
  168. if (ret)
  169. return ret;
  170. ret = ivpu_jsm_hws_set_context_sched_properties(vdev, file_priv->ctx.id, cmdq->id,
  171. priority);
  172. if (ret)
  173. return ret;
  174. return 0;
  175. }
  176. static int ivpu_register_db(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq)
  177. {
  178. struct ivpu_device *vdev = file_priv->vdev;
  179. int ret;
  180. ret = xa_alloc_cyclic(&vdev->db_xa, &cmdq->db_id, NULL, vdev->db_limit, &vdev->db_next,
  181. GFP_KERNEL);
  182. if (ret < 0) {
  183. ivpu_err(vdev, "Failed to allocate doorbell ID: %d\n", ret);
  184. return ret;
  185. }
  186. if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW)
  187. ret = ivpu_jsm_hws_register_db(vdev, file_priv->ctx.id, cmdq->id, cmdq->db_id,
  188. cmdq->mem->vpu_addr, ivpu_bo_size(cmdq->mem));
  189. else
  190. ret = ivpu_jsm_register_db(vdev, file_priv->ctx.id, cmdq->db_id,
  191. cmdq->mem->vpu_addr, ivpu_bo_size(cmdq->mem));
  192. if (!ret) {
  193. ivpu_dbg(vdev, JOB, "DB %d registered to cmdq %d ctx %d priority %d\n",
  194. cmdq->db_id, cmdq->id, file_priv->ctx.id, cmdq->priority);
  195. } else {
  196. xa_erase(&vdev->db_xa, cmdq->db_id);
  197. cmdq->db_id = 0;
  198. }
  199. return ret;
  200. }
  201. static void ivpu_cmdq_jobq_reset(struct ivpu_device *vdev, struct vpu_job_queue *jobq)
  202. {
  203. jobq->header.head = 0;
  204. jobq->header.tail = 0;
  205. wmb(); /* Flush WC buffer for jobq->header */
  206. }
  207. static int ivpu_cmdq_register(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq)
  208. {
  209. struct ivpu_device *vdev = file_priv->vdev;
  210. int ret;
  211. lockdep_assert_held(&file_priv->lock);
  212. if (cmdq->db_id)
  213. return 0;
  214. ivpu_cmdq_jobq_reset(vdev, cmdq->jobq);
  215. if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW) {
  216. ret = ivpu_hws_cmdq_init(file_priv, cmdq, VPU_ENGINE_COMPUTE, cmdq->priority);
  217. if (ret)
  218. return ret;
  219. }
  220. ret = ivpu_register_db(file_priv, cmdq);
  221. if (ret)
  222. return ret;
  223. return 0;
  224. }
  225. static int ivpu_cmdq_unregister(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq)
  226. {
  227. struct ivpu_device *vdev = file_priv->vdev;
  228. int ret;
  229. lockdep_assert_held(&file_priv->lock);
  230. if (!cmdq->db_id)
  231. return 0;
  232. ret = ivpu_jsm_unregister_db(vdev, cmdq->db_id);
  233. if (!ret)
  234. ivpu_dbg(vdev, JOB, "DB %d unregistered\n", cmdq->db_id);
  235. if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW) {
  236. ret = ivpu_jsm_hws_destroy_cmdq(vdev, file_priv->ctx.id, cmdq->id);
  237. if (!ret)
  238. ivpu_dbg(vdev, JOB, "Command queue %d destroyed, ctx %d\n",
  239. cmdq->id, file_priv->ctx.id);
  240. }
  241. xa_erase(&file_priv->vdev->db_xa, cmdq->db_id);
  242. cmdq->db_id = 0;
  243. return 0;
  244. }
  245. static inline u8 ivpu_job_to_jsm_priority(u8 priority)
  246. {
  247. if (priority == DRM_IVPU_JOB_PRIORITY_DEFAULT)
  248. return VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL;
  249. return priority - 1;
  250. }
  251. static void ivpu_cmdq_destroy(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq)
  252. {
  253. ivpu_cmdq_unregister(file_priv, cmdq);
  254. xa_erase(&file_priv->cmdq_xa, cmdq->id);
  255. ivpu_cmdq_free(file_priv, cmdq);
  256. }
  257. static struct ivpu_cmdq *ivpu_cmdq_acquire_legacy(struct ivpu_file_priv *file_priv, u8 priority)
  258. {
  259. struct ivpu_cmdq *cmdq;
  260. unsigned long id;
  261. lockdep_assert_held(&file_priv->lock);
  262. xa_for_each(&file_priv->cmdq_xa, id, cmdq)
  263. if (cmdq->is_legacy && cmdq->priority == priority)
  264. break;
  265. if (!cmdq) {
  266. cmdq = ivpu_cmdq_create(file_priv, priority, 0);
  267. if (!cmdq)
  268. return NULL;
  269. cmdq->is_legacy = true;
  270. }
  271. return cmdq;
  272. }
  273. static struct ivpu_cmdq *ivpu_cmdq_acquire(struct ivpu_file_priv *file_priv, u32 cmdq_id)
  274. {
  275. struct ivpu_device *vdev = file_priv->vdev;
  276. struct ivpu_cmdq *cmdq;
  277. lockdep_assert_held(&file_priv->lock);
  278. cmdq = xa_load(&file_priv->cmdq_xa, cmdq_id);
  279. if (!cmdq) {
  280. ivpu_dbg(vdev, IOCTL, "Failed to find command queue with ID: %u\n", cmdq_id);
  281. return NULL;
  282. }
  283. return cmdq;
  284. }
  285. void ivpu_cmdq_release_all_locked(struct ivpu_file_priv *file_priv)
  286. {
  287. struct ivpu_cmdq *cmdq;
  288. unsigned long cmdq_id;
  289. lockdep_assert_held(&file_priv->lock);
  290. xa_for_each(&file_priv->cmdq_xa, cmdq_id, cmdq)
  291. ivpu_cmdq_destroy(file_priv, cmdq);
  292. }
  293. /*
  294. * Mark the doorbell as unregistered
  295. * This function needs to be called when the VPU hardware is restarted
  296. * and FW loses job queue state. The next time job queue is used it
  297. * will be registered again.
  298. */
  299. static void ivpu_cmdq_reset(struct ivpu_file_priv *file_priv)
  300. {
  301. struct ivpu_cmdq *cmdq;
  302. unsigned long cmdq_id;
  303. mutex_lock(&file_priv->lock);
  304. xa_for_each(&file_priv->cmdq_xa, cmdq_id, cmdq) {
  305. xa_erase(&file_priv->vdev->db_xa, cmdq->db_id);
  306. cmdq->db_id = 0;
  307. }
  308. mutex_unlock(&file_priv->lock);
  309. }
  310. void ivpu_cmdq_reset_all_contexts(struct ivpu_device *vdev)
  311. {
  312. struct ivpu_file_priv *file_priv;
  313. unsigned long ctx_id;
  314. mutex_lock(&vdev->context_list_lock);
  315. xa_for_each(&vdev->context_xa, ctx_id, file_priv)
  316. ivpu_cmdq_reset(file_priv);
  317. mutex_unlock(&vdev->context_list_lock);
  318. }
  319. void ivpu_context_abort_locked(struct ivpu_file_priv *file_priv)
  320. {
  321. struct ivpu_device *vdev = file_priv->vdev;
  322. struct ivpu_cmdq *cmdq;
  323. unsigned long cmdq_id;
  324. lockdep_assert_held(&file_priv->lock);
  325. ivpu_dbg(vdev, JOB, "Context ID: %u abort\n", file_priv->ctx.id);
  326. xa_for_each(&file_priv->cmdq_xa, cmdq_id, cmdq)
  327. ivpu_cmdq_unregister(file_priv, cmdq);
  328. if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_OS)
  329. ivpu_jsm_context_release(vdev, file_priv->ctx.id);
  330. ivpu_mmu_disable_ssid_events(vdev, file_priv->ctx.id);
  331. file_priv->aborted = true;
  332. }
  333. static int ivpu_cmdq_push_job(struct ivpu_cmdq *cmdq, struct ivpu_job *job)
  334. {
  335. struct ivpu_device *vdev = job->vdev;
  336. struct vpu_job_queue_header *header = &cmdq->jobq->header;
  337. struct vpu_job_queue_entry *entry;
  338. u32 tail = READ_ONCE(header->tail);
  339. u32 next_entry = (tail + 1) % cmdq->entry_count;
  340. /* Check if there is space left in job queue */
  341. if (next_entry == header->head) {
  342. ivpu_dbg(vdev, JOB, "Job queue full: ctx %d cmdq %d db %d head %d tail %d\n",
  343. job->file_priv->ctx.id, cmdq->id, cmdq->db_id, header->head, tail);
  344. return -EBUSY;
  345. }
  346. entry = &cmdq->jobq->slot[tail].job;
  347. entry->batch_buf_addr = job->cmd_buf_vpu_addr;
  348. entry->job_id = job->job_id;
  349. entry->flags = 0;
  350. if (unlikely(ivpu_test_mode & IVPU_TEST_MODE_NULL_SUBMISSION))
  351. entry->flags = VPU_JOB_FLAGS_NULL_SUBMISSION_MASK;
  352. if (job->primary_preempt_buf) {
  353. entry->primary_preempt_buf_addr = job->primary_preempt_buf->vpu_addr;
  354. entry->primary_preempt_buf_size = ivpu_bo_size(job->primary_preempt_buf);
  355. }
  356. if (job->secondary_preempt_buf) {
  357. entry->secondary_preempt_buf_addr = job->secondary_preempt_buf->vpu_addr;
  358. entry->secondary_preempt_buf_size = ivpu_bo_size(job->secondary_preempt_buf);
  359. }
  360. wmb(); /* Ensure that tail is updated after filling entry */
  361. header->tail = next_entry;
  362. wmb(); /* Flush WC buffer for jobq header */
  363. return 0;
  364. }
  365. struct ivpu_fence {
  366. struct dma_fence base;
  367. spinlock_t lock; /* protects base */
  368. struct ivpu_device *vdev;
  369. };
  370. static inline struct ivpu_fence *to_vpu_fence(struct dma_fence *fence)
  371. {
  372. return container_of(fence, struct ivpu_fence, base);
  373. }
  374. static const char *ivpu_fence_get_driver_name(struct dma_fence *fence)
  375. {
  376. return DRIVER_NAME;
  377. }
  378. static const char *ivpu_fence_get_timeline_name(struct dma_fence *fence)
  379. {
  380. struct ivpu_fence *ivpu_fence = to_vpu_fence(fence);
  381. return dev_name(ivpu_fence->vdev->drm.dev);
  382. }
  383. static const struct dma_fence_ops ivpu_fence_ops = {
  384. .get_driver_name = ivpu_fence_get_driver_name,
  385. .get_timeline_name = ivpu_fence_get_timeline_name,
  386. };
  387. static struct dma_fence *ivpu_fence_create(struct ivpu_device *vdev)
  388. {
  389. struct ivpu_fence *fence;
  390. fence = kzalloc_obj(*fence);
  391. if (!fence)
  392. return NULL;
  393. fence->vdev = vdev;
  394. spin_lock_init(&fence->lock);
  395. dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1);
  396. return &fence->base;
  397. }
  398. static void ivpu_job_destroy(struct ivpu_job *job)
  399. {
  400. struct ivpu_device *vdev = job->vdev;
  401. u32 i;
  402. ivpu_dbg(vdev, JOB, "Job destroyed: id %3u ctx %2d cmdq_id %u engine %d",
  403. job->job_id, job->file_priv->ctx.id, job->cmdq_id, job->engine_idx);
  404. for (i = 0; i < job->bo_count; i++)
  405. if (job->bos[i])
  406. drm_gem_object_put(&job->bos[i]->base.base);
  407. dma_fence_put(job->done_fence);
  408. ivpu_file_priv_put(&job->file_priv);
  409. kfree(job);
  410. }
  411. static struct ivpu_job *
  412. ivpu_job_create(struct ivpu_file_priv *file_priv, u32 engine_idx, u32 bo_count)
  413. {
  414. struct ivpu_device *vdev = file_priv->vdev;
  415. struct ivpu_job *job;
  416. job = kzalloc_flex(*job, bos, bo_count);
  417. if (!job)
  418. return NULL;
  419. job->vdev = vdev;
  420. job->engine_idx = engine_idx;
  421. job->bo_count = bo_count;
  422. job->done_fence = ivpu_fence_create(vdev);
  423. if (!job->done_fence) {
  424. ivpu_err(vdev, "Failed to create a fence\n");
  425. goto err_free_job;
  426. }
  427. job->file_priv = ivpu_file_priv_get(file_priv);
  428. trace_job("create", job);
  429. ivpu_dbg(vdev, JOB, "Job created: ctx %2d engine %d", file_priv->ctx.id, job->engine_idx);
  430. return job;
  431. err_free_job:
  432. kfree(job);
  433. return NULL;
  434. }
  435. static struct ivpu_job *ivpu_job_remove_from_submitted_jobs(struct ivpu_device *vdev, u32 job_id)
  436. {
  437. struct ivpu_job *job;
  438. lockdep_assert_held(&vdev->submitted_jobs_lock);
  439. job = xa_erase(&vdev->submitted_jobs_xa, job_id);
  440. if (xa_empty(&vdev->submitted_jobs_xa) && job) {
  441. vdev->busy_time = ktime_add(ktime_sub(ktime_get(), vdev->busy_start_ts),
  442. vdev->busy_time);
  443. }
  444. return job;
  445. }
  446. bool ivpu_job_handle_engine_error(struct ivpu_device *vdev, u32 job_id, u32 job_status)
  447. {
  448. lockdep_assert_held(&vdev->submitted_jobs_lock);
  449. switch (job_status) {
  450. case VPU_JSM_STATUS_PROCESSING_ERR:
  451. case VPU_JSM_STATUS_ENGINE_RESET_REQUIRED_MIN ... VPU_JSM_STATUS_ENGINE_RESET_REQUIRED_MAX:
  452. {
  453. struct ivpu_job *job = xa_load(&vdev->submitted_jobs_xa, job_id);
  454. if (!job)
  455. return false;
  456. /* Trigger an engine reset */
  457. guard(mutex)(&job->file_priv->lock);
  458. job->job_status = job_status;
  459. if (job->file_priv->has_mmu_faults)
  460. return false;
  461. /*
  462. * Mark context as faulty and defer destruction of the job to jobs abort thread
  463. * handler to synchronize between both faults and jobs returning context violation
  464. * status and ensure both are handled in the same way
  465. */
  466. job->file_priv->has_mmu_faults = true;
  467. queue_work(system_percpu_wq, &vdev->context_abort_work);
  468. return true;
  469. }
  470. default:
  471. /* Complete job with error status, engine reset not required */
  472. break;
  473. }
  474. return false;
  475. }
  476. static int ivpu_job_signal_and_destroy(struct ivpu_device *vdev, u32 job_id, u32 job_status)
  477. {
  478. struct ivpu_job *job;
  479. lockdep_assert_held(&vdev->submitted_jobs_lock);
  480. job = xa_load(&vdev->submitted_jobs_xa, job_id);
  481. if (!job)
  482. return -ENOENT;
  483. ivpu_job_remove_from_submitted_jobs(vdev, job_id);
  484. if (job->job_status == VPU_JSM_STATUS_SUCCESS) {
  485. if (job->file_priv->has_mmu_faults)
  486. job->job_status = DRM_IVPU_JOB_STATUS_ABORTED;
  487. else
  488. job->job_status = job_status;
  489. }
  490. job->bos[CMD_BUF_IDX]->job_status = job->job_status;
  491. dma_fence_signal(job->done_fence);
  492. trace_job("done", job);
  493. ivpu_dbg(vdev, JOB, "Job complete: id %3u ctx %2d cmdq_id %u engine %d status 0x%x\n",
  494. job->job_id, job->file_priv->ctx.id, job->cmdq_id, job->engine_idx,
  495. job->job_status);
  496. ivpu_job_destroy(job);
  497. ivpu_stop_job_timeout_detection(vdev);
  498. ivpu_rpm_put(vdev);
  499. if (!xa_empty(&vdev->submitted_jobs_xa))
  500. ivpu_start_job_timeout_detection(vdev);
  501. return 0;
  502. }
  503. void ivpu_jobs_abort_all(struct ivpu_device *vdev)
  504. {
  505. struct ivpu_job *job;
  506. unsigned long id;
  507. mutex_lock(&vdev->submitted_jobs_lock);
  508. xa_for_each(&vdev->submitted_jobs_xa, id, job)
  509. ivpu_job_signal_and_destroy(vdev, id, DRM_IVPU_JOB_STATUS_ABORTED);
  510. mutex_unlock(&vdev->submitted_jobs_lock);
  511. }
  512. void ivpu_cmdq_abort_all_jobs(struct ivpu_device *vdev, u32 ctx_id, u32 cmdq_id)
  513. {
  514. struct ivpu_job *job;
  515. unsigned long id;
  516. mutex_lock(&vdev->submitted_jobs_lock);
  517. xa_for_each(&vdev->submitted_jobs_xa, id, job)
  518. if (job->file_priv->ctx.id == ctx_id && job->cmdq_id == cmdq_id)
  519. ivpu_job_signal_and_destroy(vdev, id, DRM_IVPU_JOB_STATUS_ABORTED);
  520. mutex_unlock(&vdev->submitted_jobs_lock);
  521. }
  522. static int ivpu_job_submit(struct ivpu_job *job, u8 priority, u32 cmdq_id)
  523. {
  524. struct ivpu_file_priv *file_priv = job->file_priv;
  525. struct ivpu_device *vdev = job->vdev;
  526. struct ivpu_cmdq *cmdq;
  527. bool is_first_job;
  528. int ret;
  529. ret = ivpu_rpm_get(vdev);
  530. if (ret < 0)
  531. return ret;
  532. mutex_lock(&vdev->submitted_jobs_lock);
  533. mutex_lock(&file_priv->lock);
  534. if (cmdq_id == 0)
  535. cmdq = ivpu_cmdq_acquire_legacy(file_priv, priority);
  536. else
  537. cmdq = ivpu_cmdq_acquire(file_priv, cmdq_id);
  538. if (!cmdq) {
  539. ret = -EINVAL;
  540. goto err_unlock;
  541. }
  542. ret = ivpu_cmdq_register(file_priv, cmdq);
  543. if (ret) {
  544. ivpu_err(vdev, "Failed to register command queue: %d\n", ret);
  545. goto err_unlock;
  546. }
  547. ret = ivpu_preemption_job_init(vdev, file_priv, cmdq, job);
  548. if (ret) {
  549. ivpu_err(vdev, "Failed to initialize preemption buffers for job %d: %d\n",
  550. job->job_id, ret);
  551. goto err_unlock;
  552. }
  553. job->cmdq_id = cmdq->id;
  554. is_first_job = xa_empty(&vdev->submitted_jobs_xa);
  555. ret = xa_alloc_cyclic(&vdev->submitted_jobs_xa, &job->job_id, job, file_priv->job_limit,
  556. &file_priv->job_id_next, GFP_KERNEL);
  557. if (ret < 0) {
  558. ivpu_dbg(vdev, JOB, "Too many active jobs in ctx %d\n",
  559. file_priv->ctx.id);
  560. ret = -EBUSY;
  561. goto err_unlock;
  562. }
  563. ret = ivpu_cmdq_push_job(cmdq, job);
  564. if (ret)
  565. goto err_erase_xa;
  566. ivpu_start_job_timeout_detection(vdev);
  567. if (unlikely(ivpu_test_mode & IVPU_TEST_MODE_NULL_HW)) {
  568. cmdq->jobq->header.head = cmdq->jobq->header.tail;
  569. wmb(); /* Flush WC buffer for jobq header */
  570. } else {
  571. ivpu_cmdq_ring_db(vdev, cmdq);
  572. if (is_first_job)
  573. vdev->busy_start_ts = ktime_get();
  574. }
  575. trace_job("submit", job);
  576. ivpu_dbg(vdev, JOB, "Job submitted: id %3u ctx %2d cmdq_id %u engine %d prio %d addr 0x%llx next %d\n",
  577. job->job_id, file_priv->ctx.id, cmdq->id, job->engine_idx, cmdq->priority,
  578. job->cmd_buf_vpu_addr, cmdq->jobq->header.tail);
  579. mutex_unlock(&file_priv->lock);
  580. if (unlikely(ivpu_test_mode & IVPU_TEST_MODE_NULL_HW)) {
  581. ivpu_job_signal_and_destroy(vdev, job->job_id, VPU_JSM_STATUS_SUCCESS);
  582. }
  583. mutex_unlock(&vdev->submitted_jobs_lock);
  584. return 0;
  585. err_erase_xa:
  586. xa_erase(&vdev->submitted_jobs_xa, job->job_id);
  587. err_unlock:
  588. mutex_unlock(&file_priv->lock);
  589. mutex_unlock(&vdev->submitted_jobs_lock);
  590. ivpu_rpm_put(vdev);
  591. return ret;
  592. }
  593. static int
  594. ivpu_job_prepare_bos_for_submit(struct drm_file *file, struct ivpu_job *job, u32 *buf_handles,
  595. u32 buf_count, u32 commands_offset, u32 preempt_buffer_index)
  596. {
  597. struct ivpu_file_priv *file_priv = job->file_priv;
  598. struct ivpu_device *vdev = file_priv->vdev;
  599. struct ww_acquire_ctx acquire_ctx;
  600. enum dma_resv_usage usage;
  601. struct ivpu_bo *bo;
  602. int ret;
  603. u32 i;
  604. for (i = 0; i < buf_count; i++) {
  605. struct drm_gem_object *obj = drm_gem_object_lookup(file, buf_handles[i]);
  606. if (!obj) {
  607. ivpu_dbg(vdev, IOCTL, "Failed to lookup GEM object with handle %u\n",
  608. buf_handles[i]);
  609. return -ENOENT;
  610. }
  611. job->bos[i] = to_ivpu_bo(obj);
  612. ret = ivpu_bo_bind(job->bos[i]);
  613. if (ret)
  614. return ret;
  615. }
  616. bo = job->bos[CMD_BUF_IDX];
  617. if (!dma_resv_test_signaled(bo->base.base.resv, DMA_RESV_USAGE_READ)) {
  618. ivpu_dbg(vdev, IOCTL, "Buffer is already in use by another job\n");
  619. return -EBUSY;
  620. }
  621. if (commands_offset >= ivpu_bo_size(bo)) {
  622. ivpu_dbg(vdev, IOCTL, "Invalid commands offset %u for buffer size %zu\n",
  623. commands_offset, ivpu_bo_size(bo));
  624. return -EINVAL;
  625. }
  626. job->cmd_buf_vpu_addr = bo->vpu_addr + commands_offset;
  627. if (preempt_buffer_index) {
  628. struct ivpu_bo *preempt_bo = job->bos[preempt_buffer_index];
  629. if (ivpu_bo_size(preempt_bo) < ivpu_fw_preempt_buf_size(vdev)) {
  630. ivpu_dbg(vdev, IOCTL, "Preemption buffer is too small\n");
  631. return -EINVAL;
  632. }
  633. if (ivpu_bo_is_mappable(preempt_bo)) {
  634. ivpu_dbg(vdev, IOCTL, "Preemption buffer cannot be mappable\n");
  635. return -EINVAL;
  636. }
  637. job->primary_preempt_buf = preempt_bo;
  638. }
  639. ret = drm_gem_lock_reservations((struct drm_gem_object **)job->bos, buf_count,
  640. &acquire_ctx);
  641. if (ret) {
  642. ivpu_warn_ratelimited(vdev, "Failed to lock reservations: %d\n", ret);
  643. return ret;
  644. }
  645. for (i = 0; i < buf_count; i++) {
  646. ret = dma_resv_reserve_fences(job->bos[i]->base.base.resv, 1);
  647. if (ret) {
  648. ivpu_warn_ratelimited(vdev, "Failed to reserve fences: %d\n", ret);
  649. goto unlock_reservations;
  650. }
  651. }
  652. for (i = 0; i < buf_count; i++) {
  653. usage = (i == CMD_BUF_IDX) ? DMA_RESV_USAGE_WRITE : DMA_RESV_USAGE_BOOKKEEP;
  654. dma_resv_add_fence(job->bos[i]->base.base.resv, job->done_fence, usage);
  655. }
  656. unlock_reservations:
  657. drm_gem_unlock_reservations((struct drm_gem_object **)job->bos, buf_count, &acquire_ctx);
  658. wmb(); /* Flush write combining buffers */
  659. return ret;
  660. }
  661. static int ivpu_submit(struct drm_file *file, struct ivpu_file_priv *file_priv, u32 cmdq_id,
  662. u32 buffer_count, u32 engine, void __user *buffers_ptr, u32 cmds_offset,
  663. u32 preempt_buffer_index, u8 priority)
  664. {
  665. struct ivpu_device *vdev = file_priv->vdev;
  666. struct ivpu_job *job;
  667. u32 *buf_handles;
  668. int idx, ret;
  669. buf_handles = kcalloc(buffer_count, sizeof(u32), GFP_KERNEL);
  670. if (!buf_handles)
  671. return -ENOMEM;
  672. ret = copy_from_user(buf_handles, buffers_ptr, buffer_count * sizeof(u32));
  673. if (ret) {
  674. ret = -EFAULT;
  675. goto err_free_handles;
  676. }
  677. if (!drm_dev_enter(&vdev->drm, &idx)) {
  678. ret = -ENODEV;
  679. goto err_free_handles;
  680. }
  681. ivpu_dbg(vdev, JOB, "Submit ioctl: ctx %u cmdq_id %u buf_count %u\n",
  682. file_priv->ctx.id, cmdq_id, buffer_count);
  683. job = ivpu_job_create(file_priv, engine, buffer_count);
  684. if (!job) {
  685. ret = -ENOMEM;
  686. goto err_exit_dev;
  687. }
  688. ret = ivpu_job_prepare_bos_for_submit(file, job, buf_handles, buffer_count, cmds_offset,
  689. preempt_buffer_index);
  690. if (ret)
  691. goto err_destroy_job;
  692. down_read(&vdev->pm->reset_lock);
  693. ret = ivpu_job_submit(job, priority, cmdq_id);
  694. up_read(&vdev->pm->reset_lock);
  695. if (ret)
  696. goto err_signal_fence;
  697. drm_dev_exit(idx);
  698. kfree(buf_handles);
  699. return ret;
  700. err_signal_fence:
  701. dma_fence_signal(job->done_fence);
  702. err_destroy_job:
  703. ivpu_job_destroy(job);
  704. err_exit_dev:
  705. drm_dev_exit(idx);
  706. err_free_handles:
  707. kfree(buf_handles);
  708. return ret;
  709. }
  710. int ivpu_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
  711. {
  712. struct ivpu_file_priv *file_priv = file->driver_priv;
  713. struct ivpu_device *vdev = file_priv->vdev;
  714. struct drm_ivpu_submit *args = data;
  715. u8 priority;
  716. if (args->engine != DRM_IVPU_ENGINE_COMPUTE) {
  717. ivpu_dbg(vdev, IOCTL, "Invalid engine %d\n", args->engine);
  718. return -EINVAL;
  719. }
  720. if (args->priority > DRM_IVPU_JOB_PRIORITY_REALTIME) {
  721. ivpu_dbg(vdev, IOCTL, "Invalid priority %d\n", args->priority);
  722. return -EINVAL;
  723. }
  724. if (args->buffer_count == 0 || args->buffer_count > JOB_MAX_BUFFER_COUNT) {
  725. ivpu_dbg(vdev, IOCTL, "Invalid buffer count %u\n", args->buffer_count);
  726. return -EINVAL;
  727. }
  728. if (!IS_ALIGNED(args->commands_offset, 8)) {
  729. ivpu_dbg(vdev, IOCTL, "Invalid commands offset %u\n", args->commands_offset);
  730. return -EINVAL;
  731. }
  732. if (!file_priv->ctx.id) {
  733. ivpu_dbg(vdev, IOCTL, "Context not initialized\n");
  734. return -EINVAL;
  735. }
  736. if (file_priv->has_mmu_faults) {
  737. ivpu_dbg(vdev, IOCTL, "Context %u has MMU faults\n", file_priv->ctx.id);
  738. return -EBADFD;
  739. }
  740. priority = ivpu_job_to_jsm_priority(args->priority);
  741. return ivpu_submit(file, file_priv, 0, args->buffer_count, args->engine,
  742. (void __user *)args->buffers_ptr, args->commands_offset, 0, priority);
  743. }
  744. int ivpu_cmdq_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
  745. {
  746. struct ivpu_file_priv *file_priv = file->driver_priv;
  747. struct ivpu_device *vdev = file_priv->vdev;
  748. struct drm_ivpu_cmdq_submit *args = data;
  749. if (!ivpu_is_capable(file_priv->vdev, DRM_IVPU_CAP_MANAGE_CMDQ)) {
  750. ivpu_dbg(vdev, IOCTL, "Command queue management not supported\n");
  751. return -ENODEV;
  752. }
  753. if (args->cmdq_id < IVPU_CMDQ_MIN_ID || args->cmdq_id > IVPU_CMDQ_MAX_ID) {
  754. ivpu_dbg(vdev, IOCTL, "Invalid command queue ID %u\n", args->cmdq_id);
  755. return -EINVAL;
  756. }
  757. if (args->buffer_count == 0 || args->buffer_count > JOB_MAX_BUFFER_COUNT) {
  758. ivpu_dbg(vdev, IOCTL, "Invalid buffer count %u\n", args->buffer_count);
  759. return -EINVAL;
  760. }
  761. if (args->preempt_buffer_index >= args->buffer_count) {
  762. ivpu_dbg(vdev, IOCTL, "Invalid preemption buffer index %u\n",
  763. args->preempt_buffer_index);
  764. return -EINVAL;
  765. }
  766. if (!IS_ALIGNED(args->commands_offset, 8)) {
  767. ivpu_dbg(vdev, IOCTL, "Invalid commands offset %u\n", args->commands_offset);
  768. return -EINVAL;
  769. }
  770. if (!file_priv->ctx.id) {
  771. ivpu_dbg(vdev, IOCTL, "Context not initialized\n");
  772. return -EINVAL;
  773. }
  774. if (file_priv->has_mmu_faults) {
  775. ivpu_dbg(vdev, IOCTL, "Context %u has MMU faults\n", file_priv->ctx.id);
  776. return -EBADFD;
  777. }
  778. return ivpu_submit(file, file_priv, args->cmdq_id, args->buffer_count, VPU_ENGINE_COMPUTE,
  779. (void __user *)args->buffers_ptr, args->commands_offset,
  780. args->preempt_buffer_index, 0);
  781. }
  782. int ivpu_cmdq_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
  783. {
  784. struct ivpu_file_priv *file_priv = file->driver_priv;
  785. struct ivpu_device *vdev = file_priv->vdev;
  786. struct drm_ivpu_cmdq_create *args = data;
  787. struct ivpu_cmdq *cmdq;
  788. int ret;
  789. if (!ivpu_is_capable(vdev, DRM_IVPU_CAP_MANAGE_CMDQ)) {
  790. ivpu_dbg(vdev, IOCTL, "Command queue management not supported\n");
  791. return -ENODEV;
  792. }
  793. if (args->priority > DRM_IVPU_JOB_PRIORITY_REALTIME) {
  794. ivpu_dbg(vdev, IOCTL, "Invalid priority %d\n", args->priority);
  795. return -EINVAL;
  796. }
  797. ret = ivpu_rpm_get(vdev);
  798. if (ret < 0)
  799. return ret;
  800. mutex_lock(&file_priv->lock);
  801. cmdq = ivpu_cmdq_create(file_priv, ivpu_job_to_jsm_priority(args->priority), args->flags);
  802. if (cmdq)
  803. args->cmdq_id = cmdq->id;
  804. mutex_unlock(&file_priv->lock);
  805. ivpu_rpm_put(vdev);
  806. return cmdq ? 0 : -ENOMEM;
  807. }
  808. int ivpu_cmdq_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
  809. {
  810. struct ivpu_file_priv *file_priv = file->driver_priv;
  811. struct ivpu_device *vdev = file_priv->vdev;
  812. struct drm_ivpu_cmdq_destroy *args = data;
  813. struct ivpu_cmdq *cmdq;
  814. u32 cmdq_id = 0;
  815. int ret;
  816. if (!ivpu_is_capable(vdev, DRM_IVPU_CAP_MANAGE_CMDQ)) {
  817. ivpu_dbg(vdev, IOCTL, "Command queue management not supported\n");
  818. return -ENODEV;
  819. }
  820. ret = ivpu_rpm_get(vdev);
  821. if (ret < 0)
  822. return ret;
  823. mutex_lock(&file_priv->lock);
  824. cmdq = xa_load(&file_priv->cmdq_xa, args->cmdq_id);
  825. if (!cmdq || cmdq->is_legacy) {
  826. ret = -ENOENT;
  827. } else {
  828. cmdq_id = cmdq->id;
  829. ivpu_cmdq_destroy(file_priv, cmdq);
  830. ret = 0;
  831. }
  832. mutex_unlock(&file_priv->lock);
  833. /* Abort any pending jobs only if cmdq was destroyed */
  834. if (!ret)
  835. ivpu_cmdq_abort_all_jobs(vdev, file_priv->ctx.id, cmdq_id);
  836. ivpu_rpm_put(vdev);
  837. return ret;
  838. }
  839. static void
  840. ivpu_job_done_callback(struct ivpu_device *vdev, struct ivpu_ipc_hdr *ipc_hdr,
  841. struct vpu_jsm_msg *jsm_msg)
  842. {
  843. struct vpu_ipc_msg_payload_job_done *payload;
  844. if (!jsm_msg) {
  845. ivpu_err(vdev, "IPC message has no JSM payload\n");
  846. return;
  847. }
  848. if (jsm_msg->result != VPU_JSM_STATUS_SUCCESS) {
  849. ivpu_err(vdev, "Invalid JSM message result: %d\n", jsm_msg->result);
  850. return;
  851. }
  852. payload = (struct vpu_ipc_msg_payload_job_done *)&jsm_msg->payload;
  853. mutex_lock(&vdev->submitted_jobs_lock);
  854. if (!ivpu_job_handle_engine_error(vdev, payload->job_id, payload->job_status))
  855. /* No engine error, complete the job normally */
  856. ivpu_job_signal_and_destroy(vdev, payload->job_id, payload->job_status);
  857. mutex_unlock(&vdev->submitted_jobs_lock);
  858. }
  859. void ivpu_job_done_consumer_init(struct ivpu_device *vdev)
  860. {
  861. ivpu_ipc_consumer_add(vdev, &vdev->job_done_consumer,
  862. VPU_IPC_CHAN_JOB_RET, ivpu_job_done_callback);
  863. }
  864. void ivpu_job_done_consumer_fini(struct ivpu_device *vdev)
  865. {
  866. ivpu_ipc_consumer_del(vdev, &vdev->job_done_consumer);
  867. }
  868. void ivpu_context_abort_work_fn(struct work_struct *work)
  869. {
  870. struct ivpu_device *vdev = container_of(work, struct ivpu_device, context_abort_work);
  871. struct ivpu_file_priv *file_priv;
  872. struct ivpu_job *job;
  873. unsigned long ctx_id;
  874. unsigned long id;
  875. if (drm_WARN_ON(&vdev->drm, pm_runtime_get_if_active(vdev->drm.dev) <= 0))
  876. return;
  877. if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW)
  878. if (ivpu_jsm_reset_engine(vdev, 0))
  879. goto runtime_put;
  880. mutex_lock(&vdev->context_list_lock);
  881. xa_for_each(&vdev->context_xa, ctx_id, file_priv) {
  882. if (!file_priv->has_mmu_faults || file_priv->aborted)
  883. continue;
  884. mutex_lock(&file_priv->lock);
  885. ivpu_context_abort_locked(file_priv);
  886. mutex_unlock(&file_priv->lock);
  887. }
  888. mutex_unlock(&vdev->context_list_lock);
  889. /*
  890. * We will not receive new MMU event interrupts until existing events are discarded
  891. * however, we want to discard these events only after aborting the faulty context
  892. * to avoid generating new faults from that context
  893. */
  894. ivpu_mmu_discard_events(vdev);
  895. if (vdev->fw->sched_mode != VPU_SCHEDULING_MODE_HW)
  896. goto runtime_put;
  897. if (ivpu_jsm_hws_resume_engine(vdev, 0))
  898. goto runtime_put;
  899. /*
  900. * In hardware scheduling mode NPU already has stopped processing jobs
  901. * and won't send us any further notifications, thus we have to free job related resources
  902. * and notify userspace
  903. */
  904. mutex_lock(&vdev->submitted_jobs_lock);
  905. xa_for_each(&vdev->submitted_jobs_xa, id, job)
  906. if (job->file_priv->aborted)
  907. ivpu_job_signal_and_destroy(vdev, job->job_id, DRM_IVPU_JOB_STATUS_ABORTED);
  908. mutex_unlock(&vdev->submitted_jobs_lock);
  909. runtime_put:
  910. pm_runtime_put_autosuspend(vdev->drm.dev);
  911. }