lpfc 8.2.2 : Miscellaneous Bug Fixes
Subsystems (2)
PATCH 6/8 lpfc 8.2.2 : Miscellaneous Bug Fixes
Miscellaneous Bug Fixes:
- Fix vport ndlp ref counting errors
- Fix use after free of ndlp structure
- Use the correct flag to check for LOADING setting.
- Fix driver unload bugs (related to shost references) after link down or rscn
- Fix up HBQ initialization
- Fix port_list locking around driver unload.
- Fix references to hostdata as a phba
- Fix GFFID type offset to work correctly with big endian structure.
- Only call pci_disable_msi if the pci_enable_msi succeeded
- Fix vport_delete wait/fail if in discovery
- Put a reference on the nameservers ndlp when performing CT traffic.
- Remove unbalanced hba unlock.
- Fix up HBQ processing
- Fix lpfc debugfs discovery trace output for ELS rsp cmpl
- Send ADISC when rpi is 0
- Stop FDISC retrying forever
- Unable to retrieve correct config parameter for vport
- Fix sli_validate_fcp_iocb, sli_sum_iocb, sli_abort_iocb to be vport-aware.
- Fix index-out-of-range error in iocb. Spotted by Coverity.
drivers/scsi/lpfc/lpfc_attr.c +10 -19
@@ -1027,8 +1027,8 @@ static CLASS_DEVICE_ATTR(lpfc_soft_wwpn,static ssize_t lpfc_soft_wwnn_show (struct class_device *cdev,char *buf) { -struct Scsi_Host *host =class_to_shost (cdev); -struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; +struct Scsi_Host *shost =class_to_shost (cdev); +struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;return snprintf (buf,PAGE_SIZE ,"0x%llx\n" , (unsigned long long )phba->cfg_soft_wwnn); }
@@ -1037,8 +1037,8 @@ lpfc_soft_wwnn_show(struct class_devicestatic ssize_t lpfc_soft_wwnn_store (struct class_device *cdev,const char *buf,size_t count) { -struct Scsi_Host *host =class_to_shost (cdev); -struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; +struct Scsi_Host *shost =class_to_shost (cdev); +struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;unsigned int i, j, cnt=count;u8 wwnn[8 ];
@@ -1153,24 +1153,15 @@ lpfc_nodev_tmo_init(struct lpfc_vport *vstatic void lpfc_update_rport_devloss_tmo (struct lpfc_vport *vport) { -struct lpfc_vport **vports;struct Scsi_Host *shost;struct lpfc_nodelist *ndlp; -int i; - vports =lpfc_create_vport_work_array (vport->phba); -if (vports !=NULL ) -for (i =0 ; i <LPFC_MAX_VPORTS && vports[i] !=NULL ; i++) { - shost =lpfc_shost_from_vport (vports[i]); -spin_lock_irq (shost->host_lock); -list_for_each_entry (ndlp, &vports[i]->fc_nodes, - nlp_listp) -if (ndlp->rport) - ndlp->rport->dev_loss_tmo = - vport->cfg_devloss_tmo; -spin_unlock_irq (shost->host_lock); - } -lpfc_destroy_vport_work_array (vports); + shost =lpfc_shost_from_vport (vport); +spin_lock_irq (shost->host_lock); +list_for_each_entry (ndlp, &vport->fc_nodes, nlp_listp) +if (ndlp->rport) + ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; +spin_unlock_irq (shost->host_lock); } static int
drivers/scsi/lpfc/lpfc_crtn.h +9 -9
@@ -102,7 +102,7 @@ int lpfc_issue_els_scr(struct lpfc_vportint lpfc_els_free_iocb (struct lpfc_hba *,struct lpfc_iocbq *);int lpfc_ct_free_iocb (struct lpfc_hba *,struct lpfc_iocbq *);int lpfc_els_rsp_acc (struct lpfc_vport *,uint32_t ,struct lpfc_iocbq *, -struct lpfc_nodelist *,LPFC_MBOXQ_t *,uint8_t ); +struct lpfc_nodelist *,LPFC_MBOXQ_t *);int lpfc_els_rsp_reject (struct lpfc_vport *,uint32_t ,struct lpfc_iocbq *,struct lpfc_nodelist *,LPFC_MBOXQ_t *); int lpfc_els_rsp_adisc_acc(struct lpfc_vport *, struct lpfc_iocbq *,
@@ -163,9 +163,11 @@ LPFC_MBOXQ_t *lpfc_mbox_get(struct lpfc_void lpfc_mbox_cmpl_put (struct lpfc_hba *,LPFC_MBOXQ_t *);int lpfc_mbox_tmo_val (struct lpfc_hba *,int ); -void lpfc_config_hbq (struct lpfc_hba *,struct lpfc_hbq_init *,uint32_t , -LPFC_MBOXQ_t *); +void lpfc_config_hbq (struct lpfc_hba *,uint32_t ,struct lpfc_hbq_init *, +uint32_t ,LPFC_MBOXQ_t *);struct lpfc_hbq_entry *lpfc_sli_next_hbq_slot (struct lpfc_hba *,uint32_t ); +struct hbq_dmabuf *lpfc_els_hbq_alloc (struct lpfc_hba *); +void lpfc_els_hbq_free (struct lpfc_hba *,struct hbq_dmabuf *);int lpfc_mem_alloc (struct lpfc_hba *);void lpfc_mem_free (struct lpfc_hba *);
@@ -202,6 +204,7 @@ int lpfc_sli_ringpostbuf_put(struct lpfcstruct lpfc_dmabuf *lpfc_sli_ringpostbuf_get (struct lpfc_hba *,struct lpfc_sli_ring *,dma_addr_t ); +int lpfc_sli_hbq_count (void );int lpfc_sli_hbqbuf_init_hbqs (struct lpfc_hba *,uint32_t );int lpfc_sli_hbqbuf_add_hbqs (struct lpfc_hba *,uint32_t );void lpfc_sli_hbqbuf_free_all (struct lpfc_hba *);
@@ -209,10 +212,9 @@ struct hbq_dmabuf *lpfc_sli_hbqbuf_find(int lpfc_sli_hbq_size (void );int lpfc_sli_issue_abort_iotag (struct lpfc_hba *,struct lpfc_sli_ring *,struct lpfc_iocbq *); -int lpfc_sli_sum_iocb (struct lpfc_hba *,struct lpfc_sli_ring *,uint16_t , -uint64_t ,lpfc_ctx_cmd ); -int lpfc_sli_abort_iocb (struct lpfc_hba *,struct lpfc_sli_ring *,uint16_t , -uint64_t ,uint32_t ,lpfc_ctx_cmd ); +int lpfc_sli_sum_iocb (struct lpfc_vport *,uint16_t ,uint64_t ,lpfc_ctx_cmd ); +int lpfc_sli_abort_iocb (struct lpfc_vport *,struct lpfc_sli_ring *,uint16_t , +uint64_t ,lpfc_ctx_cmd );void lpfc_mbox_timeout (unsigned long );void lpfc_mbox_timeout_handler (struct lpfc_hba *);
@@ -236,8 +238,6 @@ void lpfc_sli_abort_fcp_cmpl(struct lpfcstruct lpfc_iocbq * cmdiocb, struct lpfc_iocbq * rspiocb); -void *lpfc_hbq_alloc (struct lpfc_hba *,int ,dma_addr_t *); -void lpfc_hbq_free (struct lpfc_hba *,void *,dma_addr_t );void lpfc_sli_free_hbq (struct lpfc_hba *,struct hbq_dmabuf *);void *lpfc_mbuf_alloc (struct lpfc_hba *,int ,dma_addr_t *);
drivers/scsi/lpfc/lpfc_ct.c +19 -0
@@ -257,6 +257,10 @@ lpfc_ct_free_iocb(struct lpfc_hba *phba, {struct lpfc_dmabuf *buf_ptr; +if (ctiocb->context_un.ndlp) { +lpfc_nlp_put (ctiocb->context_un.ndlp); + ctiocb->context_un.ndlp =NULL ; + }if (ctiocb->context1) { buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1;lpfc_mbuf_free (phba, buf_ptr->virt, buf_ptr->phys);
@@ -314,6 +318,7 @@ lpfc_gen_req(struct lpfc_vport *vport, s/* Save for completion so we can release these resources */ geniocb->context1 = (uint8_t *) inp; geniocb->context2 = (uint8_t *) outp; + geniocb->context_un.ndlp = ndlp;/* Fill in payload, bp points to frame payload */ icmd->ulpCommand =CMD_GEN_REQUEST64_CR ;
@@ -548,8 +553,12 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hbastruct lpfc_dmabuf *bmp;struct lpfc_dmabuf *outp;struct lpfc_sli_ct_request *CTrsp; +struct lpfc_nodelist *ndlp;int rc; +/* First save ndlp, before we overwrite it */ + ndlp = cmdiocb->context_un.ndlp; +/* we pass cmdiocb to state machine which needs rspiocb as well */ cmdiocb->context_un.rsp_iocb = rspiocb;
@@ -674,6 +683,7 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hbalpfc_disc_start (vport); } out: + cmdiocb->context_un.ndlp = ndlp;/* Now restore ndlp for free */ lpfc_ct_free_iocb (phba, cmdiocb);return ; }
@@ -776,10 +786,14 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hbastruct lpfc_dmabuf *outp;IOCB_t *irsp;struct lpfc_sli_ct_request *CTrsp; +struct lpfc_nodelist *ndlp;int cmdcode, rc;uint8_t retry;uint32_t latt; +/* First save ndlp, before we overwrite it */ + ndlp = cmdiocb->context_un.ndlp; +/* we pass cmdiocb to state machine which needs rspiocb as well */ cmdiocb->context_un.rsp_iocb = rspiocb;
@@ -828,6 +842,7 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba } out: + cmdiocb->context_un.ndlp = ndlp;/* Now restore ndlp for free */ lpfc_ct_free_iocb (phba, cmdiocb);return ; }
@@ -1066,6 +1081,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, in cmpl = lpfc_cmpl_ct_cmd_rff_id;break ; } +lpfc_nlp_get (ndlp);if (!lpfc_ct_cmd (vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) {/* On success, The cmpl function will free the buffers */
@@ -1076,6 +1092,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, in } rc=6 ; +lpfc_nlp_put (ndlp);lpfc_mbuf_free (phba, bmp->virt, bmp->phys); ns_cmd_free_bmp:kfree (bmp);
@@ -1501,10 +1518,12 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, bpl->tus.w =le32_to_cpu (bpl->tus.w); cmpl = lpfc_cmpl_ct_cmd_fdmi; +lpfc_nlp_get (ndlp);if (!lpfc_ct_cmd (vport, mp, bmp, ndlp, cmpl,FC_MAX_NS_RSP ,0 ))return 0 ; +lpfc_nlp_put (ndlp);lpfc_mbuf_free (phba, bmp->virt, bmp->phys); fdmi_cmd_free_bmp:kfree (bmp);
drivers/scsi/lpfc/lpfc_debugfs.c +5 -6
@@ -71,7 +71,7 @@* lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in * lpfc_debugfs.h . */ -static int lpfc_debugfs_enable =0 ; +static int lpfc_debugfs_enable =1 ;module_param (lpfc_debugfs_enable, int,0 );MODULE_PARM_DESC (lpfc_debugfs_enable,"Enable debugfs services" );
@@ -113,7 +113,6 @@ struct lpfc_debug { };extern struct lpfc_hbq_init *lpfc_hbq_defs[]; -extern int lpfc_sli_hbq_count (void );atomic_t lpfc_debugfs_seq_trc_cnt =ATOMIC_INIT (0 );unsigned long lpfc_debugfs_start_time =0L ;
@@ -233,8 +232,9 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hb len +=snprintf (buf+len, size-len,"HBQ %d Info\n" , i); + hbqs = &phba->hbqs[i]; posted =0 ; -list_for_each_entry (d_buf, &phba->hbq_buffer_list, list) +list_for_each_entry (d_buf, &hbqs->hbq_buffer_list, list) posted++; hip = lpfc_hbq_defs[i];
@@ -243,7 +243,6 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hb hip->hbq_index, hip->profile, hip->rn, hip->buffer_count, hip->init_count, hip->add_count, posted); - hbqs = &phba->hbqs[i]; raw_index = phba->hbq_get[i]; getidx =le32_to_cpu (raw_index); len += snprintf(buf+len, size-len,
@@ -251,7 +250,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hb hbqs->entry_count, hbqs->hbqPutIdx, hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx); - hbqe = (struct lpfc_hbq_entry *) phba->hbqslimp.virt; + hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;for (j=0 ; j<hbqs->entry_count; j++) { len += snprintf(buf+len, size-len, "%03d: %08x %04x %05x ", j,
@@ -277,7 +276,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hb }/* Get the Buffer info for the posted buffer */ -list_for_each_entry (d_buf, &phba->hbq_buffer_list, list) { +list_for_each_entry (d_buf, &hbqs->hbq_buffer_list, list) { hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf); phys = ((uint64_t )hbq_buf->dbuf.phys &0xffffffff );if (phys == hbqe->bde.addrLow) {
drivers/scsi/lpfc/lpfc_els.c +32 -32
180 lines not on this page · raw message
drivers/scsi/lpfc/lpfc.h +22 -11
@@ -78,6 +78,7 @@ struct lpfc_dma_pool {struct hbq_dmabuf {struct lpfc_dmabuf dbuf; +uint32_t size;uint32_t tag; };
@@ -329,15 +330,7 @@ struct lpfc_vport {#define FC_LOADING 0x1/* HBA in process of loading drvr */ #define FC_UNLOADING 0x2/* HBA in process of unloading drvr */ char *vname;/* Application assigned name */ -struct fc_vport *fc_vport; -#ifdef CONFIG_LPFC_DEBUG_FS -struct dentry *debug_disc_trc; -struct dentry *debug_nodelist; -struct dentry *vport_debugfs_root; -struct lpfc_debugfs_trc *disc_trc; -atomic_t disc_trc_cnt; -#endif /* Vport Config Parameters */ uint32_t cfg_scan_down;uint32_t cfg_lun_queue_depth;
@@ -353,6 +346,16 @@ struct lpfc_vport {uint32_t cfg_max_luns;uint32_t dev_loss_tmo_changed; + +struct fc_vport *fc_vport; + +#ifdef CONFIG_LPFC_DEBUG_FS +struct dentry *debug_disc_trc; +struct dentry *debug_nodelist; +struct dentry *vport_debugfs_root; +struct lpfc_debugfs_trc *disc_trc; +atomic_t disc_trc_cnt; +#endif };struct hbq_s {
@@ -360,11 +363,19 @@ struct hbq_s {uint32_t next_hbqPutIdx;/* Index to next HBQ slot to use */ uint32_t hbqPutIdx;/* HBQ slot to use */ uint32_t local_hbqGetIdx;/* Local copy of Get index from Port */ +void *hbq_virt;/* Virtual ptr to this hbq */ +struct list_head hbq_buffer_list;/* buffers assigned to this HBQ */ +/* Callback for HBQ buffer allocation */ +struct hbq_dmabuf *(*hbq_alloc_buffer) (struct lpfc_hba *); +/* Callback for HBQ buffer free */ +void (*hbq_free_buffer) (struct lpfc_hba *, +struct hbq_dmabuf *); }; -#define LPFC_MAX_HBQS 16 -/* this matches the possition in the lpfc_hbq_defs array */ +#define LPFC_MAX_HBQS 4 +/* this matches the position in the lpfc_hbq_defs array */ #define LPFC_ELS_HBQ 0 +#define LPFC_EXTRA_HBQ 1struct lpfc_hba {struct lpfc_sli sli;
@@ -460,7 +471,6 @@ struct lpfc_hba {wait_queue_head_t *work_wait;struct task_struct *worker_thread; -struct list_head hbq_buffer_list;uint32_t hbq_count;/* Count of configured HBQs */ struct hbq_s hbqs[LPFC_MAX_HBQS ];/* local copy of hbq indicies */
@@ -529,6 +539,7 @@ struct lpfc_hba {mempool_t *nlp_mem_pool;struct fc_host_statistics link_stats; +uint8_t using_msi;struct list_head port_list;struct lpfc_vport *pport;/* physical lpfc_vport pointer */
drivers/scsi/lpfc/lpfc_hbadisc.c +31 -22
97 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_hw.h +4 -0
@@ -150,7 +150,11 @@ struct lpfc_sli_ct_request {struct gff_acc {uint8_t fbits[128 ]; } gff_acc; +#ifdef __BIG_ENDIAN_BITFIELD +#define FCP_TYPE_FEATURE_OFFSET 7 +#else /* __LITTLE_ENDIAN_BITFIELD */ #define FCP_TYPE_FEATURE_OFFSET 4 +#endif struct rff {uint32_t PortId;uint8_t reserved[2 ];
drivers/scsi/lpfc/lpfc_init.c +48 -38
228 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_mbox.c +4 -2
@@ -560,7 +560,8 @@ lpfc_build_hbq_profile5(struct config_hb }void -lpfc_config_hbq (struct lpfc_hba *phba,struct lpfc_hbq_init *hbq_desc, +lpfc_config_hbq (struct lpfc_hba *phba,uint32_t id, +struct lpfc_hbq_init *hbq_desc,uint32_t hbq_entry_index,LPFC_MBOXQ_t *pmb) {int i;
@@ -568,6 +569,7 @@ lpfc_config_hbq(struct lpfc_hba *phba, sstruct config_hbq_var *hbqmb = &mb->un.varCfgHbq;memset (pmb,0 ,sizeof (LPFC_MBOXQ_t)); + hbqmb->hbqId = id; hbqmb->entry_count = hbq_desc->entry_count;/* # entries in HBQ */ hbqmb->recvNotify = hbq_desc->rn;/* Receive * Notification */
@@ -687,7 +689,7 @@ lpfc_config_port(struct lpfc_hba *phba,if (phba->sli_rev ==3 && phba->vpd.sli3Feat.cerbm) { mb->un.varCfgPort.cerbm =1 ;/* Request HBQs */ - mb->un.varCfgPort.max_hbq =1 ;/* Requesting 2 HBQs */ + mb->un.varCfgPort.max_hbq =lpfc_sli_hbq_count ();if (phba->max_vpi && phba->cfg_enable_npiv && phba->vpd.sli3Feat.cmv) { mb->un.varCfgPort.max_vpi = phba->max_vpi;
drivers/scsi/lpfc/lpfc_mem.c +22 -10
@@ -231,21 +231,34 @@ lpfc_mbuf_free(struct lpfc_hba * phba, vreturn ; } -void * -lpfc_hbq_alloc (struct lpfc_hba *phba,int mem_flags,dma_addr_t *handle) +struct hbq_dmabuf * +lpfc_els_hbq_alloc (struct lpfc_hba *phba) { -void *ret; - ret =pci_pool_alloc (phba->lpfc_hbq_pool,GFP_ATOMIC , handle); -return ret; +struct hbq_dmabuf *hbqbp; + + hbqbp =kmalloc (sizeof (struct hbq_dmabuf ),GFP_KERNEL ); +if (!hbqbp) +return NULL ; + + hbqbp->dbuf.virt =pci_pool_alloc (phba->lpfc_hbq_pool,GFP_KERNEL , + &hbqbp->dbuf.phys); +if (!hbqbp->dbuf.virt) { +kfree (hbqbp); +return NULL ; + } + hbqbp->size =LPFC_BPL_SIZE ; +return hbqbp; }void -lpfc_hbq_free (struct lpfc_hba *phba,void *virt,dma_addr_t dma) +lpfc_els_hbq_free (struct lpfc_hba *phba,struct hbq_dmabuf *hbqbp) { -pci_pool_free (phba->lpfc_hbq_pool, virt, dma); +pci_pool_free (phba->lpfc_hbq_pool, hbqbp->dbuf.virt, hbqbp->dbuf.phys); +kfree (hbqbp);return ; } +/* This is ONLY called for the LPFC_ELS_HBQ */ void lpfc_in_buf_free (struct lpfc_hba *phba,struct lpfc_dmabuf *mp) {
@@ -254,9 +267,8 @@ lpfc_in_buf_free(struct lpfc_hba *phba,if (phba->sli3_options &LPFC_SLI3_HBQ_ENABLED ) { hbq_entry = container_of(mp, struct hbq_dmabuf, dbuf);if (hbq_entry->tag ==-1 ) { -lpfc_hbq_free (phba, hbq_entry->dbuf.virt, - hbq_entry->dbuf.phys); -kfree (hbq_entry); + (phba->hbqs[LPFC_ELS_HBQ ].hbq_free_buffer) + (phba, hbq_entry); }else {lpfc_sli_free_hbq (phba, hbq_entry); }
drivers/scsi/lpfc/lpfc_nportdisc.c +18 -13
@@ -329,7 +329,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport,case NLP_STE_PRLI_ISSUE :case NLP_STE_UNMAPPED_NODE :case NLP_STE_MAPPED_NODE : -lpfc_els_rsp_acc (vport,ELS_CMD_PLOGI , cmdiocb, ndlp,NULL ,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_PLOGI , cmdiocb, ndlp,NULL );return 1 ; }
@@ -407,7 +407,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, ndlp, mbox);return 1 ; } -lpfc_els_rsp_acc (vport,ELS_CMD_PLOGI , cmdiocb, ndlp, mbox,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_PLOGI , cmdiocb, ndlp, mbox);return 1 ; out:
@@ -451,7 +451,7 @@ lpfc_rcv_padisc(struct lpfc_vport *vportlpfc_els_rsp_adisc_acc (vport, cmdiocb, ndlp); }else {lpfc_els_rsp_acc (vport,ELS_CMD_PLOGI , cmdiocb, ndlp, -NULL ,0 ); +NULL ); }return 1 ; }
@@ -488,9 +488,9 @@ lpfc_rcv_logo(struct lpfc_vport *vport, ndlp->nlp_flag |=NLP_LOGO_ACC ;spin_unlock_irq (shost->host_lock);if (els_cmd ==ELS_CMD_PRLO ) -lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL ,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL );else -lpfc_els_rsp_acc (vport,ELS_CMD_ACC , cmdiocb, ndlp,NULL ,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_ACC , cmdiocb, ndlp,NULL );if (!(ndlp->nlp_type &NLP_FABRIC ) || (ndlp->nlp_state ==NLP_STE_ADISC_ISSUE )) {
@@ -564,6 +564,11 @@ lpfc_disc_set_adisc(struct lpfc_vport *v {struct Scsi_Host *shost =lpfc_shost_from_vport (vport); +if (!ndlp->nlp_rpi) { + ndlp->nlp_flag &= ~NLP_NPR_ADISC ; +return 0 ; + } +/* Check config parameter use-adisc or FCP-2 */ if ((vport->cfg_use_adisc && (vport->fc_flag &FC_RSCN_MODE )) || ndlp->nlp_fcp_info &NLP_FCP_2_DEVICE ) {
@@ -627,7 +632,7 @@ lpfc_rcv_logo_unused_node(struct lpfc_vpspin_lock_irq (shost->host_lock); ndlp->nlp_flag |=NLP_LOGO_ACC ;spin_unlock_irq (shost->host_lock); -lpfc_els_rsp_acc (vport,ELS_CMD_ACC , cmdiocb, ndlp,NULL ,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_ACC , cmdiocb, ndlp,NULL );lpfc_nlp_set_state (vport, ndlp,NLP_STE_UNUSED_NODE );return ndlp->nlp_state;
@@ -723,7 +728,7 @@ lpfc_rcv_els_plogi_issue(struct lpfc_vpolpfc_els_abort (phba, ndlp);if (evt ==NLP_EVT_RCV_LOGO ) { -lpfc_els_rsp_acc (vport,ELS_CMD_ACC , cmdiocb, ndlp,NULL ,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_ACC , cmdiocb, ndlp,NULL ); }else {lpfc_issue_els_logo (vport, ndlp,0 ); }
@@ -1167,7 +1172,7 @@ lpfc_rcv_prlo_reglogin_issue(struct lpfcstruct lpfc_iocbq *cmdiocb; cmdiocb = (struct lpfc_iocbq *) arg; -lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL ,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL );return ndlp->nlp_state; }
@@ -1322,7 +1327,7 @@ lpfc_rcv_prlo_prli_issue(struct lpfc_vpo {struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; -lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL ,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL );return ndlp->nlp_state; }
@@ -1514,7 +1519,7 @@ lpfc_rcv_prlo_unmap_node(struct lpfc_vpo {struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; -lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL ,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL );return ndlp->nlp_state; }
@@ -1585,8 +1590,8 @@ lpfc_rcv_prlo_mapped_node(struct lpfc_vpstruct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;/* flush the target */ -lpfc_sli_abort_iocb (phba, &phba->sli.ring[phba->sli.fcp_ring], - ndlp->nlp_sid,0 ,0 ,LPFC_CTX_TGT ); +lpfc_sli_abort_iocb (vport, &phba->sli.ring[phba->sli.fcp_ring], + ndlp->nlp_sid,0 ,LPFC_CTX_TGT );/* Treat like rcv logo */ lpfc_rcv_logo (vport, ndlp, cmdiocb,ELS_CMD_PRLO );
@@ -1719,7 +1724,7 @@ lpfc_rcv_prlo_npr_node(struct lpfc_vport ndlp->nlp_flag |=NLP_LOGO_ACC ;spin_unlock_irq (shost->host_lock); -lpfc_els_rsp_acc (vport,ELS_CMD_ACC , cmdiocb, ndlp,NULL ,0 ); +lpfc_els_rsp_acc (vport,ELS_CMD_ACC , cmdiocb, ndlp,NULL );if ((ndlp->nlp_flag &NLP_DELAY_TMO ) ==0 ) {mod_timer (&ndlp->nlp_delayfunc, jiffies +HZ *1 );
drivers/scsi/lpfc/lpfc_scsi.c +9 -17
@@ -152,7 +152,6 @@ lpfc_ramp_down_queue_handler(struct lpfc } }lpfc_destroy_vport_work_array (vports); -spin_unlock_irq (&phba->hbalock);atomic_set (&phba->num_rsrc_err,0 );atomic_set (&phba->num_cmd_success,0 ); }
@@ -1195,14 +1194,12 @@ lpfc_device_reset_handler(struct scsi_cm* Unfortunately, some targets do not abide by this forcing the driver * to double check. */ - cnt =lpfc_sli_sum_iocb (phba, &phba->sli.ring[phba->sli.fcp_ring], - cmnd->device->id, cmnd->device->lun, + cnt =lpfc_sli_sum_iocb (vport, cmnd->device->id, cmnd->device->lun,LPFC_CTX_LUN );if (cnt) -lpfc_sli_abort_iocb (phba, - &phba->sli.ring[phba->sli.fcp_ring], +lpfc_sli_abort_iocb (vport, &phba->sli.ring[phba->sli.fcp_ring], cmnd->device->id, cmnd->device->lun, -0 ,LPFC_CTX_LUN ); +LPFC_CTX_LUN ); loopcnt =0 ;while (cnt) {schedule_timeout_uninterruptible (LPFC_RESET_WAIT *HZ );
@@ -1211,10 +1208,8 @@ lpfc_device_reset_handler(struct scsi_cm > (2 * vport->cfg_devloss_tmo)/LPFC_RESET_WAIT)break ; - cnt =lpfc_sli_sum_iocb (phba, - &phba->sli.ring[phba->sli.fcp_ring], - cmnd->device->id, cmnd->device->lun, -LPFC_CTX_LUN ); + cnt =lpfc_sli_sum_iocb (vport, cmnd->device->id, + cmnd->device->lun,LPFC_CTX_LUN ); }if (cnt) {
@@ -1304,11 +1299,10 @@ lpfc_bus_reset_handler(struct scsi_cmnd* the targets. Unfortunately, some targets do not abide by * this forcing the driver to double check. */ - cnt =lpfc_sli_sum_iocb (phba, &phba->sli.ring[phba->sli.fcp_ring], -0 ,0 ,LPFC_CTX_HOST ); + cnt =lpfc_sli_sum_iocb (vport,0 ,0 ,LPFC_CTX_HOST );if (cnt) -lpfc_sli_abort_iocb (phba, &phba->sli.ring[phba->sli.fcp_ring], -0 ,0 ,0 ,LPFC_CTX_HOST ); +lpfc_sli_abort_iocb (vport, &phba->sli.ring[phba->sli.fcp_ring], +0 ,0 ,LPFC_CTX_HOST ); loopcnt =0 ;while (cnt) {schedule_timeout_uninterruptible (LPFC_RESET_WAIT *HZ );
@@ -1317,9 +1311,7 @@ lpfc_bus_reset_handler(struct scsi_cmnd > (2 * vport->cfg_devloss_tmo)/LPFC_RESET_WAIT)break ; - cnt =lpfc_sli_sum_iocb (phba, - &phba->sli.ring[phba->sli.fcp_ring], -0 ,0 ,LPFC_CTX_HOST ); + cnt =lpfc_sli_sum_iocb (vport,0 ,0 ,LPFC_CTX_HOST ); }if (cnt) {
drivers/scsi/lpfc/lpfc_sli.c +79 -49
273 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_sli.h +4 -4
@@ -26,7 +26,6 @@ struct lpfc_vport;typedef enum _lpfc_ctx_cmd {LPFC_CTX_LUN ,LPFC_CTX_TGT , -LPFC_CTX_CTX ,LPFC_CTX_HOST }lpfc_ctx_cmd ;
@@ -54,9 +53,10 @@ struct lpfc_iocbq {void *context2;/* caller context information */ void *context3;/* caller context information */ union { -wait_queue_head_t *wait_queue; -struct lpfc_iocbq *rsp_iocb; -struct lpfcMboxq *mbox; +wait_queue_head_t *wait_queue; +struct lpfc_iocbq *rsp_iocb; +struct lpfcMboxq *mbox; +struct lpfc_nodelist *ndlp; } context_un; void (*fabric_iocb_cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
drivers/scsi/lpfc/lpfc_vport.c +26 -14
@@ -432,8 +432,29 @@ lpfc_vport_delete(struct fc_vport *fc_vpstruct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;struct lpfc_hba *phba = vport->phba;long timeout; -int rc =VPORT_ERROR ; +if (vport->port_type ==LPFC_PHYSICAL_PORT ) { +lpfc_printf_vlog (vport,KERN_ERR ,LOG_VPORT , +"1812 vport_delete failed: Cannot delete " +"physical host\n" ); +return VPORT_ERROR ; + } +/* +* If we are not unloading the driver then prevent the vport_delete +* from happening until after this vport's discovery is finished. +*/ +if (!(phba->pport->load_flag &FC_UNLOADING )) { +int check_count =0 ; +while (check_count < ((phba->fc_ratov *3 ) +3 ) && + vport->port_state >LPFC_VPORT_FAILED && + vport->port_state <LPFC_VPORT_READY ) { + check_count++; +msleep (1000 ); + } +if (vport->port_state >LPFC_VPORT_FAILED && + vport->port_state <LPFC_VPORT_READY ) +return -EAGAIN ; + }/* * This is a bit of a mess. We want to ensure the shost doesn't get * torn down until we're done with the embedded lpfc_vport structure.
@@ -451,16 +472,9 @@ lpfc_vport_delete(struct fc_vport *fc_vp*/ if (!scsi_host_get (shost) || !scsi_host_get (shost))return VPORT_INVAL ; - -if (vport->port_type ==LPFC_PHYSICAL_PORT ) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_VPORT , -"1812 vport_delete failed: Cannot delete " -"physical host\n" ); - goto out; - } - +spin_lock_irq (&phba->hbalock); vport->load_flag |=FC_UNLOADING ; - +spin_unlock_irq (&phba->hbalock);kfree (vport->vname);lpfc_debugfs_terminate (vport);fc_remove_host (lpfc_shost_from_vport (vport));
@@ -514,10 +528,8 @@ skip_logo:spin_unlock_irq (&phba->hbalock);lpfc_printf_vlog (vport,KERN_ERR ,LOG_VPORT ,"1828 Vport Deleted.\n" ); - rc =VPORT_OK ; -out:scsi_host_put (shost); -return rc; +return VPORT_OK ; }EXPORT_SYMBOL (lpfc_vport_create);
@@ -536,7 +548,7 @@ lpfc_create_vport_work_array(struct lpfcspin_lock_irq (&phba->hbalock);list_for_each_entry (port_iterator, &phba->port_list, listentry) {if (!scsi_host_get (lpfc_shost_from_vport (port_iterator))) { -lpfc_printf_vlog (port_iterator,KERN_ERR ,LOG_VPORT , +lpfc_printf_vlog (port_iterator,KERN_WARNING ,LOG_VPORT ,"1801 Create vport work array FAILED: " "cannot do scsi_host_get\n" );continue ;