diff options
author | James Smart <james.smart@emulex.com> | 2010-06-07 15:23:35 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-27 13:01:32 -0400 |
commit | 6e7288d9a4b6691bf13fb07e3593d70d725d0737 (patch) | |
tree | 96541fadecb72ba942848da0c7ae71d772392849 /drivers/scsi/lpfc | |
parent | ffc954936b134cc6d2eba1282cc71084929c3704 (diff) |
[SCSI] lpfc 8.3.13: Initialization code clean up and fixes.
- Add poll or wait flag parameter to hba_init_link and hba_down_link.
- (From Linux Community) Make return with ENXIO negative.
- Remove unused INB code from driver.
- Prevent block_magmt_io from returning until mailbox is inactive.
Signed-off-by: Alex Iannicelli <alex.iannicelli@emulex.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/lpfc')
-rw-r--r-- | drivers/scsi/lpfc/lpfc.h | 8 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_attr.c | 4 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_hw.h | 8 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_init.c | 40 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_mbox.c | 1 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_sli.c | 22 |
6 files changed, 43 insertions, 40 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index e35a4c71eb9a..4cb78483bf79 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h | |||
@@ -510,9 +510,9 @@ struct lpfc_hba { | |||
510 | void (*lpfc_stop_port) | 510 | void (*lpfc_stop_port) |
511 | (struct lpfc_hba *); | 511 | (struct lpfc_hba *); |
512 | int (*lpfc_hba_init_link) | 512 | int (*lpfc_hba_init_link) |
513 | (struct lpfc_hba *); | 513 | (struct lpfc_hba *, uint32_t); |
514 | int (*lpfc_hba_down_link) | 514 | int (*lpfc_hba_down_link) |
515 | (struct lpfc_hba *); | 515 | (struct lpfc_hba *, uint32_t); |
516 | 516 | ||
517 | /* SLI4 specific HBA data structure */ | 517 | /* SLI4 specific HBA data structure */ |
518 | struct lpfc_sli4_hba sli4_hba; | 518 | struct lpfc_sli4_hba sli4_hba; |
@@ -525,7 +525,6 @@ struct lpfc_hba { | |||
525 | #define LPFC_SLI3_NPIV_ENABLED 0x02 | 525 | #define LPFC_SLI3_NPIV_ENABLED 0x02 |
526 | #define LPFC_SLI3_VPORT_TEARDOWN 0x04 | 526 | #define LPFC_SLI3_VPORT_TEARDOWN 0x04 |
527 | #define LPFC_SLI3_CRP_ENABLED 0x08 | 527 | #define LPFC_SLI3_CRP_ENABLED 0x08 |
528 | #define LPFC_SLI3_INB_ENABLED 0x10 | ||
529 | #define LPFC_SLI3_BG_ENABLED 0x20 | 528 | #define LPFC_SLI3_BG_ENABLED 0x20 |
530 | #define LPFC_SLI3_DSS_ENABLED 0x40 | 529 | #define LPFC_SLI3_DSS_ENABLED 0x40 |
531 | uint32_t iocb_cmd_size; | 530 | uint32_t iocb_cmd_size; |
@@ -557,9 +556,6 @@ struct lpfc_hba { | |||
557 | 556 | ||
558 | MAILBOX_t *mbox; | 557 | MAILBOX_t *mbox; |
559 | uint32_t *mbox_ext; | 558 | uint32_t *mbox_ext; |
560 | uint32_t *inb_ha_copy; | ||
561 | uint32_t *inb_counter; | ||
562 | uint32_t inb_last_counter; | ||
563 | uint32_t ha_copy; | 559 | uint32_t ha_copy; |
564 | struct _PCB *pcb; | 560 | struct _PCB *pcb; |
565 | struct _IOCB *IOCBs; | 561 | struct _IOCB *IOCBs; |
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index bf33b315f93e..b17fe5149e38 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -506,10 +506,10 @@ lpfc_link_state_store(struct device *dev, struct device_attribute *attr, | |||
506 | 506 | ||
507 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && | 507 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
508 | (phba->link_state == LPFC_LINK_DOWN)) | 508 | (phba->link_state == LPFC_LINK_DOWN)) |
509 | status = phba->lpfc_hba_init_link(phba); | 509 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
510 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && | 510 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
511 | (phba->link_state >= LPFC_LINK_UP)) | 511 | (phba->link_state >= LPFC_LINK_UP)) |
512 | status = phba->lpfc_hba_down_link(phba); | 512 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
513 | 513 | ||
514 | if (status == 0) | 514 | if (status == 0) |
515 | return strlen(buf); | 515 | return strlen(buf); |
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index e654d01dad24..bc813fd99d5e 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h | |||
@@ -3014,18 +3014,10 @@ struct sli3_pgp { | |||
3014 | uint32_t hbq_get[16]; | 3014 | uint32_t hbq_get[16]; |
3015 | }; | 3015 | }; |
3016 | 3016 | ||
3017 | struct sli3_inb_pgp { | ||
3018 | uint32_t ha_copy; | ||
3019 | uint32_t counter; | ||
3020 | struct lpfc_pgp port[MAX_RINGS]; | ||
3021 | uint32_t hbq_get[16]; | ||
3022 | }; | ||
3023 | |||
3024 | union sli_var { | 3017 | union sli_var { |
3025 | struct sli2_desc s2; | 3018 | struct sli2_desc s2; |
3026 | struct sli3_desc s3; | 3019 | struct sli3_desc s3; |
3027 | struct sli3_pgp s3_pgp; | 3020 | struct sli3_pgp s3_pgp; |
3028 | struct sli3_inb_pgp s3_inb_pgp; | ||
3029 | }; | 3021 | }; |
3030 | 3022 | ||
3031 | typedef struct { | 3023 | typedef struct { |
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index cd9697edf860..8da8fc69227f 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c | |||
@@ -621,6 +621,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) | |||
621 | /** | 621 | /** |
622 | * lpfc_hba_init_link - Initialize the FC link | 622 | * lpfc_hba_init_link - Initialize the FC link |
623 | * @phba: pointer to lpfc hba data structure. | 623 | * @phba: pointer to lpfc hba data structure. |
624 | * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT | ||
624 | * | 625 | * |
625 | * This routine will issue the INIT_LINK mailbox command call. | 626 | * This routine will issue the INIT_LINK mailbox command call. |
626 | * It is available to other drivers through the lpfc_hba data | 627 | * It is available to other drivers through the lpfc_hba data |
@@ -632,7 +633,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) | |||
632 | * Any other value - error | 633 | * Any other value - error |
633 | **/ | 634 | **/ |
634 | int | 635 | int |
635 | lpfc_hba_init_link(struct lpfc_hba *phba) | 636 | lpfc_hba_init_link(struct lpfc_hba *phba, uint32_t flag) |
636 | { | 637 | { |
637 | struct lpfc_vport *vport = phba->pport; | 638 | struct lpfc_vport *vport = phba->pport; |
638 | LPFC_MBOXQ_t *pmb; | 639 | LPFC_MBOXQ_t *pmb; |
@@ -651,7 +652,7 @@ lpfc_hba_init_link(struct lpfc_hba *phba) | |||
651 | phba->cfg_link_speed); | 652 | phba->cfg_link_speed); |
652 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | 653 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
653 | lpfc_set_loopback_flag(phba); | 654 | lpfc_set_loopback_flag(phba); |
654 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | 655 | rc = lpfc_sli_issue_mbox(phba, pmb, flag); |
655 | if (rc != MBX_SUCCESS) { | 656 | if (rc != MBX_SUCCESS) { |
656 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 657 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
657 | "0498 Adapter failed to init, mbxCmd x%x " | 658 | "0498 Adapter failed to init, mbxCmd x%x " |
@@ -664,17 +665,21 @@ lpfc_hba_init_link(struct lpfc_hba *phba) | |||
664 | writel(0xffffffff, phba->HAregaddr); | 665 | writel(0xffffffff, phba->HAregaddr); |
665 | readl(phba->HAregaddr); /* flush */ | 666 | readl(phba->HAregaddr); /* flush */ |
666 | phba->link_state = LPFC_HBA_ERROR; | 667 | phba->link_state = LPFC_HBA_ERROR; |
667 | if (rc != MBX_BUSY) | 668 | if (rc != MBX_BUSY || flag == MBX_POLL) |
668 | mempool_free(pmb, phba->mbox_mem_pool); | 669 | mempool_free(pmb, phba->mbox_mem_pool); |
669 | return -EIO; | 670 | return -EIO; |
670 | } | 671 | } |
671 | phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; | 672 | phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; |
673 | if (flag == MBX_POLL) | ||
674 | mempool_free(pmb, phba->mbox_mem_pool); | ||
672 | 675 | ||
673 | return 0; | 676 | return 0; |
674 | } | 677 | } |
675 | 678 | ||
676 | /** | 679 | /** |
677 | * lpfc_hba_down_link - this routine downs the FC link | 680 | * lpfc_hba_down_link - this routine downs the FC link |
681 | * @phba: pointer to lpfc hba data structure. | ||
682 | * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT | ||
678 | * | 683 | * |
679 | * This routine will issue the DOWN_LINK mailbox command call. | 684 | * This routine will issue the DOWN_LINK mailbox command call. |
680 | * It is available to other drivers through the lpfc_hba data | 685 | * It is available to other drivers through the lpfc_hba data |
@@ -685,7 +690,7 @@ lpfc_hba_init_link(struct lpfc_hba *phba) | |||
685 | * Any other value - error | 690 | * Any other value - error |
686 | **/ | 691 | **/ |
687 | int | 692 | int |
688 | lpfc_hba_down_link(struct lpfc_hba *phba) | 693 | lpfc_hba_down_link(struct lpfc_hba *phba, uint32_t flag) |
689 | { | 694 | { |
690 | LPFC_MBOXQ_t *pmb; | 695 | LPFC_MBOXQ_t *pmb; |
691 | int rc; | 696 | int rc; |
@@ -701,7 +706,7 @@ lpfc_hba_down_link(struct lpfc_hba *phba) | |||
701 | "0491 Adapter Link is disabled.\n"); | 706 | "0491 Adapter Link is disabled.\n"); |
702 | lpfc_down_link(phba, pmb); | 707 | lpfc_down_link(phba, pmb); |
703 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | 708 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
704 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | 709 | rc = lpfc_sli_issue_mbox(phba, pmb, flag); |
705 | if ((rc != MBX_SUCCESS) && (rc != MBX_BUSY)) { | 710 | if ((rc != MBX_SUCCESS) && (rc != MBX_BUSY)) { |
706 | lpfc_printf_log(phba, | 711 | lpfc_printf_log(phba, |
707 | KERN_ERR, LOG_INIT, | 712 | KERN_ERR, LOG_INIT, |
@@ -711,6 +716,9 @@ lpfc_hba_down_link(struct lpfc_hba *phba) | |||
711 | mempool_free(pmb, phba->mbox_mem_pool); | 716 | mempool_free(pmb, phba->mbox_mem_pool); |
712 | return -EIO; | 717 | return -EIO; |
713 | } | 718 | } |
719 | if (flag == MBX_POLL) | ||
720 | mempool_free(pmb, phba->mbox_mem_pool); | ||
721 | |||
714 | return 0; | 722 | return 0; |
715 | } | 723 | } |
716 | 724 | ||
@@ -2279,10 +2287,32 @@ static void | |||
2279 | lpfc_block_mgmt_io(struct lpfc_hba * phba) | 2287 | lpfc_block_mgmt_io(struct lpfc_hba * phba) |
2280 | { | 2288 | { |
2281 | unsigned long iflag; | 2289 | unsigned long iflag; |
2290 | uint8_t actcmd = MBX_HEARTBEAT; | ||
2291 | unsigned long timeout; | ||
2292 | |||
2282 | 2293 | ||
2283 | spin_lock_irqsave(&phba->hbalock, iflag); | 2294 | spin_lock_irqsave(&phba->hbalock, iflag); |
2284 | phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; | 2295 | phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; |
2296 | if (phba->sli.mbox_active) | ||
2297 | actcmd = phba->sli.mbox_active->u.mb.mbxCommand; | ||
2285 | spin_unlock_irqrestore(&phba->hbalock, iflag); | 2298 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
2299 | /* Determine how long we might wait for the active mailbox | ||
2300 | * command to be gracefully completed by firmware. | ||
2301 | */ | ||
2302 | timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, actcmd) * 1000) + | ||
2303 | jiffies; | ||
2304 | /* Wait for the outstnading mailbox command to complete */ | ||
2305 | while (phba->sli.mbox_active) { | ||
2306 | /* Check active mailbox complete status every 2ms */ | ||
2307 | msleep(2); | ||
2308 | if (time_after(jiffies, timeout)) { | ||
2309 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, | ||
2310 | "2813 Mgmt IO is Blocked %x " | ||
2311 | "- mbox cmd %x still active\n", | ||
2312 | phba->sli.sli_flag, actcmd); | ||
2313 | break; | ||
2314 | } | ||
2315 | } | ||
2286 | } | 2316 | } |
2287 | 2317 | ||
2288 | /** | 2318 | /** |
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index e84dc33ca201..196371fae242 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c | |||
@@ -1199,7 +1199,6 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1199 | mb->un.varCfgPort.cdss = 1; /* Configure Security */ | 1199 | mb->un.varCfgPort.cdss = 1; /* Configure Security */ |
1200 | mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ | 1200 | mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ |
1201 | mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */ | 1201 | mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */ |
1202 | mb->un.varCfgPort.cinb = 1; /* Interrupt Notification Block */ | ||
1203 | mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count(); | 1202 | mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count(); |
1204 | if (phba->max_vpi && phba->cfg_enable_npiv && | 1203 | if (phba->max_vpi && phba->cfg_enable_npiv && |
1205 | phba->vpd.sli3Feat.cmv) { | 1204 | phba->vpd.sli3Feat.cmv) { |
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 7a61455140b6..87ae175a0830 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
@@ -3794,7 +3794,7 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba) | |||
3794 | 3794 | ||
3795 | phba->link_state = LPFC_HBA_ERROR; | 3795 | phba->link_state = LPFC_HBA_ERROR; |
3796 | mempool_free(pmb, phba->mbox_mem_pool); | 3796 | mempool_free(pmb, phba->mbox_mem_pool); |
3797 | return ENXIO; | 3797 | return -ENXIO; |
3798 | } | 3798 | } |
3799 | } | 3799 | } |
3800 | phba->hbq_count = hbq_count; | 3800 | phba->hbq_count = hbq_count; |
@@ -3885,7 +3885,6 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode) | |||
3885 | phba->sli3_options &= ~(LPFC_SLI3_NPIV_ENABLED | | 3885 | phba->sli3_options &= ~(LPFC_SLI3_NPIV_ENABLED | |
3886 | LPFC_SLI3_HBQ_ENABLED | | 3886 | LPFC_SLI3_HBQ_ENABLED | |
3887 | LPFC_SLI3_CRP_ENABLED | | 3887 | LPFC_SLI3_CRP_ENABLED | |
3888 | LPFC_SLI3_INB_ENABLED | | ||
3889 | LPFC_SLI3_BG_ENABLED); | 3888 | LPFC_SLI3_BG_ENABLED); |
3890 | if (rc != MBX_SUCCESS) { | 3889 | if (rc != MBX_SUCCESS) { |
3891 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 3890 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
@@ -3927,20 +3926,9 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode) | |||
3927 | phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED; | 3926 | phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED; |
3928 | if (pmb->u.mb.un.varCfgPort.gcrp) | 3927 | if (pmb->u.mb.un.varCfgPort.gcrp) |
3929 | phba->sli3_options |= LPFC_SLI3_CRP_ENABLED; | 3928 | phba->sli3_options |= LPFC_SLI3_CRP_ENABLED; |
3930 | if (pmb->u.mb.un.varCfgPort.ginb) { | 3929 | |
3931 | phba->sli3_options |= LPFC_SLI3_INB_ENABLED; | 3930 | phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get; |
3932 | phba->hbq_get = phba->mbox->us.s3_inb_pgp.hbq_get; | 3931 | phba->port_gp = phba->mbox->us.s3_pgp.port; |
3933 | phba->port_gp = phba->mbox->us.s3_inb_pgp.port; | ||
3934 | phba->inb_ha_copy = &phba->mbox->us.s3_inb_pgp.ha_copy; | ||
3935 | phba->inb_counter = &phba->mbox->us.s3_inb_pgp.counter; | ||
3936 | phba->inb_last_counter = | ||
3937 | phba->mbox->us.s3_inb_pgp.counter; | ||
3938 | } else { | ||
3939 | phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get; | ||
3940 | phba->port_gp = phba->mbox->us.s3_pgp.port; | ||
3941 | phba->inb_ha_copy = NULL; | ||
3942 | phba->inb_counter = NULL; | ||
3943 | } | ||
3944 | 3932 | ||
3945 | if (phba->cfg_enable_bg) { | 3933 | if (phba->cfg_enable_bg) { |
3946 | if (pmb->u.mb.un.varCfgPort.gbg) | 3934 | if (pmb->u.mb.un.varCfgPort.gbg) |
@@ -3953,8 +3941,6 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode) | |||
3953 | } else { | 3941 | } else { |
3954 | phba->hbq_get = NULL; | 3942 | phba->hbq_get = NULL; |
3955 | phba->port_gp = phba->mbox->us.s2.port; | 3943 | phba->port_gp = phba->mbox->us.s2.port; |
3956 | phba->inb_ha_copy = NULL; | ||
3957 | phba->inb_counter = NULL; | ||
3958 | phba->max_vpi = 0; | 3944 | phba->max_vpi = 0; |
3959 | } | 3945 | } |
3960 | do_prep_failed: | 3946 | do_prep_failed: |