Skip to content

Commit efeda3b

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Move resource to allow code reuse
dsd_list contains a list of dsd buffer resources allocated during traffic time. It resides in the qla_hw_data location where some of the code is not reusable. Move this list to qpair to allow reuse by either single queue or multi queue adapter / code. Signed-off-by: Quinn Tran <qutran@marvell.com> Signed-off-by: Nilesh Javali <njavali@marvell.com> Link: https://lore.kernel.org/r/20230817063132.21900-2-njavali@marvell.com Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent a31a596 commit efeda3b

File tree

4 files changed

+47
-34
lines changed

4 files changed

+47
-34
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,6 +3787,12 @@ struct qla_qpair {
37873787

37883788
uint16_t id; /* qp number used with FW */
37893789
uint16_t vp_idx; /* vport ID */
3790+
3791+
uint16_t dsd_inuse;
3792+
uint16_t dsd_avail;
3793+
struct list_head dsd_list;
3794+
#define NUM_DSD_CHAIN 4096
3795+
37903796
mempool_t *srb_mempool;
37913797

37923798
struct pci_dev *pdev;
@@ -4715,11 +4721,6 @@ struct qla_hw_data {
47154721
struct fw_blob *hablob;
47164722
struct qla82xx_legacy_intr_set nx_legacy_intr;
47174723

4718-
uint16_t gbl_dsd_inuse;
4719-
uint16_t gbl_dsd_avail;
4720-
struct list_head gbl_dsd_list;
4721-
#define NUM_DSD_CHAIN 4096
4722-
47234724
uint8_t fw_type;
47244725
uint32_t file_prd_off; /* File firmware product offset */
47254726

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9643,6 +9643,7 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos,
96439643
qpair->vp_idx = vp_idx;
96449644
qpair->fw_started = ha->flags.fw_started;
96459645
INIT_LIST_HEAD(&qpair->hints_list);
9646+
INIT_LIST_HEAD(&qpair->dsd_list);
96469647
qpair->chip_reset = ha->base_qpair->chip_reset;
96479648
qpair->enable_class_2 = ha->base_qpair->enable_class_2;
96489649
qpair->enable_explicit_conf =
@@ -9771,6 +9772,19 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair)
97719772
if (ret != QLA_SUCCESS)
97729773
goto fail;
97739774

9775+
if (!list_empty(&qpair->dsd_list)) {
9776+
struct dsd_dma *dsd_ptr, *tdsd_ptr;
9777+
9778+
/* clean up allocated prev pool */
9779+
list_for_each_entry_safe(dsd_ptr, tdsd_ptr,
9780+
&qpair->dsd_list, list) {
9781+
dma_pool_free(ha->dl_dma_pool, dsd_ptr->dsd_addr,
9782+
dsd_ptr->dsd_list_dma);
9783+
list_del(&dsd_ptr->list);
9784+
kfree(dsd_ptr);
9785+
}
9786+
}
9787+
97749788
mutex_lock(&ha->mq_lock);
97759789
ha->queue_pair_map[qpair->id] = NULL;
97769790
clear_bit(qpair->id, ha->qpair_qid_map);

drivers/scsi/qla2xxx/qla_iocb.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,13 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
636636
tot_dsds -= avail_dsds;
637637
dsd_list_len = (avail_dsds + 1) * QLA_DSD_SIZE;
638638

639-
dsd_ptr = list_first_entry(&ha->gbl_dsd_list,
640-
struct dsd_dma, list);
639+
dsd_ptr = list_first_entry(&qpair->dsd_list, struct dsd_dma, list);
641640
next_dsd = dsd_ptr->dsd_addr;
642641
list_del(&dsd_ptr->list);
643-
ha->gbl_dsd_avail--;
642+
qpair->dsd_avail--;
644643
list_add_tail(&dsd_ptr->list, &ctx->dsd_list);
645644
ctx->dsd_use_cnt++;
646-
ha->gbl_dsd_inuse++;
645+
qpair->dsd_inuse++;
647646

648647
if (first_iocb) {
649648
first_iocb = 0;
@@ -3367,6 +3366,7 @@ qla82xx_start_scsi(srb_t *sp)
33673366
struct qla_hw_data *ha = vha->hw;
33683367
struct req_que *req = NULL;
33693368
struct rsp_que *rsp = NULL;
3369+
struct qla_qpair *qpair = sp->qpair;
33703370

33713371
/* Setup device pointers. */
33723372
reg = &ha->iobase->isp82;
@@ -3415,18 +3415,18 @@ qla82xx_start_scsi(srb_t *sp)
34153415
uint16_t i;
34163416

34173417
more_dsd_lists = qla24xx_calc_dsd_lists(tot_dsds);
3418-
if ((more_dsd_lists + ha->gbl_dsd_inuse) >= NUM_DSD_CHAIN) {
3418+
if ((more_dsd_lists + qpair->dsd_inuse) >= NUM_DSD_CHAIN) {
34193419
ql_dbg(ql_dbg_io, vha, 0x300d,
34203420
"Num of DSD list %d is than %d for cmd=%p.\n",
3421-
more_dsd_lists + ha->gbl_dsd_inuse, NUM_DSD_CHAIN,
3421+
more_dsd_lists + qpair->dsd_inuse, NUM_DSD_CHAIN,
34223422
cmd);
34233423
goto queuing_error;
34243424
}
34253425

3426-
if (more_dsd_lists <= ha->gbl_dsd_avail)
3426+
if (more_dsd_lists <= qpair->dsd_avail)
34273427
goto sufficient_dsds;
34283428
else
3429-
more_dsd_lists -= ha->gbl_dsd_avail;
3429+
more_dsd_lists -= qpair->dsd_avail;
34303430

34313431
for (i = 0; i < more_dsd_lists; i++) {
34323432
dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC);
@@ -3446,8 +3446,8 @@ qla82xx_start_scsi(srb_t *sp)
34463446
"for cmd=%p.\n", cmd);
34473447
goto queuing_error;
34483448
}
3449-
list_add_tail(&dsd_ptr->list, &ha->gbl_dsd_list);
3450-
ha->gbl_dsd_avail++;
3449+
list_add_tail(&dsd_ptr->list, &qpair->dsd_list);
3450+
qpair->dsd_avail++;
34513451
}
34523452

34533453
sufficient_dsds:

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ static void qla_init_base_qpair(struct scsi_qla_host *vha, struct req_que *req,
432432
ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q];
433433
ha->base_qpair->srb_mempool = ha->srb_mempool;
434434
INIT_LIST_HEAD(&ha->base_qpair->hints_list);
435+
INIT_LIST_HEAD(&ha->base_qpair->dsd_list);
435436
ha->base_qpair->enable_class_2 = ql2xenableclass2;
436437
/* init qpair to this cpu. Will adjust at run time. */
437438
qla_cpu_update(rsp->qpair, raw_smp_processor_id());
@@ -750,9 +751,9 @@ void qla2x00_sp_free_dma(srb_t *sp)
750751

751752
dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
752753
ctx1->fcp_cmnd_dma);
753-
list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list);
754-
ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt;
755-
ha->gbl_dsd_avail += ctx1->dsd_use_cnt;
754+
list_splice(&ctx1->dsd_list, &sp->qpair->dsd_list);
755+
sp->qpair->dsd_inuse -= ctx1->dsd_use_cnt;
756+
sp->qpair->dsd_avail += ctx1->dsd_use_cnt;
756757
}
757758

758759
if (sp->flags & SRB_GOT_BUF)
@@ -836,9 +837,9 @@ void qla2xxx_qpair_sp_free_dma(srb_t *sp)
836837

837838
dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
838839
ctx1->fcp_cmnd_dma);
839-
list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list);
840-
ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt;
841-
ha->gbl_dsd_avail += ctx1->dsd_use_cnt;
840+
list_splice(&ctx1->dsd_list, &sp->qpair->dsd_list);
841+
sp->qpair->dsd_inuse -= ctx1->dsd_use_cnt;
842+
sp->qpair->dsd_avail += ctx1->dsd_use_cnt;
842843
sp->flags &= ~SRB_FCP_CMND_DMA_VALID;
843844
}
844845

@@ -4402,7 +4403,6 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
44024403
"sf_init_cb=%p.\n", ha->sf_init_cb);
44034404
}
44044405

4405-
INIT_LIST_HEAD(&ha->gbl_dsd_list);
44064406

44074407
/* Get consistent memory allocated for Async Port-Database. */
44084408
if (!IS_FWI2_CAPABLE(ha)) {
@@ -4934,18 +4934,16 @@ qla2x00_mem_free(struct qla_hw_data *ha)
49344934
ha->gid_list = NULL;
49354935
ha->gid_list_dma = 0;
49364936

4937-
if (IS_QLA82XX(ha)) {
4938-
if (!list_empty(&ha->gbl_dsd_list)) {
4939-
struct dsd_dma *dsd_ptr, *tdsd_ptr;
4940-
4941-
/* clean up allocated prev pool */
4942-
list_for_each_entry_safe(dsd_ptr,
4943-
tdsd_ptr, &ha->gbl_dsd_list, list) {
4944-
dma_pool_free(ha->dl_dma_pool,
4945-
dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma);
4946-
list_del(&dsd_ptr->list);
4947-
kfree(dsd_ptr);
4948-
}
4937+
if (!list_empty(&ha->base_qpair->dsd_list)) {
4938+
struct dsd_dma *dsd_ptr, *tdsd_ptr;
4939+
4940+
/* clean up allocated prev pool */
4941+
list_for_each_entry_safe(dsd_ptr, tdsd_ptr,
4942+
&ha->base_qpair->dsd_list, list) {
4943+
dma_pool_free(ha->dl_dma_pool, dsd_ptr->dsd_addr,
4944+
dsd_ptr->dsd_list_dma);
4945+
list_del(&dsd_ptr->list);
4946+
kfree(dsd_ptr);
49494947
}
49504948
}
49514949

0 commit comments

Comments
 (0)