Skip to content

Commit bf803df

Browse files
committed
wd_util: consider sw has no hw ctx and op type
sw and hw will share common resources like ctxs and pool. So handle cases only sw exist, without ctx and op Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
1 parent cb314ae commit bf803df

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

wd_util.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,6 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
224224
}
225225

226226
for (i = 0; i < cfg->ctx_num; i++) {
227-
if (!cfg->ctxs[i].ctx) {
228-
WD_ERR("invalid: ctx is NULL!\n");
229-
ret = -WD_EINVAL;
230-
goto err_out;
231-
}
232-
233227
clone_ctx_to_internal(cfg->ctxs + i, ctxs + i);
234228
ret = pthread_spin_init(&ctxs[i].lock, PTHREAD_PROCESS_SHARED);
235229
if (ret) {
@@ -1153,17 +1147,21 @@ static int wd_get_wd_ctx(struct wd_env_config_per_numa *config,
11531147
return 0;
11541148

11551149
free_ctx:
1156-
for (j = start; j < i; j++)
1157-
wd_release_ctx(ctx_config->ctxs[j].ctx);
1150+
for (j = start; j < i; j++) {
1151+
if (ctx_config->ctxs[j].ctx)
1152+
wd_release_ctx(ctx_config->ctxs[j].ctx);
1153+
}
11581154
return ret;
11591155
}
11601156

11611157
static void wd_put_wd_ctx(struct wd_ctx_config *ctx_config, __u32 ctx_num)
11621158
{
11631159
__u32 i;
11641160

1165-
for (i = 0; i < ctx_num; i++)
1166-
wd_release_ctx(ctx_config->ctxs[i].ctx);
1161+
for (i = 0; i < ctx_num; i++) {
1162+
if (ctx_config->ctxs[i].ctx)
1163+
wd_release_ctx(ctx_config->ctxs[i].ctx);
1164+
}
11671165
}
11681166

11691167
static int wd_alloc_ctx(struct wd_env_config *config)
@@ -2147,7 +2145,14 @@ int wd_ctx_param_init(struct wd_ctx_params *ctx_params,
21472145
numa_free_nodemask(ctx_params->bmp);
21482146
return -WD_EAGAIN;
21492147
}
2150-
2148+
if (ctx_params->op_type_num == 0) {
2149+
/* set default */
2150+
ctx_params->op_type_num = 1;
2151+
if (ctx_params->ctx_set_num) {
2152+
ctx_params->ctx_set_num[0].sync_ctx_num = 1;
2153+
ctx_params->ctx_set_num[0].async_ctx_num = 1;
2154+
}
2155+
}
21512156
return 0;
21522157
}
21532158

@@ -2452,12 +2457,6 @@ static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *l
24522457
/* self-decrease i to eliminate self-increase on next loop */
24532458
i--;
24542459
continue;
2455-
} else if (!ctx_config->ctxs[i].ctx) {
2456-
/*
2457-
* wd_release_ctx_set will release ctx in
2458-
* caller wd_init_ctx_and_sched.
2459-
*/
2460-
return -WD_ENOMEM;
24612460
}
24622461
ctx_config->ctxs[i].op_type = op_type;
24632462
ctx_config->ctxs[i].ctx_mode =

0 commit comments

Comments
 (0)