Skip to content

Commit 7818618

Browse files
committed
accel/amdxdna: Enable temporal sharing only mode
Newer firmware versions prefer temporal sharing only mode. In this mode, the driver no longer needs to manage AIE array column allocation. Instead, a new field, num_unused_col, is added to the hardware context creation request to specify how many columns will not be used by this hardware context. Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://patch.msgid.link/20251217191150.2145937-1-lizhi.hou@amd.com
1 parent 3ef9384 commit 7818618

6 files changed

Lines changed: 21 additions & 4 deletions

File tree

drivers/accel/amdxdna/aie2_ctx.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,12 @@ static int aie2_alloc_resource(struct amdxdna_hwctx *hwctx)
468468
struct alloc_requests *xrs_req;
469469
int ret;
470470

471+
if (AIE2_FEATURE_ON(xdna->dev_handle, AIE2_TEMPORAL_ONLY)) {
472+
hwctx->num_unused_col = xdna->dev_handle->total_col - hwctx->num_col;
473+
hwctx->num_col = xdna->dev_handle->total_col;
474+
return aie2_create_context(xdna->dev_handle, hwctx);
475+
}
476+
471477
xrs_req = kzalloc(sizeof(*xrs_req), GFP_KERNEL);
472478
if (!xrs_req)
473479
return -ENOMEM;
@@ -499,9 +505,15 @@ static void aie2_release_resource(struct amdxdna_hwctx *hwctx)
499505
struct amdxdna_dev *xdna = hwctx->client->xdna;
500506
int ret;
501507

502-
ret = xrs_release_resource(xdna->xrs_hdl, (uintptr_t)hwctx);
503-
if (ret)
504-
XDNA_ERR(xdna, "Release AIE resource failed, ret %d", ret);
508+
if (AIE2_FEATURE_ON(xdna->dev_handle, AIE2_TEMPORAL_ONLY)) {
509+
ret = aie2_destroy_context(xdna->dev_handle, hwctx);
510+
if (ret)
511+
XDNA_ERR(xdna, "Destroy temporal only context failed, ret %d", ret);
512+
} else {
513+
ret = xrs_release_resource(xdna->xrs_hdl, (uintptr_t)hwctx);
514+
if (ret)
515+
XDNA_ERR(xdna, "Release AIE resource failed, ret %d", ret);
516+
}
505517
}
506518

507519
static int aie2_ctx_syncobj_create(struct amdxdna_hwctx *hwctx)

drivers/accel/amdxdna/aie2_message.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ int aie2_create_context(struct amdxdna_dev_hdl *ndev, struct amdxdna_hwctx *hwct
218218
req.aie_type = 1;
219219
req.start_col = hwctx->start_col;
220220
req.num_col = hwctx->num_col;
221+
req.num_unused_col = hwctx->num_unused_col;
221222
req.num_cq_pairs_requested = 1;
222223
req.pasid = hwctx->client->pasid;
223224
req.context_priority = 2;

drivers/accel/amdxdna/aie2_msg_priv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ struct create_ctx_req {
112112
__u32 aie_type;
113113
__u8 start_col;
114114
__u8 num_col;
115-
__u16 reserved;
115+
__u8 num_unused_col;
116+
__u8 reserved;
116117
__u8 num_cq_pairs_requested;
117118
__u8 reserved1;
118119
__u16 pasid;

drivers/accel/amdxdna/aie2_pci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ struct aie2_hw_ops {
232232
enum aie2_fw_feature {
233233
AIE2_NPU_COMMAND,
234234
AIE2_PREEMPT,
235+
AIE2_TEMPORAL_ONLY,
235236
AIE2_FEATURE_MAX
236237
};
237238

drivers/accel/amdxdna/amdxdna_ctx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct amdxdna_hwctx {
9898
u32 *col_list;
9999
u32 start_col;
100100
u32 num_col;
101+
u32 num_unused_col;
101102
#define HWCTX_STAT_INIT 0
102103
#define HWCTX_STAT_READY 1
103104
#define HWCTX_STAT_STOP 2

drivers/accel/amdxdna/npu4_regs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const struct dpm_clk_freq npu4_dpm_clk_table[] = {
9090
const struct aie2_fw_feature_tbl npu4_fw_feature_table[] = {
9191
{ .feature = AIE2_NPU_COMMAND, .min_minor = 15 },
9292
{ .feature = AIE2_PREEMPT, .min_minor = 12 },
93+
{ .feature = AIE2_TEMPORAL_ONLY, .min_minor = 12 },
9394
{ 0 }
9495
};
9596

0 commit comments

Comments
 (0)