Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/clangtidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ jobs:
# Review uses external combined database
- name: Create clang-tidy review
id: review
# continue-on-error allows the job to pass when the GitHub PR diff API
# returns HTTP 406 (diff exceeds the 300-file limit). The upload step
# is guarded by `steps.review.outcome == 'success'` so it only runs
# when the review was actually generated.
continue-on-error: true
uses: stsoe/clang-tidy-review@patches
with:
apt_packages: |
Expand All @@ -98,5 +103,6 @@ jobs:
split_workflow: true

- name: Upload clang-tidy review
if: steps.review.outcome == 'success'
uses: stsoe/clang-tidy-review/upload@patches
id: upload-review
18 changes: 9 additions & 9 deletions src/runtime_src/core/edge/drm/zocl/edge/zocl_hwctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,26 @@ static int zocl_cu_ctx_to_info(struct drm_zocl_dev *zdev, struct drm_zocl_open_c
{
uint32_t slot_hndl = kds_hw_ctx->slot_idx;
struct kds_sched *kds = &zdev->kds;
char *kname_p = drm_cu_ctx->cu_name;
char name[CU_NAME_MAX_LEN + 1];
char *kname_p = name;
char *token;
struct xrt_cu *xcu = NULL;
char iname[CU_NAME_MAX_LEN];
char kname[CU_NAME_MAX_LEN];
int i = 0;

strcpy(kname, strsep(&kname_p, ":"));
strcpy(iname, strsep(&kname_p, ":"));
memcpy(name, drm_cu_ctx->cu_name, CU_NAME_MAX_LEN);
name[CU_NAME_MAX_LEN] = '\0';
token = strsep(&kname_p, ":");
strscpy(kname, token ? token : "", sizeof(kname));
token = strsep(&kname_p, ":");
strscpy(iname, token ? token : "", sizeof(iname));

/* Retrive the CU index from the given slot */
for (i = 0; i < MAX_CUS; i++) {
xcu = kds->cu_mgmt.xcus[i];
if (!xcu)
continue;

if ((xcu->info.slot_idx == slot_hndl) && (!strcmp(xcu->info.kname, kname)) && (!strcmp(xcu->info.iname, iname))) {
kds_cu_info->cu_domain = DOMAIN_PL;
kds_cu_info->cu_idx = i;
goto done;
}
}
Comment on lines 116 to 127

/* Retrive the SCU index from the given slot */
Expand Down
13 changes: 10 additions & 3 deletions src/runtime_src/core/edge/drm/zocl/zert/zocl_ctrl_ert.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ static inline u32 reg_read(void __iomem *base, u64 off)

static void cu_conf2info(struct xgq_cmd_config_cu *conf, struct xrt_cu_info *info)
{
char *kname_p = conf->name;
char name[sizeof(conf->name) + 1];
char *kname_p = name;
char *token;

memcpy(name, conf->name, sizeof(conf->name));
name[sizeof(conf->name)] = 0;

memset(info, 0, sizeof(*info));
info->num_res = 1;
Expand All @@ -176,8 +181,10 @@ static void cu_conf2info(struct xgq_cmd_config_cu *conf, struct xrt_cu_info *inf
info->model = XCU_HLS;
info->cu_domain = conf->cu_domain;
info->cu_idx = conf->cu_idx;
strcpy(info->kname, strsep(&kname_p, ":"));
strcpy(info->iname, strsep(&kname_p, ":"));
token = strsep(&kname_p, ":");
strscpy(info->kname, token ? token : "", sizeof(info->kname));
token = strsep(&kname_p, ":");
strscpy(info->iname, token ? token : "", sizeof(info->iname));
memcpy(info->uuid, conf->uuid, sizeof(info->uuid));
}

Expand Down
73 changes: 37 additions & 36 deletions src/runtime_src/core/pcie/driver/linux/xocl/subdev/ert_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,47 +493,48 @@ static void ert_ctrl_submit_exit_cmd(struct ert_ctrl *ec)

static bool ert_ctrl_abort_sync(struct kds_ert *ert, struct kds_client *client, int cu_idx)
{
return true;
}

static inline int ert_ctrl_alloc_ert_xgq(struct ert_ctrl *ec, int num)
{
void *tmp;

if (num <= ec->ec_exgq_capacity)
return 0;

if (num > MAX_CU_XGQ)
return -EINVAL;

tmp = kzalloc(sizeof(ec->ec_exgq[0]) * num, GFP_KERNEL);
if (!tmp)
return -ENOMEM;

if (!ec->ec_exgq_capacity) {
ec->ec_exgq = tmp;
ec->ec_exgq_capacity = num;
return 0;
struct kds_client_hw_ctx *hw_ctx;
unsigned long submitted = 0, completed = 0;
int timeout_ms = 5000;

/* Sum submitted and completed counts across all hw contexts */
list_for_each_entry(hw_ctx, &client->hw_ctx_list, link) {
int i;

for (i = 0; i < MAX_CUS; i++) {
submitted += stat_read(hw_ctx->stats, s_cnt[i]);
submitted += stat_read(hw_ctx->stats, scu_s_cnt[i]);
completed += stat_read(hw_ctx->stats, c_cnt[i]);
completed += stat_read(hw_ctx->stats, scu_c_cnt[i]);
}
}

memcpy(tmp, ec->ec_exgq, sizeof(void *) * ec->ec_exgq_capacity);
kfree(ec->ec_exgq);
ec->ec_exgq = tmp;
ec->ec_exgq_capacity = num;
if (submitted == completed)
return false;

return 0;
}
/* Wait for in-flight commands to drain before client is freed */
do {
msleep(500);
timeout_ms -= 500;
submitted = 0;
completed = 0;
list_for_each_entry(hw_ctx, &client->hw_ctx_list, link) {
int i;

static int ert_ctrl_legacy_init(struct ert_ctrl *ec)
{
struct xocl_subdev_info subdev_info = XOCL_DEVINFO_COMMAND_QUEUE;
xdev_handle_t xdev = xocl_get_xdev(ec->ec_pdev);
struct xocl_ert_cq_privdata priv = {0};
int err = 0;

priv.cq_base = ec->ec_cq_base;
priv.cq_range = ec->ec_cq_range;
for (i = 0; i < MAX_CUS; i++) {
submitted += stat_read(hw_ctx->stats, s_cnt[i]);
submitted += stat_read(hw_ctx->stats, scu_s_cnt[i]);
completed += stat_read(hw_ctx->stats, c_cnt[i]);
completed += stat_read(hw_ctx->stats, scu_c_cnt[i]);
}
}
if (submitted == completed)
return false;
} while (timeout_ms > 0);

return true;
}
537
subdev_info.priv_data = &priv;
subdev_info.data_len = sizeof(priv);
Comment on lines +535 to 577
err = xocl_subdev_create(xdev, &subdev_info);
Expand Down
26 changes: 13 additions & 13 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 @@ -1470,7 +1470,7 @@ static bool xocl_validate_paddr(struct xocl_dev *xdev, u64 paddr, u64 size)
#endif

int xocl_pwrite_unmgd_ioctl(struct drm_device *dev, void *data,
struct drm_file *filp)
struct drm_file *filp)
{
const struct drm_xocl_pwrite_unmgd *args = data;
struct xocl_drm *drm_p = dev->dev_private;
Expand All @@ -1482,27 +1482,19 @@ int xocl_pwrite_unmgd_ioctl(struct drm_device *dev, void *data,
return -EFAULT;
}

if (!capable(CAP_SYS_ADMIN))
return -EACCES;

if (args->size == 0)
return 0;

/* currently we are not able to return error because
* it is unclear that what addresses are valid other than
* ddr area. we should revisit this sometime.
* if (!xocl_validate_paddr(xdev, args->paddr, args->size)) {
* userpf_err(xdev, "invalid paddr: 0x%llx, size:0x%llx",
* args->paddr, args->size);
* return -EINVAL;
* }
*/


ret = xocl_migrate_unmgd(xdev, args->data_ptr, args->paddr, args->size, 1);

return ret;
}

int xocl_pread_unmgd_ioctl(struct drm_device *dev, void *data,
struct drm_file *filp)
struct drm_file *filp)
{
const struct drm_xocl_pwrite_unmgd *args = data;
struct xocl_drm *drm_p = dev->dev_private;
Expand All @@ -1514,9 +1506,17 @@ int xocl_pread_unmgd_ioctl(struct drm_device *dev, void *data,
return -EFAULT;
}

if (!capable(CAP_SYS_ADMIN))
return -EACCES;

if (args->size == 0)
return 0;

ret = xocl_migrate_unmgd(xdev, args->data_ptr, args->paddr, args->size, 0);

return ret;
}

/* currently we are not able to return error because
* it is unclear that what addresses are valid other than
* ddr area. we should revisit this sometime.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,26 @@ xocl_cu_ctx_to_info(struct xocl_dev *xdev, struct drm_xocl_open_cu_ctx *cu_args,
{
uint32_t slot_hndl = hw_ctx->slot_idx;
struct kds_sched *kds = &XDEV(xdev)->kds;
char *kname_p = cu_args->cu_name;
char name[CU_NAME_MAX_LEN + 1];
char *kname_p = name;
char *token;
struct xrt_cu *xcu = NULL;
char iname[CU_NAME_MAX_LEN];
char kname[CU_NAME_MAX_LEN];
int i = 0;

strcpy(kname, strsep(&kname_p, ":"));
strcpy(iname, strsep(&kname_p, ":"));
memcpy(name, cu_args->cu_name, CU_NAME_MAX_LEN);
name[CU_NAME_MAX_LEN] = '\0';
token = strsep(&kname_p, ":");
strscpy(kname, token ? token : "", sizeof(kname));
token = strsep(&kname_p, ":");
strscpy(iname, token ? token : "", sizeof(iname));

/* Retrieve the CU index from the given slot */
for (i = 0; i < MAX_CUS; i++) {
xcu = kds->cu_mgmt.xcus[i];
if (!xcu)
continue;

if ((xcu->info.slot_idx == slot_hndl) &&
(!strcmp(xcu->info.kname, kname)) &&
(!strcmp(xcu->info.iname, iname))) {
cu_info->cu_domain = DOMAIN_PL;
cu_info->cu_idx = i;
goto done;
}
}
Comment on lines 127 to 140
Expand Down
Loading