Skip to content

Commit efa74a6

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Adjust IOCB resource on qpair create
During NVMe queue creation, a new qpair is created. FW resource limit needs to be re-adjusted to take into account the new qpair. Otherwise, NVMe command can not go through. This issue was discovered while testing/forcing FW execution to fail at load time. Add call to readjust IOCB and exchange limit. In addition, get FW state command and require FW to be running. Otherwise, error is generated. Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran <qutran@marvell.com> Signed-off-by: Nilesh Javali <njavali@marvell.com> Link: https://lore.kernel.org/r/20230714070104.40052-3-njavali@marvell.com Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 6dfe434 commit efa74a6

File tree

4 files changed

+38
-19
lines changed

4 files changed

+38
-19
lines changed

drivers/scsi/qla2xxx/qla_gbl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void qla_edif_sess_down(struct scsi_qla_host *vha, struct fc_port *sess);
143143
void qla_edif_clear_appdata(struct scsi_qla_host *vha,
144144
struct fc_port *fcport);
145145
const char *sc_to_str(uint16_t cmd);
146+
void qla_adjust_iocb_limit(scsi_qla_host_t *vha);
146147

147148
/*
148149
* Global Data in qla_os.c source file.

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4153,41 +4153,55 @@ qla24xx_detect_sfp(scsi_qla_host_t *vha)
41534153
return ha->flags.lr_detected;
41544154
}
41554155

4156-
void qla_init_iocb_limit(scsi_qla_host_t *vha)
4156+
static void __qla_adjust_iocb_limit(struct qla_qpair *qpair)
41574157
{
4158-
u16 i, num_qps;
4159-
u32 limit;
4160-
struct qla_hw_data *ha = vha->hw;
4158+
u8 num_qps;
4159+
u16 limit;
4160+
struct qla_hw_data *ha = qpair->vha->hw;
41614161

41624162
num_qps = ha->num_qpairs + 1;
41634163
limit = (ha->orig_fw_iocb_count * QLA_IOCB_PCT_LIMIT) / 100;
41644164

4165-
ha->base_qpair->fwres.iocbs_total = ha->orig_fw_iocb_count;
4166-
ha->base_qpair->fwres.iocbs_limit = limit;
4167-
ha->base_qpair->fwres.iocbs_qp_limit = limit / num_qps;
4168-
ha->base_qpair->fwres.iocbs_used = 0;
4165+
qpair->fwres.iocbs_total = ha->orig_fw_iocb_count;
4166+
qpair->fwres.iocbs_limit = limit;
4167+
qpair->fwres.iocbs_qp_limit = limit / num_qps;
4168+
4169+
qpair->fwres.exch_total = ha->orig_fw_xcb_count;
4170+
qpair->fwres.exch_limit = (ha->orig_fw_xcb_count *
4171+
QLA_IOCB_PCT_LIMIT) / 100;
4172+
}
4173+
4174+
void qla_init_iocb_limit(scsi_qla_host_t *vha)
4175+
{
4176+
u8 i;
4177+
struct qla_hw_data *ha = vha->hw;
41694178

4170-
ha->base_qpair->fwres.exch_total = ha->orig_fw_xcb_count;
4171-
ha->base_qpair->fwres.exch_limit = (ha->orig_fw_xcb_count *
4172-
QLA_IOCB_PCT_LIMIT) / 100;
4179+
__qla_adjust_iocb_limit(ha->base_qpair);
4180+
ha->base_qpair->fwres.iocbs_used = 0;
41734181
ha->base_qpair->fwres.exch_used = 0;
41744182

41754183
for (i = 0; i < ha->max_qpairs; i++) {
41764184
if (ha->queue_pair_map[i]) {
4177-
ha->queue_pair_map[i]->fwres.iocbs_total =
4178-
ha->orig_fw_iocb_count;
4179-
ha->queue_pair_map[i]->fwres.iocbs_limit = limit;
4180-
ha->queue_pair_map[i]->fwres.iocbs_qp_limit =
4181-
limit / num_qps;
4185+
__qla_adjust_iocb_limit(ha->queue_pair_map[i]);
41824186
ha->queue_pair_map[i]->fwres.iocbs_used = 0;
4183-
ha->queue_pair_map[i]->fwres.exch_total = ha->orig_fw_xcb_count;
4184-
ha->queue_pair_map[i]->fwres.exch_limit =
4185-
(ha->orig_fw_xcb_count * QLA_IOCB_PCT_LIMIT) / 100;
41864187
ha->queue_pair_map[i]->fwres.exch_used = 0;
41874188
}
41884189
}
41894190
}
41904191

4192+
void qla_adjust_iocb_limit(scsi_qla_host_t *vha)
4193+
{
4194+
u8 i;
4195+
struct qla_hw_data *ha = vha->hw;
4196+
4197+
__qla_adjust_iocb_limit(ha->base_qpair);
4198+
4199+
for (i = 0; i < ha->max_qpairs; i++) {
4200+
if (ha->queue_pair_map[i])
4201+
__qla_adjust_iocb_limit(ha->queue_pair_map[i]);
4202+
}
4203+
}
4204+
41914205
/**
41924206
* qla2x00_setup_chip() - Load and start RISC firmware.
41934207
* @vha: HA context

drivers/scsi/qla2xxx/qla_mbx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,9 @@ qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states)
22132213
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1054,
22142214
"Entered %s.\n", __func__);
22152215

2216+
if (!ha->flags.fw_started)
2217+
return QLA_FUNCTION_FAILED;
2218+
22162219
mcp->mb[0] = MBC_GET_FIRMWARE_STATE;
22172220
mcp->out_mb = MBX_0;
22182221
if (IS_FWI2_CAPABLE(vha->hw))

drivers/scsi/qla2xxx/qla_nvme.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ static int qla_nvme_alloc_queue(struct nvme_fc_local_port *lport,
132132
"Failed to allocate qpair\n");
133133
return -EINVAL;
134134
}
135+
qla_adjust_iocb_limit(vha);
135136
}
136137
*handle = qpair;
137138

0 commit comments

Comments
 (0)