-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ps kernel hard code handling changes #8276
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,6 +324,8 @@ enum class key_type | |
kernel_max_bandwidth_mbps, | ||
sub_device_path, | ||
read_trace_data, | ||
aie_skd_xclbin, | ||
skd_axlf_size, | ||
noop | ||
}; | ||
|
||
|
@@ -3819,6 +3821,36 @@ struct read_trace_data : request | |
virtual std::any | ||
get(const device*, const std::any&) const = 0; | ||
}; | ||
|
||
/* SKD Request to load xclbin for a specific UUID */ | ||
struct aie_skd_xclbin : request | ||
{ | ||
using result_type = uint32_t; | ||
using skd_uuid_ptr_type = uint64_t; | ||
using skd_axlf_ptr_type = uint64_t; | ||
|
||
static const key_type key = key_type::aie_skd_xclbin; | ||
struct args { | ||
uint64_t skd_uuid_ptr; | ||
uint64_t skd_axlf_ptr; | ||
}; | ||
|
||
virtual std::any | ||
get(const device*, const std::any& skd_uuid_ptr, const std::any& skd_axlf_ptr) const = 0; | ||
}; | ||
|
||
/* SKD Request to read the axlf size for a specific uuid */ | ||
struct skd_axlf_size : request | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add comment for this too. |
||
{ | ||
using skd_uuid_ptr_type = uint64_t; | ||
using result_type = uint32_t; | ||
|
||
static const key_type key = key_type::skd_axlf_size; | ||
|
||
virtual std::any | ||
get(const device*, const std::any& skd_uuid_ptr) const = 0; | ||
}; | ||
|
||
} // query | ||
|
||
} // xrt_core | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
#include "zocl_aie.h" | ||
#include "xrt_xclbin.h" | ||
#include "xclbin.h" | ||
#include "zocl_xclbin.h" | ||
|
||
#ifndef __NONE_PETALINUX__ | ||
#include <linux/xlnx-ai-engine.h> | ||
|
@@ -552,6 +553,99 @@ int zocl_aie_freqscale(struct drm_zocl_dev *zdev, void *data) | |
} | ||
} | ||
|
||
int zocl_aie_skd_xclbin(struct drm_zocl_dev *zdev, void *data) | ||
{ | ||
struct drm_zocl_aie_skd_xclbin *args = data; | ||
struct drm_zocl_slot *zocl_slot = NULL; | ||
uuid_t *slot_uuid = NULL; | ||
uuid_t *skd_uuid = NULL; | ||
int i, slot_id = MAX_PR_SLOT_NUM, ret = 0; | ||
void *uuid_ptr = (void *)(uintptr_t)args->skd_uuid_ptr; | ||
|
||
skd_uuid = vmalloc(sizeof(uuid_t)); | ||
if (!skd_uuid) | ||
return -ENOMEM; | ||
|
||
ret = copy_from_user(skd_uuid, uuid_ptr, sizeof(uuid_t)); | ||
if (ret) { | ||
vfree(skd_uuid); | ||
return ret; | ||
} | ||
mutex_lock(&zdev->aie_lock); | ||
|
||
for (i = 0; i < MAX_PR_SLOT_NUM; i++) { | ||
struct drm_zocl_slot *slot = NULL; | ||
slot = zdev->pr_slot[i]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sanity Check required, before accessing the fields There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (!slot) |
||
mutex_lock(&zdev->pr_slot[i]->slot_xclbin_lock); | ||
slot_uuid = zocl_xclbin_get_uuid(zdev->pr_slot[i]); | ||
if(slot_uuid) { | ||
if(uuid_equal(slot_uuid, skd_uuid)) { | ||
slot_id = i; | ||
mutex_unlock(&zdev->pr_slot[i]->slot_xclbin_lock); | ||
break; | ||
} | ||
} | ||
mutex_unlock(&zdev->pr_slot[i]->slot_xclbin_lock); | ||
} | ||
zocl_slot = zdev->pr_slot[slot_id]; | ||
ret = copy_to_user(args->skd_axlf_ptr, (char *)zocl_slot->axlf, zocl_slot->axlf_size); | ||
if (ret) { | ||
vfree(skd_uuid); | ||
mutex_unlock(&zdev->aie_lock); | ||
return ret; | ||
} | ||
mutex_unlock(&zdev->aie_lock); | ||
vfree(skd_uuid); | ||
return 0; | ||
} | ||
|
||
int zocl_skd_axlf_size(struct drm_zocl_dev *zdev, void *data) | ||
{ | ||
struct drm_zocl_skd_axlf_size *args = data; | ||
struct drm_zocl_slot *zocl_slot = NULL; | ||
uuid_t *slot_uuid = NULL; | ||
uuid_t *skd_uuid = NULL; | ||
int i, slot_id = MAX_PR_SLOT_NUM, ret = 0; | ||
void *uuid_ptr = (void *)(uintptr_t)args->skd_uuid_ptr; | ||
|
||
skd_uuid = vmalloc(sizeof(uuid_t)); | ||
if (!skd_uuid) | ||
return -ENOMEM; | ||
|
||
ret = copy_from_user(skd_uuid, uuid_ptr, sizeof(uuid_t)); | ||
if (ret) { | ||
vfree(skd_uuid); | ||
return ret; | ||
} | ||
mutex_lock(&zdev->aie_lock); | ||
|
||
for (i = 0; i < MAX_PR_SLOT_NUM; i++) { | ||
struct drm_zocl_slot *slot = NULL; | ||
slot = zdev->pr_slot[i]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (!slot) |
||
mutex_lock(&zdev->pr_slot[i]->slot_xclbin_lock); | ||
slot_uuid = zocl_xclbin_get_uuid(zdev->pr_slot[i]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sanity check for unused slot |
||
if(slot_uuid) { | ||
if(uuid_equal(slot_uuid, skd_uuid)) { | ||
slot_id = i; | ||
mutex_unlock(&zdev->pr_slot[i]->slot_xclbin_lock); | ||
break; | ||
} | ||
} | ||
mutex_unlock(&zdev->pr_slot[i]->slot_xclbin_lock); | ||
} | ||
if(i == MAX_PR_SLOT_NUM) | ||
{ | ||
DRM_ERROR(" %s: UUID not found \n",__func__); | ||
mutex_unlock(&zdev->aie_lock); | ||
return -ENODEV; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mutex_unlock(&zdev->aie_lock); |
||
} | ||
zocl_slot = zdev->pr_slot[slot_id]; | ||
args->axlf_size = zocl_slot->axlf_size; | ||
|
||
mutex_unlock(&zdev->aie_lock); | ||
return 0; | ||
} | ||
|
||
int | ||
zocl_aie_kds_add_graph_context(struct drm_zocl_dev *zdev, u32 gid, | ||
u32 ctx_code, struct kds_client *client) | ||
|
@@ -843,4 +937,4 @@ zocl_init_aie(struct drm_zocl_dev *zdev) | |
zdev->aie_information = aie; | ||
|
||
return 0; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment about this request type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added