Skip to content

Commit 3320707

Browse files
committed
accel/amdxdna: Enable hardware context priority
Newer firmware supports hardware context priority. Set the priority based on application input. Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://patch.msgid.link/20251217171719.2139025-1-lizhi.hou@amd.com
1 parent 7818618 commit 3320707

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

drivers/accel/amdxdna/aie2_message.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,27 @@ static int aie2_destroy_context_req(struct amdxdna_dev_hdl *ndev, u32 id)
205205

206206
return ret;
207207
}
208+
209+
static u32 aie2_get_context_priority(struct amdxdna_dev_hdl *ndev,
210+
struct amdxdna_hwctx *hwctx)
211+
{
212+
if (!AIE2_FEATURE_ON(ndev, AIE2_PREEMPT))
213+
return PRIORITY_HIGH;
214+
215+
switch (hwctx->qos.priority) {
216+
case AMDXDNA_QOS_REALTIME_PRIORITY:
217+
return PRIORITY_REALTIME;
218+
case AMDXDNA_QOS_HIGH_PRIORITY:
219+
return PRIORITY_HIGH;
220+
case AMDXDNA_QOS_NORMAL_PRIORITY:
221+
return PRIORITY_NORMAL;
222+
case AMDXDNA_QOS_LOW_PRIORITY:
223+
return PRIORITY_LOW;
224+
default:
225+
return PRIORITY_HIGH;
226+
}
227+
}
228+
208229
int aie2_create_context(struct amdxdna_dev_hdl *ndev, struct amdxdna_hwctx *hwctx)
209230
{
210231
DECLARE_AIE2_MSG(create_ctx, MSG_OP_CREATE_CONTEXT);
@@ -221,7 +242,7 @@ int aie2_create_context(struct amdxdna_dev_hdl *ndev, struct amdxdna_hwctx *hwct
221242
req.num_unused_col = hwctx->num_unused_col;
222243
req.num_cq_pairs_requested = 1;
223244
req.pasid = hwctx->client->pasid;
224-
req.context_priority = 2;
245+
req.context_priority = aie2_get_context_priority(ndev, hwctx);
225246

226247
ret = aie2_send_mgmt_msg_wait(ndev, &msg);
227248
if (ret)

drivers/accel/amdxdna/aie2_msg_priv.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ struct cq_pair {
108108
struct cq_info i2x_q;
109109
};
110110

111+
#define PRIORITY_REALTIME 1
112+
#define PRIORITY_HIGH 2
113+
#define PRIORITY_NORMAL 3
114+
#define PRIORITY_LOW 4
115+
111116
struct create_ctx_req {
112117
__u32 aie_type;
113118
__u8 start_col;

include/uapi/drm/amdxdna_accel.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ extern "C" {
1919
#define AMDXDNA_INVALID_BO_HANDLE 0
2020
#define AMDXDNA_INVALID_FENCE_HANDLE 0
2121

22+
/*
23+
* Define hardware context priority
24+
*/
25+
#define AMDXDNA_QOS_REALTIME_PRIORITY 0x100
26+
#define AMDXDNA_QOS_HIGH_PRIORITY 0x180
27+
#define AMDXDNA_QOS_NORMAL_PRIORITY 0x200
28+
#define AMDXDNA_QOS_LOW_PRIORITY 0x280
29+
2230
enum amdxdna_device_type {
2331
AMDXDNA_DEV_TYPE_UNKNOWN = -1,
2432
AMDXDNA_DEV_TYPE_KMQ,

0 commit comments

Comments
 (0)