@@ -224,12 +224,6 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
224
224
}
225
225
226
226
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
-
233
227
clone_ctx_to_internal (cfg -> ctxs + i , ctxs + i );
234
228
ret = pthread_spin_init (& ctxs [i ].lock , PTHREAD_PROCESS_SHARED );
235
229
if (ret ) {
@@ -1153,17 +1147,21 @@ static int wd_get_wd_ctx(struct wd_env_config_per_numa *config,
1153
1147
return 0 ;
1154
1148
1155
1149
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
+ }
1158
1154
return ret ;
1159
1155
}
1160
1156
1161
1157
static void wd_put_wd_ctx (struct wd_ctx_config * ctx_config , __u32 ctx_num )
1162
1158
{
1163
1159
__u32 i ;
1164
1160
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
+ }
1167
1165
}
1168
1166
1169
1167
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,
2147
2145
numa_free_nodemask (ctx_params -> bmp );
2148
2146
return - WD_EAGAIN ;
2149
2147
}
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
+ }
2151
2156
return 0 ;
2152
2157
}
2153
2158
@@ -2452,12 +2457,6 @@ static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *l
2452
2457
/* self-decrease i to eliminate self-increase on next loop */
2453
2458
i -- ;
2454
2459
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 ;
2461
2460
}
2462
2461
ctx_config -> ctxs [i ].op_type = op_type ;
2463
2462
ctx_config -> ctxs [i ].ctx_mode =
0 commit comments