@@ -153,6 +153,25 @@ static void idxd_cleanup_interrupts(struct idxd_device *idxd)
153
153
pci_free_irq_vectors (pdev );
154
154
}
155
155
156
+ static void idxd_clean_wqs (struct idxd_device * idxd )
157
+ {
158
+ struct idxd_wq * wq ;
159
+ struct device * conf_dev ;
160
+ int i ;
161
+
162
+ for (i = 0 ; i < idxd -> max_wqs ; i ++ ) {
163
+ wq = idxd -> wqs [i ];
164
+ if (idxd -> hw .wq_cap .op_config )
165
+ bitmap_free (wq -> opcap_bmap );
166
+ kfree (wq -> wqcfg );
167
+ conf_dev = wq_confdev (wq );
168
+ put_device (conf_dev );
169
+ kfree (wq );
170
+ }
171
+ bitmap_free (idxd -> wq_enable_map );
172
+ kfree (idxd -> wqs );
173
+ }
174
+
156
175
static int idxd_setup_wqs (struct idxd_device * idxd )
157
176
{
158
177
struct device * dev = & idxd -> pdev -> dev ;
@@ -243,6 +262,21 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
243
262
return rc ;
244
263
}
245
264
265
+ static void idxd_clean_engines (struct idxd_device * idxd )
266
+ {
267
+ struct idxd_engine * engine ;
268
+ struct device * conf_dev ;
269
+ int i ;
270
+
271
+ for (i = 0 ; i < idxd -> max_engines ; i ++ ) {
272
+ engine = idxd -> engines [i ];
273
+ conf_dev = engine_confdev (engine );
274
+ put_device (conf_dev );
275
+ kfree (engine );
276
+ }
277
+ kfree (idxd -> engines );
278
+ }
279
+
246
280
static int idxd_setup_engines (struct idxd_device * idxd )
247
281
{
248
282
struct idxd_engine * engine ;
@@ -294,6 +328,19 @@ static int idxd_setup_engines(struct idxd_device *idxd)
294
328
return rc ;
295
329
}
296
330
331
+ static void idxd_clean_groups (struct idxd_device * idxd )
332
+ {
333
+ struct idxd_group * group ;
334
+ int i ;
335
+
336
+ for (i = 0 ; i < idxd -> max_groups ; i ++ ) {
337
+ group = idxd -> groups [i ];
338
+ put_device (group_confdev (group ));
339
+ kfree (group );
340
+ }
341
+ kfree (idxd -> groups );
342
+ }
343
+
297
344
static int idxd_setup_groups (struct idxd_device * idxd )
298
345
{
299
346
struct device * dev = & idxd -> pdev -> dev ;
@@ -408,7 +455,7 @@ static int idxd_init_evl(struct idxd_device *idxd)
408
455
static int idxd_setup_internals (struct idxd_device * idxd )
409
456
{
410
457
struct device * dev = & idxd -> pdev -> dev ;
411
- int rc , i ;
458
+ int rc ;
412
459
413
460
init_waitqueue_head (& idxd -> cmd_waitq );
414
461
@@ -439,14 +486,11 @@ static int idxd_setup_internals(struct idxd_device *idxd)
439
486
err_evl :
440
487
destroy_workqueue (idxd -> wq );
441
488
err_wkq_create :
442
- for (i = 0 ; i < idxd -> max_groups ; i ++ )
443
- put_device (group_confdev (idxd -> groups [i ]));
489
+ idxd_clean_groups (idxd );
444
490
err_group :
445
- for (i = 0 ; i < idxd -> max_engines ; i ++ )
446
- put_device (engine_confdev (idxd -> engines [i ]));
491
+ idxd_clean_engines (idxd );
447
492
err_engine :
448
- for (i = 0 ; i < idxd -> max_wqs ; i ++ )
449
- put_device (wq_confdev (idxd -> wqs [i ]));
493
+ idxd_clean_wqs (idxd );
450
494
err_wqs :
451
495
return rc ;
452
496
}
0 commit comments