[SCSI] qla2xxx: Consolidate firmware-dump handling across ISPs.
authorAndrew Vasquez <andrew.vasquez@qlogic.com>
Wed, 17 May 2006 22:09:50 +0000 (15:09 -0700)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Sat, 20 May 2006 14:50:11 +0000 (09:50 -0500)
Simplify and centralise buffer allocation/deallocation, as
there's no point in having two memory request methods.

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/qla2xxx/qla_dbg.c
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_os.c

index fee0c493775b8656d5275f95f9fc289c9a061ccb..e96d58ded57c3a08e28a7ddc73ecc193f6762107 100644 (file)
@@ -46,22 +46,16 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf, loff_t off,
        case 0:
                if (ha->fw_dump_reading == 1) {
                        qla_printk(KERN_INFO, ha,
-                           "Firmware dump cleared on (%ld).\n",
-                           ha->host_no);
+                           "Firmware dump cleared on (%ld).\n", ha->host_no);
 
                        vfree(ha->fw_dump_buffer);
-                       if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
-                               free_pages((unsigned long)ha->fw_dump,
-                                   ha->fw_dump_order);
-
-                       ha->fw_dump_reading = 0;
                        ha->fw_dump_buffer = NULL;
-                       ha->fw_dump = NULL;
+                       ha->fw_dump_reading = 0;
                        ha->fw_dumped = 0;
                }
                break;
        case 1:
-               if ((ha->fw_dump || ha->fw_dumped) && !ha->fw_dump_reading) {
+               if (ha->fw_dumped && !ha->fw_dump_reading) {
                        ha->fw_dump_reading = 1;
 
                        if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
index e8120fb7f88e80eecc83ec2c44090e13cac96142..74e54713aa7c2307f0f0200b874c6b5a7a1b891b 100644 (file)
@@ -28,7 +28,7 @@ qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
        uint16_t __iomem *dmp_reg;
        unsigned long   flags;
        struct qla2300_fw_dump  *fw;
-       uint32_t        dump_size, data_ram_cnt;
+       uint32_t        data_ram_cnt;
 
        risc_address = data_ram_cnt = 0;
        mb0 = mb2 = 0;
@@ -37,23 +37,16 @@ qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
        if (!hardware_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
 
-       if (ha->fw_dump != NULL) {
+       if (!ha->fw_dump) {
                qla_printk(KERN_WARNING, ha,
-                   "Firmware has been previously dumped (%p) -- ignoring "
-                   "request...\n", ha->fw_dump);
+                   "No buffer available for dump!!!\n");
                goto qla2300_fw_dump_failed;
        }
 
-       /* Allocate (large) dump buffer. */
-       dump_size = sizeof(struct qla2300_fw_dump);
-       dump_size += (ha->fw_memory_size - 0x11000) * sizeof(uint16_t);
-       ha->fw_dump_order = get_order(dump_size);
-       ha->fw_dump = (struct qla2300_fw_dump *) __get_free_pages(GFP_ATOMIC,
-           ha->fw_dump_order);
-       if (ha->fw_dump == NULL) {
+       if (ha->fw_dumped) {
                qla_printk(KERN_WARNING, ha,
-                   "Unable to allocated memory for firmware dump (%d/%d).\n",
-                   ha->fw_dump_order, dump_size);
+                   "Firmware has been previously dumped (%p) -- ignoring "
+                   "request...\n", ha->fw_dump);
                goto qla2300_fw_dump_failed;
        }
        fw = ha->fw_dump;
@@ -358,17 +351,16 @@ qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
                }
        }
 
-
        if (rval != QLA_SUCCESS) {
                qla_printk(KERN_WARNING, ha,
                    "Failed to dump firmware (%x)!!!\n", rval);
+               ha->fw_dumped = 0;
 
-               free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
-               ha->fw_dump = NULL;
        } else {
                qla_printk(KERN_INFO, ha,
                    "Firmware dump saved to temp buffer (%ld/%p).\n",
                    ha->host_no, ha->fw_dump);
+               ha->fw_dumped = 1;
        }
 
 qla2300_fw_dump_failed:
@@ -587,21 +579,16 @@ qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
        if (!hardware_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
 
-       if (ha->fw_dump != NULL) {
+       if (!ha->fw_dump) {
                qla_printk(KERN_WARNING, ha,
-                   "Firmware has been previously dumped (%p) -- ignoring "
-                   "request...\n", ha->fw_dump);
+                   "No buffer available for dump!!!\n");
                goto qla2100_fw_dump_failed;
        }
 
-       /* Allocate (large) dump buffer. */
-       ha->fw_dump_order = get_order(sizeof(struct qla2100_fw_dump));
-       ha->fw_dump = (struct qla2100_fw_dump *) __get_free_pages(GFP_ATOMIC,
-           ha->fw_dump_order);
-       if (ha->fw_dump == NULL) {
+       if (ha->fw_dumped) {
                qla_printk(KERN_WARNING, ha,
-                   "Unable to allocated memory for firmware dump (%d/%Zd).\n",
-                   ha->fw_dump_order, sizeof(struct qla2100_fw_dump));
+                   "Firmware has been previously dumped (%p) -- ignoring "
+                   "request...\n", ha->fw_dump);
                goto qla2100_fw_dump_failed;
        }
        fw = ha->fw_dump;
@@ -777,13 +764,13 @@ qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
        if (rval != QLA_SUCCESS) {
                qla_printk(KERN_WARNING, ha,
                    "Failed to dump firmware (%x)!!!\n", rval);
+               ha->fw_dumped = 0;
 
-               free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
-               ha->fw_dump = NULL;
        } else {
                qla_printk(KERN_INFO, ha,
                    "Firmware dump saved to temp buffer (%ld/%p).\n",
                    ha->host_no, ha->fw_dump);
+               ha->fw_dumped = 1;
        }
 
 qla2100_fw_dump_failed:
@@ -988,7 +975,7 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
        if (!hardware_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
 
-       if (!ha->fw_dump24) {
+       if (!ha->fw_dump) {
                qla_printk(KERN_WARNING, ha,
                    "No buffer available for dump!!!\n");
                goto qla24xx_fw_dump_failed;
@@ -997,10 +984,10 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
        if (ha->fw_dumped) {
                qla_printk(KERN_WARNING, ha,
                    "Firmware has been previously dumped (%p) -- ignoring "
-                   "request...\n", ha->fw_dump24);
+                   "request...\n", ha->fw_dump);
                goto qla24xx_fw_dump_failed;
        }
-       fw = (struct qla24xx_fw_dump *) ha->fw_dump24;
+       fw = ha->fw_dump;
 
        rval = QLA_SUCCESS;
        fw->host_status = RD_REG_DWORD(&reg->host_status);
@@ -1654,7 +1641,7 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
        } else {
                qla_printk(KERN_INFO, ha,
                    "Firmware dump saved to temp buffer (%ld/%p).\n",
-                   ha->host_no, ha->fw_dump24);
+                   ha->host_no, ha->fw_dump);
                ha->fw_dumped = 1;
        }
 
@@ -1672,7 +1659,7 @@ qla24xx_ascii_fw_dump(scsi_qla_host_t *ha)
        uint32_t ext_mem_cnt;
 
        uiter = ha->fw_dump_buffer;
-       fw = ha->fw_dump24;
+       fw = ha->fw_dump;
 
        qla_uprintf(&uiter, "ISP FW Version %d.%02d.%02d Attributes %04x\n",
            ha->fw_major_version, ha->fw_minor_version,
index 30a931979889c49d325dda5f57a7c0b999eb887b..d6f6579cfd277671da7fcfcbdccba0fef26ffe14 100644 (file)
@@ -2304,15 +2304,11 @@ typedef struct scsi_qla_host {
 
        /* Firmware dump information. */
        void            *fw_dump;
-       int             fw_dump_order;
+       int             fw_dumped;
        int             fw_dump_reading;
        char            *fw_dump_buffer;
        int             fw_dump_buffer_len;
 
-       int             fw_dumped;
-       void            *fw_dump24;
-       int             fw_dump24_len;
-
        uint8_t         host_str[16];
        uint32_t        pci_attr;
 
index 748be95c51a7771e1fe678870bfa6159ce8136e7..011e8795545aecb91eeff8f1b3879f960a87c3cd 100644 (file)
@@ -773,16 +773,26 @@ qla24xx_chip_diag(scsi_qla_host_t *ha)
 static void
 qla2x00_alloc_fw_dump(scsi_qla_host_t *ha)
 {
+       uint32_t dump_size = 0;
+
        ha->fw_dumped = 0;
-       ha->fw_dump24_len = sizeof(struct qla24xx_fw_dump);
-       ha->fw_dump24_len += (ha->fw_memory_size - 0x100000) * sizeof(uint32_t);
-       ha->fw_dump24 = vmalloc(ha->fw_dump24_len);
-       if (ha->fw_dump24)
+       if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
+               dump_size = sizeof(struct qla2100_fw_dump);
+       } else if (IS_QLA23XX(ha)) {
+               dump_size = sizeof(struct qla2300_fw_dump);
+               dump_size += (ha->fw_memory_size - 0x11000) * sizeof(uint16_t);
+        } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
+               dump_size = sizeof(struct qla24xx_fw_dump);
+               dump_size += (ha->fw_memory_size - 0x100000) * sizeof(uint32_t);
+       }
+
+       ha->fw_dump = vmalloc(dump_size);
+       if (ha->fw_dump)
                qla_printk(KERN_INFO, ha, "Allocated (%d KB) for firmware "
-                   "dump...\n", ha->fw_dump24_len / 1024);
+                   "dump...\n", dump_size / 1024);
        else
                qla_printk(KERN_WARNING, ha, "Unable to allocate (%d KB) for "
-                   "firmware dump!!!\n", ha->fw_dump24_len / 1024);
+                   "firmware dump!!!\n", dump_size / 1024);
 }
 
 /**
@@ -800,13 +810,12 @@ qla2x00_resize_request_q(scsi_qla_host_t *ha)
        dma_addr_t request_dma;
        request_t *request_ring;
 
+       qla2x00_alloc_fw_dump(ha);
+
        /* Valid only on recent ISPs. */
        if (IS_QLA2100(ha) || IS_QLA2200(ha))
                return;
 
-       if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
-               qla2x00_alloc_fw_dump(ha);
-
        /* Retrieve IOCB counts available to the firmware. */
        rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt);
        if (rval)
index b6adc8a9d4c8e26250938f1c0a9e87c48a692a48..1052528c3109e3041290c0b6816bc6fe88ca6a58 100644 (file)
@@ -2068,15 +2068,10 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
        }
        INIT_LIST_HEAD(&ha->fcports);
 
-       if (ha->fw_dump)
-               free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
-
-       vfree(ha->fw_dump24);
-
+       vfree(ha->fw_dump);
        vfree(ha->fw_dump_buffer);
 
        ha->fw_dump = NULL;
-       ha->fw_dump24 = NULL;
        ha->fw_dumped = 0;
        ha->fw_dump_reading = 0;
        ha->fw_dump_buffer = NULL;