aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorAndrew Vasquez <andrew.vasquez@qlogic.com>2006-05-17 18:09:50 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-05-20 10:50:11 -0400
commitd4e3e04d789ba23027c66e176b10ac7477906948 (patch)
treee98c514c2b3505af6f0c0a2e48f697899735ff15 /drivers/scsi
parentcb63067a772c0149184309a1f232d62c81a93673 (diff)
[SCSI] qla2xxx: Consolidate firmware-dump handling across ISPs.
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>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c53
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h6
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c27
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c7
5 files changed, 43 insertions, 62 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index fee0c493775b..e96d58ded57c 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -46,22 +46,16 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf, loff_t off,
46 case 0: 46 case 0:
47 if (ha->fw_dump_reading == 1) { 47 if (ha->fw_dump_reading == 1) {
48 qla_printk(KERN_INFO, ha, 48 qla_printk(KERN_INFO, ha,
49 "Firmware dump cleared on (%ld).\n", 49 "Firmware dump cleared on (%ld).\n", ha->host_no);
50 ha->host_no);
51 50
52 vfree(ha->fw_dump_buffer); 51 vfree(ha->fw_dump_buffer);
53 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
54 free_pages((unsigned long)ha->fw_dump,
55 ha->fw_dump_order);
56
57 ha->fw_dump_reading = 0;
58 ha->fw_dump_buffer = NULL; 52 ha->fw_dump_buffer = NULL;
59 ha->fw_dump = NULL; 53 ha->fw_dump_reading = 0;
60 ha->fw_dumped = 0; 54 ha->fw_dumped = 0;
61 } 55 }
62 break; 56 break;
63 case 1: 57 case 1:
64 if ((ha->fw_dump || ha->fw_dumped) && !ha->fw_dump_reading) { 58 if (ha->fw_dumped && !ha->fw_dump_reading) {
65 ha->fw_dump_reading = 1; 59 ha->fw_dump_reading = 1;
66 60
67 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 61 if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index e8120fb7f88e..74e54713aa7c 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -28,7 +28,7 @@ qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
28 uint16_t __iomem *dmp_reg; 28 uint16_t __iomem *dmp_reg;
29 unsigned long flags; 29 unsigned long flags;
30 struct qla2300_fw_dump *fw; 30 struct qla2300_fw_dump *fw;
31 uint32_t dump_size, data_ram_cnt; 31 uint32_t data_ram_cnt;
32 32
33 risc_address = data_ram_cnt = 0; 33 risc_address = data_ram_cnt = 0;
34 mb0 = mb2 = 0; 34 mb0 = mb2 = 0;
@@ -37,23 +37,16 @@ qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
37 if (!hardware_locked) 37 if (!hardware_locked)
38 spin_lock_irqsave(&ha->hardware_lock, flags); 38 spin_lock_irqsave(&ha->hardware_lock, flags);
39 39
40 if (ha->fw_dump != NULL) { 40 if (!ha->fw_dump) {
41 qla_printk(KERN_WARNING, ha, 41 qla_printk(KERN_WARNING, ha,
42 "Firmware has been previously dumped (%p) -- ignoring " 42 "No buffer available for dump!!!\n");
43 "request...\n", ha->fw_dump);
44 goto qla2300_fw_dump_failed; 43 goto qla2300_fw_dump_failed;
45 } 44 }
46 45
47 /* Allocate (large) dump buffer. */ 46 if (ha->fw_dumped) {
48 dump_size = sizeof(struct qla2300_fw_dump);
49 dump_size += (ha->fw_memory_size - 0x11000) * sizeof(uint16_t);
50 ha->fw_dump_order = get_order(dump_size);
51 ha->fw_dump = (struct qla2300_fw_dump *) __get_free_pages(GFP_ATOMIC,
52 ha->fw_dump_order);
53 if (ha->fw_dump == NULL) {
54 qla_printk(KERN_WARNING, ha, 47 qla_printk(KERN_WARNING, ha,
55 "Unable to allocated memory for firmware dump (%d/%d).\n", 48 "Firmware has been previously dumped (%p) -- ignoring "
56 ha->fw_dump_order, dump_size); 49 "request...\n", ha->fw_dump);
57 goto qla2300_fw_dump_failed; 50 goto qla2300_fw_dump_failed;
58 } 51 }
59 fw = ha->fw_dump; 52 fw = ha->fw_dump;
@@ -358,17 +351,16 @@ qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
358 } 351 }
359 } 352 }
360 353
361
362 if (rval != QLA_SUCCESS) { 354 if (rval != QLA_SUCCESS) {
363 qla_printk(KERN_WARNING, ha, 355 qla_printk(KERN_WARNING, ha,
364 "Failed to dump firmware (%x)!!!\n", rval); 356 "Failed to dump firmware (%x)!!!\n", rval);
357 ha->fw_dumped = 0;
365 358
366 free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
367 ha->fw_dump = NULL;
368 } else { 359 } else {
369 qla_printk(KERN_INFO, ha, 360 qla_printk(KERN_INFO, ha,
370 "Firmware dump saved to temp buffer (%ld/%p).\n", 361 "Firmware dump saved to temp buffer (%ld/%p).\n",
371 ha->host_no, ha->fw_dump); 362 ha->host_no, ha->fw_dump);
363 ha->fw_dumped = 1;
372 } 364 }
373 365
374qla2300_fw_dump_failed: 366qla2300_fw_dump_failed:
@@ -587,21 +579,16 @@ qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
587 if (!hardware_locked) 579 if (!hardware_locked)
588 spin_lock_irqsave(&ha->hardware_lock, flags); 580 spin_lock_irqsave(&ha->hardware_lock, flags);
589 581
590 if (ha->fw_dump != NULL) { 582 if (!ha->fw_dump) {
591 qla_printk(KERN_WARNING, ha, 583 qla_printk(KERN_WARNING, ha,
592 "Firmware has been previously dumped (%p) -- ignoring " 584 "No buffer available for dump!!!\n");
593 "request...\n", ha->fw_dump);
594 goto qla2100_fw_dump_failed; 585 goto qla2100_fw_dump_failed;
595 } 586 }
596 587
597 /* Allocate (large) dump buffer. */ 588 if (ha->fw_dumped) {
598 ha->fw_dump_order = get_order(sizeof(struct qla2100_fw_dump));
599 ha->fw_dump = (struct qla2100_fw_dump *) __get_free_pages(GFP_ATOMIC,
600 ha->fw_dump_order);
601 if (ha->fw_dump == NULL) {
602 qla_printk(KERN_WARNING, ha, 589 qla_printk(KERN_WARNING, ha,
603 "Unable to allocated memory for firmware dump (%d/%Zd).\n", 590 "Firmware has been previously dumped (%p) -- ignoring "
604 ha->fw_dump_order, sizeof(struct qla2100_fw_dump)); 591 "request...\n", ha->fw_dump);
605 goto qla2100_fw_dump_failed; 592 goto qla2100_fw_dump_failed;
606 } 593 }
607 fw = ha->fw_dump; 594 fw = ha->fw_dump;
@@ -777,13 +764,13 @@ qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
777 if (rval != QLA_SUCCESS) { 764 if (rval != QLA_SUCCESS) {
778 qla_printk(KERN_WARNING, ha, 765 qla_printk(KERN_WARNING, ha,
779 "Failed to dump firmware (%x)!!!\n", rval); 766 "Failed to dump firmware (%x)!!!\n", rval);
767 ha->fw_dumped = 0;
780 768
781 free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
782 ha->fw_dump = NULL;
783 } else { 769 } else {
784 qla_printk(KERN_INFO, ha, 770 qla_printk(KERN_INFO, ha,
785 "Firmware dump saved to temp buffer (%ld/%p).\n", 771 "Firmware dump saved to temp buffer (%ld/%p).\n",
786 ha->host_no, ha->fw_dump); 772 ha->host_no, ha->fw_dump);
773 ha->fw_dumped = 1;
787 } 774 }
788 775
789qla2100_fw_dump_failed: 776qla2100_fw_dump_failed:
@@ -988,7 +975,7 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
988 if (!hardware_locked) 975 if (!hardware_locked)
989 spin_lock_irqsave(&ha->hardware_lock, flags); 976 spin_lock_irqsave(&ha->hardware_lock, flags);
990 977
991 if (!ha->fw_dump24) { 978 if (!ha->fw_dump) {
992 qla_printk(KERN_WARNING, ha, 979 qla_printk(KERN_WARNING, ha,
993 "No buffer available for dump!!!\n"); 980 "No buffer available for dump!!!\n");
994 goto qla24xx_fw_dump_failed; 981 goto qla24xx_fw_dump_failed;
@@ -997,10 +984,10 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
997 if (ha->fw_dumped) { 984 if (ha->fw_dumped) {
998 qla_printk(KERN_WARNING, ha, 985 qla_printk(KERN_WARNING, ha,
999 "Firmware has been previously dumped (%p) -- ignoring " 986 "Firmware has been previously dumped (%p) -- ignoring "
1000 "request...\n", ha->fw_dump24); 987 "request...\n", ha->fw_dump);
1001 goto qla24xx_fw_dump_failed; 988 goto qla24xx_fw_dump_failed;
1002 } 989 }
1003 fw = (struct qla24xx_fw_dump *) ha->fw_dump24; 990 fw = ha->fw_dump;
1004 991
1005 rval = QLA_SUCCESS; 992 rval = QLA_SUCCESS;
1006 fw->host_status = RD_REG_DWORD(&reg->host_status); 993 fw->host_status = RD_REG_DWORD(&reg->host_status);
@@ -1654,7 +1641,7 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1654 } else { 1641 } else {
1655 qla_printk(KERN_INFO, ha, 1642 qla_printk(KERN_INFO, ha,
1656 "Firmware dump saved to temp buffer (%ld/%p).\n", 1643 "Firmware dump saved to temp buffer (%ld/%p).\n",
1657 ha->host_no, ha->fw_dump24); 1644 ha->host_no, ha->fw_dump);
1658 ha->fw_dumped = 1; 1645 ha->fw_dumped = 1;
1659 } 1646 }
1660 1647
@@ -1672,7 +1659,7 @@ qla24xx_ascii_fw_dump(scsi_qla_host_t *ha)
1672 uint32_t ext_mem_cnt; 1659 uint32_t ext_mem_cnt;
1673 1660
1674 uiter = ha->fw_dump_buffer; 1661 uiter = ha->fw_dump_buffer;
1675 fw = ha->fw_dump24; 1662 fw = ha->fw_dump;
1676 1663
1677 qla_uprintf(&uiter, "ISP FW Version %d.%02d.%02d Attributes %04x\n", 1664 qla_uprintf(&uiter, "ISP FW Version %d.%02d.%02d Attributes %04x\n",
1678 ha->fw_major_version, ha->fw_minor_version, 1665 ha->fw_major_version, ha->fw_minor_version,
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 30a931979889..d6f6579cfd27 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2304,15 +2304,11 @@ typedef struct scsi_qla_host {
2304 2304
2305 /* Firmware dump information. */ 2305 /* Firmware dump information. */
2306 void *fw_dump; 2306 void *fw_dump;
2307 int fw_dump_order; 2307 int fw_dumped;
2308 int fw_dump_reading; 2308 int fw_dump_reading;
2309 char *fw_dump_buffer; 2309 char *fw_dump_buffer;
2310 int fw_dump_buffer_len; 2310 int fw_dump_buffer_len;
2311 2311
2312 int fw_dumped;
2313 void *fw_dump24;
2314 int fw_dump24_len;
2315
2316 uint8_t host_str[16]; 2312 uint8_t host_str[16];
2317 uint32_t pci_attr; 2313 uint32_t pci_attr;
2318 2314
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 748be95c51a7..011e8795545a 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -773,16 +773,26 @@ qla24xx_chip_diag(scsi_qla_host_t *ha)
773static void 773static void
774qla2x00_alloc_fw_dump(scsi_qla_host_t *ha) 774qla2x00_alloc_fw_dump(scsi_qla_host_t *ha)
775{ 775{
776 uint32_t dump_size = 0;
777
776 ha->fw_dumped = 0; 778 ha->fw_dumped = 0;
777 ha->fw_dump24_len = sizeof(struct qla24xx_fw_dump); 779 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
778 ha->fw_dump24_len += (ha->fw_memory_size - 0x100000) * sizeof(uint32_t); 780 dump_size = sizeof(struct qla2100_fw_dump);
779 ha->fw_dump24 = vmalloc(ha->fw_dump24_len); 781 } else if (IS_QLA23XX(ha)) {
780 if (ha->fw_dump24) 782 dump_size = sizeof(struct qla2300_fw_dump);
783 dump_size += (ha->fw_memory_size - 0x11000) * sizeof(uint16_t);
784 } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
785 dump_size = sizeof(struct qla24xx_fw_dump);
786 dump_size += (ha->fw_memory_size - 0x100000) * sizeof(uint32_t);
787 }
788
789 ha->fw_dump = vmalloc(dump_size);
790 if (ha->fw_dump)
781 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for firmware " 791 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for firmware "
782 "dump...\n", ha->fw_dump24_len / 1024); 792 "dump...\n", dump_size / 1024);
783 else 793 else
784 qla_printk(KERN_WARNING, ha, "Unable to allocate (%d KB) for " 794 qla_printk(KERN_WARNING, ha, "Unable to allocate (%d KB) for "
785 "firmware dump!!!\n", ha->fw_dump24_len / 1024); 795 "firmware dump!!!\n", dump_size / 1024);
786} 796}
787 797
788/** 798/**
@@ -800,13 +810,12 @@ qla2x00_resize_request_q(scsi_qla_host_t *ha)
800 dma_addr_t request_dma; 810 dma_addr_t request_dma;
801 request_t *request_ring; 811 request_t *request_ring;
802 812
813 qla2x00_alloc_fw_dump(ha);
814
803 /* Valid only on recent ISPs. */ 815 /* Valid only on recent ISPs. */
804 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 816 if (IS_QLA2100(ha) || IS_QLA2200(ha))
805 return; 817 return;
806 818
807 if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
808 qla2x00_alloc_fw_dump(ha);
809
810 /* Retrieve IOCB counts available to the firmware. */ 819 /* Retrieve IOCB counts available to the firmware. */
811 rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt); 820 rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt);
812 if (rval) 821 if (rval)
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index b6adc8a9d4c8..1052528c3109 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -2068,15 +2068,10 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
2068 } 2068 }
2069 INIT_LIST_HEAD(&ha->fcports); 2069 INIT_LIST_HEAD(&ha->fcports);
2070 2070
2071 if (ha->fw_dump) 2071 vfree(ha->fw_dump);
2072 free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
2073
2074 vfree(ha->fw_dump24);
2075
2076 vfree(ha->fw_dump_buffer); 2072 vfree(ha->fw_dump_buffer);
2077 2073
2078 ha->fw_dump = NULL; 2074 ha->fw_dump = NULL;
2079 ha->fw_dump24 = NULL;
2080 ha->fw_dumped = 0; 2075 ha->fw_dumped = 0;
2081 ha->fw_dump_reading = 0; 2076 ha->fw_dump_reading = 0;
2082 ha->fw_dump_buffer = NULL; 2077 ha->fw_dump_buffer = NULL;