diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_sli.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_sli.c | 470 |
1 files changed, 342 insertions, 128 deletions
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 7b785ade8b07..bb69a7a1ec59 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2005 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2006 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -513,7 +513,9 @@ lpfc_sli_chk_mbx_command(uint8_t mbxCommand) | |||
513 | case MBX_SET_MASK: | 513 | case MBX_SET_MASK: |
514 | case MBX_SET_SLIM: | 514 | case MBX_SET_SLIM: |
515 | case MBX_UNREG_D_ID: | 515 | case MBX_UNREG_D_ID: |
516 | case MBX_KILL_BOARD: | ||
516 | case MBX_CONFIG_FARP: | 517 | case MBX_CONFIG_FARP: |
518 | case MBX_BEACON: | ||
517 | case MBX_LOAD_AREA: | 519 | case MBX_LOAD_AREA: |
518 | case MBX_RUN_BIU_DIAG64: | 520 | case MBX_RUN_BIU_DIAG64: |
519 | case MBX_CONFIG_PORT: | 521 | case MBX_CONFIG_PORT: |
@@ -764,7 +766,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
764 | } | 766 | } |
765 | /* unSolicited Responses */ | 767 | /* unSolicited Responses */ |
766 | if (pring->prt[0].profile) { | 768 | if (pring->prt[0].profile) { |
767 | (pring->prt[0].lpfc_sli_rcv_unsol_event) (phba, pring, saveq); | 769 | if (pring->prt[0].lpfc_sli_rcv_unsol_event) |
770 | (pring->prt[0].lpfc_sli_rcv_unsol_event) (phba, pring, | ||
771 | saveq); | ||
768 | match = 1; | 772 | match = 1; |
769 | } else { | 773 | } else { |
770 | /* We must search, based on rctl / type | 774 | /* We must search, based on rctl / type |
@@ -775,8 +779,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
775 | Rctl) | 779 | Rctl) |
776 | && (pring->prt[i]. | 780 | && (pring->prt[i]. |
777 | type == Type)) { | 781 | type == Type)) { |
778 | (pring->prt[i].lpfc_sli_rcv_unsol_event) | 782 | if (pring->prt[i].lpfc_sli_rcv_unsol_event) |
779 | (phba, pring, saveq); | 783 | (pring->prt[i].lpfc_sli_rcv_unsol_event) |
784 | (phba, pring, saveq); | ||
780 | match = 1; | 785 | match = 1; |
781 | break; | 786 | break; |
782 | } | 787 | } |
@@ -1149,12 +1154,17 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, | |||
1149 | cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring, | 1154 | cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring, |
1150 | &rspiocbq); | 1155 | &rspiocbq); |
1151 | if ((cmdiocbq) && (cmdiocbq->iocb_cmpl)) { | 1156 | if ((cmdiocbq) && (cmdiocbq->iocb_cmpl)) { |
1152 | spin_unlock_irqrestore( | 1157 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { |
1153 | phba->host->host_lock, iflag); | 1158 | (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, |
1154 | (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, | 1159 | &rspiocbq); |
1155 | &rspiocbq); | 1160 | } else { |
1156 | spin_lock_irqsave(phba->host->host_lock, | 1161 | spin_unlock_irqrestore( |
1157 | iflag); | 1162 | phba->host->host_lock, iflag); |
1163 | (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, | ||
1164 | &rspiocbq); | ||
1165 | spin_lock_irqsave(phba->host->host_lock, | ||
1166 | iflag); | ||
1167 | } | ||
1158 | } | 1168 | } |
1159 | break; | 1169 | break; |
1160 | default: | 1170 | default: |
@@ -1512,98 +1522,240 @@ lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
1512 | return errcnt; | 1522 | return errcnt; |
1513 | } | 1523 | } |
1514 | 1524 | ||
1515 | /****************************************************************************** | 1525 | int |
1516 | * lpfc_sli_send_reset | 1526 | lpfc_sli_brdready(struct lpfc_hba * phba, uint32_t mask) |
1517 | * | ||
1518 | * Note: After returning from this function, the HBA cannot be accessed for | ||
1519 | * 1 ms. Since we do not wish to delay in interrupt context, it is the | ||
1520 | * responsibility of the caller to perform the mdelay(1) and flush via readl(). | ||
1521 | ******************************************************************************/ | ||
1522 | static int | ||
1523 | lpfc_sli_send_reset(struct lpfc_hba * phba, uint16_t skip_post) | ||
1524 | { | 1527 | { |
1525 | MAILBOX_t *swpmb; | 1528 | uint32_t status; |
1526 | volatile uint32_t word0; | 1529 | int i = 0; |
1527 | void __iomem *to_slim; | 1530 | int retval = 0; |
1528 | unsigned long flags = 0; | ||
1529 | |||
1530 | spin_lock_irqsave(phba->host->host_lock, flags); | ||
1531 | 1531 | ||
1532 | /* A board reset must use REAL SLIM. */ | 1532 | /* Read the HBA Host Status Register */ |
1533 | phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE; | 1533 | status = readl(phba->HSregaddr); |
1534 | 1534 | ||
1535 | word0 = 0; | 1535 | /* |
1536 | swpmb = (MAILBOX_t *) & word0; | 1536 | * Check status register every 100ms for 5 retries, then every |
1537 | swpmb->mbxCommand = MBX_RESTART; | 1537 | * 500ms for 5, then every 2.5 sec for 5, then reset board and |
1538 | swpmb->mbxHc = 1; | 1538 | * every 2.5 sec for 4. |
1539 | * Break our of the loop if errors occurred during init. | ||
1540 | */ | ||
1541 | while (((status & mask) != mask) && | ||
1542 | !(status & HS_FFERM) && | ||
1543 | i++ < 20) { | ||
1539 | 1544 | ||
1540 | to_slim = phba->MBslimaddr; | 1545 | if (i <= 5) |
1541 | writel(*(uint32_t *) swpmb, to_slim); | 1546 | msleep(10); |
1542 | readl(to_slim); /* flush */ | 1547 | else if (i <= 10) |
1548 | msleep(500); | ||
1549 | else | ||
1550 | msleep(2500); | ||
1543 | 1551 | ||
1544 | /* Only skip post after fc_ffinit is completed */ | 1552 | if (i == 15) { |
1545 | if (skip_post) { | 1553 | phba->hba_state = LPFC_STATE_UNKNOWN; /* Do post */ |
1546 | word0 = 1; /* This is really setting up word1 */ | 1554 | lpfc_sli_brdrestart(phba); |
1547 | } else { | 1555 | } |
1548 | word0 = 0; /* This is really setting up word1 */ | 1556 | /* Read the HBA Host Status Register */ |
1557 | status = readl(phba->HSregaddr); | ||
1549 | } | 1558 | } |
1550 | to_slim = phba->MBslimaddr + sizeof (uint32_t); | ||
1551 | writel(*(uint32_t *) swpmb, to_slim); | ||
1552 | readl(to_slim); /* flush */ | ||
1553 | |||
1554 | /* Turn off parity checking and serr during the physical reset */ | ||
1555 | pci_read_config_word(phba->pcidev, PCI_COMMAND, &phba->pci_cfg_value); | ||
1556 | pci_write_config_word(phba->pcidev, PCI_COMMAND, | ||
1557 | (phba->pci_cfg_value & | ||
1558 | ~(PCI_COMMAND_PARITY | PCI_COMMAND_SERR))); | ||
1559 | |||
1560 | writel(HC_INITFF, phba->HCregaddr); | ||
1561 | 1559 | ||
1562 | phba->hba_state = LPFC_INIT_START; | 1560 | /* Check to see if any errors occurred during init */ |
1563 | spin_unlock_irqrestore(phba->host->host_lock, flags); | 1561 | if ((status & HS_FFERM) || (i >= 20)) { |
1562 | phba->hba_state = LPFC_HBA_ERROR; | ||
1563 | retval = 1; | ||
1564 | } | ||
1564 | 1565 | ||
1565 | return 0; | 1566 | return retval; |
1566 | } | 1567 | } |
1567 | 1568 | ||
1568 | static int | 1569 | #define BARRIER_TEST_PATTERN (0xdeadbeef) |
1569 | lpfc_sli_brdreset(struct lpfc_hba * phba, uint16_t skip_post) | 1570 | |
1571 | void lpfc_reset_barrier(struct lpfc_hba * phba) | ||
1570 | { | 1572 | { |
1571 | struct lpfc_sli_ring *pring; | 1573 | uint32_t * resp_buf; |
1572 | int i; | 1574 | uint32_t * mbox_buf; |
1573 | struct lpfc_dmabuf *mp, *next_mp; | 1575 | volatile uint32_t mbox; |
1574 | unsigned long flags = 0; | 1576 | uint32_t hc_copy; |
1577 | int i; | ||
1578 | uint8_t hdrtype; | ||
1579 | |||
1580 | pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype); | ||
1581 | if (hdrtype != 0x80 || | ||
1582 | (FC_JEDEC_ID(phba->vpd.rev.biuRev) != HELIOS_JEDEC_ID && | ||
1583 | FC_JEDEC_ID(phba->vpd.rev.biuRev) != THOR_JEDEC_ID)) | ||
1584 | return; | ||
1575 | 1585 | ||
1576 | lpfc_sli_send_reset(phba, skip_post); | 1586 | /* |
1577 | mdelay(1); | 1587 | * Tell the other part of the chip to suspend temporarily all |
1588 | * its DMA activity. | ||
1589 | */ | ||
1590 | resp_buf = (uint32_t *)phba->MBslimaddr; | ||
1578 | 1591 | ||
1579 | spin_lock_irqsave(phba->host->host_lock, flags); | 1592 | /* Disable the error attention */ |
1580 | /* Risk the write on flush case ie no delay after the readl */ | 1593 | hc_copy = readl(phba->HCregaddr); |
1594 | writel((hc_copy & ~HC_ERINT_ENA), phba->HCregaddr); | ||
1581 | readl(phba->HCregaddr); /* flush */ | 1595 | readl(phba->HCregaddr); /* flush */ |
1582 | /* Now toggle INITFF bit set by lpfc_sli_send_reset */ | 1596 | |
1583 | writel(0, phba->HCregaddr); | 1597 | if (readl(phba->HAregaddr) & HA_ERATT) { |
1598 | /* Clear Chip error bit */ | ||
1599 | writel(HA_ERATT, phba->HAregaddr); | ||
1600 | phba->stopped = 1; | ||
1601 | } | ||
1602 | |||
1603 | mbox = 0; | ||
1604 | ((MAILBOX_t *)&mbox)->mbxCommand = MBX_KILL_BOARD; | ||
1605 | ((MAILBOX_t *)&mbox)->mbxOwner = OWN_CHIP; | ||
1606 | |||
1607 | writel(BARRIER_TEST_PATTERN, (resp_buf + 1)); | ||
1608 | mbox_buf = (uint32_t *)phba->MBslimaddr; | ||
1609 | writel(mbox, mbox_buf); | ||
1610 | |||
1611 | for (i = 0; | ||
1612 | readl(resp_buf + 1) != ~(BARRIER_TEST_PATTERN) && i < 50; i++) | ||
1613 | mdelay(1); | ||
1614 | |||
1615 | if (readl(resp_buf + 1) != ~(BARRIER_TEST_PATTERN)) { | ||
1616 | if (phba->sli.sli_flag & LPFC_SLI2_ACTIVE || | ||
1617 | phba->stopped) | ||
1618 | goto restore_hc; | ||
1619 | else | ||
1620 | goto clear_errat; | ||
1621 | } | ||
1622 | |||
1623 | ((MAILBOX_t *)&mbox)->mbxOwner = OWN_HOST; | ||
1624 | for (i = 0; readl(resp_buf) != mbox && i < 500; i++) | ||
1625 | mdelay(1); | ||
1626 | |||
1627 | clear_errat: | ||
1628 | |||
1629 | while (!(readl(phba->HAregaddr) & HA_ERATT) && ++i < 500) | ||
1630 | mdelay(1); | ||
1631 | |||
1632 | if (readl(phba->HAregaddr) & HA_ERATT) { | ||
1633 | writel(HA_ERATT, phba->HAregaddr); | ||
1634 | phba->stopped = 1; | ||
1635 | } | ||
1636 | |||
1637 | restore_hc: | ||
1638 | writel(hc_copy, phba->HCregaddr); | ||
1584 | readl(phba->HCregaddr); /* flush */ | 1639 | readl(phba->HCregaddr); /* flush */ |
1640 | } | ||
1585 | 1641 | ||
1586 | /* Restore PCI cmd register */ | 1642 | int |
1587 | pci_write_config_word(phba->pcidev, PCI_COMMAND, phba->pci_cfg_value); | 1643 | lpfc_sli_brdkill(struct lpfc_hba * phba) |
1644 | { | ||
1645 | struct lpfc_sli *psli; | ||
1646 | LPFC_MBOXQ_t *pmb; | ||
1647 | uint32_t status; | ||
1648 | uint32_t ha_copy; | ||
1649 | int retval; | ||
1650 | int i = 0; | ||
1588 | 1651 | ||
1589 | /* perform board reset */ | 1652 | psli = &phba->sli; |
1590 | phba->fc_eventTag = 0; | ||
1591 | phba->fc_myDID = 0; | ||
1592 | phba->fc_prevDID = Mask_DID; | ||
1593 | 1653 | ||
1594 | /* Reset HBA */ | 1654 | /* Kill HBA */ |
1595 | lpfc_printf_log(phba, | 1655 | lpfc_printf_log(phba, |
1596 | KERN_INFO, | 1656 | KERN_INFO, |
1597 | LOG_SLI, | 1657 | LOG_SLI, |
1598 | "%d:0325 Reset HBA Data: x%x x%x x%x\n", | 1658 | "%d:0329 Kill HBA Data: x%x x%x\n", |
1599 | phba->brd_no, | 1659 | phba->brd_no, |
1600 | phba->hba_state, | 1660 | phba->hba_state, |
1601 | phba->sli.sli_flag, | 1661 | psli->sli_flag); |
1602 | skip_post); | 1662 | |
1663 | if ((pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, | ||
1664 | GFP_KERNEL)) == 0) | ||
1665 | return 1; | ||
1666 | |||
1667 | /* Disable the error attention */ | ||
1668 | spin_lock_irq(phba->host->host_lock); | ||
1669 | status = readl(phba->HCregaddr); | ||
1670 | status &= ~HC_ERINT_ENA; | ||
1671 | writel(status, phba->HCregaddr); | ||
1672 | readl(phba->HCregaddr); /* flush */ | ||
1673 | spin_unlock_irq(phba->host->host_lock); | ||
1674 | |||
1675 | lpfc_kill_board(phba, pmb); | ||
1676 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | ||
1677 | retval = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | ||
1678 | |||
1679 | if (retval != MBX_SUCCESS) { | ||
1680 | if (retval != MBX_BUSY) | ||
1681 | mempool_free(pmb, phba->mbox_mem_pool); | ||
1682 | return 1; | ||
1683 | } | ||
1684 | |||
1685 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | ||
1686 | |||
1687 | mempool_free(pmb, phba->mbox_mem_pool); | ||
1688 | |||
1689 | /* There is no completion for a KILL_BOARD mbox cmd. Check for an error | ||
1690 | * attention every 100ms for 3 seconds. If we don't get ERATT after | ||
1691 | * 3 seconds we still set HBA_ERROR state because the status of the | ||
1692 | * board is now undefined. | ||
1693 | */ | ||
1694 | ha_copy = readl(phba->HAregaddr); | ||
1695 | |||
1696 | while ((i++ < 30) && !(ha_copy & HA_ERATT)) { | ||
1697 | mdelay(100); | ||
1698 | ha_copy = readl(phba->HAregaddr); | ||
1699 | } | ||
1700 | |||
1701 | del_timer_sync(&psli->mbox_tmo); | ||
1702 | if (ha_copy & HA_ERATT) { | ||
1703 | writel(HA_ERATT, phba->HAregaddr); | ||
1704 | phba->stopped = 1; | ||
1705 | } | ||
1706 | spin_lock_irq(phba->host->host_lock); | ||
1707 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | ||
1708 | spin_unlock_irq(phba->host->host_lock); | ||
1709 | |||
1710 | psli->mbox_active = NULL; | ||
1711 | lpfc_hba_down_post(phba); | ||
1712 | phba->hba_state = LPFC_HBA_ERROR; | ||
1713 | |||
1714 | return (ha_copy & HA_ERATT ? 0 : 1); | ||
1715 | } | ||
1716 | |||
1717 | int | ||
1718 | lpfc_sli_brdreset(struct lpfc_hba * phba) | ||
1719 | { | ||
1720 | struct lpfc_sli *psli; | ||
1721 | struct lpfc_sli_ring *pring; | ||
1722 | uint16_t cfg_value; | ||
1723 | int i; | ||
1724 | |||
1725 | psli = &phba->sli; | ||
1726 | |||
1727 | /* Reset HBA */ | ||
1728 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, | ||
1729 | "%d:0325 Reset HBA Data: x%x x%x\n", phba->brd_no, | ||
1730 | phba->hba_state, psli->sli_flag); | ||
1731 | |||
1732 | /* perform board reset */ | ||
1733 | phba->fc_eventTag = 0; | ||
1734 | phba->fc_myDID = 0; | ||
1735 | phba->fc_prevDID = 0; | ||
1736 | |||
1737 | psli->sli_flag = 0; | ||
1738 | |||
1739 | /* Turn off parity checking and serr during the physical reset */ | ||
1740 | pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value); | ||
1741 | pci_write_config_word(phba->pcidev, PCI_COMMAND, | ||
1742 | (cfg_value & | ||
1743 | ~(PCI_COMMAND_PARITY | PCI_COMMAND_SERR))); | ||
1744 | |||
1745 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | ||
1746 | /* Now toggle INITFF bit in the Host Control Register */ | ||
1747 | writel(HC_INITFF, phba->HCregaddr); | ||
1748 | mdelay(1); | ||
1749 | readl(phba->HCregaddr); /* flush */ | ||
1750 | writel(0, phba->HCregaddr); | ||
1751 | readl(phba->HCregaddr); /* flush */ | ||
1752 | |||
1753 | /* Restore PCI cmd register */ | ||
1754 | pci_write_config_word(phba->pcidev, PCI_COMMAND, cfg_value); | ||
1603 | 1755 | ||
1604 | /* Initialize relevant SLI info */ | 1756 | /* Initialize relevant SLI info */ |
1605 | for (i = 0; i < phba->sli.num_rings; i++) { | 1757 | for (i = 0; i < psli->num_rings; i++) { |
1606 | pring = &phba->sli.ring[i]; | 1758 | pring = &psli->ring[i]; |
1607 | pring->flag = 0; | 1759 | pring->flag = 0; |
1608 | pring->rspidx = 0; | 1760 | pring->rspidx = 0; |
1609 | pring->next_cmdidx = 0; | 1761 | pring->next_cmdidx = 0; |
@@ -1611,27 +1763,64 @@ lpfc_sli_brdreset(struct lpfc_hba * phba, uint16_t skip_post) | |||
1611 | pring->cmdidx = 0; | 1763 | pring->cmdidx = 0; |
1612 | pring->missbufcnt = 0; | 1764 | pring->missbufcnt = 0; |
1613 | } | 1765 | } |
1614 | spin_unlock_irqrestore(phba->host->host_lock, flags); | ||
1615 | 1766 | ||
1616 | if (skip_post) { | 1767 | phba->hba_state = LPFC_WARM_START; |
1617 | mdelay(100); | 1768 | return 0; |
1769 | } | ||
1770 | |||
1771 | int | ||
1772 | lpfc_sli_brdrestart(struct lpfc_hba * phba) | ||
1773 | { | ||
1774 | MAILBOX_t *mb; | ||
1775 | struct lpfc_sli *psli; | ||
1776 | uint16_t skip_post; | ||
1777 | volatile uint32_t word0; | ||
1778 | void __iomem *to_slim; | ||
1779 | |||
1780 | spin_lock_irq(phba->host->host_lock); | ||
1781 | |||
1782 | psli = &phba->sli; | ||
1783 | |||
1784 | /* Restart HBA */ | ||
1785 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, | ||
1786 | "%d:0328 Restart HBA Data: x%x x%x\n", phba->brd_no, | ||
1787 | phba->hba_state, psli->sli_flag); | ||
1788 | |||
1789 | word0 = 0; | ||
1790 | mb = (MAILBOX_t *) &word0; | ||
1791 | mb->mbxCommand = MBX_RESTART; | ||
1792 | mb->mbxHc = 1; | ||
1793 | |||
1794 | lpfc_reset_barrier(phba); | ||
1795 | |||
1796 | to_slim = phba->MBslimaddr; | ||
1797 | writel(*(uint32_t *) mb, to_slim); | ||
1798 | readl(to_slim); /* flush */ | ||
1799 | |||
1800 | /* Only skip post after fc_ffinit is completed */ | ||
1801 | if (phba->hba_state) { | ||
1802 | skip_post = 1; | ||
1803 | word0 = 1; /* This is really setting up word1 */ | ||
1618 | } else { | 1804 | } else { |
1619 | mdelay(2000); | 1805 | skip_post = 0; |
1806 | word0 = 0; /* This is really setting up word1 */ | ||
1620 | } | 1807 | } |
1808 | to_slim = (uint8_t *) phba->MBslimaddr + sizeof (uint32_t); | ||
1809 | writel(*(uint32_t *) mb, to_slim); | ||
1810 | readl(to_slim); /* flush */ | ||
1621 | 1811 | ||
1622 | spin_lock_irqsave(phba->host->host_lock, flags); | 1812 | lpfc_sli_brdreset(phba); |
1623 | /* Cleanup preposted buffers on the ELS ring */ | 1813 | phba->stopped = 0; |
1624 | pring = &phba->sli.ring[LPFC_ELS_RING]; | 1814 | phba->hba_state = LPFC_INIT_START; |
1625 | list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { | 1815 | |
1626 | list_del(&mp->list); | 1816 | spin_unlock_irq(phba->host->host_lock); |
1627 | pring->postbufq_cnt--; | 1817 | |
1628 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 1818 | if (skip_post) |
1629 | kfree(mp); | 1819 | mdelay(100); |
1630 | } | 1820 | else |
1631 | spin_unlock_irqrestore(phba->host->host_lock, flags); | 1821 | mdelay(2000); |
1632 | 1822 | ||
1633 | for (i = 0; i < phba->sli.num_rings; i++) | 1823 | lpfc_hba_down_post(phba); |
1634 | lpfc_sli_abort_iocb_ring(phba, &phba->sli.ring[i]); | ||
1635 | 1824 | ||
1636 | return 0; | 1825 | return 0; |
1637 | } | 1826 | } |
@@ -1691,7 +1880,8 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba) | |||
1691 | } | 1880 | } |
1692 | 1881 | ||
1693 | if (i == 15) { | 1882 | if (i == 15) { |
1694 | lpfc_sli_brdreset(phba, 0); | 1883 | phba->hba_state = LPFC_STATE_UNKNOWN; /* Do post */ |
1884 | lpfc_sli_brdrestart(phba); | ||
1695 | } | 1885 | } |
1696 | /* Read the HBA Host Status Register */ | 1886 | /* Read the HBA Host Status Register */ |
1697 | status = readl(phba->HSregaddr); | 1887 | status = readl(phba->HSregaddr); |
@@ -1735,8 +1925,8 @@ lpfc_sli_hba_setup(struct lpfc_hba * phba) | |||
1735 | } | 1925 | } |
1736 | 1926 | ||
1737 | while (resetcount < 2 && !done) { | 1927 | while (resetcount < 2 && !done) { |
1738 | phba->hba_state = 0; | 1928 | phba->hba_state = LPFC_STATE_UNKNOWN; |
1739 | lpfc_sli_brdreset(phba, 0); | 1929 | lpfc_sli_brdrestart(phba); |
1740 | msleep(2500); | 1930 | msleep(2500); |
1741 | rc = lpfc_sli_chipset_init(phba); | 1931 | rc = lpfc_sli_chipset_init(phba); |
1742 | if (rc) | 1932 | if (rc) |
@@ -1920,6 +2110,21 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
1920 | mb = &pmbox->mb; | 2110 | mb = &pmbox->mb; |
1921 | status = MBX_SUCCESS; | 2111 | status = MBX_SUCCESS; |
1922 | 2112 | ||
2113 | if (phba->hba_state == LPFC_HBA_ERROR) { | ||
2114 | spin_unlock_irqrestore(phba->host->host_lock, drvr_flag); | ||
2115 | |||
2116 | /* Mbox command <mbxCommand> cannot issue */ | ||
2117 | LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag) | ||
2118 | return (MBX_NOT_FINISHED); | ||
2119 | } | ||
2120 | |||
2121 | if (mb->mbxCommand != MBX_KILL_BOARD && flag & MBX_NOWAIT && | ||
2122 | !(readl(phba->HCregaddr) & HC_MBINT_ENA)) { | ||
2123 | spin_unlock_irqrestore(phba->host->host_lock, drvr_flag); | ||
2124 | LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag) | ||
2125 | return (MBX_NOT_FINISHED); | ||
2126 | } | ||
2127 | |||
1923 | if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { | 2128 | if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { |
1924 | /* Polling for a mbox command when another one is already active | 2129 | /* Polling for a mbox command when another one is already active |
1925 | * is not allowed in SLI. Also, the driver must have established | 2130 | * is not allowed in SLI. Also, the driver must have established |
@@ -2002,7 +2207,8 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2002 | 2207 | ||
2003 | /* If we are not polling, we MUST be in SLI2 mode */ | 2208 | /* If we are not polling, we MUST be in SLI2 mode */ |
2004 | if (flag != MBX_POLL) { | 2209 | if (flag != MBX_POLL) { |
2005 | if (!(psli->sli_flag & LPFC_SLI2_ACTIVE)) { | 2210 | if (!(psli->sli_flag & LPFC_SLI2_ACTIVE) && |
2211 | (mb->mbxCommand != MBX_KILL_BOARD)) { | ||
2006 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | 2212 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; |
2007 | spin_unlock_irqrestore(phba->host->host_lock, | 2213 | spin_unlock_irqrestore(phba->host->host_lock, |
2008 | drvr_flag); | 2214 | drvr_flag); |
@@ -2086,8 +2292,9 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) | |||
2086 | ha_copy = readl(phba->HAregaddr); | 2292 | ha_copy = readl(phba->HAregaddr); |
2087 | 2293 | ||
2088 | /* Wait for command to complete */ | 2294 | /* Wait for command to complete */ |
2089 | while (((word0 & OWN_CHIP) == OWN_CHIP) | 2295 | while (((word0 & OWN_CHIP) == OWN_CHIP) || |
2090 | || !(ha_copy & HA_MBATT)) { | 2296 | (!(ha_copy & HA_MBATT) && |
2297 | (phba->hba_state > LPFC_WARM_START))) { | ||
2091 | if (i++ >= 100) { | 2298 | if (i++ >= 100) { |
2092 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; | 2299 | psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; |
2093 | spin_unlock_irqrestore(phba->host->host_lock, | 2300 | spin_unlock_irqrestore(phba->host->host_lock, |
@@ -2237,16 +2444,6 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2237 | !(phba->sli.sli_flag & LPFC_PROCESS_LA))) | 2444 | !(phba->sli.sli_flag & LPFC_PROCESS_LA))) |
2238 | goto iocb_busy; | 2445 | goto iocb_busy; |
2239 | 2446 | ||
2240 | /* | ||
2241 | * Check to see if this is a high priority command. | ||
2242 | * If so bypass tx queue processing. | ||
2243 | */ | ||
2244 | if (unlikely((flag & SLI_IOCB_HIGH_PRIORITY) && | ||
2245 | (iocb = lpfc_sli_next_iocb_slot(phba, pring)))) { | ||
2246 | lpfc_sli_submit_iocb(phba, pring, iocb, piocb); | ||
2247 | piocb = NULL; | ||
2248 | } | ||
2249 | |||
2250 | while ((iocb = lpfc_sli_next_iocb_slot(phba, pring)) && | 2447 | while ((iocb = lpfc_sli_next_iocb_slot(phba, pring)) && |
2251 | (nextiocb = lpfc_sli_next_iocb(phba, pring, &piocb))) | 2448 | (nextiocb = lpfc_sli_next_iocb(phba, pring, &piocb))) |
2252 | lpfc_sli_submit_iocb(phba, pring, iocb, nextiocb); | 2449 | lpfc_sli_submit_iocb(phba, pring, iocb, nextiocb); |
@@ -2274,6 +2471,37 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
2274 | return IOCB_BUSY; | 2471 | return IOCB_BUSY; |
2275 | } | 2472 | } |
2276 | 2473 | ||
2474 | static int | ||
2475 | lpfc_extra_ring_setup( struct lpfc_hba *phba) | ||
2476 | { | ||
2477 | struct lpfc_sli *psli; | ||
2478 | struct lpfc_sli_ring *pring; | ||
2479 | |||
2480 | psli = &phba->sli; | ||
2481 | |||
2482 | /* Adjust cmd/rsp ring iocb entries more evenly */ | ||
2483 | pring = &psli->ring[psli->fcp_ring]; | ||
2484 | pring->numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES; | ||
2485 | pring->numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES; | ||
2486 | pring->numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES; | ||
2487 | pring->numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES; | ||
2488 | |||
2489 | pring = &psli->ring[1]; | ||
2490 | pring->numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES; | ||
2491 | pring->numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; | ||
2492 | pring->numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; | ||
2493 | pring->numRiocb += SLI2_IOCB_RSP_R3XTRA_ENTRIES; | ||
2494 | |||
2495 | /* Setup default profile for this ring */ | ||
2496 | pring->iotag_max = 4096; | ||
2497 | pring->num_mask = 1; | ||
2498 | pring->prt[0].profile = 0; /* Mask 0 */ | ||
2499 | pring->prt[0].rctl = FC_UNSOL_DATA; | ||
2500 | pring->prt[0].type = 5; | ||
2501 | pring->prt[0].lpfc_sli_rcv_unsol_event = NULL; | ||
2502 | return 0; | ||
2503 | } | ||
2504 | |||
2277 | int | 2505 | int |
2278 | lpfc_sli_setup(struct lpfc_hba *phba) | 2506 | lpfc_sli_setup(struct lpfc_hba *phba) |
2279 | { | 2507 | { |
@@ -2357,6 +2585,8 @@ lpfc_sli_setup(struct lpfc_hba *phba) | |||
2357 | "SLI2 SLIM Data: x%x x%x\n", | 2585 | "SLI2 SLIM Data: x%x x%x\n", |
2358 | phba->brd_no, totiocb, MAX_SLI2_IOCB); | 2586 | phba->brd_no, totiocb, MAX_SLI2_IOCB); |
2359 | } | 2587 | } |
2588 | if (phba->cfg_multi_ring_support == 2) | ||
2589 | lpfc_extra_ring_setup(phba); | ||
2360 | 2590 | ||
2361 | return 0; | 2591 | return 0; |
2362 | } | 2592 | } |
@@ -2465,15 +2695,6 @@ lpfc_sli_hba_down(struct lpfc_hba * phba) | |||
2465 | 2695 | ||
2466 | spin_unlock_irqrestore(phba->host->host_lock, flags); | 2696 | spin_unlock_irqrestore(phba->host->host_lock, flags); |
2467 | 2697 | ||
2468 | /* | ||
2469 | * Provided the hba is not in an error state, reset it. It is not | ||
2470 | * capable of IO anymore. | ||
2471 | */ | ||
2472 | if (phba->hba_state != LPFC_HBA_ERROR) { | ||
2473 | phba->hba_state = LPFC_INIT_START; | ||
2474 | lpfc_sli_brdreset(phba, 1); | ||
2475 | } | ||
2476 | |||
2477 | return 1; | 2698 | return 1; |
2478 | } | 2699 | } |
2479 | 2700 | ||
@@ -2877,11 +3098,10 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, | |||
2877 | pmboxq->context1 = NULL; | 3098 | pmboxq->context1 = NULL; |
2878 | /* if schedule_timeout returns 0, we timed out and were not | 3099 | /* if schedule_timeout returns 0, we timed out and were not |
2879 | woken up */ | 3100 | woken up */ |
2880 | if (timeleft == 0) { | 3101 | if ((timeleft == 0) || signal_pending(current)) |
2881 | retval = MBX_TIMEOUT; | 3102 | retval = MBX_TIMEOUT; |
2882 | } else { | 3103 | else |
2883 | retval = MBX_SUCCESS; | 3104 | retval = MBX_SUCCESS; |
2884 | } | ||
2885 | } | 3105 | } |
2886 | 3106 | ||
2887 | 3107 | ||
@@ -2987,13 +3207,7 @@ lpfc_intr_handler(int irq, void *dev_id, struct pt_regs * regs) | |||
2987 | /* Clear Chip error bit */ | 3207 | /* Clear Chip error bit */ |
2988 | writel(HA_ERATT, phba->HAregaddr); | 3208 | writel(HA_ERATT, phba->HAregaddr); |
2989 | readl(phba->HAregaddr); /* flush */ | 3209 | readl(phba->HAregaddr); /* flush */ |
2990 | 3210 | phba->stopped = 1; | |
2991 | /* | ||
2992 | * Reseting the HBA is the only reliable way | ||
2993 | * to shutdown interrupt when there is a | ||
2994 | * ERROR. | ||
2995 | */ | ||
2996 | lpfc_sli_send_reset(phba, phba->hba_state); | ||
2997 | } | 3211 | } |
2998 | 3212 | ||
2999 | spin_lock(phba->host->host_lock); | 3213 | spin_lock(phba->host->host_lock); |