Skip to content

Commit b853007

Browse files
committed
accel/amdxdna: Remove hardware context status
One newly supported command does not require hardware context configuration to be performed upfront. As a result, checking hardware context status causes this command to fail incorrectly. Remove hardware context status handling entirely. For other commands, if userspace submits a request without configuring the hardware context first, the firmware will report an error or time out as appropriate. Fixes: aac2430 ("accel/amdxdna: Add command execution") Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://patch.msgid.link/20260202212450.2681273-1-lizhi.hou@amd.com
1 parent fe6d29b commit b853007

3 files changed

Lines changed: 5 additions & 28 deletions

File tree

drivers/accel/amdxdna/aie2_ctx.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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 */
6251
static 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

@@ -315,7 +297,7 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
315297
struct dma_fence *fence;
316298
int ret;
317299

318-
if (hwctx->status != HWCTX_STAT_READY)
300+
if (!hwctx->priv->mbox_chann)
319301
return NULL;
320302

321303
if (!mmget_not_zero(job->mm))
@@ -666,7 +648,6 @@ int aie2_hwctx_init(struct amdxdna_hwctx *hwctx)
666648
}
667649
amdxdna_pm_suspend_put(xdna);
668650

669-
hwctx->status = HWCTX_STAT_INIT;
670651
init_waitqueue_head(&priv->job_free_wq);
671652

672653
XDNA_DBG(xdna, "hwctx %s init completed", hwctx->name);
@@ -710,7 +691,6 @@ void aie2_hwctx_fini(struct amdxdna_hwctx *hwctx)
710691
/* Request fw to destroy hwctx and cancel the rest pending requests */
711692
drm_sched_stop(&hwctx->priv->sched, NULL);
712693
aie2_release_resource(hwctx);
713-
hwctx->status = HWCTX_STAT_STOP;
714694
drm_sched_start(&hwctx->priv->sched, 0);
715695

716696
mutex_unlock(&xdna->dev_lock);
@@ -755,7 +735,7 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 size
755735
if (XDNA_MBZ_DBG(xdna, config->pad, sizeof(config->pad)))
756736
return -EINVAL;
757737

758-
if (hwctx->status != HWCTX_STAT_INIT) {
738+
if (hwctx->cus) {
759739
XDNA_ERR(xdna, "Not support re-config CU");
760740
return -EINVAL;
761741
}
@@ -786,7 +766,6 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 size
786766
}
787767

788768
wmb(); /* To avoid locking in command submit when check status */
789-
hwctx->status = HWCTX_STAT_READY;
790769

791770
return 0;
792771

drivers/accel/amdxdna/aie2_message.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,9 @@ int aie2_config_cu(struct amdxdna_hwctx *hwctx,
493493
if (!chann)
494494
return -ENODEV;
495495

496+
if (!hwctx->cus)
497+
return 0;
498+
496499
if (hwctx->cus->num_cus > MAX_NUM_CUS) {
497500
XDNA_DBG(xdna, "Exceed maximum CU %d", MAX_NUM_CUS);
498501
return -EINVAL;

drivers/accel/amdxdna/amdxdna_ctx.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ struct amdxdna_hwctx {
9999
u32 start_col;
100100
u32 num_col;
101101
u32 num_unused_col;
102-
#define HWCTX_STAT_INIT 0
103-
#define HWCTX_STAT_READY 1
104-
#define HWCTX_STAT_STOP 2
105-
u32 status;
106-
u32 old_status;
107102

108103
struct amdxdna_qos_info qos;
109104
struct amdxdna_hwctx_param_config_cu *cus;

0 commit comments

Comments
 (0)