Skip to content

Commit 32566a6

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Remove NLP_RELEASE_RPI flag from nodelist structure
An RPI is tightly bound to an NDLP structure and is freed only upon release of an NDLP object. As such, there should be no logic that frees an RPI outside of the lpfc_nlp_release() routine. In order to reinforce the original design usage of RPIs, remove the NLP_RELEASE_RPI flag and related logic. Signed-off-by: Justin Tee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4281f44 commit 32566a6

File tree

6 files changed

+44
-127
lines changed

6 files changed

+44
-127
lines changed

drivers/scsi/lpfc/lpfc_crtn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ int lpfc_issue_reg_vfi(struct lpfc_vport *);
571571
int lpfc_issue_unreg_vfi(struct lpfc_vport *);
572572
int lpfc_selective_reset(struct lpfc_hba *);
573573
int lpfc_sli4_read_config(struct lpfc_hba *);
574-
void lpfc_sli4_node_prep(struct lpfc_hba *);
574+
void lpfc_sli4_node_rpi_restore(struct lpfc_hba *phba);
575575
int lpfc_sli4_els_sgl_update(struct lpfc_hba *phba);
576576
int lpfc_sli4_nvmet_sgl_update(struct lpfc_hba *phba);
577577
int lpfc_io_buf_flush(struct lpfc_hba *phba, struct list_head *sglist);

drivers/scsi/lpfc/lpfc_disc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ struct lpfc_node_rrq {
185185
/* Defines for nlp_flag (uint32) */
186186
#define NLP_IGNR_REG_CMPL 0x00000001 /* Rcvd rscn before we cmpl reg login */
187187
#define NLP_REG_LOGIN_SEND 0x00000002 /* sent reglogin to adapter */
188-
#define NLP_RELEASE_RPI 0x00000004 /* Release RPI to free pool */
189188
#define NLP_SUPPRESS_RSP 0x00000010 /* Remote NPort supports suppress rsp */
190189
#define NLP_PLOGI_SND 0x00000020 /* sent PLOGI request for this entry */
191190
#define NLP_PRLI_SND 0x00000040 /* sent PRLI request for this entry */

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,8 +3063,6 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
30633063
*/
30643064
if (ndlp->nlp_flag & NLP_TARGET_REMOVE) {
30653065
spin_lock_irq(&ndlp->lock);
3066-
if (phba->sli_rev == LPFC_SLI_REV4)
3067-
ndlp->nlp_flag |= NLP_RELEASE_RPI;
30683066
ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
30693067
spin_unlock_irq(&ndlp->lock);
30703068
lpfc_disc_state_machine(vport, ndlp, cmdiocb,
@@ -5456,24 +5454,14 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
54565454
}
54575455

54585456
/* An SLI4 NPIV instance wants to drop the node at this point under
5459-
* these conditions and release the RPI.
5457+
* these conditions because it doesn't need the login.
54605458
*/
54615459
if (phba->sli_rev == LPFC_SLI_REV4 &&
54625460
vport && vport->port_type == LPFC_NPIV_PORT &&
54635461
!(ndlp->fc4_xpt_flags & SCSI_XPT_REGD)) {
5464-
if (ndlp->nlp_flag & NLP_RELEASE_RPI) {
5465-
if (ndlp->nlp_state != NLP_STE_PLOGI_ISSUE &&
5466-
ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) {
5467-
lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi);
5468-
spin_lock_irq(&ndlp->lock);
5469-
ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
5470-
ndlp->nlp_flag &= ~NLP_RELEASE_RPI;
5471-
spin_unlock_irq(&ndlp->lock);
5472-
}
5473-
lpfc_drop_node(vport, ndlp);
5474-
} else if (ndlp->nlp_state != NLP_STE_PLOGI_ISSUE &&
5475-
ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE &&
5476-
ndlp->nlp_state != NLP_STE_PRLI_ISSUE) {
5462+
if (ndlp->nlp_state != NLP_STE_PLOGI_ISSUE &&
5463+
ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE &&
5464+
ndlp->nlp_state != NLP_STE_PRLI_ISSUE) {
54775465
/* Drop ndlp if there is no planned or outstanding
54785466
* issued PRLI.
54795467
*
@@ -5852,18 +5840,6 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError,
58525840
return 1;
58535841
}
58545842

5855-
/* The NPIV instance is rejecting this unsolicited ELS. Make sure the
5856-
* node's assigned RPI gets released provided this node is not already
5857-
* registered with the transport.
5858-
*/
5859-
if (phba->sli_rev == LPFC_SLI_REV4 &&
5860-
vport->port_type == LPFC_NPIV_PORT &&
5861-
!(ndlp->fc4_xpt_flags & SCSI_XPT_REGD)) {
5862-
spin_lock_irq(&ndlp->lock);
5863-
ndlp->nlp_flag |= NLP_RELEASE_RPI;
5864-
spin_unlock_irq(&ndlp->lock);
5865-
}
5866-
58675843
rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
58685844
if (rc == IOCB_ERROR) {
58695845
lpfc_els_free_iocb(phba, elsiocb);

drivers/scsi/lpfc/lpfc_hbadisc.c

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5212,14 +5212,6 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
52125212
ndlp->nlp_defer_did = NLP_EVT_NOTHING_PENDING;
52135213
lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
52145214
} else {
5215-
/* NLP_RELEASE_RPI is only set for SLI4 ports. */
5216-
if (ndlp->nlp_flag & NLP_RELEASE_RPI) {
5217-
lpfc_sli4_free_rpi(vport->phba, ndlp->nlp_rpi);
5218-
spin_lock_irq(&ndlp->lock);
5219-
ndlp->nlp_flag &= ~NLP_RELEASE_RPI;
5220-
ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
5221-
spin_unlock_irq(&ndlp->lock);
5222-
}
52235215
spin_lock_irq(&ndlp->lock);
52245216
ndlp->nlp_flag &= ~NLP_UNREG_INP;
52255217
spin_unlock_irq(&ndlp->lock);
@@ -5242,8 +5234,6 @@ static void
52425234
lpfc_set_unreg_login_mbx_cmpl(struct lpfc_hba *phba, struct lpfc_vport *vport,
52435235
struct lpfc_nodelist *ndlp, LPFC_MBOXQ_t *mbox)
52445236
{
5245-
unsigned long iflags;
5246-
52475237
/* Driver always gets a reference on the mailbox job
52485238
* in support of async jobs.
52495239
*/
@@ -5261,13 +5251,6 @@ lpfc_set_unreg_login_mbx_cmpl(struct lpfc_hba *phba, struct lpfc_vport *vport,
52615251
(kref_read(&ndlp->kref) > 0)) {
52625252
mbox->mbox_cmpl = lpfc_sli4_unreg_rpi_cmpl_clr;
52635253
} else {
5264-
if (test_bit(FC_UNLOADING, &vport->load_flag)) {
5265-
if (phba->sli_rev == LPFC_SLI_REV4) {
5266-
spin_lock_irqsave(&ndlp->lock, iflags);
5267-
ndlp->nlp_flag |= NLP_RELEASE_RPI;
5268-
spin_unlock_irqrestore(&ndlp->lock, iflags);
5269-
}
5270-
}
52715254
mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
52725255
}
52735256
}
@@ -5330,14 +5313,11 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
53305313
return 1;
53315314
}
53325315

5316+
/* Accept PLOGIs after unreg_rpi_cmpl. */
53335317
if (mbox->mbox_cmpl == lpfc_sli4_unreg_rpi_cmpl_clr)
5334-
/*
5335-
* accept PLOGIs after unreg_rpi_cmpl
5336-
*/
53375318
acc_plogi = 0;
5338-
if (((ndlp->nlp_DID & Fabric_DID_MASK) !=
5339-
Fabric_DID_MASK) &&
5340-
(!test_bit(FC_OFFLINE_MODE, &vport->fc_flag)))
5319+
5320+
if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag))
53415321
ndlp->nlp_flag |= NLP_UNREG_INP;
53425322

53435323
lpfc_printf_vlog(vport, KERN_INFO,
@@ -5561,10 +5541,6 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
55615541
list_del_init(&ndlp->dev_loss_evt.evt_listp);
55625542
list_del_init(&ndlp->recovery_evt.evt_listp);
55635543
lpfc_cleanup_vports_rrqs(vport, ndlp);
5564-
5565-
if (phba->sli_rev == LPFC_SLI_REV4)
5566-
ndlp->nlp_flag |= NLP_RELEASE_RPI;
5567-
55685544
return 0;
55695545
}
55705546

@@ -6573,8 +6549,9 @@ lpfc_nlp_init(struct lpfc_vport *vport, uint32_t did)
65736549
INIT_LIST_HEAD(&ndlp->nlp_listp);
65746550
if (vport->phba->sli_rev == LPFC_SLI_REV4) {
65756551
ndlp->nlp_rpi = rpi;
6576-
lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE | LOG_DISCOVERY,
6577-
"0007 Init New ndlp x%px, rpi:x%x DID:%x "
6552+
lpfc_printf_vlog(vport, KERN_INFO,
6553+
LOG_ELS | LOG_NODE | LOG_DISCOVERY,
6554+
"0007 Init New ndlp x%px, rpi:x%x DID:x%x "
65786555
"flg:x%x refcnt:%d\n",
65796556
ndlp, ndlp->nlp_rpi, ndlp->nlp_DID,
65806557
ndlp->nlp_flag, kref_read(&ndlp->kref));
@@ -6619,19 +6596,12 @@ lpfc_nlp_release(struct kref *kref)
66196596
lpfc_cancel_retry_delay_tmo(vport, ndlp);
66206597
lpfc_cleanup_node(vport, ndlp);
66216598

6622-
/* Not all ELS transactions have registered the RPI with the port.
6623-
* In these cases the rpi usage is temporary and the node is
6624-
* released when the WQE is completed. Catch this case to free the
6625-
* RPI to the pool. Because this node is in the release path, a lock
6626-
* is unnecessary. All references are gone and the node has been
6627-
* dequeued.
6599+
/* All nodes are initialized with an RPI that needs to be released
6600+
* now. All references are gone and the node has been dequeued.
66286601
*/
6629-
if (ndlp->nlp_flag & NLP_RELEASE_RPI) {
6630-
if (ndlp->nlp_rpi != LPFC_RPI_ALLOC_ERROR &&
6631-
!(ndlp->nlp_flag & (NLP_RPI_REGISTERED | NLP_UNREG_INP))) {
6632-
lpfc_sli4_free_rpi(vport->phba, ndlp->nlp_rpi);
6633-
ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
6634-
}
6602+
if (vport->phba->sli_rev == LPFC_SLI_REV4) {
6603+
lpfc_sli4_free_rpi(vport->phba, ndlp->nlp_rpi);
6604+
ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
66356605
}
66366606

66376607
/* The node is not freed back to memory, it is released to a pool so

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3380,15 +3380,15 @@ lpfc_block_mgmt_io(struct lpfc_hba *phba, int mbx_action)
33803380
}
33813381

33823382
/**
3383-
* lpfc_sli4_node_prep - Assign RPIs for active nodes.
3383+
* lpfc_sli4_node_rpi_restore - Recover assigned RPIs for active nodes.
33843384
* @phba: pointer to lpfc hba data structure.
33853385
*
33863386
* Allocate RPIs for all active remote nodes. This is needed whenever
33873387
* an SLI4 adapter is reset and the driver is not unloading. Its purpose
33883388
* is to fixup the temporary rpi assignments.
33893389
**/
33903390
void
3391-
lpfc_sli4_node_prep(struct lpfc_hba *phba)
3391+
lpfc_sli4_node_rpi_restore(struct lpfc_hba *phba)
33923392
{
33933393
struct lpfc_nodelist *ndlp, *next_ndlp;
33943394
struct lpfc_vport **vports;
@@ -3398,10 +3398,10 @@ lpfc_sli4_node_prep(struct lpfc_hba *phba)
33983398
return;
33993399

34003400
vports = lpfc_create_vport_work_array(phba);
3401-
if (vports == NULL)
3401+
if (!vports)
34023402
return;
34033403

3404-
for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
3404+
for (i = 0; i <= phba->max_vports && vports[i]; i++) {
34053405
if (test_bit(FC_UNLOADING, &vports[i]->load_flag))
34063406
continue;
34073407

@@ -3410,7 +3410,13 @@ lpfc_sli4_node_prep(struct lpfc_hba *phba)
34103410
nlp_listp) {
34113411
rpi = lpfc_sli4_alloc_rpi(phba);
34123412
if (rpi == LPFC_RPI_ALLOC_ERROR) {
3413-
/* TODO print log? */
3413+
lpfc_printf_vlog(ndlp->vport, KERN_INFO,
3414+
LOG_NODE | LOG_DISCOVERY,
3415+
"0099 RPI alloc error for "
3416+
"ndlp x%px DID:x%06x "
3417+
"flg:x%x\n",
3418+
ndlp, ndlp->nlp_DID,
3419+
ndlp->nlp_flag);
34143420
continue;
34153421
}
34163422
ndlp->nlp_rpi = rpi;
@@ -3830,26 +3836,6 @@ lpfc_offline_prep(struct lpfc_hba *phba, int mbx_action)
38303836
ndlp->nlp_flag &= ~(NLP_UNREG_INP |
38313837
NLP_RPI_REGISTERED);
38323838
spin_unlock_irq(&ndlp->lock);
3833-
if (phba->sli_rev == LPFC_SLI_REV4)
3834-
lpfc_sli_rpi_release(vports[i],
3835-
ndlp);
3836-
} else {
3837-
lpfc_unreg_rpi(vports[i], ndlp);
3838-
}
3839-
/*
3840-
* Whenever an SLI4 port goes offline, free the
3841-
* RPI. Get a new RPI when the adapter port
3842-
* comes back online.
3843-
*/
3844-
if (phba->sli_rev == LPFC_SLI_REV4) {
3845-
lpfc_printf_vlog(vports[i], KERN_INFO,
3846-
LOG_NODE | LOG_DISCOVERY,
3847-
"0011 Free RPI x%x on "
3848-
"ndlp: x%px did x%x\n",
3849-
ndlp->nlp_rpi, ndlp,
3850-
ndlp->nlp_DID);
3851-
lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi);
3852-
ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
38533839
}
38543840

38553841
if (ndlp->nlp_type & NLP_FABRIC) {

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,27 +2844,6 @@ lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
28442844
return;
28452845
}
28462846

2847-
static void
2848-
__lpfc_sli_rpi_release(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
2849-
{
2850-
unsigned long iflags;
2851-
2852-
if (ndlp->nlp_flag & NLP_RELEASE_RPI) {
2853-
lpfc_sli4_free_rpi(vport->phba, ndlp->nlp_rpi);
2854-
spin_lock_irqsave(&ndlp->lock, iflags);
2855-
ndlp->nlp_flag &= ~NLP_RELEASE_RPI;
2856-
ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
2857-
spin_unlock_irqrestore(&ndlp->lock, iflags);
2858-
}
2859-
ndlp->nlp_flag &= ~NLP_UNREG_INP;
2860-
}
2861-
2862-
void
2863-
lpfc_sli_rpi_release(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
2864-
{
2865-
__lpfc_sli_rpi_release(vport, ndlp);
2866-
}
2867-
28682847
/**
28692848
* lpfc_sli_def_mbox_cmpl - Default mailbox completion handler
28702849
* @phba: Pointer to HBA context object.
@@ -2944,8 +2923,6 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
29442923
ndlp->nlp_flag &= ~NLP_UNREG_INP;
29452924
ndlp->nlp_defer_did = NLP_EVT_NOTHING_PENDING;
29462925
lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2947-
} else {
2948-
__lpfc_sli_rpi_release(vport, ndlp);
29492926
}
29502927

29512928
/* The unreg_login mailbox is complete and had a
@@ -2993,6 +2970,7 @@ lpfc_sli4_unreg_rpi_cmpl_clr(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
29932970
{
29942971
struct lpfc_vport *vport = pmb->vport;
29952972
struct lpfc_nodelist *ndlp;
2973+
u32 unreg_inp;
29962974

29972975
ndlp = pmb->ctx_ndlp;
29982976
if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) {
@@ -3011,14 +2989,22 @@ lpfc_sli4_unreg_rpi_cmpl_clr(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
30112989
ndlp->nlp_DID, ndlp->nlp_defer_did,
30122990
ndlp->nlp_flag,
30132991
ndlp);
3014-
ndlp->nlp_flag &= ~NLP_LOGO_ACC;
2992+
2993+
/* Cleanup the nlp_flag now that the UNREG RPI
2994+
* has completed.
2995+
*/
2996+
spin_lock_irq(&ndlp->lock);
2997+
unreg_inp = ndlp->nlp_flag & NLP_UNREG_INP;
2998+
ndlp->nlp_flag &=
2999+
~(NLP_UNREG_INP | NLP_LOGO_ACC);
3000+
spin_unlock_irq(&ndlp->lock);
30153001

30163002
/* Check to see if there are any deferred
30173003
* events to process
30183004
*/
3019-
if ((ndlp->nlp_flag & NLP_UNREG_INP) &&
3020-
(ndlp->nlp_defer_did !=
3021-
NLP_EVT_NOTHING_PENDING)) {
3005+
if (unreg_inp &&
3006+
ndlp->nlp_defer_did !=
3007+
NLP_EVT_NOTHING_PENDING) {
30223008
lpfc_printf_vlog(
30233009
vport, KERN_INFO,
30243010
LOG_MBOX | LOG_SLI | LOG_NODE,
@@ -3027,14 +3013,12 @@ lpfc_sli4_unreg_rpi_cmpl_clr(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
30273013
"NPort x%x Data: x%x x%px\n",
30283014
ndlp->nlp_rpi, ndlp->nlp_DID,
30293015
ndlp->nlp_defer_did, ndlp);
3030-
ndlp->nlp_flag &= ~NLP_UNREG_INP;
30313016
ndlp->nlp_defer_did =
30323017
NLP_EVT_NOTHING_PENDING;
30333018
lpfc_issue_els_plogi(
30343019
vport, ndlp->nlp_DID, 0);
3035-
} else {
3036-
__lpfc_sli_rpi_release(vport, ndlp);
30373020
}
3021+
30383022
lpfc_nlp_put(ndlp);
30393023
}
30403024
}
@@ -8752,6 +8736,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
87528736
lpfc_sli_config_mbox_opcode_get(
87538737
phba, mboxq),
87548738
rc, dd);
8739+
87558740
/*
87568741
* Allocate all resources (xri,rpi,vpi,vfi) now. Subsequent
87578742
* calls depends on these resources to complete port setup.
@@ -8764,6 +8749,8 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
87648749
goto out_free_mbox;
87658750
}
87668751

8752+
lpfc_sli4_node_rpi_restore(phba);
8753+
87678754
lpfc_set_host_data(phba, mboxq);
87688755

87698756
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
@@ -8951,7 +8938,6 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
89518938
rc = -ENODEV;
89528939
goto out_free_iocblist;
89538940
}
8954-
lpfc_sli4_node_prep(phba);
89558941

89568942
if (!test_bit(HBA_FCOE_MODE, &phba->hba_flag)) {
89578943
if ((phba->nvmet_support == 0) || (phba->cfg_nvmet_mrq == 1)) {

0 commit comments

Comments
 (0)