Skip to content

Commit

Permalink
Cherry picks #7519 & #7527 for 2023.1 branch (#7534)
Browse files Browse the repository at this point in the history
* CR-1160935 : Fixed a issue for xbtest invalid card BDF (#7519)

* Fixed a issue for xbtest invalid card BDF

* Fixed a issue for xbtest invalid card BDF

Signed-off-by: Saifuddin <saifuddi@xilinx.com>

* incorporate review comments

Signed-off-by: Saifuddin <saifuddi@xilinx.com>

---------

Signed-off-by: Saifuddin <saifuddi@xilinx.com>
(cherry picked from commit e5ba80c)

* Fixed xocl driver issues (#7527)

Signed-off-by: Saifuddin <saifuddi@xilinx.com>
(cherry picked from commit 5cc7361)
  • Loading branch information
saifuddin-xilinx authored May 3, 2023
1 parent aeda151 commit adf27ad
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
22 changes: 13 additions & 9 deletions src/runtime_src/core/pcie/driver/linux/xocl/userpf/xocl_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,16 +559,20 @@ __xocl_create_bo_ioctl(struct drm_device *dev, struct drm_file *filp,
uint32_t slot_id = 0;
int ret;

/* Currently userspace will provide the corresponding hw context id.
* Driver has to map that hw context to the corresponding slot id.
*/
hw_ctx_id = xocl_bo_slot_idx(args->flags);
ret = xocl_get_slot_id_by_hw_ctx_id(xdev, filp, hw_ctx_id);
if (ret < 0)
return ERR_PTR(ret);
if (bo_type != XOCL_BO_EXECBUF) {
/* Currently userspace will provide the corresponding hw context id.
* Driver has to map that hw context to the corresponding slot id.
* This is not valid for Host memory.
*/
hw_ctx_id = xocl_bo_slot_idx(args->flags);
ret = xocl_get_slot_id_by_hw_ctx_id(xdev, filp, hw_ctx_id);
if (ret < 0)
return ERR_PTR(ret);

slot_id = ret;
args->flags = xocl_bo_set_slot_idx(args->flags, slot_id);
}

slot_id = ret;
args->flags = xocl_bo_set_slot_idx(args->flags, slot_id);
xobj = xocl_create_bo(dev, args->size, args->flags, bo_type);
if (IS_ERR(xobj)) {
DRM_ERROR("object creation failed idx %d, size 0x%llx\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ static int xocl_mm_insert_node_range_all(struct xocl_drm *drm_p, uint32_t *mem_i

phy_bank_exists = true;
start_addr = mem_data->m_base_address;
end_addr = start_addr + mem_data->m_size;
end_addr = start_addr + mem_data->m_size * 1024;

#if defined(XOCL_DRM_FREE_MALLOC)
ret = drm_mm_insert_node_in_range(xocl_mm->mm, dnode, size, PAGE_SIZE, 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,6 @@ xocl_read_axlf_helper(struct xocl_drm *drm_p, struct drm_xocl_axlf *axlf_ptr,
}

done:
/* Update the slot */
*slot = slot_id;
if (size < 0)
err = size;
if (err) {
Expand All @@ -766,6 +764,8 @@ xocl_read_axlf_helper(struct xocl_drm *drm_p, struct drm_xocl_axlf *axlf_ptr,
userpf_info(xdev, "Loaded xclbin %pUb", &bin_obj.m_header.uuid);

out_done:
/* Update the slot */
*slot = slot_id;
vfree(axlf);
return err;
}
Expand Down
22 changes: 14 additions & 8 deletions src/runtime_src/core/pcie/linux/system_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,23 @@ std::shared_ptr<pci::dev>
system_linux::
get_pcidev(unsigned index, bool is_user) const
{
if (is_user) {
if (index < user_ready_list.size())
return user_ready_list[index];
try {
if (is_user) {
if (index < user_ready_list.size())
return user_ready_list[index];

return user_nonready_list[index - user_ready_list.size()];
}
if ((index - user_ready_list.size()) < user_nonready_list.size())
return user_nonready_list.at(index - user_ready_list.size());
}

if (index < mgmt_ready_list.size())
return mgmt_ready_list[index];
if (index < mgmt_ready_list.size())
return mgmt_ready_list[index];

return mgmt_nonready_list[index - mgmt_ready_list.size()];
return mgmt_nonready_list.at(index - mgmt_ready_list.size());
}
catch (const std::exception&) {
return nullptr;
}
}

size_t
Expand Down

0 comments on commit adf27ad

Please sign in to comment.