Commit 7a67735b authored by Andrew Vasquez's avatar Andrew Vasquez Committed by James Bottomley

[SCSI] qla2xxx: Cache swl during fabric discovery.

Rather than continuously allocating and freeing swl within the discovery
process, simply pre-allocate it the first time that it's needed, cache it
through the rest of the lifecycle of the driver and free it at module unload.
Signed-off-by: default avatarAndrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: default avatarChad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 733a95bd
...@@ -2674,6 +2674,8 @@ struct qla_hw_data { ...@@ -2674,6 +2674,8 @@ struct qla_hw_data {
void *async_pd; void *async_pd;
dma_addr_t async_pd_dma; dma_addr_t async_pd_dma;
void *swl;
/* These are used by mailbox operations. */ /* These are used by mailbox operations. */
volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT]; volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
......
...@@ -3133,20 +3133,21 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, ...@@ -3133,20 +3133,21 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
rval = QLA_SUCCESS; rval = QLA_SUCCESS;
/* Try GID_PT to get device list, else GAN. */ /* Try GID_PT to get device list, else GAN. */
swl = kcalloc(MAX_FIBRE_DEVICES, sizeof(sw_info_t), GFP_KERNEL); if (!ha->swl)
ha->swl = kcalloc(MAX_FIBRE_DEVICES, sizeof(sw_info_t),
GFP_KERNEL);
swl = ha->swl;
if (!swl) { if (!swl) {
/*EMPTY*/ /*EMPTY*/
ql_dbg(ql_dbg_disc, vha, 0x2054, ql_dbg(ql_dbg_disc, vha, 0x2054,
"GID_PT allocations failed, fallback on GA_NXT.\n"); "GID_PT allocations failed, fallback on GA_NXT.\n");
} else { } else {
memset(swl, 0, MAX_FIBRE_DEVICES * sizeof(sw_info_t));
if (qla2x00_gid_pt(vha, swl) != QLA_SUCCESS) { if (qla2x00_gid_pt(vha, swl) != QLA_SUCCESS) {
kfree(swl);
swl = NULL; swl = NULL;
} else if (qla2x00_gpn_id(vha, swl) != QLA_SUCCESS) { } else if (qla2x00_gpn_id(vha, swl) != QLA_SUCCESS) {
kfree(swl);
swl = NULL; swl = NULL;
} else if (qla2x00_gnn_id(vha, swl) != QLA_SUCCESS) { } else if (qla2x00_gnn_id(vha, swl) != QLA_SUCCESS) {
kfree(swl);
swl = NULL; swl = NULL;
} else if (ql2xiidmaenable && } else if (ql2xiidmaenable &&
qla2x00_gfpn_id(vha, swl) == QLA_SUCCESS) { qla2x00_gfpn_id(vha, swl) == QLA_SUCCESS) {
...@@ -3164,7 +3165,6 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, ...@@ -3164,7 +3165,6 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
if (new_fcport == NULL) { if (new_fcport == NULL) {
ql_log(ql_log_warn, vha, 0x205e, ql_log(ql_log_warn, vha, 0x205e,
"Failed to allocate memory for fcport.\n"); "Failed to allocate memory for fcport.\n");
kfree(swl);
return (QLA_MEMORY_ALLOC_FAILED); return (QLA_MEMORY_ALLOC_FAILED);
} }
new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
...@@ -3341,14 +3341,12 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, ...@@ -3341,14 +3341,12 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
if (new_fcport == NULL) { if (new_fcport == NULL) {
ql_log(ql_log_warn, vha, 0x2066, ql_log(ql_log_warn, vha, 0x2066,
"Memory allocation failed for fcport.\n"); "Memory allocation failed for fcport.\n");
kfree(swl);
return (QLA_MEMORY_ALLOC_FAILED); return (QLA_MEMORY_ALLOC_FAILED);
} }
new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
new_fcport->d_id.b24 = nxt_d_id.b24; new_fcport->d_id.b24 = nxt_d_id.b24;
} }
kfree(swl);
kfree(new_fcport); kfree(new_fcport);
return (rval); return (rval);
......
...@@ -3280,6 +3280,7 @@ qla2x00_mem_free(struct qla_hw_data *ha) ...@@ -3280,6 +3280,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
vfree(ha->optrom_buffer); vfree(ha->optrom_buffer);
kfree(ha->nvram); kfree(ha->nvram);
kfree(ha->npiv_info); kfree(ha->npiv_info);
kfree(ha->swl);
ha->srb_mempool = NULL; ha->srb_mempool = NULL;
ha->ctx_mempool = NULL; ha->ctx_mempool = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment