-
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 3 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,35 @@ 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 | ||
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 a comment about this request type. 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. Added |
||
{ | ||
using result_type = bool; | ||
using ps_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 ps_uuid_ptr; | ||
uint64_t skd_axlf_ptr; | ||
}; | ||
|
||
virtual std::any | ||
get(const device*, const std::any& arg) const = 0; | ||
}; | ||
|
||
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 ps_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& ps_uuid_ptr) const = 0; | ||
}; | ||
|
||
} // query | ||
|
||
} // xrt_core | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -600,7 +600,7 @@ static ssize_t read_xclbin_full(struct file *filp, struct kobject *kobj, | |
read_lock(&zdev->attr_rwlock); | ||
|
||
// Only read slot 0's xclbin - TODO: extend to multi-slot | ||
zocl_slot = zdev->pr_slot[0]; | ||
zocl_slot = zdev->pr_slot[1]; | ||
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. This index should come as an input. 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. this is a dead code, sysfs functionality is being used anymore |
||
if (!zocl_slot || !zocl_slot->axlf) { | ||
read_unlock(&zdev->attr_rwlock); | ||
return 0; | ||
|
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,98 @@ 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->ps_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++) { | ||
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. Please correct the format |
||
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->ps_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++) { | ||
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. Please correct the format |
||
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__); | ||
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 +936,4 @@ zocl_init_aie(struct drm_zocl_dev *zdev) | |
zdev->aie_information = aie; | ||
|
||
return 0; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,7 +124,9 @@ enum drm_zocl_ops { | |
DRM_ZOCL_AIE_FREQSCALE, | ||
/* Set CU read-only range */ | ||
DRM_ZOCL_SET_CU_READONLY_RANGE, | ||
DRM_ZOCL_NUM_IOCTLS | ||
DRM_ZOCL_NUM_IOCTLS, | ||
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. NUM_IOCTL should be at the end. it should be last macro. |
||
DRM_ZOCL_AIE_SKD_XCLBIN, | ||
DRM_ZOCL_SKD_AXLF_SIZE | ||
}; | ||
|
||
enum drm_zocl_sync_bo_dir { | ||
|
@@ -548,6 +550,16 @@ struct drm_zocl_error_inject { | |
uint16_t err_class; | ||
}; | ||
|
||
struct drm_zocl_aie_skd_xclbin { | ||
uint64_t skd_axlf_ptr; | ||
uint64_t ps_uuid_ptr; | ||
}; | ||
|
||
struct drm_zocl_skd_axlf_size { | ||
uint64_t ps_uuid_ptr; | ||
uint32_t axlf_size; | ||
}; | ||
|
||
#define DRM_IOCTL_ZOCL_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + \ | ||
DRM_ZOCL_CREATE_BO, \ | ||
struct drm_zocl_create_bo) | ||
|
@@ -596,4 +608,8 @@ struct drm_zocl_error_inject { | |
DRM_ZOCL_AIE_FREQSCALE, struct drm_zocl_aie_freq_scale) | ||
#define DRM_IOCTL_ZOCL_SET_CU_READONLY_RANGE DRM_IOWR(DRM_COMMAND_BASE + \ | ||
DRM_ZOCL_SET_CU_READONLY_RANGE, struct drm_zocl_set_cu_range) | ||
#define DRM_IOCTL_ZOCL_AIE_SKD_XCLBIN DRM_IOWR(DRM_COMMAND_BASE + \ | ||
DRM_ZOCL_AIE_SKD_XCLBIN, struct drm_zocl_aie_skd_xclbin) | ||
#define DRM_IOCTL_ZOCL_SKD_AXLF_SIZE DRM_IOWR(DRM_COMMAND_BASE + \ | ||
DRM_ZOCL_SKD_AXLF_SIZE, struct drm_zocl_skd_axlf_size) | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ namespace xrt { | |
m_parent_bo_handle(xrt::shim_int::get_buffer_handle(xrtDeviceToXclDevice(handle), parent_mem_bo_in)), | ||
m_mem_start_paddr(mem_start_paddr_in), | ||
m_mem_size(mem_size_in) | ||
|
||
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. remove the new line? |
||
{ | ||
} | ||
|
||
|
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.
ps_uuid_ptr is already uint64_t, dont call reinterpret cast.