@@ -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
@@ -2433,9 +2438,10 @@ static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *l
2433
2438
if (!ctx_set_num )
2434
2439
return 0 ;
2435
2440
2441
+ /* sw share common resources, so dev is NULL is treated as error */
2436
2442
dev = wd_find_dev_by_numa (list , numa_id );
2437
2443
if (WD_IS_ERR (dev ))
2438
- return WD_PTR_ERR ( dev ) ;
2444
+ return 0 ;
2439
2445
2440
2446
for (i = idx ; i < count ; i ++ ) {
2441
2447
ctx_config -> ctxs [i ].ctx = wd_request_ctx (dev );
@@ -2452,12 +2458,6 @@ static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *l
2452
2458
/* self-decrease i to eliminate self-increase on next loop */
2453
2459
i -- ;
2454
2460
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
2461
}
2462
2462
ctx_config -> ctxs [i ].op_type = op_type ;
2463
2463
ctx_config -> ctxs [i ].ctx_mode =
@@ -2557,9 +2557,20 @@ static int wd_alg_ctx_init(struct wd_init_attrs *attrs)
2557
2557
int numa_cnt , ret ;
2558
2558
2559
2559
list = wd_get_accel_list (attrs -> alg );
2560
- if (!list ) {
2561
- WD_ERR ("failed to get devices!\n" );
2562
- return - WD_ENODEV ;
2560
+ if (list ) {
2561
+ /*
2562
+ * Not every numa has a device. Therefore, the first thing is to
2563
+ * filter the devices in the selected numa node, and the second
2564
+ * thing is to obtain the distribution of devices.
2565
+ */
2566
+ used_list = wd_get_usable_list (list , used_bmp );
2567
+ if (WD_IS_ERR (used_list )) {
2568
+ ret = WD_PTR_ERR (used_list );
2569
+ WD_ERR ("failed to get usable devices(%d)!\n" , ret );
2570
+ goto out_freelist ;
2571
+ }
2572
+
2573
+ wd_init_device_nodemask (used_list , used_bmp );
2563
2574
}
2564
2575
2565
2576
op_type_num = ctx_params -> op_type_num ;
@@ -2571,20 +2582,6 @@ static int wd_alg_ctx_init(struct wd_init_attrs *attrs)
2571
2582
goto out_freelist ;
2572
2583
}
2573
2584
2574
- /*
2575
- * Not every numa has a device. Therefore, the first thing is to
2576
- * filter the devices in the selected numa node, and the second
2577
- * thing is to obtain the distribution of devices.
2578
- */
2579
- used_list = wd_get_usable_list (list , used_bmp );
2580
- if (WD_IS_ERR (used_list )) {
2581
- ret = WD_PTR_ERR (used_list );
2582
- WD_ERR ("failed to get usable devices(%d)!\n" , ret );
2583
- goto out_freelist ;
2584
- }
2585
-
2586
- wd_init_device_nodemask (used_list , used_bmp );
2587
-
2588
2585
numa_cnt = numa_bitmask_weight (used_bmp );
2589
2586
if (!numa_cnt ) {
2590
2587
ret = numa_cnt ;
0 commit comments