]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
qla2xxx: Cache swl during fabric discovery.
authorAndrew Vasquez <andrew.vasquez@qlogic.com>
Tue, 10 Apr 2012 11:52:14 +0000 (17:22 +0530)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Wed, 9 May 2012 00:40:58 +0000 (17:40 -0700)
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.

JIRA Key: V2632FC-124

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_os.c

index ba60565300d0ccf1636254eda489c31e646b5862..e3e19ec5a55730d9b0bb84ff2c492e5c1bba4dd4 100644 (file)
@@ -2674,6 +2674,8 @@ struct qla_hw_data {
        void            *async_pd;
        dma_addr_t      async_pd_dma;
 
+       void            *swl;
+
        /* These are used by mailbox operations. */
        volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
 
index a3359290a9c3709a0f60b867c865a86ddc4bc432..95c4c7ba629f36c4fa93f120a6d640b721df94bb 100644 (file)
@@ -3164,20 +3164,21 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
        rval = QLA_SUCCESS;
 
        /* 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) {
                /*EMPTY*/
                ql_dbg(ql_dbg_disc, vha, 0x2054,
                    "GID_PT allocations failed, fallback on GA_NXT.\n");
        } else {
+               memset(swl, 0, MAX_FIBRE_DEVICES * sizeof(sw_info_t));
                if (qla2x00_gid_pt(vha, swl) != QLA_SUCCESS) {
-                       kfree(swl);
                        swl = NULL;
                } else if (qla2x00_gpn_id(vha, swl) != QLA_SUCCESS) {
-                       kfree(swl);
                        swl = NULL;
                } else if (qla2x00_gnn_id(vha, swl) != QLA_SUCCESS) {
-                       kfree(swl);
                        swl = NULL;
                } else if (ql2xiidmaenable &&
                    qla2x00_gfpn_id(vha, swl) == QLA_SUCCESS) {
@@ -3195,7 +3196,6 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
        if (new_fcport == NULL) {
                ql_log(ql_log_warn, vha, 0x205e,
                    "Failed to allocate memory for fcport.\n");
-               kfree(swl);
                return (QLA_MEMORY_ALLOC_FAILED);
        }
        new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
@@ -3372,14 +3372,12 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
                if (new_fcport == NULL) {
                        ql_log(ql_log_warn, vha, 0x2066,
                            "Memory allocation failed for fcport.\n");
-                       kfree(swl);
                        return (QLA_MEMORY_ALLOC_FAILED);
                }
                new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
                new_fcport->d_id.b24 = nxt_d_id.b24;
        }
 
-       kfree(swl);
        kfree(new_fcport);
 
        return (rval);
index 58ee44c896504acb5b6fc762b7a6c6f74371f574..aa4674f05b779d8a6df9e2fb8105263fd7863170 100644 (file)
@@ -3205,6 +3205,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
        vfree(ha->optrom_buffer);
        kfree(ha->nvram);
        kfree(ha->npiv_info);
+       kfree(ha->swl);
 
        ha->srb_mempool = NULL;
        ha->ctx_mempool = NULL;