Skip to content

Commit adf27ad

Browse files
Cherry picks #7519 & #7527 for 2023.1 branch (#7534)
* 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 <[email protected]> * incorporate review comments Signed-off-by: Saifuddin <[email protected]> --------- Signed-off-by: Saifuddin <[email protected]> (cherry picked from commit e5ba80c) * Fixed xocl driver issues (#7527) Signed-off-by: Saifuddin <[email protected]> (cherry picked from commit 5cc7361)
1 parent aeda151 commit adf27ad

File tree

4 files changed

+30
-20
lines changed

4 files changed

+30
-20
lines changed

src/runtime_src/core/pcie/driver/linux/xocl/userpf/xocl_bo.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -559,16 +559,20 @@ __xocl_create_bo_ioctl(struct drm_device *dev, struct drm_file *filp,
559559
uint32_t slot_id = 0;
560560
int ret;
561561

562-
/* Currently userspace will provide the corresponding hw context id.
563-
* Driver has to map that hw context to the corresponding slot id.
564-
*/
565-
hw_ctx_id = xocl_bo_slot_idx(args->flags);
566-
ret = xocl_get_slot_id_by_hw_ctx_id(xdev, filp, hw_ctx_id);
567-
if (ret < 0)
568-
return ERR_PTR(ret);
562+
if (bo_type != XOCL_BO_EXECBUF) {
563+
/* Currently userspace will provide the corresponding hw context id.
564+
* Driver has to map that hw context to the corresponding slot id.
565+
* This is not valid for Host memory.
566+
*/
567+
hw_ctx_id = xocl_bo_slot_idx(args->flags);
568+
ret = xocl_get_slot_id_by_hw_ctx_id(xdev, filp, hw_ctx_id);
569+
if (ret < 0)
570+
return ERR_PTR(ret);
571+
572+
slot_id = ret;
573+
args->flags = xocl_bo_set_slot_idx(args->flags, slot_id);
574+
}
569575

570-
slot_id = ret;
571-
args->flags = xocl_bo_set_slot_idx(args->flags, slot_id);
572576
xobj = xocl_create_bo(dev, args->size, args->flags, bo_type);
573577
if (IS_ERR(xobj)) {
574578
DRM_ERROR("object creation failed idx %d, size 0x%llx\n",

src/runtime_src/core/pcie/driver/linux/xocl/userpf/xocl_drm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ static int xocl_mm_insert_node_range_all(struct xocl_drm *drm_p, uint32_t *mem_i
715715

716716
phy_bank_exists = true;
717717
start_addr = mem_data->m_base_address;
718-
end_addr = start_addr + mem_data->m_size;
718+
end_addr = start_addr + mem_data->m_size * 1024;
719719

720720
#if defined(XOCL_DRM_FREE_MALLOC)
721721
ret = drm_mm_insert_node_in_range(xocl_mm->mm, dnode, size, PAGE_SIZE, 0,

src/runtime_src/core/pcie/driver/linux/xocl/userpf/xocl_ioctl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,6 @@ xocl_read_axlf_helper(struct xocl_drm *drm_p, struct drm_xocl_axlf *axlf_ptr,
744744
}
745745

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

768766
out_done:
767+
/* Update the slot */
768+
*slot = slot_id;
769769
vfree(axlf);
770770
return err;
771771
}

src/runtime_src/core/pcie/linux/system_linux.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,23 @@ std::shared_ptr<pci::dev>
127127
system_linux::
128128
get_pcidev(unsigned index, bool is_user) const
129129
{
130-
if (is_user) {
131-
if (index < user_ready_list.size())
132-
return user_ready_list[index];
130+
try {
131+
if (is_user) {
132+
if (index < user_ready_list.size())
133+
return user_ready_list[index];
133134

134-
return user_nonready_list[index - user_ready_list.size()];
135-
}
135+
if ((index - user_ready_list.size()) < user_nonready_list.size())
136+
return user_nonready_list.at(index - user_ready_list.size());
137+
}
136138

137-
if (index < mgmt_ready_list.size())
138-
return mgmt_ready_list[index];
139+
if (index < mgmt_ready_list.size())
140+
return mgmt_ready_list[index];
139141

140-
return mgmt_nonready_list[index - mgmt_ready_list.size()];
142+
return mgmt_nonready_list.at(index - mgmt_ready_list.size());
143+
}
144+
catch (const std::exception&) {
145+
return nullptr;
146+
}
141147
}
142148

143149
size_t

0 commit comments

Comments
 (0)