diff options
Diffstat (limited to 'drivers/scsi/qla1280.c')
-rw-r--r-- | drivers/scsi/qla1280.c | 162 |
1 files changed, 109 insertions, 53 deletions
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 49ac4148493b..b8166ecfd0e3 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c | |||
@@ -17,9 +17,11 @@ | |||
17 | * General Public License for more details. | 17 | * General Public License for more details. |
18 | * | 18 | * |
19 | ******************************************************************************/ | 19 | ******************************************************************************/ |
20 | #define QLA1280_VERSION "3.27" | 20 | #define QLA1280_VERSION "3.27.1" |
21 | /***************************************************************************** | 21 | /***************************************************************************** |
22 | Revision History: | 22 | Revision History: |
23 | Rev 3.27.1, February 8, 2010, Michael Reed | ||
24 | - Retain firmware image for error recovery. | ||
23 | Rev 3.27, February 10, 2009, Michael Reed | 25 | Rev 3.27, February 10, 2009, Michael Reed |
24 | - General code cleanup. | 26 | - General code cleanup. |
25 | - Improve error recovery. | 27 | - Improve error recovery. |
@@ -346,7 +348,6 @@ | |||
346 | #include <linux/pci.h> | 348 | #include <linux/pci.h> |
347 | #include <linux/proc_fs.h> | 349 | #include <linux/proc_fs.h> |
348 | #include <linux/stat.h> | 350 | #include <linux/stat.h> |
349 | #include <linux/slab.h> | ||
350 | #include <linux/pci_ids.h> | 351 | #include <linux/pci_ids.h> |
351 | #include <linux/interrupt.h> | 352 | #include <linux/interrupt.h> |
352 | #include <linux/init.h> | 353 | #include <linux/init.h> |
@@ -538,9 +539,9 @@ __setup("qla1280=", qla1280_setup); | |||
538 | /*****************************************/ | 539 | /*****************************************/ |
539 | 540 | ||
540 | struct qla_boards { | 541 | struct qla_boards { |
541 | unsigned char name[9]; /* Board ID String */ | 542 | char *name; /* Board ID String */ |
542 | int numPorts; /* Number of SCSI ports */ | 543 | int numPorts; /* Number of SCSI ports */ |
543 | char *fwname; /* firmware name */ | 544 | int fw_index; /* index into qla1280_fw_tbl for firmware */ |
544 | }; | 545 | }; |
545 | 546 | ||
546 | /* NOTE: the last argument in each entry is used to index ql1280_board_tbl */ | 547 | /* NOTE: the last argument in each entry is used to index ql1280_board_tbl */ |
@@ -561,15 +562,30 @@ static struct pci_device_id qla1280_pci_tbl[] = { | |||
561 | }; | 562 | }; |
562 | MODULE_DEVICE_TABLE(pci, qla1280_pci_tbl); | 563 | MODULE_DEVICE_TABLE(pci, qla1280_pci_tbl); |
563 | 564 | ||
565 | DEFINE_MUTEX(qla1280_firmware_mutex); | ||
566 | |||
567 | struct qla_fw { | ||
568 | char *fwname; | ||
569 | const struct firmware *fw; | ||
570 | }; | ||
571 | |||
572 | #define QL_NUM_FW_IMAGES 3 | ||
573 | |||
574 | struct qla_fw qla1280_fw_tbl[QL_NUM_FW_IMAGES] = { | ||
575 | {"qlogic/1040.bin", NULL}, /* image 0 */ | ||
576 | {"qlogic/1280.bin", NULL}, /* image 1 */ | ||
577 | {"qlogic/12160.bin", NULL}, /* image 2 */ | ||
578 | }; | ||
579 | |||
580 | /* NOTE: Order of boards in this table must match order in qla1280_pci_tbl */ | ||
564 | static struct qla_boards ql1280_board_tbl[] = { | 581 | static struct qla_boards ql1280_board_tbl[] = { |
565 | /* Name , Number of ports, FW details */ | 582 | {.name = "QLA12160", .numPorts = 2, .fw_index = 2}, |
566 | {"QLA12160", 2, "qlogic/12160.bin"}, | 583 | {.name = "QLA1040" , .numPorts = 1, .fw_index = 0}, |
567 | {"QLA1040", 1, "qlogic/1040.bin"}, | 584 | {.name = "QLA1080" , .numPorts = 1, .fw_index = 1}, |
568 | {"QLA1080", 1, "qlogic/1280.bin"}, | 585 | {.name = "QLA1240" , .numPorts = 2, .fw_index = 1}, |
569 | {"QLA1240", 2, "qlogic/1280.bin"}, | 586 | {.name = "QLA1280" , .numPorts = 2, .fw_index = 1}, |
570 | {"QLA1280", 2, "qlogic/1280.bin"}, | 587 | {.name = "QLA10160", .numPorts = 1, .fw_index = 2}, |
571 | {"QLA10160", 1, "qlogic/12160.bin"}, | 588 | {.name = " ", .numPorts = 0, .fw_index = -1}, |
572 | {" ", 0, " "}, | ||
573 | }; | 589 | }; |
574 | 590 | ||
575 | static int qla1280_verbose = 1; | 591 | static int qla1280_verbose = 1; |
@@ -1512,6 +1528,63 @@ qla1280_initialize_adapter(struct scsi_qla_host *ha) | |||
1512 | } | 1528 | } |
1513 | 1529 | ||
1514 | /* | 1530 | /* |
1531 | * qla1280_request_firmware | ||
1532 | * Acquire firmware for chip. Retain in memory | ||
1533 | * for error recovery. | ||
1534 | * | ||
1535 | * Input: | ||
1536 | * ha = adapter block pointer. | ||
1537 | * | ||
1538 | * Returns: | ||
1539 | * Pointer to firmware image or an error code | ||
1540 | * cast to pointer via ERR_PTR(). | ||
1541 | */ | ||
1542 | static const struct firmware * | ||
1543 | qla1280_request_firmware(struct scsi_qla_host *ha) | ||
1544 | { | ||
1545 | const struct firmware *fw; | ||
1546 | int err; | ||
1547 | int index; | ||
1548 | char *fwname; | ||
1549 | |||
1550 | spin_unlock_irq(ha->host->host_lock); | ||
1551 | mutex_lock(&qla1280_firmware_mutex); | ||
1552 | |||
1553 | index = ql1280_board_tbl[ha->devnum].fw_index; | ||
1554 | fw = qla1280_fw_tbl[index].fw; | ||
1555 | if (fw) | ||
1556 | goto out; | ||
1557 | |||
1558 | fwname = qla1280_fw_tbl[index].fwname; | ||
1559 | err = request_firmware(&fw, fwname, &ha->pdev->dev); | ||
1560 | |||
1561 | if (err) { | ||
1562 | printk(KERN_ERR "Failed to load image \"%s\" err %d\n", | ||
1563 | fwname, err); | ||
1564 | fw = ERR_PTR(err); | ||
1565 | goto unlock; | ||
1566 | } | ||
1567 | if ((fw->size % 2) || (fw->size < 6)) { | ||
1568 | printk(KERN_ERR "Invalid firmware length %zu in image \"%s\"\n", | ||
1569 | fw->size, fwname); | ||
1570 | release_firmware(fw); | ||
1571 | fw = ERR_PTR(-EINVAL); | ||
1572 | goto unlock; | ||
1573 | } | ||
1574 | |||
1575 | qla1280_fw_tbl[index].fw = fw; | ||
1576 | |||
1577 | out: | ||
1578 | ha->fwver1 = fw->data[0]; | ||
1579 | ha->fwver2 = fw->data[1]; | ||
1580 | ha->fwver3 = fw->data[2]; | ||
1581 | unlock: | ||
1582 | mutex_unlock(&qla1280_firmware_mutex); | ||
1583 | spin_lock_irq(ha->host->host_lock); | ||
1584 | return fw; | ||
1585 | } | ||
1586 | |||
1587 | /* | ||
1515 | * Chip diagnostics | 1588 | * Chip diagnostics |
1516 | * Test chip for proper operation. | 1589 | * Test chip for proper operation. |
1517 | * | 1590 | * |
@@ -1634,30 +1707,18 @@ qla1280_chip_diag(struct scsi_qla_host *ha) | |||
1634 | static int | 1707 | static int |
1635 | qla1280_load_firmware_pio(struct scsi_qla_host *ha) | 1708 | qla1280_load_firmware_pio(struct scsi_qla_host *ha) |
1636 | { | 1709 | { |
1710 | /* enter with host_lock acquired */ | ||
1711 | |||
1637 | const struct firmware *fw; | 1712 | const struct firmware *fw; |
1638 | const __le16 *fw_data; | 1713 | const __le16 *fw_data; |
1639 | uint16_t risc_address, risc_code_size; | 1714 | uint16_t risc_address, risc_code_size; |
1640 | uint16_t mb[MAILBOX_REGISTER_COUNT], i; | 1715 | uint16_t mb[MAILBOX_REGISTER_COUNT], i; |
1641 | int err; | 1716 | int err = 0; |
1717 | |||
1718 | fw = qla1280_request_firmware(ha); | ||
1719 | if (IS_ERR(fw)) | ||
1720 | return PTR_ERR(fw); | ||
1642 | 1721 | ||
1643 | spin_unlock_irq(ha->host->host_lock); | ||
1644 | err = request_firmware(&fw, ql1280_board_tbl[ha->devnum].fwname, | ||
1645 | &ha->pdev->dev); | ||
1646 | spin_lock_irq(ha->host->host_lock); | ||
1647 | if (err) { | ||
1648 | printk(KERN_ERR "Failed to load image \"%s\" err %d\n", | ||
1649 | ql1280_board_tbl[ha->devnum].fwname, err); | ||
1650 | return err; | ||
1651 | } | ||
1652 | if ((fw->size % 2) || (fw->size < 6)) { | ||
1653 | printk(KERN_ERR "Bogus length %zu in image \"%s\"\n", | ||
1654 | fw->size, ql1280_board_tbl[ha->devnum].fwname); | ||
1655 | err = -EINVAL; | ||
1656 | goto out; | ||
1657 | } | ||
1658 | ha->fwver1 = fw->data[0]; | ||
1659 | ha->fwver2 = fw->data[1]; | ||
1660 | ha->fwver3 = fw->data[2]; | ||
1661 | fw_data = (const __le16 *)&fw->data[0]; | 1722 | fw_data = (const __le16 *)&fw->data[0]; |
1662 | ha->fwstart = __le16_to_cpu(fw_data[2]); | 1723 | ha->fwstart = __le16_to_cpu(fw_data[2]); |
1663 | 1724 | ||
@@ -1675,11 +1736,10 @@ qla1280_load_firmware_pio(struct scsi_qla_host *ha) | |||
1675 | if (err) { | 1736 | if (err) { |
1676 | printk(KERN_ERR "scsi(%li): Failed to load firmware\n", | 1737 | printk(KERN_ERR "scsi(%li): Failed to load firmware\n", |
1677 | ha->host_no); | 1738 | ha->host_no); |
1678 | goto out; | 1739 | break; |
1679 | } | 1740 | } |
1680 | } | 1741 | } |
1681 | out: | 1742 | |
1682 | release_firmware(fw); | ||
1683 | return err; | 1743 | return err; |
1684 | } | 1744 | } |
1685 | 1745 | ||
@@ -1687,6 +1747,7 @@ out: | |||
1687 | static int | 1747 | static int |
1688 | qla1280_load_firmware_dma(struct scsi_qla_host *ha) | 1748 | qla1280_load_firmware_dma(struct scsi_qla_host *ha) |
1689 | { | 1749 | { |
1750 | /* enter with host_lock acquired */ | ||
1690 | const struct firmware *fw; | 1751 | const struct firmware *fw; |
1691 | const __le16 *fw_data; | 1752 | const __le16 *fw_data; |
1692 | uint16_t risc_address, risc_code_size; | 1753 | uint16_t risc_address, risc_code_size; |
@@ -1701,24 +1762,10 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha) | |||
1701 | return -ENOMEM; | 1762 | return -ENOMEM; |
1702 | #endif | 1763 | #endif |
1703 | 1764 | ||
1704 | spin_unlock_irq(ha->host->host_lock); | 1765 | fw = qla1280_request_firmware(ha); |
1705 | err = request_firmware(&fw, ql1280_board_tbl[ha->devnum].fwname, | 1766 | if (IS_ERR(fw)) |
1706 | &ha->pdev->dev); | 1767 | return PTR_ERR(fw); |
1707 | spin_lock_irq(ha->host->host_lock); | 1768 | |
1708 | if (err) { | ||
1709 | printk(KERN_ERR "Failed to load image \"%s\" err %d\n", | ||
1710 | ql1280_board_tbl[ha->devnum].fwname, err); | ||
1711 | return err; | ||
1712 | } | ||
1713 | if ((fw->size % 2) || (fw->size < 6)) { | ||
1714 | printk(KERN_ERR "Bogus length %zu in image \"%s\"\n", | ||
1715 | fw->size, ql1280_board_tbl[ha->devnum].fwname); | ||
1716 | err = -EINVAL; | ||
1717 | goto out; | ||
1718 | } | ||
1719 | ha->fwver1 = fw->data[0]; | ||
1720 | ha->fwver2 = fw->data[1]; | ||
1721 | ha->fwver3 = fw->data[2]; | ||
1722 | fw_data = (const __le16 *)&fw->data[0]; | 1769 | fw_data = (const __le16 *)&fw->data[0]; |
1723 | ha->fwstart = __le16_to_cpu(fw_data[2]); | 1770 | ha->fwstart = __le16_to_cpu(fw_data[2]); |
1724 | 1771 | ||
@@ -1803,7 +1850,6 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha) | |||
1803 | #if DUMP_IT_BACK | 1850 | #if DUMP_IT_BACK |
1804 | pci_free_consistent(ha->pdev, 8000, tbuf, p_tbuf); | 1851 | pci_free_consistent(ha->pdev, 8000, tbuf, p_tbuf); |
1805 | #endif | 1852 | #endif |
1806 | release_firmware(fw); | ||
1807 | return err; | 1853 | return err; |
1808 | } | 1854 | } |
1809 | 1855 | ||
@@ -1842,6 +1888,7 @@ qla1280_start_firmware(struct scsi_qla_host *ha) | |||
1842 | static int | 1888 | static int |
1843 | qla1280_load_firmware(struct scsi_qla_host *ha) | 1889 | qla1280_load_firmware(struct scsi_qla_host *ha) |
1844 | { | 1890 | { |
1891 | /* enter with host_lock taken */ | ||
1845 | int err; | 1892 | int err; |
1846 | 1893 | ||
1847 | err = qla1280_chip_diag(ha); | 1894 | err = qla1280_chip_diag(ha); |
@@ -4420,7 +4467,16 @@ qla1280_init(void) | |||
4420 | static void __exit | 4467 | static void __exit |
4421 | qla1280_exit(void) | 4468 | qla1280_exit(void) |
4422 | { | 4469 | { |
4470 | int i; | ||
4471 | |||
4423 | pci_unregister_driver(&qla1280_pci_driver); | 4472 | pci_unregister_driver(&qla1280_pci_driver); |
4473 | /* release any allocated firmware images */ | ||
4474 | for (i = 0; i < QL_NUM_FW_IMAGES; i++) { | ||
4475 | if (qla1280_fw_tbl[i].fw) { | ||
4476 | release_firmware(qla1280_fw_tbl[i].fw); | ||
4477 | qla1280_fw_tbl[i].fw = NULL; | ||
4478 | } | ||
4479 | } | ||
4424 | } | 4480 | } |
4425 | 4481 | ||
4426 | module_init(qla1280_init); | 4482 | module_init(qla1280_init); |