-
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
Conversation
Signed-off-by: rave <karthik>
#ifdef XCLBIN_FULL_READ | ||
auto xclbin_full = xrt_core::device_query<xrt_core::query::xclbin_full>(this); | ||
if (xclbin_full.empty()) | ||
throw error(ENODEV, "no cached xclbin data"); | ||
|
||
const axlf* top = reinterpret_cast<axlf *>(xclbin_full.data()); | ||
const axlf* skd_axlf_ptr = reinterpret_cast<axlf *>(xclbin_full.data()); | ||
#else | ||
uint64_t ps_uuid_ptr = reinterpret_cast<uint64_t>(xclbin_id.get()); | ||
const axlf* skd_axlf_ptr; | ||
char* buf = new char[MAX_AXLF_BUF_SIZE]; | ||
|
||
if (!buf) | ||
throw error(ENOMEM, "Cannot allocate axlf buffer"); | ||
|
||
skd_axlf_ptr = reinterpret_cast<axlf*> (buf); | ||
xrt_core::query::aie_skd_xclbin::args arg = {reinterpret_cast<uint64_t>(ps_uuid_ptr), reinterpret_cast<uint64_t>(skd_axlf_ptr)}; | ||
|
||
try { | ||
xrt_core::device_query<xrt_core::query::aie_skd_xclbin>(this, arg); | ||
} | ||
catch (const std::exception &e) { | ||
std::cerr << boost::format("ERROR: Failed to get xclbin for uuid (%lx)\n %s\n") % uuid_loaded.get() % e.what(); | ||
throw xrt_core::error(std::errc::operation_canceled); | ||
} | ||
#endif |
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.
This needs commenting and cannot use new
.
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 another query to read axlf size, please review
@@ -108,6 +108,8 @@ typedef GUID xuid_t; | |||
#define SIZE_OF_STRUCT(s) \ | |||
char (*__fail)[sizeof(struct s)] = 1 | |||
|
|||
#define MAX_AXLF_BUF_SIZE (4096*1024) |
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.
Looks random. What is this and why?
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.
Removed
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.
i Still see this macro
@@ -3819,6 +3820,23 @@ struct read_trace_data : request | |||
virtual std::any | |||
get(const device*, const std::any&) const = 0; | |||
}; | |||
|
|||
struct aie_skd_xclbin : request |
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
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.
As discussed offline, Please simplify the logic and update existing load_xclbin to support this case also.
No new #ifdefs . We are already struggling to remove AIE* defines
Signed-off-by: rave <karthik>
Signed-off-by: rave <karthik>
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
This index should come as an input.
Think about, if two or more PS XCLBINs are loaded
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.
this is a dead code, sysfs functionality is being used anymore
} | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct the format
for (i = 0; i < MAX_PR_SLOT_NUM; i++)
|
||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
if (!slot)
continue;
} | ||
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 comment
The 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]; | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Sanity check for unused slot
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 comment
The reason will be displayed to describe this comment to others. Learn more.
mutex_unlock(&zdev->aie_lock);
Signed-off-by: rave <karthik>
@@ -108,6 +108,8 @@ typedef GUID xuid_t; | |||
#define SIZE_OF_STRUCT(s) \ | |||
char (*__fail)[sizeof(struct s)] = 1 | |||
|
|||
#define MAX_AXLF_BUF_SIZE (4096*1024) |
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.
i Still see this macro
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
remove the new line?
if (fd_obj->fd < 0) | ||
throw xrt_core::error(-EINVAL, boost::str(boost::format("Cannot open %s") % zocl_device)); | ||
|
||
if (ioctl(fd_obj->fd, DRM_IOCTL_ZOCL_SKD_AXLF_SIZE, &aie_arg)) |
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.
please dont call ioctls from here. create shim function and call it..
struct drm_zocl_skd_axlf_size aie_arg; | ||
aie_arg.ps_uuid_ptr = std::any_cast<xrt_core::query::skd_axlf_size::ps_uuid_ptr_type>(skd_uuid_ptr); | ||
|
||
const std::string zocl_device = "/dev/dri/" + get_render_devname(); |
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.
shim function should take care of this. please dont repeat the logic
aie_arg.ps_uuid_ptr = std::any_cast<xrt_core::query::aie_skd_xclbin::ps_uuid_ptr_type>(args.ps_uuid_ptr); | ||
aie_arg.skd_axlf_ptr = std::any_cast<xrt_core::query::aie_skd_xclbin::skd_axlf_ptr_type>(args.skd_axlf_ptr); | ||
|
||
const std::string zocl_device = "/dev/dri/" + get_render_devname(); |
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.
same as below. create shim function to handle this
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
NUM_IOCTL should be at the end. it should be last macro.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
add comment for this too.
|
||
const axlf* top = reinterpret_cast<axlf *>(xclbin_full.data()); | ||
xrt_core::query::aie_skd_xclbin::args arg = {reinterpret_cast<uint64_t>(ps_uuid_ptr), reinterpret_cast<uint64_t>(buf.data())}; |
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.
Signed-off-by: rave <karthik>
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
if (!slot)
continue;
Signed-off-by: rave <karthik>
Hi @karthdmg-xilinx , |
Not handling the multi slot changes for now, hence rejecting this PR |
Problem solved by the commit
The existing code reads/assumes ps kernel slot at 0th index by default when loading the xclbin based on UUID.
Made changes such that User queries based on UUID using IOCTL and reads the appropriate AXLF buffer.
Bug / issue (if any) fixed, which PR introduced the bug, how it was discovered
Program PS kernel on latest XRT.
How problem was solved, alternative solutions (if any) and why they were rejected
eliminate hard codes changes of loading ps kernel.
Risks (if any) associated the changes in the commit
None
What has been tested and how, request additional testing if necessary
Program PS, PL/PS and AIE kernels and verify the behavior.
Documentation impact (if any)
Need to update multi slot behavior for ps kernels.