@@ -47,17 +47,6 @@ static void aie2_job_put(struct amdxdna_sched_job *job)
4747 kref_put (& job -> refcnt , aie2_job_release );
4848}
4949
50- static void aie2_hwctx_status_shift_stop (struct amdxdna_hwctx * hwctx )
51- {
52- hwctx -> old_status = hwctx -> status ;
53- hwctx -> status = HWCTX_STAT_STOP ;
54- }
55-
56- static void aie2_hwctx_status_restore (struct amdxdna_hwctx * hwctx )
57- {
58- hwctx -> status = hwctx -> old_status ;
59- }
60-
6150/* The bad_job is used in aie2_sched_job_timedout, otherwise, set it to NULL */
6251static void aie2_hwctx_stop (struct amdxdna_dev * xdna , struct amdxdna_hwctx * hwctx ,
6352 struct drm_sched_job * bad_job )
@@ -84,11 +73,6 @@ static int aie2_hwctx_restart(struct amdxdna_dev *xdna, struct amdxdna_hwctx *hw
8473 goto out ;
8574 }
8675
87- if (hwctx -> status != HWCTX_STAT_READY ) {
88- XDNA_DBG (xdna , "hwctx is not ready, status %d" , hwctx -> status );
89- goto out ;
90- }
91-
9276 ret = aie2_config_cu (hwctx , NULL );
9377 if (ret ) {
9478 XDNA_ERR (xdna , "Config cu failed, ret %d" , ret );
@@ -140,7 +124,6 @@ static int aie2_hwctx_suspend_cb(struct amdxdna_hwctx *hwctx, void *arg)
140124
141125 aie2_hwctx_wait_for_idle (hwctx );
142126 aie2_hwctx_stop (xdna , hwctx , NULL );
143- aie2_hwctx_status_shift_stop (hwctx );
144127
145128 return 0 ;
146129}
@@ -162,7 +145,6 @@ static int aie2_hwctx_resume_cb(struct amdxdna_hwctx *hwctx, void *arg)
162145{
163146 struct amdxdna_dev * xdna = hwctx -> client -> xdna ;
164147
165- aie2_hwctx_status_restore (hwctx );
166148 return aie2_hwctx_restart (xdna , hwctx );
167149}
168150
@@ -292,7 +274,7 @@ aie2_sched_cmdlist_resp_handler(void *handle, void __iomem *data, size_t size)
292274 ret = - EINVAL ;
293275 goto out ;
294276 }
295- amdxdna_cmd_set_state (cmd_abo , fail_cmd_status );
277+ amdxdna_cmd_set_state (cmd_abo , ERT_CMD_STATE_ERROR );
296278
297279 if (amdxdna_cmd_get_op (cmd_abo ) == ERT_CMD_CHAIN ) {
298280 struct amdxdna_cmd_chain * cc = amdxdna_cmd_get_payload (cmd_abo , NULL );
@@ -315,12 +297,19 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
315297 struct dma_fence * fence ;
316298 int ret ;
317299
300+ if (!hwctx -> priv -> mbox_chann )
301+ return NULL ;
302+
318303 if (!mmget_not_zero (job -> mm ))
319304 return ERR_PTR (- ESRCH );
320305
321306 kref_get (& job -> refcnt );
322307 fence = dma_fence_get (job -> fence );
323308
309+ ret = amdxdna_pm_resume_get (hwctx -> client -> xdna );
310+ if (ret )
311+ goto out ;
312+
324313 if (job -> drv_cmd ) {
325314 switch (job -> drv_cmd -> opcode ) {
326315 case SYNC_DEBUG_BO :
@@ -347,6 +336,7 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
347336
348337out :
349338 if (ret ) {
339+ amdxdna_pm_suspend_put (hwctx -> client -> xdna );
350340 dma_fence_put (job -> fence );
351341 aie2_job_put (job );
352342 mmput (job -> mm );
@@ -663,7 +653,6 @@ int aie2_hwctx_init(struct amdxdna_hwctx *hwctx)
663653 }
664654 amdxdna_pm_suspend_put (xdna );
665655
666- hwctx -> status = HWCTX_STAT_INIT ;
667656 init_waitqueue_head (& priv -> job_free_wq );
668657
669658 XDNA_DBG (xdna , "hwctx %s init completed" , hwctx -> name );
@@ -705,7 +694,9 @@ void aie2_hwctx_fini(struct amdxdna_hwctx *hwctx)
705694 aie2_hwctx_wait_for_idle (hwctx );
706695
707696 /* Request fw to destroy hwctx and cancel the rest pending requests */
697+ drm_sched_stop (& hwctx -> priv -> sched , NULL );
708698 aie2_release_resource (hwctx );
699+ drm_sched_start (& hwctx -> priv -> sched , 0 );
709700
710701 mutex_unlock (& xdna -> dev_lock );
711702 drm_sched_entity_destroy (& hwctx -> priv -> entity );
@@ -749,7 +740,7 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 size
749740 if (XDNA_MBZ_DBG (xdna , config -> pad , sizeof (config -> pad )))
750741 return - EINVAL ;
751742
752- if (hwctx -> status != HWCTX_STAT_INIT ) {
743+ if (hwctx -> cus ) {
753744 XDNA_ERR (xdna , "Not support re-config CU" );
754745 return - EINVAL ;
755746 }
@@ -780,7 +771,6 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 size
780771 }
781772
782773 wmb (); /* To avoid locking in command submit when check status */
783- hwctx -> status = HWCTX_STAT_READY ;
784774
785775 return 0 ;
786776
@@ -1003,23 +993,19 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
1003993 goto free_chain ;
1004994 }
1005995
1006- ret = amdxdna_pm_resume_get (xdna );
1007- if (ret )
1008- goto cleanup_job ;
1009-
1010996retry :
1011997 ret = drm_gem_lock_reservations (job -> bos , job -> bo_cnt , & acquire_ctx );
1012998 if (ret ) {
1013999 XDNA_WARN (xdna , "Failed to lock BOs, ret %d" , ret );
1014- goto suspend_put ;
1000+ goto cleanup_job ;
10151001 }
10161002
10171003 for (i = 0 ; i < job -> bo_cnt ; i ++ ) {
10181004 ret = dma_resv_reserve_fences (job -> bos [i ]-> resv , 1 );
10191005 if (ret ) {
10201006 XDNA_WARN (xdna , "Failed to reserve fences %d" , ret );
10211007 drm_gem_unlock_reservations (job -> bos , job -> bo_cnt , & acquire_ctx );
1022- goto suspend_put ;
1008+ goto cleanup_job ;
10231009 }
10241010 }
10251011
@@ -1034,12 +1020,12 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
10341020 msecs_to_jiffies (HMM_RANGE_DEFAULT_TIMEOUT );
10351021 } else if (time_after (jiffies , timeout )) {
10361022 ret = - ETIME ;
1037- goto suspend_put ;
1023+ goto cleanup_job ;
10381024 }
10391025
10401026 ret = aie2_populate_range (abo );
10411027 if (ret )
1042- goto suspend_put ;
1028+ goto cleanup_job ;
10431029 goto retry ;
10441030 }
10451031 }
@@ -1065,8 +1051,6 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
10651051
10661052 return 0 ;
10671053
1068- suspend_put :
1069- amdxdna_pm_suspend_put (xdna );
10701054cleanup_job :
10711055 drm_sched_job_cleanup (& job -> base );
10721056free_chain :
0 commit comments