aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJames Smart <James.Smart@Emulex.Com>2008-08-24 21:50:00 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-10-13 09:28:53 -0400
commitd7c255b26d8e3f12164d82093de3bf22efad2b4a (patch)
tree0b3467eda322ec2d90e5a7369891ab4ba12ff0a1 /drivers/scsi
parent34b02dcdcf1865405f4762b991965c0c3b8a3ae0 (diff)
[SCSI] lpfc 8.2.8 : Miscellaneous Bug Fixes
Miscellaneous Fixes: - Fix the wrong variable name used for checking node active usage status - Fix numerous duplicate log message numbers - Fix change KERN_WARNING messages to KERN_INFO. - Stop sending erroneous LOGO to fabric after vport is already terminated - Fix HBQ allocates that were kalloc'ing w/ GFP_KERNEL while holding a lock. - Fix gcc 4.3.2 compiler warnings and a sparse warning - Fix bugs in handling unsolicited ct event queue - Reorder some of the initial link up checks, to remove odd VPI states. - Correct poor VPI handling - Add debug messages - Expand Update_CFG mailbox definition - Fix handling of VPD data offsets - Reorder loopback flags - convert to use offsetof() Signed-off-by: James Smart <james.smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/lpfc/lpfc.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c32
-rw-r--r--drivers/scsi/lpfc/lpfc_crtn.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c15
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c20
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c87
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c18
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h31
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c30
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c9
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c6
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c105
-rw-r--r--drivers/scsi/lpfc/lpfc_vport.c14
13 files changed, 219 insertions, 152 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 327eeb051087..f57a416033b9 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -499,7 +499,7 @@ struct lpfc_hba {
499 499
500 wait_queue_head_t work_waitq; 500 wait_queue_head_t work_waitq;
501 struct task_struct *worker_thread; 501 struct task_struct *worker_thread;
502 long data_flags; 502 unsigned long data_flags;
503 503
504 uint32_t hbq_in_use; /* HBQs in use flag */ 504 uint32_t hbq_in_use; /* HBQs in use flag */
505 struct list_head hbqbuf_in_list; /* in-fly hbq buffer list */ 505 struct list_head hbqbuf_in_list; /* in-fly hbq buffer list */
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 2926a2a7ee70..172b6b0a5704 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -1302,7 +1302,7 @@ lpfc_##attr##_init(struct lpfc_vport *vport, int val) \
1302 return 0;\ 1302 return 0;\
1303 }\ 1303 }\
1304 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ 1304 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1305 "0449 lpfc_"#attr" attribute cannot be set to %d, "\ 1305 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
1306 "allowed range is ["#minval", "#maxval"]\n", val); \ 1306 "allowed range is ["#minval", "#maxval"]\n", val); \
1307 vport->cfg_##attr = default;\ 1307 vport->cfg_##attr = default;\
1308 return -EINVAL;\ 1308 return -EINVAL;\
@@ -1334,7 +1334,7 @@ lpfc_##attr##_set(struct lpfc_vport *vport, int val) \
1334 return 0;\ 1334 return 0;\
1335 }\ 1335 }\
1336 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ 1336 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1337 "0450 lpfc_"#attr" attribute cannot be set to %d, "\ 1337 "0424 lpfc_"#attr" attribute cannot be set to %d, "\
1338 "allowed range is ["#minval", "#maxval"]\n", val); \ 1338 "allowed range is ["#minval", "#maxval"]\n", val); \
1339 return -EINVAL;\ 1339 return -EINVAL;\
1340} 1340}
@@ -1803,7 +1803,7 @@ lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val)
1803 vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; 1803 vport->cfg_nodev_tmo = vport->cfg_devloss_tmo;
1804 if (val != LPFC_DEF_DEVLOSS_TMO) 1804 if (val != LPFC_DEF_DEVLOSS_TMO)
1805 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1805 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1806 "0402 Ignoring nodev_tmo module " 1806 "0407 Ignoring nodev_tmo module "
1807 "parameter because devloss_tmo is " 1807 "parameter because devloss_tmo is "
1808 "set.\n"); 1808 "set.\n");
1809 return 0; 1809 return 0;
@@ -2030,7 +2030,7 @@ lpfc_restrict_login_init(struct lpfc_vport *vport, int val)
2030{ 2030{
2031 if (val < 0 || val > 1) { 2031 if (val < 0 || val > 1) {
2032 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 2032 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2033 "0449 lpfc_restrict_login attribute cannot " 2033 "0422 lpfc_restrict_login attribute cannot "
2034 "be set to %d, allowed range is [0, 1]\n", 2034 "be set to %d, allowed range is [0, 1]\n",
2035 val); 2035 val);
2036 vport->cfg_restrict_login = 1; 2036 vport->cfg_restrict_login = 1;
@@ -2065,7 +2065,7 @@ lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
2065{ 2065{
2066 if (val < 0 || val > 1) { 2066 if (val < 0 || val > 1) {
2067 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 2067 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
2068 "0450 lpfc_restrict_login attribute cannot " 2068 "0425 lpfc_restrict_login attribute cannot "
2069 "be set to %d, allowed range is [0, 1]\n", 2069 "be set to %d, allowed range is [0, 1]\n",
2070 val); 2070 val);
2071 vport->cfg_restrict_login = 1; 2071 vport->cfg_restrict_login = 1;
@@ -2249,7 +2249,7 @@ lpfc_link_speed_init(struct lpfc_hba *phba, int val)
2249 return 0; 2249 return 0;
2250 } 2250 }
2251 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 2251 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2252 "0454 lpfc_link_speed attribute cannot " 2252 "0405 lpfc_link_speed attribute cannot "
2253 "be set to %d, allowed values are " 2253 "be set to %d, allowed values are "
2254 "["LPFC_LINK_SPEED_STRING"]\n", val); 2254 "["LPFC_LINK_SPEED_STRING"]\n", val);
2255 phba->cfg_link_speed = 0; 2255 phba->cfg_link_speed = 0;
@@ -2787,17 +2787,15 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr,
2787 /* If HBA encountered an error attention, allow only DUMP 2787 /* If HBA encountered an error attention, allow only DUMP
2788 * or RESTART mailbox commands until the HBA is restarted. 2788 * or RESTART mailbox commands until the HBA is restarted.
2789 */ 2789 */
2790 if ((phba->pport->stopped) && 2790 if (phba->pport->stopped &&
2791 (phba->sysfs_mbox.mbox->mb.mbxCommand != 2791 phba->sysfs_mbox.mbox->mb.mbxCommand != MBX_DUMP_MEMORY &&
2792 MBX_DUMP_MEMORY && 2792 phba->sysfs_mbox.mbox->mb.mbxCommand != MBX_RESTART &&
2793 phba->sysfs_mbox.mbox->mb.mbxCommand != 2793 phba->sysfs_mbox.mbox->mb.mbxCommand != MBX_WRITE_VPARMS &&
2794 MBX_RESTART && 2794 phba->sysfs_mbox.mbox->mb.mbxCommand != MBX_WRITE_WWN)
2795 phba->sysfs_mbox.mbox->mb.mbxCommand != 2795 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
2796 MBX_WRITE_VPARMS)) { 2796 "1259 mbox: Issued mailbox cmd "
2797 sysfs_mbox_idle(phba); 2797 "0x%x while in stopped state.\n",
2798 spin_unlock_irq(&phba->hbalock); 2798 phba->sysfs_mbox.mbox->mb.mbxCommand);
2799 return -EPERM;
2800 }
2801 2799
2802 phba->sysfs_mbox.mbox->vport = vport; 2800 phba->sysfs_mbox.mbox->vport = vport;
2803 2801
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index 1b8245213b83..189ce9f8a7b1 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -269,7 +269,7 @@ void lpfc_dev_loss_tmo_callbk(struct fc_rport *rport);
269 269
270struct lpfc_vport *lpfc_create_port(struct lpfc_hba *, int, struct device *); 270struct lpfc_vport *lpfc_create_port(struct lpfc_hba *, int, struct device *);
271int lpfc_vport_disable(struct fc_vport *fc_vport, bool disable); 271int lpfc_vport_disable(struct fc_vport *fc_vport, bool disable);
272void lpfc_mbx_unreg_vpi(struct lpfc_vport *); 272int lpfc_mbx_unreg_vpi(struct lpfc_vport *);
273void destroy_port(struct lpfc_vport *); 273void destroy_port(struct lpfc_vport *);
274int lpfc_get_instance(void); 274int lpfc_get_instance(void);
275void lpfc_host_attrib_init(struct Scsi_Host *); 275void lpfc_host_attrib_init(struct Scsi_Host *);
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 0f387862cf77..71cfee884b8a 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -134,25 +134,24 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
134 } 134 }
135 list_del(&head); 135 list_del(&head);
136 } else { 136 } else {
137 struct lpfc_iocbq *next; 137 INIT_LIST_HEAD(&head);
138 138 list_add_tail(&head, &piocbq->list);
139 list_for_each_entry_safe(iocbq, next, &piocbq->list, list) { 139 list_for_each_entry(iocbq, &head, list) {
140 icmd = &iocbq->iocb; 140 icmd = &iocbq->iocb;
141 if (icmd->ulpBdeCount == 0) 141 if (icmd->ulpBdeCount == 0)
142 lpfc_ct_unsol_buffer(phba, piocbq, NULL, 0); 142 lpfc_ct_unsol_buffer(phba, iocbq, NULL, 0);
143 for (i = 0; i < icmd->ulpBdeCount; i++) { 143 for (i = 0; i < icmd->ulpBdeCount; i++) {
144 paddr = getPaddr(icmd->un.cont64[i].addrHigh, 144 paddr = getPaddr(icmd->un.cont64[i].addrHigh,
145 icmd->un.cont64[i].addrLow); 145 icmd->un.cont64[i].addrLow);
146 mp = lpfc_sli_ringpostbuf_get(phba, pring, 146 mp = lpfc_sli_ringpostbuf_get(phba, pring,
147 paddr); 147 paddr);
148 size = icmd->un.cont64[i].tus.f.bdeSize; 148 size = icmd->un.cont64[i].tus.f.bdeSize;
149 lpfc_ct_unsol_buffer(phba, piocbq, mp, size); 149 lpfc_ct_unsol_buffer(phba, iocbq, mp, size);
150 lpfc_in_buf_free(phba, mp); 150 lpfc_in_buf_free(phba, mp);
151 } 151 }
152 list_del(&iocbq->list);
153 lpfc_sli_release_iocbq(phba, iocbq);
154 lpfc_post_buffer(phba, pring, i); 152 lpfc_post_buffer(phba, pring, i);
155 } 153 }
154 list_del(&head);
156 } 155 }
157} 156}
158 157
@@ -861,7 +860,7 @@ lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
861 860
862 retry++; 861 retry++;
863 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 862 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
864 "0216 Retrying NS cmd %x\n", cmdcode); 863 "0250 Retrying NS cmd %x\n", cmdcode);
865 rc = lpfc_ns_cmd(vport, cmdcode, retry, 0); 864 rc = lpfc_ns_cmd(vport, cmdcode, retry, 0);
866 if (rc == 0) 865 if (rc == 0)
867 goto out; 866 goto out;
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 2f6d34924b7d..f85b99a7c43d 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -1119,7 +1119,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1119 atomic_set(&lpfc_debugfs_hba_count, 0); 1119 atomic_set(&lpfc_debugfs_hba_count, 0);
1120 if (!lpfc_debugfs_root) { 1120 if (!lpfc_debugfs_root) {
1121 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1121 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1122 "0409 Cannot create debugfs root\n"); 1122 "0408 Cannot create debugfs root\n");
1123 goto debug_failed; 1123 goto debug_failed;
1124 } 1124 }
1125 } 1125 }
@@ -1133,7 +1133,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1133 debugfs_create_dir(name, lpfc_debugfs_root); 1133 debugfs_create_dir(name, lpfc_debugfs_root);
1134 if (!phba->hba_debugfs_root) { 1134 if (!phba->hba_debugfs_root) {
1135 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1135 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1136 "0409 Cannot create debugfs hba\n"); 1136 "0412 Cannot create debugfs hba\n");
1137 goto debug_failed; 1137 goto debug_failed;
1138 } 1138 }
1139 atomic_inc(&lpfc_debugfs_hba_count); 1139 atomic_inc(&lpfc_debugfs_hba_count);
@@ -1147,7 +1147,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1147 phba, &lpfc_debugfs_op_hbqinfo); 1147 phba, &lpfc_debugfs_op_hbqinfo);
1148 if (!phba->debug_hbqinfo) { 1148 if (!phba->debug_hbqinfo) {
1149 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1149 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1150 "0409 Cannot create debugfs hbqinfo\n"); 1150 "0411 Cannot create debugfs hbqinfo\n");
1151 goto debug_failed; 1151 goto debug_failed;
1152 } 1152 }
1153 1153
@@ -1159,7 +1159,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1159 phba, &lpfc_debugfs_op_dumpHBASlim); 1159 phba, &lpfc_debugfs_op_dumpHBASlim);
1160 if (!phba->debug_dumpHBASlim) { 1160 if (!phba->debug_dumpHBASlim) {
1161 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1161 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1162 "0409 Cannot create debugfs dumpHBASlim\n"); 1162 "0413 Cannot create debugfs dumpHBASlim\n");
1163 goto debug_failed; 1163 goto debug_failed;
1164 } 1164 }
1165 1165
@@ -1171,7 +1171,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1171 phba, &lpfc_debugfs_op_dumpHostSlim); 1171 phba, &lpfc_debugfs_op_dumpHostSlim);
1172 if (!phba->debug_dumpHostSlim) { 1172 if (!phba->debug_dumpHostSlim) {
1173 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1173 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1174 "0409 Cannot create debugfs dumpHostSlim\n"); 1174 "0414 Cannot create debugfs dumpHostSlim\n");
1175 goto debug_failed; 1175 goto debug_failed;
1176 } 1176 }
1177 1177
@@ -1201,7 +1201,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1201 phba, &lpfc_debugfs_op_slow_ring_trc); 1201 phba, &lpfc_debugfs_op_slow_ring_trc);
1202 if (!phba->debug_slow_ring_trc) { 1202 if (!phba->debug_slow_ring_trc) {
1203 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1203 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1204 "0409 Cannot create debugfs " 1204 "0415 Cannot create debugfs "
1205 "slow_ring_trace\n"); 1205 "slow_ring_trace\n");
1206 goto debug_failed; 1206 goto debug_failed;
1207 } 1207 }
@@ -1212,7 +1212,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1212 GFP_KERNEL); 1212 GFP_KERNEL);
1213 if (!phba->slow_ring_trc) { 1213 if (!phba->slow_ring_trc) {
1214 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1214 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1215 "0409 Cannot create debugfs " 1215 "0416 Cannot create debugfs "
1216 "slow_ring buffer\n"); 1216 "slow_ring buffer\n");
1217 goto debug_failed; 1217 goto debug_failed;
1218 } 1218 }
@@ -1229,7 +1229,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1229 debugfs_create_dir(name, phba->hba_debugfs_root); 1229 debugfs_create_dir(name, phba->hba_debugfs_root);
1230 if (!vport->vport_debugfs_root) { 1230 if (!vport->vport_debugfs_root) {
1231 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1231 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1232 "0409 Cant create debugfs"); 1232 "0417 Cant create debugfs");
1233 goto debug_failed; 1233 goto debug_failed;
1234 } 1234 }
1235 atomic_inc(&phba->debugfs_vport_count); 1235 atomic_inc(&phba->debugfs_vport_count);
@@ -1258,7 +1258,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1258 1258
1259 if (!vport->disc_trc) { 1259 if (!vport->disc_trc) {
1260 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1260 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1261 "0409 Cannot create debugfs disc trace " 1261 "0418 Cannot create debugfs disc trace "
1262 "buffer\n"); 1262 "buffer\n");
1263 goto debug_failed; 1263 goto debug_failed;
1264 } 1264 }
@@ -1271,7 +1271,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
1271 vport, &lpfc_debugfs_op_disc_trc); 1271 vport, &lpfc_debugfs_op_disc_trc);
1272 if (!vport->debug_disc_trc) { 1272 if (!vport->debug_disc_trc) {
1273 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 1273 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1274 "0409 Cannot create debugfs " 1274 "0419 Cannot create debugfs "
1275 "discovery_trace\n"); 1275 "discovery_trace\n");
1276 goto debug_failed; 1276 goto debug_failed;
1277 } 1277 }
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 89bd9ab46de7..d0730e79c1a7 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -473,7 +473,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
473 */ 473 */
474 list_for_each_entry_safe(np, next_np, 474 list_for_each_entry_safe(np, next_np,
475 &vport->fc_nodes, nlp_listp) { 475 &vport->fc_nodes, nlp_listp) {
476 if (!NLP_CHK_NODE_ACT(ndlp)) 476 if (!NLP_CHK_NODE_ACT(np))
477 continue; 477 continue;
478 if ((np->nlp_state != NLP_STE_NPR_NODE) || 478 if ((np->nlp_state != NLP_STE_NPR_NODE) ||
479 !(np->nlp_flag & NLP_NPR_ADISC)) 479 !(np->nlp_flag & NLP_NPR_ADISC))
@@ -2585,7 +2585,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2585 (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID)) 2585 (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID))
2586 ) { 2586 ) {
2587 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, 2587 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2588 "0123 FDISC Failed (x%x). " 2588 "0122 FDISC Failed (x%x). "
2589 "Fabric Detected Bad WWN\n", 2589 "Fabric Detected Bad WWN\n",
2590 stat.un.lsRjtError); 2590 stat.un.lsRjtError);
2591 lpfc_vport_set_state(vport, 2591 lpfc_vport_set_state(vport,
@@ -3966,7 +3966,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3966 if (rscn_id == hba_id) { 3966 if (rscn_id == hba_id) {
3967 /* ALL NPortIDs in RSCN are on HBA */ 3967 /* ALL NPortIDs in RSCN are on HBA */
3968 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 3968 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
3969 "0214 Ignore RSCN " 3969 "0219 Ignore RSCN "
3970 "Data: x%x x%x x%x x%x\n", 3970 "Data: x%x x%x x%x x%x\n",
3971 vport->fc_flag, payload_len, 3971 vport->fc_flag, payload_len,
3972 *lp, vport->fc_rscn_id_cnt); 3972 *lp, vport->fc_rscn_id_cnt);
@@ -5165,8 +5165,6 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
5165 } 5165 }
5166 5166
5167 phba->fc_stat.elsRcvFrame++; 5167 phba->fc_stat.elsRcvFrame++;
5168 if (elsiocb->context1)
5169 lpfc_nlp_put(elsiocb->context1);
5170 5168
5171 elsiocb->context1 = lpfc_nlp_get(ndlp); 5169 elsiocb->context1 = lpfc_nlp_get(ndlp);
5172 elsiocb->vport = vport; 5170 elsiocb->vport = vport;
@@ -5376,6 +5374,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
5376 NULL); 5374 NULL);
5377 } 5375 }
5378 5376
5377 lpfc_nlp_put(elsiocb->context1);
5378 elsiocb->context1 = NULL;
5379 return; 5379 return;
5380 5380
5381dropit: 5381dropit:
@@ -5440,6 +5440,7 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
5440 struct lpfc_dmabuf *bdeBuf1 = elsiocb->context2; 5440 struct lpfc_dmabuf *bdeBuf1 = elsiocb->context2;
5441 struct lpfc_dmabuf *bdeBuf2 = elsiocb->context3; 5441 struct lpfc_dmabuf *bdeBuf2 = elsiocb->context3;
5442 5442
5443 elsiocb->context1 = NULL;
5443 elsiocb->context2 = NULL; 5444 elsiocb->context2 = NULL;
5444 elsiocb->context3 = NULL; 5445 elsiocb->context3 = NULL;
5445 5446
@@ -5487,8 +5488,6 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
5487 * The different unsolicited event handlers would tell us 5488 * The different unsolicited event handlers would tell us
5488 * if they are done with "mp" by setting context2 to NULL. 5489 * if they are done with "mp" by setting context2 to NULL.
5489 */ 5490 */
5490 lpfc_nlp_put(elsiocb->context1);
5491 elsiocb->context1 = NULL;
5492 if (elsiocb->context2) { 5491 if (elsiocb->context2) {
5493 lpfc_in_buf_free(phba, (struct lpfc_dmabuf *)elsiocb->context2); 5492 lpfc_in_buf_free(phba, (struct lpfc_dmabuf *)elsiocb->context2);
5494 elsiocb->context2 = NULL; 5493 elsiocb->context2 = NULL;
@@ -5750,54 +5749,56 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
5750 goto out; 5749 goto out;
5751 /* FDISC failed */ 5750 /* FDISC failed */
5752 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, 5751 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
5753 "0124 FDISC failed. (%d/%d)\n", 5752 "0126 FDISC failed. (%d/%d)\n",
5754 irsp->ulpStatus, irsp->un.ulpWord[4]); 5753 irsp->ulpStatus, irsp->un.ulpWord[4]);
5754 goto fdisc_failed;
5755 }
5755 if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING) 5756 if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING)
5756 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 5757 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
5757 lpfc_nlp_put(ndlp); 5758 lpfc_nlp_put(ndlp);
5758 /* giving up on FDISC. Cancel discovery timer */ 5759 /* giving up on FDISC. Cancel discovery timer */
5759 lpfc_can_disctmo(vport); 5760 lpfc_can_disctmo(vport);
5760 } else { 5761 spin_lock_irq(shost->host_lock);
5761 spin_lock_irq(shost->host_lock); 5762 vport->fc_flag |= FC_FABRIC;
5762 vport->fc_flag |= FC_FABRIC; 5763 if (vport->phba->fc_topology == TOPOLOGY_LOOP)
5763 if (vport->phba->fc_topology == TOPOLOGY_LOOP) 5764 vport->fc_flag |= FC_PUBLIC_LOOP;
5764 vport->fc_flag |= FC_PUBLIC_LOOP; 5765 spin_unlock_irq(shost->host_lock);
5765 spin_unlock_irq(shost->host_lock);
5766 5766
5767 vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; 5767 vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID;
5768 lpfc_vport_set_state(vport, FC_VPORT_ACTIVE); 5768 lpfc_vport_set_state(vport, FC_VPORT_ACTIVE);
5769 if ((vport->fc_prevDID != vport->fc_myDID) && 5769 if ((vport->fc_prevDID != vport->fc_myDID) &&
5770 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { 5770 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
5771 /* If our NportID changed, we need to ensure all 5771 /* If our NportID changed, we need to ensure all
5772 * remaining NPORTs get unreg_login'ed so we can 5772 * remaining NPORTs get unreg_login'ed so we can
5773 * issue unreg_vpi. 5773 * issue unreg_vpi.
5774 */ 5774 */
5775 list_for_each_entry_safe(np, next_np, 5775 list_for_each_entry_safe(np, next_np,
5776 &vport->fc_nodes, nlp_listp) { 5776 &vport->fc_nodes, nlp_listp) {
5777 if (!NLP_CHK_NODE_ACT(ndlp) || 5777 if (!NLP_CHK_NODE_ACT(ndlp) ||
5778 (np->nlp_state != NLP_STE_NPR_NODE) || 5778 (np->nlp_state != NLP_STE_NPR_NODE) ||
5779 !(np->nlp_flag & NLP_NPR_ADISC)) 5779 !(np->nlp_flag & NLP_NPR_ADISC))
5780 continue; 5780 continue;
5781 spin_lock_irq(shost->host_lock);
5782 np->nlp_flag &= ~NLP_NPR_ADISC;
5783 spin_unlock_irq(shost->host_lock);
5784 lpfc_unreg_rpi(vport, np);
5785 }
5786 lpfc_mbx_unreg_vpi(vport);
5787 spin_lock_irq(shost->host_lock); 5781 spin_lock_irq(shost->host_lock);
5788 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 5782 np->nlp_flag &= ~NLP_NPR_ADISC;
5789 spin_unlock_irq(shost->host_lock); 5783 spin_unlock_irq(shost->host_lock);
5784 lpfc_unreg_rpi(vport, np);
5790 } 5785 }
5791 5786 lpfc_mbx_unreg_vpi(vport);
5792 if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) 5787 spin_lock_irq(shost->host_lock);
5793 lpfc_register_new_vport(phba, vport, ndlp); 5788 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
5794 else 5789 spin_unlock_irq(shost->host_lock);
5795 lpfc_do_scr_ns_plogi(phba, vport);
5796
5797 /* Unconditionaly kick off releasing fabric node for vports */
5798 lpfc_nlp_put(ndlp);
5799 } 5790 }
5800 5791
5792 if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
5793 lpfc_register_new_vport(phba, vport, ndlp);
5794 else
5795 lpfc_do_scr_ns_plogi(phba, vport);
5796 goto out;
5797fdisc_failed:
5798 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
5799 /* Cancel discovery timer */
5800 lpfc_can_disctmo(vport);
5801 lpfc_nlp_put(ndlp);
5801out: 5802out:
5802 lpfc_els_free_iocb(phba, cmdiocb); 5803 lpfc_els_free_iocb(phba, cmdiocb);
5803} 5804}
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index aaf398e5c93f..72c1cf15ef2b 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -207,8 +207,16 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)
207 return; 207 return;
208 } 208 }
209 209
210 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE) 210 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE) {
211 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
212 "0284 Devloss timeout Ignored on "
213 "WWPN %x:%x:%x:%x:%x:%x:%x:%x "
214 "NPort x%x\n",
215 *name, *(name+1), *(name+2), *(name+3),
216 *(name+4), *(name+5), *(name+6), *(name+7),
217 ndlp->nlp_DID);
211 return; 218 return;
219 }
212 220
213 if (ndlp->nlp_type & NLP_FABRIC) { 221 if (ndlp->nlp_type & NLP_FABRIC) {
214 /* We will clean up these Nodes in linkup */ 222 /* We will clean up these Nodes in linkup */
@@ -1169,7 +1177,7 @@ lpfc_mbx_cmpl_unreg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1169 scsi_host_put(shost); 1177 scsi_host_put(shost);
1170} 1178}
1171 1179
1172void 1180int
1173lpfc_mbx_unreg_vpi(struct lpfc_vport *vport) 1181lpfc_mbx_unreg_vpi(struct lpfc_vport *vport)
1174{ 1182{
1175 struct lpfc_hba *phba = vport->phba; 1183 struct lpfc_hba *phba = vport->phba;
@@ -1178,7 +1186,7 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vport)
1178 1186
1179 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 1187 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1180 if (!mbox) 1188 if (!mbox)
1181 return; 1189 return 1;
1182 1190
1183 lpfc_unreg_vpi(phba, vport->vpi, mbox); 1191 lpfc_unreg_vpi(phba, vport->vpi, mbox);
1184 mbox->vport = vport; 1192 mbox->vport = vport;
@@ -1189,7 +1197,9 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vport)
1189 "1800 Could not issue unreg_vpi\n"); 1197 "1800 Could not issue unreg_vpi\n");
1190 mempool_free(mbox, phba->mbox_mem_pool); 1198 mempool_free(mbox, phba->mbox_mem_pool);
1191 vport->unreg_vpi_cmpl = VPORT_ERROR; 1199 vport->unreg_vpi_cmpl = VPORT_ERROR;
1200 return rc;
1192 } 1201 }
1202 return 0;
1193} 1203}
1194 1204
1195static void 1205static void
@@ -2778,7 +2788,7 @@ restart_disc:
2778 2788
2779 default: 2789 default:
2780 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, 2790 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2781 "0229 Unexpected discovery timeout, " 2791 "0273 Unexpected discovery timeout, "
2782 "vport State x%x\n", vport->port_state); 2792 "vport State x%x\n", vport->port_state);
2783 break; 2793 break;
2784 } 2794 }
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index a986332fecf6..9f94dab5ea73 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -2318,6 +2318,36 @@ typedef struct {
2318#define DMP_RSP_OFFSET 0x14 /* word 5 contains first word of rsp */ 2318#define DMP_RSP_OFFSET 0x14 /* word 5 contains first word of rsp */
2319#define DMP_RSP_SIZE 0x6C /* maximum of 27 words of rsp data */ 2319#define DMP_RSP_SIZE 0x6C /* maximum of 27 words of rsp data */
2320 2320
2321/* Structure for MB Command UPDATE_CFG (0x1B) */
2322
2323struct update_cfg_var {
2324#ifdef __BIG_ENDIAN_BITFIELD
2325 uint32_t rsvd2:16;
2326 uint32_t type:8;
2327 uint32_t rsvd:1;
2328 uint32_t ra:1;
2329 uint32_t co:1;
2330 uint32_t cv:1;
2331 uint32_t req:4;
2332 uint32_t entry_length:16;
2333 uint32_t region_id:16;
2334#else /* __LITTLE_ENDIAN_BITFIELD */
2335 uint32_t req:4;
2336 uint32_t cv:1;
2337 uint32_t co:1;
2338 uint32_t ra:1;
2339 uint32_t rsvd:1;
2340 uint32_t type:8;
2341 uint32_t rsvd2:16;
2342 uint32_t region_id:16;
2343 uint32_t entry_length:16;
2344#endif
2345
2346 uint32_t resp_info;
2347 uint32_t byte_cnt;
2348 uint32_t data_offset;
2349};
2350
2321struct hbq_mask { 2351struct hbq_mask {
2322#ifdef __BIG_ENDIAN_BITFIELD 2352#ifdef __BIG_ENDIAN_BITFIELD
2323 uint8_t tmatch; 2353 uint8_t tmatch;
@@ -2672,6 +2702,7 @@ typedef union {
2672 * NEW_FEATURE 2702 * NEW_FEATURE
2673 */ 2703 */
2674 struct config_hbq_var varCfgHbq;/* cmd = 0x7c (CONFIG_HBQ) */ 2704 struct config_hbq_var varCfgHbq;/* cmd = 0x7c (CONFIG_HBQ) */
2705 struct update_cfg_var varUpdateCfg; /* cmd = 0x1B (UPDATE_CFG)*/
2675 CONFIG_PORT_VAR varCfgPort; /* cmd = 0x88 (CONFIG_PORT) */ 2706 CONFIG_PORT_VAR varCfgPort; /* cmd = 0x88 (CONFIG_PORT) */
2676 REG_VPI_VAR varRegVpi; /* cmd = 0x96 (REG_VPI) */ 2707 REG_VPI_VAR varRegVpi; /* cmd = 0x96 (REG_VPI) */
2677 UNREG_VPI_VAR varUnregVpi; /* cmd = 0x97 (UNREG_VPI) */ 2708 UNREG_VPI_VAR varUnregVpi; /* cmd = 0x97 (UNREG_VPI) */
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 6a7a039e8904..b8989c43aaf2 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -183,12 +183,9 @@ lpfc_config_port_prep(struct lpfc_hba *phba)
183 sizeof (phba->RandomData)); 183 sizeof (phba->RandomData));
184 184
185 /* Get adapter VPD information */ 185 /* Get adapter VPD information */
186 pmb->context2 = kmalloc(DMP_RSP_SIZE, GFP_KERNEL);
187 if (!pmb->context2)
188 goto out_free_mbox;
189 lpfc_vpd_data = kmalloc(DMP_VPD_SIZE, GFP_KERNEL); 186 lpfc_vpd_data = kmalloc(DMP_VPD_SIZE, GFP_KERNEL);
190 if (!lpfc_vpd_data) 187 if (!lpfc_vpd_data)
191 goto out_free_context2; 188 goto out_free_mbox;
192 189
193 do { 190 do {
194 lpfc_dump_mem(phba, pmb, offset); 191 lpfc_dump_mem(phba, pmb, offset);
@@ -203,15 +200,14 @@ lpfc_config_port_prep(struct lpfc_hba *phba)
203 } 200 }
204 if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset) 201 if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset)
205 mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset; 202 mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset;
206 lpfc_sli_pcimem_bcopy(pmb->context2, lpfc_vpd_data + offset, 203 lpfc_sli_pcimem_bcopy(((uint8_t *)mb) + DMP_RSP_OFFSET,
204 lpfc_vpd_data + offset,
207 mb->un.varDmp.word_cnt); 205 mb->un.varDmp.word_cnt);
208 offset += mb->un.varDmp.word_cnt; 206 offset += mb->un.varDmp.word_cnt;
209 } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE); 207 } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE);
210 lpfc_parse_vpd(phba, lpfc_vpd_data, offset); 208 lpfc_parse_vpd(phba, lpfc_vpd_data, offset);
211 209
212 kfree(lpfc_vpd_data); 210 kfree(lpfc_vpd_data);
213out_free_context2:
214 kfree(pmb->context2);
215out_free_mbox: 211out_free_mbox:
216 mempool_free(pmb, phba->mbox_mem_pool); 212 mempool_free(pmb, phba->mbox_mem_pool);
217 return 0; 213 return 0;
@@ -425,9 +421,8 @@ lpfc_config_port_post(struct lpfc_hba *phba)
425 421
426 lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); 422 lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed);
427 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 423 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
428 pmb->vport = vport;
429 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
430 lpfc_set_loopback_flag(phba); 424 lpfc_set_loopback_flag(phba);
425 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
431 if (rc != MBX_SUCCESS) { 426 if (rc != MBX_SUCCESS) {
432 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 427 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
433 "0454 Adapter failed to init, mbxCmd x%x " 428 "0454 Adapter failed to init, mbxCmd x%x "
@@ -462,7 +457,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
462 rc); 457 rc);
463 mempool_free(pmb, phba->mbox_mem_pool); 458 mempool_free(pmb, phba->mbox_mem_pool);
464 } 459 }
465 return (0); 460 return 0;
466} 461}
467 462
468/** 463/**
@@ -841,7 +836,7 @@ lpfc_handle_eratt(struct lpfc_hba *phba)
841 temp_event_data.data = (uint32_t)temperature; 836 temp_event_data.data = (uint32_t)temperature;
842 837
843 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 838 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
844 "0459 Adapter maximum temperature exceeded " 839 "0406 Adapter maximum temperature exceeded "
845 "(%ld), taking this port offline " 840 "(%ld), taking this port offline "
846 "Data: x%x x%x x%x\n", 841 "Data: x%x x%x x%x\n",
847 temperature, phba->work_hs, 842 temperature, phba->work_hs,
@@ -1595,7 +1590,7 @@ lpfc_cleanup(struct lpfc_vport *vport)
1595 &vport->fc_nodes, nlp_listp) { 1590 &vport->fc_nodes, nlp_listp) {
1596 lpfc_printf_vlog(ndlp->vport, KERN_ERR, 1591 lpfc_printf_vlog(ndlp->vport, KERN_ERR,
1597 LOG_NODE, 1592 LOG_NODE,
1598 "0282: did:x%x ndlp:x%p " 1593 "0282 did:x%x ndlp:x%p "
1599 "usgmap:x%x refcnt:%d\n", 1594 "usgmap:x%x refcnt:%d\n",
1600 ndlp->nlp_DID, (void *)ndlp, 1595 ndlp->nlp_DID, (void *)ndlp,
1601 ndlp->nlp_usg_map, 1596 ndlp->nlp_usg_map,
@@ -2320,10 +2315,10 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
2320 goto out_iounmap; 2315 goto out_iounmap;
2321 2316
2322 memset(phba->slim2p.virt, 0, SLI2_SLIM_SIZE); 2317 memset(phba->slim2p.virt, 0, SLI2_SLIM_SIZE);
2323 phba->mbox = phba->slim2p.virt; 2318 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx);
2324 phba->pcb = (phba->slim2p.virt + sizeof(MAILBOX_t)); 2319 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb));
2325 phba->IOCBs = (phba->slim2p.virt + sizeof(MAILBOX_t) + 2320 phba->IOCBs = (phba->slim2p.virt +
2326 sizeof(struct _PCB)); 2321 offsetof(struct lpfc_sli2_slim, IOCBs));
2327 2322
2328 phba->hbqslimp.virt = dma_alloc_coherent(&phba->pcidev->dev, 2323 phba->hbqslimp.virt = dma_alloc_coherent(&phba->pcidev->dev,
2329 lpfc_sli_hbq_size(), 2324 lpfc_sli_hbq_size(),
@@ -2889,7 +2884,8 @@ lpfc_init(void)
2889 error = pci_register_driver(&lpfc_driver); 2884 error = pci_register_driver(&lpfc_driver);
2890 if (error) { 2885 if (error) {
2891 fc_release_transport(lpfc_transport_template); 2886 fc_release_transport(lpfc_transport_template);
2892 fc_release_transport(lpfc_vport_transport_template); 2887 if (lpfc_enable_npiv)
2888 fc_release_transport(lpfc_vport_transport_template);
2893 } 2889 }
2894 2890
2895 return error; 2891 return error;
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 705c4ae1bdc3..83ffa75378e5 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -1853,8 +1853,13 @@ static uint32_t
1853lpfc_cmpl_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 1853lpfc_cmpl_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1854 void *arg, uint32_t evt) 1854 void *arg, uint32_t evt)
1855{ 1855{
1856 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1857 if (ndlp->nlp_DID == Fabric_DID) {
1858 spin_lock_irq(shost->host_lock);
1859 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
1860 spin_unlock_irq(shost->host_lock);
1861 }
1856 lpfc_unreg_rpi(vport, ndlp); 1862 lpfc_unreg_rpi(vport, ndlp);
1857 /* This routine does nothing, just return the current state */
1858 return ndlp->nlp_state; 1863 return ndlp->nlp_state;
1859} 1864}
1860 1865
@@ -2143,7 +2148,7 @@ lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2143 lpfc_nlp_put(ndlp); 2148 lpfc_nlp_put(ndlp);
2144 } else { 2149 } else {
2145 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 2150 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2146 "0212 DSM out state %d on NPort free\n", rc); 2151 "0213 DSM out state %d on NPort free\n", rc);
2147 2152
2148 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, 2153 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2149 "DSM out: ste:%d did:x%x flg:x%x", 2154 "DSM out: ste:%d did:x%x flg:x%x",
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index c1bb90cf0d06..b73968b2b8b4 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -627,9 +627,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
627 cmd->result = ScsiResult(DID_BUS_BUSY, 0); 627 cmd->result = ScsiResult(DID_BUS_BUSY, 0);
628 break; 628 break;
629 case IOSTAT_LOCAL_REJECT: 629 case IOSTAT_LOCAL_REJECT:
630 if (lpfc_cmd->result == RJT_UNAVAIL_PERM || 630 if (lpfc_cmd->result == IOERR_INVALID_RPI ||
631 lpfc_cmd->result == IOERR_NO_RESOURCES || 631 lpfc_cmd->result == IOERR_NO_RESOURCES ||
632 lpfc_cmd->result == RJT_LOGIN_REQUIRED) { 632 lpfc_cmd->result == IOERR_ABORT_REQUESTED) {
633 cmd->result = ScsiResult(DID_REQUEUE, 0); 633 cmd->result = ScsiResult(DID_REQUEUE, 0);
634 break; 634 break;
635 } /* else: fall through */ 635 } /* else: fall through */
@@ -1318,7 +1318,7 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
1318 struct lpfc_hba *phba = vport->phba; 1318 struct lpfc_hba *phba = vport->phba;
1319 struct lpfc_nodelist *ndlp = NULL; 1319 struct lpfc_nodelist *ndlp = NULL;
1320 int match; 1320 int match;
1321 int ret = SUCCESS, status, i; 1321 int ret = SUCCESS, status = SUCCESS, i;
1322 int cnt; 1322 int cnt;
1323 struct lpfc_scsi_buf * lpfc_cmd; 1323 struct lpfc_scsi_buf * lpfc_cmd;
1324 unsigned long later; 1324 unsigned long later;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 77afa2ba6a2b..c7a520fa1aaa 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -844,48 +844,58 @@ struct lpfc_hbq_init *lpfc_hbq_defs[] = {
844 * @hbqno: HBQ number. 844 * @hbqno: HBQ number.
845 * @count: Number of HBQ buffers to be posted. 845 * @count: Number of HBQ buffers to be posted.
846 * 846 *
847 * This function is called with no lock held to post more 847 * This function is called with no lock held to post more hbq buffers to the
848 * hbq buffers to the given HBQ. The function returns 0 848 * given HBQ. The function returns the number of HBQ buffers successfully
849 * when successful and returns 1 other wise. 849 * posted.
850 **/ 850 **/
851static int 851static int
852lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) 852lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count)
853{ 853{
854 uint32_t i, start, end; 854 uint32_t i, posted = 0;
855 unsigned long flags; 855 unsigned long flags;
856 struct hbq_dmabuf *hbq_buffer; 856 struct hbq_dmabuf *hbq_buffer;
857 857 LIST_HEAD(hbq_buf_list);
858 if (!phba->hbqs[hbqno].hbq_alloc_buffer) 858 if (!phba->hbqs[hbqno].hbq_alloc_buffer)
859 return 0; 859 return 0;
860 860
861 start = phba->hbqs[hbqno].buffer_count; 861 if ((phba->hbqs[hbqno].buffer_count + count) >
862 end = count + start; 862 lpfc_hbq_defs[hbqno]->entry_count)
863 if (end > lpfc_hbq_defs[hbqno]->entry_count) 863 count = lpfc_hbq_defs[hbqno]->entry_count -
864 end = lpfc_hbq_defs[hbqno]->entry_count; 864 phba->hbqs[hbqno].buffer_count;
865 865 if (!count)
866 return 0;
867 /* Allocate HBQ entries */
868 for (i = 0; i < count; i++) {
869 hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba);
870 if (!hbq_buffer)
871 break;
872 list_add_tail(&hbq_buffer->dbuf.list, &hbq_buf_list);
873 }
866 /* Check whether HBQ is still in use */ 874 /* Check whether HBQ is still in use */
867 spin_lock_irqsave(&phba->hbalock, flags); 875 spin_lock_irqsave(&phba->hbalock, flags);
868 if (!phba->hbq_in_use) 876 if (!phba->hbq_in_use)
869 goto out; 877 goto err;
870 878 while (!list_empty(&hbq_buf_list)) {
871 /* Populate HBQ entries */ 879 list_remove_head(&hbq_buf_list, hbq_buffer, struct hbq_dmabuf,
872 for (i = start; i < end; i++) { 880 dbuf.list);
873 hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); 881 hbq_buffer->tag = (phba->hbqs[hbqno].buffer_count |
874 if (!hbq_buffer) 882 (hbqno << 16));
875 goto err; 883 if (lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer)) {
876 hbq_buffer->tag = (i | (hbqno << 16));
877 if (lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer))
878 phba->hbqs[hbqno].buffer_count++; 884 phba->hbqs[hbqno].buffer_count++;
879 else 885 posted++;
886 } else
880 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); 887 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer);
881 } 888 }
882
883 out:
884 spin_unlock_irqrestore(&phba->hbalock, flags); 889 spin_unlock_irqrestore(&phba->hbalock, flags);
885 return 0; 890 return posted;
886 err: 891err:
887 spin_unlock_irqrestore(&phba->hbalock, flags); 892 spin_unlock_irqrestore(&phba->hbalock, flags);
888 return 1; 893 while (!list_empty(&hbq_buf_list)) {
894 list_remove_head(&hbq_buf_list, hbq_buffer, struct hbq_dmabuf,
895 dbuf.list);
896 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer);
897 }
898 return 0;
889} 899}
890 900
891/** 901/**
@@ -894,8 +904,8 @@ lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count)
894 * @qno: HBQ number. 904 * @qno: HBQ number.
895 * 905 *
896 * This function posts more buffers to the HBQ. This function 906 * This function posts more buffers to the HBQ. This function
897 * is called with no lock held. The function returns 0 when 907 * is called with no lock held. The function returns the number of HBQ entries
898 * successful and returns 1 otherwise. 908 * successfully allocated.
899 **/ 909 **/
900int 910int
901lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) 911lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno)
@@ -911,7 +921,7 @@ lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno)
911 * 921 *
912 * This function is called from SLI initialization code path with 922 * This function is called from SLI initialization code path with
913 * no lock held to post initial HBQ buffers to firmware. The 923 * no lock held to post initial HBQ buffers to firmware. The
914 * function returns 0 when successful and returns 1 otherwise. 924 * function returns the number of HBQ entries successfully allocated.
915 **/ 925 **/
916static int 926static int
917lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno) 927lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno)
@@ -1253,7 +1263,9 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba)
1253 * This function is called from unsolicited event handler code path to get the 1263 * This function is called from unsolicited event handler code path to get the
1254 * HBQ buffer associated with an unsolicited iocb. This function is called with 1264 * HBQ buffer associated with an unsolicited iocb. This function is called with
1255 * no lock held. It returns the buffer associated with the given tag and posts 1265 * no lock held. It returns the buffer associated with the given tag and posts
1256 * another buffer to the firmware. 1266 * another buffer to the firmware. Note that the new buffer must be allocated
1267 * before taking the hbalock and that the hba lock must be held until it is
1268 * finished with the hbq entry swap.
1257 **/ 1269 **/
1258static struct lpfc_dmabuf * 1270static struct lpfc_dmabuf *
1259lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) 1271lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag)
@@ -1264,22 +1276,28 @@ lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag)
1264 dma_addr_t phys; /* mapped address */ 1276 dma_addr_t phys; /* mapped address */
1265 unsigned long flags; 1277 unsigned long flags;
1266 1278
1279 hbqno = tag >> 16;
1280 new_hbq_entry = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba);
1267 /* Check whether HBQ is still in use */ 1281 /* Check whether HBQ is still in use */
1268 spin_lock_irqsave(&phba->hbalock, flags); 1282 spin_lock_irqsave(&phba->hbalock, flags);
1269 if (!phba->hbq_in_use) { 1283 if (!phba->hbq_in_use) {
1284 if (new_hbq_entry)
1285 (phba->hbqs[hbqno].hbq_free_buffer)(phba,
1286 new_hbq_entry);
1270 spin_unlock_irqrestore(&phba->hbalock, flags); 1287 spin_unlock_irqrestore(&phba->hbalock, flags);
1271 return NULL; 1288 return NULL;
1272 } 1289 }
1273 1290
1274 hbq_entry = lpfc_sli_hbqbuf_find(phba, tag); 1291 hbq_entry = lpfc_sli_hbqbuf_find(phba, tag);
1275 if (hbq_entry == NULL) { 1292 if (hbq_entry == NULL) {
1293 if (new_hbq_entry)
1294 (phba->hbqs[hbqno].hbq_free_buffer)(phba,
1295 new_hbq_entry);
1276 spin_unlock_irqrestore(&phba->hbalock, flags); 1296 spin_unlock_irqrestore(&phba->hbalock, flags);
1277 return NULL; 1297 return NULL;
1278 } 1298 }
1279 list_del(&hbq_entry->dbuf.list); 1299 list_del(&hbq_entry->dbuf.list);
1280 1300
1281 hbqno = tag >> 16;
1282 new_hbq_entry = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba);
1283 if (new_hbq_entry == NULL) { 1301 if (new_hbq_entry == NULL) {
1284 list_add_tail(&hbq_entry->dbuf.list, &phba->hbqbuf_in_list); 1302 list_add_tail(&hbq_entry->dbuf.list, &phba->hbqbuf_in_list);
1285 spin_unlock_irqrestore(&phba->hbalock, flags); 1303 spin_unlock_irqrestore(&phba->hbalock, flags);
@@ -1748,8 +1766,8 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba)
1748 irsp->un.ulpWord[3], 1766 irsp->un.ulpWord[3],
1749 irsp->un.ulpWord[4], 1767 irsp->un.ulpWord[4],
1750 irsp->un.ulpWord[5], 1768 irsp->un.ulpWord[5],
1751 *(((uint32_t *) irsp) + 6), 1769 *(uint32_t *)&irsp->un1,
1752 *(((uint32_t *) irsp) + 7)); 1770 *((uint32_t *)&irsp->un1 + 1));
1753 } 1771 }
1754 1772
1755 switch (type) { 1773 switch (type) {
@@ -1935,8 +1953,8 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba,
1935 irsp->un.ulpWord[3], 1953 irsp->un.ulpWord[3],
1936 irsp->un.ulpWord[4], 1954 irsp->un.ulpWord[4],
1937 irsp->un.ulpWord[5], 1955 irsp->un.ulpWord[5],
1938 *(((uint32_t *) irsp) + 6), 1956 *(uint32_t *)&irsp->un1,
1939 *(((uint32_t *) irsp) + 7)); 1957 *((uint32_t *)&irsp->un1 + 1));
1940 } 1958 }
1941 1959
1942 switch (type) { 1960 switch (type) {
@@ -2921,10 +2939,8 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba)
2921 mempool_free(pmb, phba->mbox_mem_pool); 2939 mempool_free(pmb, phba->mbox_mem_pool);
2922 2940
2923 /* Initially populate or replenish the HBQs */ 2941 /* Initially populate or replenish the HBQs */
2924 for (hbqno = 0; hbqno < hbq_count; ++hbqno) { 2942 for (hbqno = 0; hbqno < hbq_count; ++hbqno)
2925 if (lpfc_sli_hbqbuf_init_hbqs(phba, hbqno)) 2943 lpfc_sli_hbqbuf_init_hbqs(phba, hbqno);
2926 return -ENOMEM;
2927 }
2928 return 0; 2944 return 0;
2929} 2945}
2930 2946
@@ -3034,6 +3050,7 @@ lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode)
3034 phba->port_gp = phba->mbox->us.s2.port; 3050 phba->port_gp = phba->mbox->us.s2.port;
3035 phba->inb_ha_copy = NULL; 3051 phba->inb_ha_copy = NULL;
3036 phba->inb_counter = NULL; 3052 phba->inb_counter = NULL;
3053 phba->max_vpi = 0;
3037 } 3054 }
3038do_prep_failed: 3055do_prep_failed:
3039 mempool_free(pmb, phba->mbox_mem_pool); 3056 mempool_free(pmb, phba->mbox_mem_pool);
@@ -4335,7 +4352,7 @@ lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
4335 4352
4336 spin_unlock_irq(&phba->hbalock); 4353 spin_unlock_irq(&phba->hbalock);
4337 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 4354 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4338 "0410 Cannot find virtual addr for buffer tag on " 4355 "0402 Cannot find virtual addr for buffer tag on "
4339 "ring %d Data x%lx x%p x%p x%x\n", 4356 "ring %d Data x%lx x%p x%p x%x\n",
4340 pring->ringno, (unsigned long) tag, 4357 pring->ringno, (unsigned long) tag,
4341 slp->next, slp->prev, pring->postbufq_cnt); 4358 slp->next, slp->prev, pring->postbufq_cnt);
@@ -4482,7 +4499,7 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
4482 4499
4483 /* ELS cmd tag <ulpIoTag> completes */ 4500 /* ELS cmd tag <ulpIoTag> completes */
4484 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 4501 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
4485 "0133 Ignoring ELS cmd tag x%x completion Data: " 4502 "0139 Ignoring ELS cmd tag x%x completion Data: "
4486 "x%x x%x x%x\n", 4503 "x%x x%x x%x\n",
4487 irsp->ulpIoTag, irsp->ulpStatus, 4504 irsp->ulpIoTag, irsp->ulpStatus,
4488 irsp->un.ulpWord[4], irsp->ulpTimeout); 4505 irsp->un.ulpWord[4], irsp->ulpTimeout);
@@ -4568,6 +4585,8 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
4568 iabt->un.acxri.abortIoTag, abtsiocbp->iotag); 4585 iabt->un.acxri.abortIoTag, abtsiocbp->iotag);
4569 retval = __lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0); 4586 retval = __lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0);
4570 4587
4588 if (retval)
4589 __lpfc_sli_release_iocbq(phba, abtsiocbp);
4571abort_iotag_exit: 4590abort_iotag_exit:
4572 /* 4591 /*
4573 * Caller to this routine should check for IOCB_ERROR 4592 * Caller to this routine should check for IOCB_ERROR
@@ -4899,7 +4918,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba,
4899 } 4918 }
4900 } else { 4919 } else {
4901 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 4920 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
4902 ":0332 IOCB wait issue failed, Data x%x\n", 4921 "0332 IOCB wait issue failed, Data x%x\n",
4903 retval); 4922 retval);
4904 retval = IOCB_ERROR; 4923 retval = IOCB_ERROR;
4905 } 4924 }
@@ -5271,7 +5290,7 @@ lpfc_intr_handler(int irq, void *dev_id)
5271 lpfc_printf_log(phba, 5290 lpfc_printf_log(phba,
5272 KERN_ERR, 5291 KERN_ERR,
5273 LOG_MBOX | LOG_SLI, 5292 LOG_MBOX | LOG_SLI,
5274 "0306 rc should have" 5293 "0350 rc should have"
5275 "been MBX_BUSY"); 5294 "been MBX_BUSY");
5276 goto send_current_mbox; 5295 goto send_current_mbox;
5277 } 5296 }
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c
index ad0f65313878..2578d5fd9537 100644
--- a/drivers/scsi/lpfc/lpfc_vport.c
+++ b/drivers/scsi/lpfc/lpfc_vport.c
@@ -577,8 +577,12 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
577 * initiated after we've disposed of all other resources associated 577 * initiated after we've disposed of all other resources associated
578 * with the port. 578 * with the port.
579 */ 579 */
580 if (!scsi_host_get(shost) || !scsi_host_get(shost)) 580 if (!scsi_host_get(shost))
581 return VPORT_INVAL; 581 return VPORT_INVAL;
582 if (!scsi_host_get(shost)) {
583 scsi_host_put(shost);
584 return VPORT_INVAL;
585 }
582 spin_lock_irq(&phba->hbalock); 586 spin_lock_irq(&phba->hbalock);
583 vport->load_flag |= FC_UNLOADING; 587 vport->load_flag |= FC_UNLOADING;
584 spin_unlock_irq(&phba->hbalock); 588 spin_unlock_irq(&phba->hbalock);
@@ -668,6 +672,8 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
668 } 672 }
669 vport->unreg_vpi_cmpl = VPORT_INVAL; 673 vport->unreg_vpi_cmpl = VPORT_INVAL;
670 timeout = msecs_to_jiffies(phba->fc_ratov * 2000); 674 timeout = msecs_to_jiffies(phba->fc_ratov * 2000);
675 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
676 goto skip_logo;
671 if (!lpfc_issue_els_npiv_logo(vport, ndlp)) 677 if (!lpfc_issue_els_npiv_logo(vport, ndlp))
672 while (vport->unreg_vpi_cmpl == VPORT_INVAL && timeout) 678 while (vport->unreg_vpi_cmpl == VPORT_INVAL && timeout)
673 timeout = schedule_timeout(timeout); 679 timeout = schedule_timeout(timeout);
@@ -689,8 +695,10 @@ skip_logo:
689 * Completion of unreg_vpi (lpfc_mbx_cmpl_unreg_vpi) 695 * Completion of unreg_vpi (lpfc_mbx_cmpl_unreg_vpi)
690 * does the scsi_host_put() to release the vport. 696 * does the scsi_host_put() to release the vport.
691 */ 697 */
692 lpfc_mbx_unreg_vpi(vport); 698 if (lpfc_mbx_unreg_vpi(vport))
693 } 699 scsi_host_put(shost);
700 } else
701 scsi_host_put(shost);
694 702
695 lpfc_free_vpi(phba, vport->vpi); 703 lpfc_free_vpi(phba, vport->vpi);
696 vport->work_port_events = 0; 704 vport->work_port_events = 0;