hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID8IIO ----------------------------------------- This patch renames `vstream->id` to `vstream->sq_id` and `vstream->user_stream_id` to `vstream->id`. Although `stream_id` and `sq_id` represent different concepts, their values are equal, and the code can still run correctly even if these variables are used interchangeably. However, it is important to place them in the correct positions. Additionally, some unnecessary debug logs are removed to retain only essential scheduling logs. Fixes: 8dde1f2e6bf6 ("xsched: Introduce vstream management") Signed-off-by: Zicheng Qu <quzicheng@huawei.com> --- include/linux/vstream.h | 2 +- kernel/xsched/core.c | 11 +++-------- kernel/xsched/vstream.c | 21 +++++++-------------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/include/linux/vstream.h b/include/linux/vstream.h index fd393ec97a99..7d99e416624f 100644 --- a/include/linux/vstream.h +++ b/include/linux/vstream.h @@ -39,8 +39,8 @@ typedef struct vstream_metadata { typedef int vstream_manage_t(struct vstream_args *arg); typedef struct vstream_info { - uint32_t user_stream_id; uint32_t id; + uint32_t sq_id; uint32_t vcq_id; uint32_t logic_vcq_id; uint32_t dev_id; diff --git a/kernel/xsched/core.c b/kernel/xsched/core.c index d4c35b24da81..f4a843acd5cd 100644 --- a/kernel/xsched/core.c +++ b/kernel/xsched/core.c @@ -215,7 +215,7 @@ static void submit_kick(struct vstream_metadata *vsm) params.group = vs->xcu->group; params.fd = vs->fd; - params.param_1 = &vs->id; + params.param_1 = &vs->sq_id; params.param_2 = &vs->channel_id; params.param_3 = vsm->sqe; params.param_4 = &vsm->sqe_num; @@ -243,7 +243,7 @@ static void submit_wait(struct vstream_metadata *vsm) params.group = vs->xcu->group; params.param_1 = &vs->channel_id; params.param_2 = &vs->logic_vcq_id; - params.param_3 = &vs->user_stream_id; + params.param_3 = &vs->id; params.param_4 = &vsm->sqe; params.param_5 = vsm->cqe; params.param_6 = vs->drv_ctx; @@ -254,9 +254,6 @@ static void submit_wait(struct vstream_metadata *vsm) XSCHED_ERR("Fail to wait Vstream id %u tasks, logic_cq_id %u.\n", vs->id, vs->logic_vcq_id); } - - XSCHED_DEBUG("Vstream id %u wait finish, logic_cq_id %u\n", - vs->id, vs->logic_vcq_id); } static int __xsched_submit(struct xsched_cu *xcu, struct xsched_entity *xse) @@ -267,8 +264,6 @@ static int __xsched_submit(struct xsched_cu *xcu, struct xsched_entity *xse) ktime_t t_start = 0; struct xcu_op_handler_params params; - XSCHED_DEBUG("%s called for xse %d on xcu %u\n", - __func__, xse->tgid, xcu->id); list_for_each_entry_safe(vsm, tmp, &xcu->vsm_list, node) { submit_kick(vsm); XSCHED_DEBUG("Xse %d vsm %u sched_delay: %lld ns\n", @@ -346,7 +341,7 @@ struct vstream_metadata *xsched_vsm_fetch_first(struct vstream_info *vs) { struct vstream_metadata *vsm; - if (list_empty(&vs->metadata_list)) { + if (!vs || list_empty(&vs->metadata_list)) { XSCHED_DEBUG("No metadata to fetch from vs %u @ %s\n", vs->id, __func__); return NULL; diff --git a/kernel/xsched/vstream.c b/kernel/xsched/vstream.c index d01151c65dcf..128a869738be 100644 --- a/kernel/xsched/vstream.c +++ b/kernel/xsched/vstream.c @@ -117,9 +117,6 @@ struct xsched_cu *xcu_find(uint32_t type, return NULL; } - XSCHED_DEBUG("XCU found: type=%u, dev_id=%u, chan_id=%u.\n", - type, dev_id, channel_id); - return group->xcu; } @@ -128,7 +125,7 @@ static int vstream_destroy(vstream_info_t *vstream) int err; struct xsched_context *ctx = NULL; - err = vstream_del(vstream, vstream->id); + err = vstream_del(vstream, vstream->sq_id); if (err) return err; @@ -198,7 +195,6 @@ int ctx_bind_to_xcu(vstream_info_t *vstream_info, struct xsched_context *ctx) ctx->xse.xcu = xcu_found; vstream_info->xcu = xcu_found; revmap_data->dev_id = vstream_info->dev_id; - XSCHED_DEBUG("Ctx bind to xcu %u @ %s\n", xcu_found->id, __func__); hash_add(ctx_revmap, &revmap_data->hash_node, (unsigned long)ctx->dev_id); @@ -252,10 +248,9 @@ static int vstream_bind_to_ctx(struct vstream_info *vs) mutex_lock(&xcu->ctx_list_lock); ctx = ctx_find_by_tgid_and_xcu(vs->tgid, xcu); - if (ctx) { - XSCHED_DEBUG("Ctx %d found @ %s\n", vs->tgid, __func__); + if (ctx) kref_get(&ctx->kref); - } else { + else { err = alloc_ctx_from_vstream(vs, &ctx); if (err) goto out_err; @@ -359,7 +354,7 @@ vstream_get_by_user_stream_id(struct xsched_cu *xcu, uint32_t user_stream_id) mutex_lock(&xcu->vs_array_lock); for (id = 0; id < MAX_VSTREAM_NUM; id++) { if (xcu->vs_array[id] != NULL && - xcu->vs_array[id]->user_stream_id == user_stream_id) { + xcu->vs_array[id]->id == user_stream_id) { ret = xcu->vs_array[id]; break; } @@ -380,8 +375,6 @@ static int vstream_bind_to_xcu(vstream_info_t *vstream_info) /* Bind vstream to a xcu. */ vstream_info->xcu = xcu_found; vstream_info->dev_id = xcu_found->id; - XSCHED_DEBUG("XCU bound to a vstream: type=%u, dev_id=%u, chan_id=%u.\n", - type, vstream_info->dev_id, vstream_info->channel_id); return 0; } @@ -427,10 +420,10 @@ static int sqcq_alloc(struct vstream_args *arg) } vstream->drv_ctx = params.param_5; - vstream->id = sq_id; + vstream->sq_id = sq_id; vstream->vcq_id = cq_id; vstream->logic_vcq_id = logic_cq_id; - vstream->user_stream_id = va_args->user_stream_id; + vstream->id = va_args->user_stream_id; vstream->tgid = tgid; vstream->sqcq_type = va_args->type; ret = vstream_bind_to_ctx(vstream); @@ -447,7 +440,7 @@ static int sqcq_alloc(struct vstream_args *arg) vstream->inode_fd = ret; /* Add new vstream to array after allocating inode */ - ret = vstream_add(vstream, vstream->id); + ret = vstream_add(vstream, vstream->sq_id); if (ret) goto out_err_vstream_file_put; -- 2.34.1