Skip to content

Commit d65237c

Browse files
Sawan Chandakmartinkpetersen
authored andcommitted
scsi: qla2xxx: Fix mailbox failure while deleting Queue pairs
In target mode driver, queue pairs are not created during driver load time, instead they are created at the configuration time after chip reset. If a user tries to load/unload driver after queue pairs are created, then there would be mailbox failure, while deleting queue pairs. Flag is added to check if queue pairs are created or not. Queue pairs will be deleted only If they were created during target configuration. Signed-off-by: Sawan Chandak <sawan.chandak@cavium.com> Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent e326d22 commit d65237c

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3997,6 +3997,8 @@ typedef struct scsi_qla_host {
39973997
uint32_t fw_tgt_reported:1;
39983998
uint32_t bbcr_enable:1;
39993999
uint32_t qpairs_available:1;
4000+
uint32_t qpairs_req_created:1;
4001+
uint32_t qpairs_rsp_created:1;
40004002
} flags;
40014003

40024004
atomic_t loop_state;

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7719,9 +7719,12 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos,
77197719

77207720
int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair)
77217721
{
7722-
int ret;
7722+
int ret = QLA_FUNCTION_FAILED;
77237723
struct qla_hw_data *ha = qpair->hw;
77247724

7725+
if (!vha->flags.qpairs_req_created && !vha->flags.qpairs_rsp_created)
7726+
goto fail;
7727+
77257728
qpair->delete_in_progress = 1;
77267729
while (atomic_read(&qpair->ref_count))
77277730
msleep(500);
@@ -7738,8 +7741,11 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair)
77387741
clear_bit(qpair->id, ha->qpair_qid_map);
77397742
ha->num_qpairs--;
77407743
list_del(&qpair->qp_list_elem);
7741-
if (list_empty(&vha->qp_list))
7744+
if (list_empty(&vha->qp_list)) {
77427745
vha->flags.qpairs_available = 0;
7746+
vha->flags.qpairs_req_created = 0;
7747+
vha->flags.qpairs_rsp_created = 0;
7748+
}
77437749
mempool_destroy(qpair->srb_mempool);
77447750
kfree(qpair);
77457751
mutex_unlock(&ha->mq_lock);

drivers/scsi/qla2xxx/qla_mid.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
645645
int ret = 0;
646646
struct req_que *req = NULL;
647647
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
648+
struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev);
648649
uint16_t que_id = 0;
649650
device_reg_t *reg;
650651
uint32_t cnt;
@@ -741,6 +742,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
741742
mutex_unlock(&ha->mq_lock);
742743
goto que_failed;
743744
}
745+
vha->flags.qpairs_req_created = 1;
744746
}
745747

746748
return req->id;
@@ -772,6 +774,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
772774
int ret = 0;
773775
struct rsp_que *rsp = NULL;
774776
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
777+
struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev);
775778
uint16_t que_id = 0;
776779
device_reg_t *reg;
777780

@@ -855,6 +858,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
855858
mutex_unlock(&ha->mq_lock);
856859
goto que_failed;
857860
}
861+
vha->flags.qpairs_rsp_created = 1;
858862
}
859863
rsp->req = NULL;
860864

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
384384
ha->base_qpair->rsp = rsp;
385385
ha->base_qpair->vha = vha;
386386
ha->base_qpair->qp_lock_ptr = &ha->hardware_lock;
387+
/* init qpair to this cpu. Will adjust at run time. */
387388
ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q];
388389
INIT_LIST_HEAD(&ha->base_qpair->hints_list);
389390
qla_cpu_update(rsp->qpair, smp_processor_id());

0 commit comments

Comments
 (0)