@@ -189,27 +189,30 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
189
189
idxd -> wq_enable_map = bitmap_zalloc_node (idxd -> max_wqs , GFP_KERNEL , dev_to_node (dev ));
190
190
if (!idxd -> wq_enable_map ) {
191
191
rc = - ENOMEM ;
192
- goto err_bitmap ;
192
+ goto err_free_wqs ;
193
193
}
194
194
195
195
for (i = 0 ; i < idxd -> max_wqs ; i ++ ) {
196
196
wq = kzalloc_node (sizeof (* wq ), GFP_KERNEL , dev_to_node (dev ));
197
197
if (!wq ) {
198
198
rc = - ENOMEM ;
199
- goto err ;
199
+ goto err_unwind ;
200
200
}
201
201
202
202
idxd_dev_set_type (& wq -> idxd_dev , IDXD_DEV_WQ );
203
203
conf_dev = wq_confdev (wq );
204
204
wq -> id = i ;
205
205
wq -> idxd = idxd ;
206
- device_initialize (wq_confdev ( wq ) );
206
+ device_initialize (conf_dev );
207
207
conf_dev -> parent = idxd_confdev (idxd );
208
208
conf_dev -> bus = & dsa_bus_type ;
209
209
conf_dev -> type = & idxd_wq_device_type ;
210
210
rc = dev_set_name (conf_dev , "wq%d.%d" , idxd -> id , wq -> id );
211
- if (rc < 0 )
212
- goto err ;
211
+ if (rc < 0 ) {
212
+ put_device (conf_dev );
213
+ kfree (wq );
214
+ goto err_unwind ;
215
+ }
213
216
214
217
mutex_init (& wq -> wq_lock );
215
218
init_waitqueue_head (& wq -> err_queue );
@@ -220,15 +223,20 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
220
223
wq -> enqcmds_retries = IDXD_ENQCMDS_RETRIES ;
221
224
wq -> wqcfg = kzalloc_node (idxd -> wqcfg_size , GFP_KERNEL , dev_to_node (dev ));
222
225
if (!wq -> wqcfg ) {
226
+ put_device (conf_dev );
227
+ kfree (wq );
223
228
rc = - ENOMEM ;
224
- goto err ;
229
+ goto err_unwind ;
225
230
}
226
231
227
232
if (idxd -> hw .wq_cap .op_config ) {
228
233
wq -> opcap_bmap = bitmap_zalloc (IDXD_MAX_OPCAP_BITS , GFP_KERNEL );
229
234
if (!wq -> opcap_bmap ) {
235
+ kfree (wq -> wqcfg );
236
+ put_device (conf_dev );
237
+ kfree (wq );
230
238
rc = - ENOMEM ;
231
- goto err_opcap_bmap ;
239
+ goto err_unwind ;
232
240
}
233
241
bitmap_copy (wq -> opcap_bmap , idxd -> opcap_bmap , IDXD_MAX_OPCAP_BITS );
234
242
}
@@ -239,13 +247,7 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
239
247
240
248
return 0 ;
241
249
242
- err_opcap_bmap :
243
- kfree (wq -> wqcfg );
244
-
245
- err :
246
- put_device (conf_dev );
247
- kfree (wq );
248
-
250
+ err_unwind :
249
251
while (-- i >= 0 ) {
250
252
wq = idxd -> wqs [i ];
251
253
if (idxd -> hw .wq_cap .op_config )
@@ -254,11 +256,10 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
254
256
conf_dev = wq_confdev (wq );
255
257
put_device (conf_dev );
256
258
kfree (wq );
257
-
258
259
}
259
260
bitmap_free (idxd -> wq_enable_map );
260
261
261
- err_bitmap :
262
+ err_free_wqs :
262
263
kfree (idxd -> wqs );
263
264
264
265
return rc ;
@@ -1291,10 +1292,12 @@ static void idxd_remove(struct pci_dev *pdev)
1291
1292
device_unregister (idxd_confdev (idxd ));
1292
1293
idxd_shutdown (pdev );
1293
1294
idxd_device_remove_debugfs (idxd );
1294
- idxd_cleanup (idxd );
1295
+ perfmon_pmu_remove (idxd );
1296
+ idxd_cleanup_interrupts (idxd );
1297
+ if (device_pasid_enabled (idxd ))
1298
+ idxd_disable_system_pasid (idxd );
1295
1299
pci_iounmap (pdev , idxd -> reg_base );
1296
1300
put_device (idxd_confdev (idxd ));
1297
- idxd_free (idxd );
1298
1301
pci_disable_device (pdev );
1299
1302
}
1300
1303
0 commit comments