Commit 6e7288d9 authored by James Smart's avatar James Smart Committed by James Bottomley

[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: default avatarAlex Iannicelli <alex.iannicelli@emulex.com>
Signed-off-by: default avatarJames Smart <james.smart@emulex.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent ffc95493
...@@ -510,9 +510,9 @@ struct lpfc_hba { ...@@ -510,9 +510,9 @@ struct lpfc_hba {
void (*lpfc_stop_port) void (*lpfc_stop_port)
(struct lpfc_hba *); (struct lpfc_hba *);
int (*lpfc_hba_init_link) int (*lpfc_hba_init_link)
(struct lpfc_hba *); (struct lpfc_hba *, uint32_t);
int (*lpfc_hba_down_link) int (*lpfc_hba_down_link)
(struct lpfc_hba *); (struct lpfc_hba *, uint32_t);
/* SLI4 specific HBA data structure */ /* SLI4 specific HBA data structure */
struct lpfc_sli4_hba sli4_hba; struct lpfc_sli4_hba sli4_hba;
...@@ -525,7 +525,6 @@ struct lpfc_hba { ...@@ -525,7 +525,6 @@ struct lpfc_hba {
#define LPFC_SLI3_NPIV_ENABLED 0x02 #define LPFC_SLI3_NPIV_ENABLED 0x02
#define LPFC_SLI3_VPORT_TEARDOWN 0x04 #define LPFC_SLI3_VPORT_TEARDOWN 0x04
#define LPFC_SLI3_CRP_ENABLED 0x08 #define LPFC_SLI3_CRP_ENABLED 0x08
#define LPFC_SLI3_INB_ENABLED 0x10
#define LPFC_SLI3_BG_ENABLED 0x20 #define LPFC_SLI3_BG_ENABLED 0x20
#define LPFC_SLI3_DSS_ENABLED 0x40 #define LPFC_SLI3_DSS_ENABLED 0x40
uint32_t iocb_cmd_size; uint32_t iocb_cmd_size;
...@@ -557,9 +556,6 @@ struct lpfc_hba { ...@@ -557,9 +556,6 @@ struct lpfc_hba {
MAILBOX_t *mbox; MAILBOX_t *mbox;
uint32_t *mbox_ext; uint32_t *mbox_ext;
uint32_t *inb_ha_copy;
uint32_t *inb_counter;
uint32_t inb_last_counter;
uint32_t ha_copy; uint32_t ha_copy;
struct _PCB *pcb; struct _PCB *pcb;
struct _IOCB *IOCBs; struct _IOCB *IOCBs;
......
...@@ -506,10 +506,10 @@ lpfc_link_state_store(struct device *dev, struct device_attribute *attr, ...@@ -506,10 +506,10 @@ lpfc_link_state_store(struct device *dev, struct device_attribute *attr,
if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && if ((strncmp(buf, "up", sizeof("up") - 1) == 0) &&
(phba->link_state == LPFC_LINK_DOWN)) (phba->link_state == LPFC_LINK_DOWN))
status = phba->lpfc_hba_init_link(phba); status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT);
else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) &&
(phba->link_state >= LPFC_LINK_UP)) (phba->link_state >= LPFC_LINK_UP))
status = phba->lpfc_hba_down_link(phba); status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT);
if (status == 0) if (status == 0)
return strlen(buf); return strlen(buf);
......
...@@ -3014,18 +3014,10 @@ struct sli3_pgp { ...@@ -3014,18 +3014,10 @@ struct sli3_pgp {
uint32_t hbq_get[16]; uint32_t hbq_get[16];
}; };
struct sli3_inb_pgp {
uint32_t ha_copy;
uint32_t counter;
struct lpfc_pgp port[MAX_RINGS];
uint32_t hbq_get[16];
};
union sli_var { union sli_var {
struct sli2_desc s2; struct sli2_desc s2;
struct sli3_desc s3; struct sli3_desc s3;
struct sli3_pgp s3_pgp; struct sli3_pgp s3_pgp;
struct sli3_inb_pgp s3_inb_pgp;
}; };
typedef struct { typedef struct {
......
...@@ -621,6 +621,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) ...@@ -621,6 +621,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
/** /**
* lpfc_hba_init_link - Initialize the FC link * lpfc_hba_init_link - Initialize the FC link
* @phba: pointer to lpfc hba data structure. * @phba: pointer to lpfc hba data structure.
* @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
* *
* This routine will issue the INIT_LINK mailbox command call. * This routine will issue the INIT_LINK mailbox command call.
* It is available to other drivers through the lpfc_hba data * It is available to other drivers through the lpfc_hba data
...@@ -632,7 +633,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) ...@@ -632,7 +633,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
* Any other value - error * Any other value - error
**/ **/
int int
lpfc_hba_init_link(struct lpfc_hba *phba) lpfc_hba_init_link(struct lpfc_hba *phba, uint32_t flag)
{ {
struct lpfc_vport *vport = phba->pport; struct lpfc_vport *vport = phba->pport;
LPFC_MBOXQ_t *pmb; LPFC_MBOXQ_t *pmb;
...@@ -651,7 +652,7 @@ lpfc_hba_init_link(struct lpfc_hba *phba) ...@@ -651,7 +652,7 @@ lpfc_hba_init_link(struct lpfc_hba *phba)
phba->cfg_link_speed); phba->cfg_link_speed);
pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
lpfc_set_loopback_flag(phba); lpfc_set_loopback_flag(phba);
rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); rc = lpfc_sli_issue_mbox(phba, pmb, flag);
if (rc != MBX_SUCCESS) { if (rc != MBX_SUCCESS) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT, lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"0498 Adapter failed to init, mbxCmd x%x " "0498 Adapter failed to init, mbxCmd x%x "
...@@ -664,17 +665,21 @@ lpfc_hba_init_link(struct lpfc_hba *phba) ...@@ -664,17 +665,21 @@ lpfc_hba_init_link(struct lpfc_hba *phba)
writel(0xffffffff, phba->HAregaddr); writel(0xffffffff, phba->HAregaddr);
readl(phba->HAregaddr); /* flush */ readl(phba->HAregaddr); /* flush */
phba->link_state = LPFC_HBA_ERROR; phba->link_state = LPFC_HBA_ERROR;
if (rc != MBX_BUSY) if (rc != MBX_BUSY || flag == MBX_POLL)
mempool_free(pmb, phba->mbox_mem_pool); mempool_free(pmb, phba->mbox_mem_pool);
return -EIO; return -EIO;
} }
phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK;
if (flag == MBX_POLL)
mempool_free(pmb, phba->mbox_mem_pool);
return 0; return 0;
} }
/** /**
* lpfc_hba_down_link - this routine downs the FC link * lpfc_hba_down_link - this routine downs the FC link
* @phba: pointer to lpfc hba data structure.
* @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
* *
* This routine will issue the DOWN_LINK mailbox command call. * This routine will issue the DOWN_LINK mailbox command call.
* It is available to other drivers through the lpfc_hba data * It is available to other drivers through the lpfc_hba data
...@@ -685,7 +690,7 @@ lpfc_hba_init_link(struct lpfc_hba *phba) ...@@ -685,7 +690,7 @@ lpfc_hba_init_link(struct lpfc_hba *phba)
* Any other value - error * Any other value - error
**/ **/
int int
lpfc_hba_down_link(struct lpfc_hba *phba) lpfc_hba_down_link(struct lpfc_hba *phba, uint32_t flag)
{ {
LPFC_MBOXQ_t *pmb; LPFC_MBOXQ_t *pmb;
int rc; int rc;
...@@ -701,7 +706,7 @@ lpfc_hba_down_link(struct lpfc_hba *phba) ...@@ -701,7 +706,7 @@ lpfc_hba_down_link(struct lpfc_hba *phba)
"0491 Adapter Link is disabled.\n"); "0491 Adapter Link is disabled.\n");
lpfc_down_link(phba, pmb); lpfc_down_link(phba, pmb);
pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); rc = lpfc_sli_issue_mbox(phba, pmb, flag);
if ((rc != MBX_SUCCESS) && (rc != MBX_BUSY)) { if ((rc != MBX_SUCCESS) && (rc != MBX_BUSY)) {
lpfc_printf_log(phba, lpfc_printf_log(phba,
KERN_ERR, LOG_INIT, KERN_ERR, LOG_INIT,
...@@ -711,6 +716,9 @@ lpfc_hba_down_link(struct lpfc_hba *phba) ...@@ -711,6 +716,9 @@ lpfc_hba_down_link(struct lpfc_hba *phba)
mempool_free(pmb, phba->mbox_mem_pool); mempool_free(pmb, phba->mbox_mem_pool);
return -EIO; return -EIO;
} }
if (flag == MBX_POLL)
mempool_free(pmb, phba->mbox_mem_pool);
return 0; return 0;
} }
...@@ -2279,10 +2287,32 @@ static void ...@@ -2279,10 +2287,32 @@ static void
lpfc_block_mgmt_io(struct lpfc_hba * phba) lpfc_block_mgmt_io(struct lpfc_hba * phba)
{ {
unsigned long iflag; unsigned long iflag;
uint8_t actcmd = MBX_HEARTBEAT;
unsigned long timeout;
spin_lock_irqsave(&phba->hbalock, iflag); spin_lock_irqsave(&phba->hbalock, iflag);
phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO;
if (phba->sli.mbox_active)
actcmd = phba->sli.mbox_active->u.mb.mbxCommand;
spin_unlock_irqrestore(&phba->hbalock, iflag); spin_unlock_irqrestore(&phba->hbalock, iflag);
/* Determine how long we might wait for the active mailbox
* command to be gracefully completed by firmware.
*/
timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, actcmd) * 1000) +
jiffies;
/* Wait for the outstnading mailbox command to complete */
while (phba->sli.mbox_active) {
/* Check active mailbox complete status every 2ms */
msleep(2);
if (time_after(jiffies, timeout)) {
lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
"2813 Mgmt IO is Blocked %x "
"- mbox cmd %x still active\n",
phba->sli.sli_flag, actcmd);
break;
}
}
} }
/** /**
......
...@@ -1199,7 +1199,6 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) ...@@ -1199,7 +1199,6 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
mb->un.varCfgPort.cdss = 1; /* Configure Security */ mb->un.varCfgPort.cdss = 1; /* Configure Security */
mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ mb->un.varCfgPort.cerbm = 1; /* Request HBQs */
mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */ mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */
mb->un.varCfgPort.cinb = 1; /* Interrupt Notification Block */
mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count(); mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count();
if (phba->max_vpi && phba->cfg_enable_npiv && if (phba->max_vpi && phba->cfg_enable_npiv &&
phba->vpd.sli3Feat.cmv) { phba->vpd.sli3Feat.cmv) {
......
...@@ -3794,7 +3794,7 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba) ...@@ -3794,7 +3794,7 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba)
phba->link_state = LPFC_HBA_ERROR; phba->link_state = LPFC_HBA_ERROR;
mempool_free(pmb, phba->mbox_mem_pool); mempool_free(pmb, phba->mbox_mem_pool);
return ENXIO; return -ENXIO;
} }
} }
phba->hbq_count = hbq_count; phba->hbq_count = hbq_count;
...@@ -3885,7 +3885,6 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode) ...@@ -3885,7 +3885,6 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode)
phba->sli3_options &= ~(LPFC_SLI3_NPIV_ENABLED | phba->sli3_options &= ~(LPFC_SLI3_NPIV_ENABLED |
LPFC_SLI3_HBQ_ENABLED | LPFC_SLI3_HBQ_ENABLED |
LPFC_SLI3_CRP_ENABLED | LPFC_SLI3_CRP_ENABLED |
LPFC_SLI3_INB_ENABLED |
LPFC_SLI3_BG_ENABLED); LPFC_SLI3_BG_ENABLED);
if (rc != MBX_SUCCESS) { if (rc != MBX_SUCCESS) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT, lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
...@@ -3927,20 +3926,9 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode) ...@@ -3927,20 +3926,9 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode)
phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED; phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED;
if (pmb->u.mb.un.varCfgPort.gcrp) if (pmb->u.mb.un.varCfgPort.gcrp)
phba->sli3_options |= LPFC_SLI3_CRP_ENABLED; phba->sli3_options |= LPFC_SLI3_CRP_ENABLED;
if (pmb->u.mb.un.varCfgPort.ginb) {
phba->sli3_options |= LPFC_SLI3_INB_ENABLED;
phba->hbq_get = phba->mbox->us.s3_inb_pgp.hbq_get;
phba->port_gp = phba->mbox->us.s3_inb_pgp.port;
phba->inb_ha_copy = &phba->mbox->us.s3_inb_pgp.ha_copy;
phba->inb_counter = &phba->mbox->us.s3_inb_pgp.counter;
phba->inb_last_counter =
phba->mbox->us.s3_inb_pgp.counter;
} else {
phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get; phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get;
phba->port_gp = phba->mbox->us.s3_pgp.port; phba->port_gp = phba->mbox->us.s3_pgp.port;
phba->inb_ha_copy = NULL;
phba->inb_counter = NULL;
}
if (phba->cfg_enable_bg) { if (phba->cfg_enable_bg) {
if (pmb->u.mb.un.varCfgPort.gbg) if (pmb->u.mb.un.varCfgPort.gbg)
...@@ -3953,8 +3941,6 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode) ...@@ -3953,8 +3941,6 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode)
} else { } else {
phba->hbq_get = NULL; phba->hbq_get = NULL;
phba->port_gp = phba->mbox->us.s2.port; phba->port_gp = phba->mbox->us.s2.port;
phba->inb_ha_copy = NULL;
phba->inb_counter = NULL;
phba->max_vpi = 0; phba->max_vpi = 0;
} }
do_prep_failed: do_prep_failed:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment