aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_init.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c122
1 files changed, 82 insertions, 40 deletions
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index a79e2c21c5e4..374c102643fe 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -73,6 +73,8 @@ static int lpfc_hba_down_post_s4(struct lpfc_hba *phba);
73static int lpfc_sli4_cq_event_pool_create(struct lpfc_hba *); 73static int lpfc_sli4_cq_event_pool_create(struct lpfc_hba *);
74static void lpfc_sli4_cq_event_pool_destroy(struct lpfc_hba *); 74static void lpfc_sli4_cq_event_pool_destroy(struct lpfc_hba *);
75static void lpfc_sli4_cq_event_release_all(struct lpfc_hba *); 75static void lpfc_sli4_cq_event_release_all(struct lpfc_hba *);
76static void lpfc_sli4_disable_intr(struct lpfc_hba *);
77static uint32_t lpfc_sli4_enable_intr(struct lpfc_hba *, uint32_t);
76 78
77static struct scsi_transport_template *lpfc_transport_template = NULL; 79static struct scsi_transport_template *lpfc_transport_template = NULL;
78static struct scsi_transport_template *lpfc_vport_transport_template = NULL; 80static struct scsi_transport_template *lpfc_vport_transport_template = NULL;
@@ -1169,7 +1171,7 @@ lpfc_offline_eratt(struct lpfc_hba *phba)
1169 spin_lock_irq(&phba->hbalock); 1171 spin_lock_irq(&phba->hbalock);
1170 psli->sli_flag &= ~LPFC_SLI_ACTIVE; 1172 psli->sli_flag &= ~LPFC_SLI_ACTIVE;
1171 spin_unlock_irq(&phba->hbalock); 1173 spin_unlock_irq(&phba->hbalock);
1172 lpfc_offline_prep(phba); 1174 lpfc_offline_prep(phba, LPFC_MBX_NO_WAIT);
1173 1175
1174 lpfc_offline(phba); 1176 lpfc_offline(phba);
1175 lpfc_reset_barrier(phba); 1177 lpfc_reset_barrier(phba);
@@ -1193,7 +1195,7 @@ lpfc_offline_eratt(struct lpfc_hba *phba)
1193static void 1195static void
1194lpfc_sli4_offline_eratt(struct lpfc_hba *phba) 1196lpfc_sli4_offline_eratt(struct lpfc_hba *phba)
1195{ 1197{
1196 lpfc_offline_prep(phba); 1198 lpfc_offline_prep(phba, LPFC_MBX_NO_WAIT);
1197 lpfc_offline(phba); 1199 lpfc_offline(phba);
1198 lpfc_sli4_brdreset(phba); 1200 lpfc_sli4_brdreset(phba);
1199 lpfc_hba_down_post(phba); 1201 lpfc_hba_down_post(phba);
@@ -1251,7 +1253,7 @@ lpfc_handle_deferred_eratt(struct lpfc_hba *phba)
1251 * There was a firmware error. Take the hba offline and then 1253 * There was a firmware error. Take the hba offline and then
1252 * attempt to restart it. 1254 * attempt to restart it.
1253 */ 1255 */
1254 lpfc_offline_prep(phba); 1256 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
1255 lpfc_offline(phba); 1257 lpfc_offline(phba);
1256 1258
1257 /* Wait for the ER1 bit to clear.*/ 1259 /* Wait for the ER1 bit to clear.*/
@@ -1372,7 +1374,7 @@ lpfc_handle_eratt_s3(struct lpfc_hba *phba)
1372 * There was a firmware error. Take the hba offline and then 1374 * There was a firmware error. Take the hba offline and then
1373 * attempt to restart it. 1375 * attempt to restart it.
1374 */ 1376 */
1375 lpfc_offline_prep(phba); 1377 lpfc_offline_prep(phba, LPFC_MBX_NO_WAIT);
1376 lpfc_offline(phba); 1378 lpfc_offline(phba);
1377 lpfc_sli_brdrestart(phba); 1379 lpfc_sli_brdrestart(phba);
1378 if (lpfc_online(phba) == 0) { /* Initialize the HBA */ 1380 if (lpfc_online(phba) == 0) { /* Initialize the HBA */
@@ -1428,6 +1430,54 @@ lpfc_handle_eratt_s3(struct lpfc_hba *phba)
1428} 1430}
1429 1431
1430/** 1432/**
1433 * lpfc_sli4_port_sta_fn_reset - The SLI4 function reset due to port status reg
1434 * @phba: pointer to lpfc hba data structure.
1435 * @mbx_action: flag for mailbox shutdown action.
1436 *
1437 * This routine is invoked to perform an SLI4 port PCI function reset in
1438 * response to port status register polling attention. It waits for port
1439 * status register (ERR, RDY, RN) bits before proceeding with function reset.
1440 * During this process, interrupt vectors are freed and later requested
1441 * for handling possible port resource change.
1442 **/
1443static int
1444lpfc_sli4_port_sta_fn_reset(struct lpfc_hba *phba, int mbx_action)
1445{
1446 int rc;
1447 uint32_t intr_mode;
1448
1449 /*
1450 * On error status condition, driver need to wait for port
1451 * ready before performing reset.
1452 */
1453 rc = lpfc_sli4_pdev_status_reg_wait(phba);
1454 if (!rc) {
1455 /* need reset: attempt for port recovery */
1456 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1457 "2887 Reset Needed: Attempting Port "
1458 "Recovery...\n");
1459 lpfc_offline_prep(phba, mbx_action);
1460 lpfc_offline(phba);
1461 /* release interrupt for possible resource change */
1462 lpfc_sli4_disable_intr(phba);
1463 lpfc_sli_brdrestart(phba);
1464 /* request and enable interrupt */
1465 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode);
1466 if (intr_mode == LPFC_INTR_ERROR) {
1467 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1468 "3175 Failed to enable interrupt\n");
1469 return -EIO;
1470 } else {
1471 phba->intr_mode = intr_mode;
1472 }
1473 rc = lpfc_online(phba);
1474 if (rc == 0)
1475 lpfc_unblock_mgmt_io(phba);
1476 }
1477 return rc;
1478}
1479
1480/**
1431 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler 1481 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler
1432 * @phba: pointer to lpfc hba data structure. 1482 * @phba: pointer to lpfc hba data structure.
1433 * 1483 *
@@ -1506,30 +1556,18 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba)
1506 reg_err2 == SLIPORT_ERR2_REG_FUNC_PROVISON) 1556 reg_err2 == SLIPORT_ERR2_REG_FUNC_PROVISON)
1507 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1557 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1508 "3145 Port Down: Provisioning\n"); 1558 "3145 Port Down: Provisioning\n");
1509 /* 1559
1510 * On error status condition, driver need to wait for port 1560 /* Check port status register for function reset */
1511 * ready before performing reset. 1561 rc = lpfc_sli4_port_sta_fn_reset(phba, LPFC_MBX_NO_WAIT);
1512 */ 1562 if (rc == 0) {
1513 rc = lpfc_sli4_pdev_status_reg_wait(phba); 1563 /* don't report event on forced debug dump */
1514 if (!rc) { 1564 if (reg_err1 == SLIPORT_ERR1_REG_ERR_CODE_2 &&
1515 /* need reset: attempt for port recovery */ 1565 reg_err2 == SLIPORT_ERR2_REG_FORCED_DUMP)
1516 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1566 return;
1517 "2887 Reset Needed: Attempting Port " 1567 else
1518 "Recovery...\n"); 1568 break;
1519 lpfc_offline_prep(phba);
1520 lpfc_offline(phba);
1521 lpfc_sli_brdrestart(phba);
1522 if (lpfc_online(phba) == 0) {
1523 lpfc_unblock_mgmt_io(phba);
1524 /* don't report event on forced debug dump */
1525 if (reg_err1 == SLIPORT_ERR1_REG_ERR_CODE_2 &&
1526 reg_err2 == SLIPORT_ERR2_REG_FORCED_DUMP)
1527 return;
1528 else
1529 break;
1530 }
1531 /* fall through for not able to recover */
1532 } 1569 }
1570 /* fall through for not able to recover */
1533 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1571 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1534 "3152 Unrecoverable error, bring the port " 1572 "3152 Unrecoverable error, bring the port "
1535 "offline\n"); 1573 "offline\n");
@@ -2494,15 +2532,19 @@ lpfc_stop_hba_timers(struct lpfc_hba *phba)
2494 * driver prepares the HBA interface for online or offline. 2532 * driver prepares the HBA interface for online or offline.
2495 **/ 2533 **/
2496static void 2534static void
2497lpfc_block_mgmt_io(struct lpfc_hba * phba) 2535lpfc_block_mgmt_io(struct lpfc_hba *phba, int mbx_action)
2498{ 2536{
2499 unsigned long iflag; 2537 unsigned long iflag;
2500 uint8_t actcmd = MBX_HEARTBEAT; 2538 uint8_t actcmd = MBX_HEARTBEAT;
2501 unsigned long timeout; 2539 unsigned long timeout;
2502 2540
2503 timeout = msecs_to_jiffies(LPFC_MBOX_TMO * 1000) + jiffies;
2504 spin_lock_irqsave(&phba->hbalock, iflag); 2541 spin_lock_irqsave(&phba->hbalock, iflag);
2505 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; 2542 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO;
2543 spin_unlock_irqrestore(&phba->hbalock, iflag);
2544 if (mbx_action == LPFC_MBX_NO_WAIT)
2545 return;
2546 timeout = msecs_to_jiffies(LPFC_MBOX_TMO * 1000) + jiffies;
2547 spin_lock_irqsave(&phba->hbalock, iflag);
2506 if (phba->sli.mbox_active) { 2548 if (phba->sli.mbox_active) {
2507 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; 2549 actcmd = phba->sli.mbox_active->u.mb.mbxCommand;
2508 /* Determine how long we might wait for the active mailbox 2550 /* Determine how long we might wait for the active mailbox
@@ -2592,7 +2634,7 @@ lpfc_online(struct lpfc_hba *phba)
2592 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, 2634 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
2593 "0458 Bring Adapter online\n"); 2635 "0458 Bring Adapter online\n");
2594 2636
2595 lpfc_block_mgmt_io(phba); 2637 lpfc_block_mgmt_io(phba, LPFC_MBX_WAIT);
2596 2638
2597 if (!lpfc_sli_queue_setup(phba)) { 2639 if (!lpfc_sli_queue_setup(phba)) {
2598 lpfc_unblock_mgmt_io(phba); 2640 lpfc_unblock_mgmt_io(phba);
@@ -2660,7 +2702,7 @@ lpfc_unblock_mgmt_io(struct lpfc_hba * phba)
2660 * queue to make it ready to be brought offline. 2702 * queue to make it ready to be brought offline.
2661 **/ 2703 **/
2662void 2704void
2663lpfc_offline_prep(struct lpfc_hba * phba) 2705lpfc_offline_prep(struct lpfc_hba *phba, int mbx_action)
2664{ 2706{
2665 struct lpfc_vport *vport = phba->pport; 2707 struct lpfc_vport *vport = phba->pport;
2666 struct lpfc_nodelist *ndlp, *next_ndlp; 2708 struct lpfc_nodelist *ndlp, *next_ndlp;
@@ -2671,7 +2713,7 @@ lpfc_offline_prep(struct lpfc_hba * phba)
2671 if (vport->fc_flag & FC_OFFLINE_MODE) 2713 if (vport->fc_flag & FC_OFFLINE_MODE)
2672 return; 2714 return;
2673 2715
2674 lpfc_block_mgmt_io(phba); 2716 lpfc_block_mgmt_io(phba, mbx_action);
2675 2717
2676 lpfc_linkdown(phba); 2718 lpfc_linkdown(phba);
2677 2719
@@ -2718,7 +2760,7 @@ lpfc_offline_prep(struct lpfc_hba * phba)
2718 } 2760 }
2719 lpfc_destroy_vport_work_array(phba, vports); 2761 lpfc_destroy_vport_work_array(phba, vports);
2720 2762
2721 lpfc_sli_mbox_sys_shutdown(phba); 2763 lpfc_sli_mbox_sys_shutdown(phba, mbx_action);
2722} 2764}
2723 2765
2724/** 2766/**
@@ -4312,7 +4354,7 @@ lpfc_reset_hba(struct lpfc_hba *phba)
4312 phba->link_state = LPFC_HBA_ERROR; 4354 phba->link_state = LPFC_HBA_ERROR;
4313 return; 4355 return;
4314 } 4356 }
4315 lpfc_offline_prep(phba); 4357 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
4316 lpfc_offline(phba); 4358 lpfc_offline(phba);
4317 lpfc_sli_brdrestart(phba); 4359 lpfc_sli_brdrestart(phba);
4318 lpfc_online(phba); 4360 lpfc_online(phba);
@@ -8890,7 +8932,7 @@ lpfc_pci_suspend_one_s3(struct pci_dev *pdev, pm_message_t msg)
8890 "0473 PCI device Power Management suspend.\n"); 8932 "0473 PCI device Power Management suspend.\n");
8891 8933
8892 /* Bring down the device */ 8934 /* Bring down the device */
8893 lpfc_offline_prep(phba); 8935 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
8894 lpfc_offline(phba); 8936 lpfc_offline(phba);
8895 kthread_stop(phba->worker_thread); 8937 kthread_stop(phba->worker_thread);
8896 8938
@@ -9016,7 +9058,7 @@ lpfc_sli_prep_dev_for_reset(struct lpfc_hba *phba)
9016 "2710 PCI channel disable preparing for reset\n"); 9058 "2710 PCI channel disable preparing for reset\n");
9017 9059
9018 /* Block any management I/Os to the device */ 9060 /* Block any management I/Os to the device */
9019 lpfc_block_mgmt_io(phba); 9061 lpfc_block_mgmt_io(phba, LPFC_MBX_WAIT);
9020 9062
9021 /* Block all SCSI devices' I/Os on the host */ 9063 /* Block all SCSI devices' I/Os on the host */
9022 lpfc_scsi_dev_block(phba); 9064 lpfc_scsi_dev_block(phba);
@@ -9160,7 +9202,7 @@ lpfc_io_slot_reset_s3(struct pci_dev *pdev)
9160 phba->intr_mode = intr_mode; 9202 phba->intr_mode = intr_mode;
9161 9203
9162 /* Take device offline, it will perform cleanup */ 9204 /* Take device offline, it will perform cleanup */
9163 lpfc_offline_prep(phba); 9205 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
9164 lpfc_offline(phba); 9206 lpfc_offline(phba);
9165 lpfc_sli_brdrestart(phba); 9207 lpfc_sli_brdrestart(phba);
9166 9208
@@ -9634,7 +9676,7 @@ lpfc_pci_suspend_one_s4(struct pci_dev *pdev, pm_message_t msg)
9634 "2843 PCI device Power Management suspend.\n"); 9676 "2843 PCI device Power Management suspend.\n");
9635 9677
9636 /* Bring down the device */ 9678 /* Bring down the device */
9637 lpfc_offline_prep(phba); 9679 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
9638 lpfc_offline(phba); 9680 lpfc_offline(phba);
9639 kthread_stop(phba->worker_thread); 9681 kthread_stop(phba->worker_thread);
9640 9682
@@ -9760,7 +9802,7 @@ lpfc_sli4_prep_dev_for_reset(struct lpfc_hba *phba)
9760 "2826 PCI channel disable preparing for reset\n"); 9802 "2826 PCI channel disable preparing for reset\n");
9761 9803
9762 /* Block any management I/Os to the device */ 9804 /* Block any management I/Os to the device */
9763 lpfc_block_mgmt_io(phba); 9805 lpfc_block_mgmt_io(phba, LPFC_MBX_NO_WAIT);
9764 9806
9765 /* Block all SCSI devices' I/Os on the host */ 9807 /* Block all SCSI devices' I/Os on the host */
9766 lpfc_scsi_dev_block(phba); 9808 lpfc_scsi_dev_block(phba);
@@ -9933,7 +9975,7 @@ lpfc_io_resume_s4(struct pci_dev *pdev)
9933 */ 9975 */
9934 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { 9976 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) {
9935 /* Perform device reset */ 9977 /* Perform device reset */
9936 lpfc_offline_prep(phba); 9978 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
9937 lpfc_offline(phba); 9979 lpfc_offline(phba);
9938 lpfc_sli_brdrestart(phba); 9980 lpfc_sli_brdrestart(phba);
9939 /* Bring the device back online */ 9981 /* Bring the device back online */