aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_sli.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_sli.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c112
1 files changed, 60 insertions, 52 deletions
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index bb69a7a1ec59..70f4d5a1348e 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -191,35 +191,12 @@ static int
191lpfc_sli_ringtxcmpl_put(struct lpfc_hba * phba, 191lpfc_sli_ringtxcmpl_put(struct lpfc_hba * phba,
192 struct lpfc_sli_ring * pring, struct lpfc_iocbq * piocb) 192 struct lpfc_sli_ring * pring, struct lpfc_iocbq * piocb)
193{ 193{
194 uint16_t iotag;
195
196 list_add_tail(&piocb->list, &pring->txcmplq); 194 list_add_tail(&piocb->list, &pring->txcmplq);
197 pring->txcmplq_cnt++; 195 pring->txcmplq_cnt++;
198 if (unlikely(pring->ringno == LPFC_ELS_RING)) 196 if (unlikely(pring->ringno == LPFC_ELS_RING))
199 mod_timer(&phba->els_tmofunc, 197 mod_timer(&phba->els_tmofunc,
200 jiffies + HZ * (phba->fc_ratov << 1)); 198 jiffies + HZ * (phba->fc_ratov << 1));
201 199
202 if (pring->fast_lookup) {
203 /* Setup fast lookup based on iotag for completion */
204 iotag = piocb->iocb.ulpIoTag;
205 if (iotag && (iotag < pring->fast_iotag))
206 *(pring->fast_lookup + iotag) = piocb;
207 else {
208
209 /* Cmd ring <ringno> put: iotag <iotag> greater then
210 configured max <fast_iotag> wd0 <icmd> */
211 lpfc_printf_log(phba,
212 KERN_ERR,
213 LOG_SLI,
214 "%d:0316 Cmd ring %d put: iotag x%x "
215 "greater then configured max x%x "
216 "wd0 x%x\n",
217 phba->brd_no,
218 pring->ringno, iotag,
219 pring->fast_iotag,
220 *(((uint32_t *)(&piocb->iocb)) + 7));
221 }
222 }
223 return (0); 200 return (0);
224} 201}
225 202
@@ -343,7 +320,8 @@ lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocbq)
343 kfree(old_arr); 320 kfree(old_arr);
344 return iotag; 321 return iotag;
345 } 322 }
346 } 323 } else
324 spin_unlock_irq(phba->host->host_lock);
347 325
348 lpfc_printf_log(phba, KERN_ERR,LOG_SLI, 326 lpfc_printf_log(phba, KERN_ERR,LOG_SLI,
349 "%d:0318 Failed to allocate IOTAG.last IOTAG is %d\n", 327 "%d:0318 Failed to allocate IOTAG.last IOTAG is %d\n",
@@ -601,7 +579,7 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
601 /* Stray Mailbox Interrupt, mbxCommand <cmd> mbxStatus 579 /* Stray Mailbox Interrupt, mbxCommand <cmd> mbxStatus
602 <status> */ 580 <status> */
603 lpfc_printf_log(phba, 581 lpfc_printf_log(phba,
604 KERN_ERR, 582 KERN_WARNING,
605 LOG_MBOX | LOG_SLI, 583 LOG_MBOX | LOG_SLI,
606 "%d:0304 Stray Mailbox Interrupt " 584 "%d:0304 Stray Mailbox Interrupt "
607 "mbxCommand x%x mbxStatus x%x\n", 585 "mbxCommand x%x mbxStatus x%x\n",
@@ -992,9 +970,11 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba)
992 * resources need to be recovered. 970 * resources need to be recovered.
993 */ 971 */
994 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) { 972 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {
995 printk(KERN_INFO "%s: IOCB cmd 0x%x processed." 973 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
996 " Skipping completion\n", __FUNCTION__, 974 "%d:0314 IOCB cmd 0x%x"
997 irsp->ulpCommand); 975 " processed. Skipping"
976 " completion", phba->brd_no,
977 irsp->ulpCommand);
998 break; 978 break;
999 } 979 }
1000 980
@@ -1127,7 +1107,7 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
1127 if (unlikely(irsp->ulpStatus)) { 1107 if (unlikely(irsp->ulpStatus)) {
1128 /* Rsp ring <ringno> error: IOCB */ 1108 /* Rsp ring <ringno> error: IOCB */
1129 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, 1109 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
1130 "%d:0326 Rsp Ring %d error: IOCB Data: " 1110 "%d:0336 Rsp Ring %d error: IOCB Data: "
1131 "x%x x%x x%x x%x x%x x%x x%x x%x\n", 1111 "x%x x%x x%x x%x x%x x%x x%x x%x\n",
1132 phba->brd_no, pring->ringno, 1112 phba->brd_no, pring->ringno,
1133 irsp->un.ulpWord[0], irsp->un.ulpWord[1], 1113 irsp->un.ulpWord[0], irsp->un.ulpWord[1],
@@ -1145,9 +1125,11 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
1145 * resources need to be recovered. 1125 * resources need to be recovered.
1146 */ 1126 */
1147 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) { 1127 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {
1148 printk(KERN_INFO "%s: IOCB cmd 0x%x processed. " 1128 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
1149 "Skipping completion\n", __FUNCTION__, 1129 "%d:0333 IOCB cmd 0x%x"
1150 irsp->ulpCommand); 1130 " processed. Skipping"
1131 " completion\n", phba->brd_no,
1132 irsp->ulpCommand);
1151 break; 1133 break;
1152 } 1134 }
1153 1135
@@ -1178,7 +1160,7 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
1178 } else { 1160 } else {
1179 /* Unknown IOCB command */ 1161 /* Unknown IOCB command */
1180 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 1162 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1181 "%d:0321 Unknown IOCB command " 1163 "%d:0334 Unknown IOCB command "
1182 "Data: x%x, x%x x%x x%x x%x\n", 1164 "Data: x%x, x%x x%x x%x x%x\n",
1183 phba->brd_no, type, irsp->ulpCommand, 1165 phba->brd_no, type, irsp->ulpCommand,
1184 irsp->ulpStatus, irsp->ulpIoTag, 1166 irsp->ulpStatus, irsp->ulpIoTag,
@@ -1261,7 +1243,7 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba,
1261 lpfc_printf_log(phba, 1243 lpfc_printf_log(phba,
1262 KERN_ERR, 1244 KERN_ERR,
1263 LOG_SLI, 1245 LOG_SLI,
1264 "%d:0312 Ring %d handler: portRspPut %d " 1246 "%d:0303 Ring %d handler: portRspPut %d "
1265 "is bigger then rsp ring %d\n", 1247 "is bigger then rsp ring %d\n",
1266 phba->brd_no, 1248 phba->brd_no,
1267 pring->ringno, portRspPut, portRspMax); 1249 pring->ringno, portRspPut, portRspMax);
@@ -1406,7 +1388,7 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba,
1406 lpfc_printf_log(phba, 1388 lpfc_printf_log(phba,
1407 KERN_ERR, 1389 KERN_ERR,
1408 LOG_SLI, 1390 LOG_SLI,
1409 "%d:0321 Unknown IOCB command " 1391 "%d:0335 Unknown IOCB command "
1410 "Data: x%x x%x x%x x%x\n", 1392 "Data: x%x x%x x%x x%x\n",
1411 phba->brd_no, 1393 phba->brd_no,
1412 irsp->ulpCommand, 1394 irsp->ulpCommand,
@@ -1422,11 +1404,11 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba,
1422 next_iocb, 1404 next_iocb,
1423 &saveq->list, 1405 &saveq->list,
1424 list) { 1406 list) {
1407 list_del(&rspiocbp->list);
1425 lpfc_sli_release_iocbq(phba, 1408 lpfc_sli_release_iocbq(phba,
1426 rspiocbp); 1409 rspiocbp);
1427 } 1410 }
1428 } 1411 }
1429
1430 lpfc_sli_release_iocbq(phba, saveq); 1412 lpfc_sli_release_iocbq(phba, saveq);
1431 } 1413 }
1432 } 1414 }
@@ -1570,8 +1552,8 @@ lpfc_sli_brdready(struct lpfc_hba * phba, uint32_t mask)
1570 1552
1571void lpfc_reset_barrier(struct lpfc_hba * phba) 1553void lpfc_reset_barrier(struct lpfc_hba * phba)
1572{ 1554{
1573 uint32_t * resp_buf; 1555 uint32_t __iomem *resp_buf;
1574 uint32_t * mbox_buf; 1556 uint32_t __iomem *mbox_buf;
1575 volatile uint32_t mbox; 1557 volatile uint32_t mbox;
1576 uint32_t hc_copy; 1558 uint32_t hc_copy;
1577 int i; 1559 int i;
@@ -1587,7 +1569,7 @@ void lpfc_reset_barrier(struct lpfc_hba * phba)
1587 * Tell the other part of the chip to suspend temporarily all 1569 * Tell the other part of the chip to suspend temporarily all
1588 * its DMA activity. 1570 * its DMA activity.
1589 */ 1571 */
1590 resp_buf = (uint32_t *)phba->MBslimaddr; 1572 resp_buf = phba->MBslimaddr;
1591 1573
1592 /* Disable the error attention */ 1574 /* Disable the error attention */
1593 hc_copy = readl(phba->HCregaddr); 1575 hc_copy = readl(phba->HCregaddr);
@@ -1605,7 +1587,7 @@ void lpfc_reset_barrier(struct lpfc_hba * phba)
1605 ((MAILBOX_t *)&mbox)->mbxOwner = OWN_CHIP; 1587 ((MAILBOX_t *)&mbox)->mbxOwner = OWN_CHIP;
1606 1588
1607 writel(BARRIER_TEST_PATTERN, (resp_buf + 1)); 1589 writel(BARRIER_TEST_PATTERN, (resp_buf + 1));
1608 mbox_buf = (uint32_t *)phba->MBslimaddr; 1590 mbox_buf = phba->MBslimaddr;
1609 writel(mbox, mbox_buf); 1591 writel(mbox, mbox_buf);
1610 1592
1611 for (i = 0; 1593 for (i = 0;
@@ -1734,15 +1716,13 @@ lpfc_sli_brdreset(struct lpfc_hba * phba)
1734 phba->fc_myDID = 0; 1716 phba->fc_myDID = 0;
1735 phba->fc_prevDID = 0; 1717 phba->fc_prevDID = 0;
1736 1718
1737 psli->sli_flag = 0;
1738
1739 /* Turn off parity checking and serr during the physical reset */ 1719 /* Turn off parity checking and serr during the physical reset */
1740 pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value); 1720 pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value);
1741 pci_write_config_word(phba->pcidev, PCI_COMMAND, 1721 pci_write_config_word(phba->pcidev, PCI_COMMAND,
1742 (cfg_value & 1722 (cfg_value &
1743 ~(PCI_COMMAND_PARITY | PCI_COMMAND_SERR))); 1723 ~(PCI_COMMAND_PARITY | PCI_COMMAND_SERR)));
1744 1724
1745 psli->sli_flag &= ~LPFC_SLI2_ACTIVE; 1725 psli->sli_flag &= ~(LPFC_SLI2_ACTIVE | LPFC_PROCESS_LA);
1746 /* Now toggle INITFF bit in the Host Control Register */ 1726 /* Now toggle INITFF bit in the Host Control Register */
1747 writel(HC_INITFF, phba->HCregaddr); 1727 writel(HC_INITFF, phba->HCregaddr);
1748 mdelay(1); 1728 mdelay(1);
@@ -1783,7 +1763,7 @@ lpfc_sli_brdrestart(struct lpfc_hba * phba)
1783 1763
1784 /* Restart HBA */ 1764 /* Restart HBA */
1785 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 1765 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
1786 "%d:0328 Restart HBA Data: x%x x%x\n", phba->brd_no, 1766 "%d:0337 Restart HBA Data: x%x x%x\n", phba->brd_no,
1787 phba->hba_state, psli->sli_flag); 1767 phba->hba_state, psli->sli_flag);
1788 1768
1789 word0 = 0; 1769 word0 = 0;
@@ -1805,7 +1785,7 @@ lpfc_sli_brdrestart(struct lpfc_hba * phba)
1805 skip_post = 0; 1785 skip_post = 0;
1806 word0 = 0; /* This is really setting up word1 */ 1786 word0 = 0; /* This is really setting up word1 */
1807 } 1787 }
1808 to_slim = (uint8_t *) phba->MBslimaddr + sizeof (uint32_t); 1788 to_slim = phba->MBslimaddr + sizeof (uint32_t);
1809 writel(*(uint32_t *) mb, to_slim); 1789 writel(*(uint32_t *) mb, to_slim);
1810 readl(to_slim); /* flush */ 1790 readl(to_slim); /* flush */
1811 1791
@@ -1815,6 +1795,9 @@ lpfc_sli_brdrestart(struct lpfc_hba * phba)
1815 1795
1816 spin_unlock_irq(phba->host->host_lock); 1796 spin_unlock_irq(phba->host->host_lock);
1817 1797
1798 memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets));
1799 psli->stats_start = get_seconds();
1800
1818 if (skip_post) 1801 if (skip_post)
1819 mdelay(100); 1802 mdelay(100);
1820 else 1803 else
@@ -1925,6 +1908,9 @@ lpfc_sli_hba_setup(struct lpfc_hba * phba)
1925 } 1908 }
1926 1909
1927 while (resetcount < 2 && !done) { 1910 while (resetcount < 2 && !done) {
1911 spin_lock_irq(phba->host->host_lock);
1912 phba->sli.sli_flag |= LPFC_SLI_MBOX_ACTIVE;
1913 spin_unlock_irq(phba->host->host_lock);
1928 phba->hba_state = LPFC_STATE_UNKNOWN; 1914 phba->hba_state = LPFC_STATE_UNKNOWN;
1929 lpfc_sli_brdrestart(phba); 1915 lpfc_sli_brdrestart(phba);
1930 msleep(2500); 1916 msleep(2500);
@@ -1932,6 +1918,9 @@ lpfc_sli_hba_setup(struct lpfc_hba * phba)
1932 if (rc) 1918 if (rc)
1933 break; 1919 break;
1934 1920
1921 spin_lock_irq(phba->host->host_lock);
1922 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
1923 spin_unlock_irq(phba->host->host_lock);
1935 resetcount++; 1924 resetcount++;
1936 1925
1937 /* Call pre CONFIG_PORT mailbox command initialization. A value of 0 1926 /* Call pre CONFIG_PORT mailbox command initialization. A value of 0
@@ -2217,7 +2206,8 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
2217 return (MBX_NOT_FINISHED); 2206 return (MBX_NOT_FINISHED);
2218 } 2207 }
2219 /* timeout active mbox command */ 2208 /* timeout active mbox command */
2220 mod_timer(&psli->mbox_tmo, jiffies + HZ * LPFC_MBOX_TMO); 2209 mod_timer(&psli->mbox_tmo, (jiffies +
2210 (HZ * lpfc_mbox_tmo_val(phba, mb->mbxCommand))));
2221 } 2211 }
2222 2212
2223 /* Mailbox cmd <cmd> issue */ 2213 /* Mailbox cmd <cmd> issue */
@@ -2277,7 +2267,6 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
2277 break; 2267 break;
2278 2268
2279 case MBX_POLL: 2269 case MBX_POLL:
2280 i = 0;
2281 psli->mbox_active = NULL; 2270 psli->mbox_active = NULL;
2282 if (psli->sli_flag & LPFC_SLI2_ACTIVE) { 2271 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
2283 /* First read mbox status word */ 2272 /* First read mbox status word */
@@ -2291,11 +2280,14 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
2291 /* Read the HBA Host Attention Register */ 2280 /* Read the HBA Host Attention Register */
2292 ha_copy = readl(phba->HAregaddr); 2281 ha_copy = readl(phba->HAregaddr);
2293 2282
2283 i = lpfc_mbox_tmo_val(phba, mb->mbxCommand);
2284 i *= 1000; /* Convert to ms */
2285
2294 /* Wait for command to complete */ 2286 /* Wait for command to complete */
2295 while (((word0 & OWN_CHIP) == OWN_CHIP) || 2287 while (((word0 & OWN_CHIP) == OWN_CHIP) ||
2296 (!(ha_copy & HA_MBATT) && 2288 (!(ha_copy & HA_MBATT) &&
2297 (phba->hba_state > LPFC_WARM_START))) { 2289 (phba->hba_state > LPFC_WARM_START))) {
2298 if (i++ >= 100) { 2290 if (i-- <= 0) {
2299 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; 2291 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
2300 spin_unlock_irqrestore(phba->host->host_lock, 2292 spin_unlock_irqrestore(phba->host->host_lock,
2301 drvr_flag); 2293 drvr_flag);
@@ -2313,7 +2305,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
2313 2305
2314 /* Can be in interrupt context, do not sleep */ 2306 /* Can be in interrupt context, do not sleep */
2315 /* (or might be called with interrupts disabled) */ 2307 /* (or might be called with interrupts disabled) */
2316 mdelay(i); 2308 mdelay(1);
2317 2309
2318 spin_lock_irqsave(phba->host->host_lock, drvr_flag); 2310 spin_lock_irqsave(phba->host->host_lock, drvr_flag);
2319 2311
@@ -2659,8 +2651,6 @@ lpfc_sli_hba_down(struct lpfc_hba * phba)
2659 2651
2660 INIT_LIST_HEAD(&(pring->txq)); 2652 INIT_LIST_HEAD(&(pring->txq));
2661 2653
2662 kfree(pring->fast_lookup);
2663 pring->fast_lookup = NULL;
2664 } 2654 }
2665 2655
2666 spin_unlock_irqrestore(phba->host->host_lock, flags); 2656 spin_unlock_irqrestore(phba->host->host_lock, flags);
@@ -3030,7 +3020,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
3030 3020
3031 if (timeleft == 0) { 3021 if (timeleft == 0) {
3032 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 3022 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
3033 "%d:0329 IOCB wait timeout error - no " 3023 "%d:0338 IOCB wait timeout error - no "
3034 "wake response Data x%x\n", 3024 "wake response Data x%x\n",
3035 phba->brd_no, timeout); 3025 phba->brd_no, timeout);
3036 retval = IOCB_TIMEDOUT; 3026 retval = IOCB_TIMEDOUT;
@@ -3110,6 +3100,24 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
3110 return retval; 3100 return retval;
3111} 3101}
3112 3102
3103int
3104lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba)
3105{
3106 int i = 0;
3107
3108 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE && !phba->stopped) {
3109 if (i++ > LPFC_MBOX_TMO * 1000)
3110 return 1;
3111
3112 if (lpfc_sli_handle_mb_event(phba) == 0)
3113 i = 0;
3114
3115 msleep(1);
3116 }
3117
3118 return (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) ? 1 : 0;
3119}
3120
3113irqreturn_t 3121irqreturn_t
3114lpfc_intr_handler(int irq, void *dev_id, struct pt_regs * regs) 3122lpfc_intr_handler(int irq, void *dev_id, struct pt_regs * regs)
3115{ 3123{