@@ -1265,15 +1265,12 @@ static u16 nvmet_pci_epf_create_cq(struct nvmet_ctrl *tctrl,
1265
1265
struct nvmet_pci_epf_queue * cq = & ctrl -> cq [cqid ];
1266
1266
u16 status ;
1267
1267
1268
- if (test_and_set_bit (NVMET_PCI_EPF_Q_LIVE , & cq -> flags ))
1268
+ if (test_bit (NVMET_PCI_EPF_Q_LIVE , & cq -> flags ))
1269
1269
return NVME_SC_QID_INVALID | NVME_STATUS_DNR ;
1270
1270
1271
1271
if (!(flags & NVME_QUEUE_PHYS_CONTIG ))
1272
1272
return NVME_SC_INVALID_QUEUE | NVME_STATUS_DNR ;
1273
1273
1274
- if (flags & NVME_CQ_IRQ_ENABLED )
1275
- set_bit (NVMET_PCI_EPF_Q_IRQ_ENABLED , & cq -> flags );
1276
-
1277
1274
cq -> pci_addr = pci_addr ;
1278
1275
cq -> qid = cqid ;
1279
1276
cq -> depth = qsize + 1 ;
@@ -1290,24 +1287,27 @@ static u16 nvmet_pci_epf_create_cq(struct nvmet_ctrl *tctrl,
1290
1287
cq -> qes = ctrl -> io_cqes ;
1291
1288
cq -> pci_size = cq -> qes * cq -> depth ;
1292
1289
1293
- cq -> iv = nvmet_pci_epf_add_irq_vector (ctrl , vector );
1294
- if (!cq -> iv ) {
1295
- status = NVME_SC_INTERNAL | NVME_STATUS_DNR ;
1296
- goto err ;
1290
+ if (flags & NVME_CQ_IRQ_ENABLED ) {
1291
+ cq -> iv = nvmet_pci_epf_add_irq_vector (ctrl , vector );
1292
+ if (!cq -> iv )
1293
+ return NVME_SC_INTERNAL | NVME_STATUS_DNR ;
1294
+ set_bit (NVMET_PCI_EPF_Q_IRQ_ENABLED , & cq -> flags );
1297
1295
}
1298
1296
1299
1297
status = nvmet_cq_create (tctrl , & cq -> nvme_cq , cqid , cq -> depth );
1300
1298
if (status != NVME_SC_SUCCESS )
1301
1299
goto err ;
1302
1300
1301
+ set_bit (NVMET_PCI_EPF_Q_LIVE , & cq -> flags );
1302
+
1303
1303
dev_dbg (ctrl -> dev , "CQ[%u]: %u entries of %zu B, IRQ vector %u\n" ,
1304
1304
cqid , qsize , cq -> qes , cq -> vector );
1305
1305
1306
1306
return NVME_SC_SUCCESS ;
1307
1307
1308
1308
err :
1309
- clear_bit ( NVMET_PCI_EPF_Q_IRQ_ENABLED , & cq -> flags );
1310
- clear_bit ( NVMET_PCI_EPF_Q_LIVE , & cq -> flags );
1309
+ if ( test_and_clear_bit ( NVMET_PCI_EPF_Q_IRQ_ENABLED , & cq -> flags ))
1310
+ nvmet_pci_epf_remove_irq_vector ( ctrl , cq -> vector );
1311
1311
return status ;
1312
1312
}
1313
1313
@@ -1333,7 +1333,7 @@ static u16 nvmet_pci_epf_create_sq(struct nvmet_ctrl *tctrl,
1333
1333
struct nvmet_pci_epf_queue * sq = & ctrl -> sq [sqid ];
1334
1334
u16 status ;
1335
1335
1336
- if (test_and_set_bit (NVMET_PCI_EPF_Q_LIVE , & sq -> flags ))
1336
+ if (test_bit (NVMET_PCI_EPF_Q_LIVE , & sq -> flags ))
1337
1337
return NVME_SC_QID_INVALID | NVME_STATUS_DNR ;
1338
1338
1339
1339
if (!(flags & NVME_QUEUE_PHYS_CONTIG ))
@@ -1355,7 +1355,7 @@ static u16 nvmet_pci_epf_create_sq(struct nvmet_ctrl *tctrl,
1355
1355
1356
1356
status = nvmet_sq_create (tctrl , & sq -> nvme_sq , sqid , sq -> depth );
1357
1357
if (status != NVME_SC_SUCCESS )
1358
- goto out_clear_bit ;
1358
+ return status ;
1359
1359
1360
1360
sq -> iod_wq = alloc_workqueue ("sq%d_wq" , WQ_UNBOUND ,
1361
1361
min_t (int , sq -> depth , WQ_MAX_ACTIVE ), sqid );
@@ -1365,15 +1365,15 @@ static u16 nvmet_pci_epf_create_sq(struct nvmet_ctrl *tctrl,
1365
1365
goto out_destroy_sq ;
1366
1366
}
1367
1367
1368
+ set_bit (NVMET_PCI_EPF_Q_LIVE , & sq -> flags );
1369
+
1368
1370
dev_dbg (ctrl -> dev , "SQ[%u]: %u entries of %zu B\n" ,
1369
1371
sqid , qsize , sq -> qes );
1370
1372
1371
1373
return NVME_SC_SUCCESS ;
1372
1374
1373
1375
out_destroy_sq :
1374
1376
nvmet_sq_destroy (& sq -> nvme_sq );
1375
- out_clear_bit :
1376
- clear_bit (NVMET_PCI_EPF_Q_LIVE , & sq -> flags );
1377
1377
return status ;
1378
1378
}
1379
1379
0 commit comments