Commit 7818618a authored by Lizhi Hou's avatar Lizhi Hou
Browse files

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: default avatarMario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: default avatarLizhi Hou <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20251217191150.2145937-1-lizhi.hou@amd.com
parent 3ef93841
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -468,6 +468,12 @@ static int aie2_alloc_resource(struct amdxdna_hwctx *hwctx)
	struct alloc_requests *xrs_req;
	int ret;

	if (AIE2_FEATURE_ON(xdna->dev_handle, AIE2_TEMPORAL_ONLY)) {
		hwctx->num_unused_col = xdna->dev_handle->total_col - hwctx->num_col;
		hwctx->num_col = xdna->dev_handle->total_col;
		return aie2_create_context(xdna->dev_handle, hwctx);
	}

	xrs_req = kzalloc(sizeof(*xrs_req), GFP_KERNEL);
	if (!xrs_req)
		return -ENOMEM;
@@ -499,10 +505,16 @@ static void aie2_release_resource(struct amdxdna_hwctx *hwctx)
	struct amdxdna_dev *xdna = hwctx->client->xdna;
	int ret;

	if (AIE2_FEATURE_ON(xdna->dev_handle, AIE2_TEMPORAL_ONLY)) {
		ret = aie2_destroy_context(xdna->dev_handle, hwctx);
		if (ret)
			XDNA_ERR(xdna, "Destroy temporal only context failed, ret %d", ret);
	} else {
		ret = xrs_release_resource(xdna->xrs_hdl, (uintptr_t)hwctx);
		if (ret)
			XDNA_ERR(xdna, "Release AIE resource failed, ret %d", ret);
	}
}

static int aie2_ctx_syncobj_create(struct amdxdna_hwctx *hwctx)
{
+1 −0
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ int aie2_create_context(struct amdxdna_dev_hdl *ndev, struct amdxdna_hwctx *hwct
	req.aie_type = 1;
	req.start_col = hwctx->start_col;
	req.num_col = hwctx->num_col;
	req.num_unused_col = hwctx->num_unused_col;
	req.num_cq_pairs_requested = 1;
	req.pasid = hwctx->client->pasid;
	req.context_priority = 2;
+2 −1
Original line number Diff line number Diff line
@@ -112,7 +112,8 @@ struct create_ctx_req {
	__u32	aie_type;
	__u8	start_col;
	__u8	num_col;
	__u16	reserved;
	__u8    num_unused_col;
	__u8	reserved;
	__u8	num_cq_pairs_requested;
	__u8	reserved1;
	__u16	pasid;
+1 −0
Original line number Diff line number Diff line
@@ -232,6 +232,7 @@ struct aie2_hw_ops {
enum aie2_fw_feature {
	AIE2_NPU_COMMAND,
	AIE2_PREEMPT,
	AIE2_TEMPORAL_ONLY,
	AIE2_FEATURE_MAX
};

+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ struct amdxdna_hwctx {
	u32				*col_list;
	u32				start_col;
	u32				num_col;
	u32				num_unused_col;
#define HWCTX_STAT_INIT  0
#define HWCTX_STAT_READY 1
#define HWCTX_STAT_STOP  2
Loading