All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dick Kennedy <dick.kennedy@broadcom.com>
To: linux-scsi@vger.kernel.org
Cc: Dick Kennedy <dick.kennedy@broadcom.com>Dick Kennedy
	<dick.kennedy@broadcom.com>,
	James Smart <james.smart@broadcom.com>
Subject: [lpfc 08/19] Fix nvme initiator handling when CONFIG_LPFC_NVME_INITIATOR is not enabled.
Date: Tue,  4 Apr 2017 10:17:01 -0700	[thread overview]
Message-ID: <1491326232-11255-9-git-send-email-rkennedy@broadcom.com> (raw)
In-Reply-To: <1491326232-11255-1-git-send-email-rkennedy@broadcom.com>

From: Dick Kennedy <rkennedy@lvnvda1400.lvn.broadcom.net>

With update nvme upstream driver sources, loading
the driver with nvme enabled resulting in this Oops.

Mar  6 10:09:55 NVME-init kernel: BUG: unable to handle kernel NULL pointer dere
ference at 0000000000000018
Mar  6 10:09:55 NVME-init kernel: IP: lpfc_nvme_update_localport+0x23/0xd0 [lpfc
]
Mar  6 10:09:55 NVME-init kernel: PGD 0
Mar  6 10:09:55 NVME-init kernel:
Mar  6 10:09:55 NVME-init kernel: Oops: 0000 [#1] SMP
Mar  6 10:09:55 NVME-init kernel: CPU: 0 PID: 10256 Comm: lpfc_worker_0 Tainted:
 G           O    4.10.0-rc7 #1
Mar  6 10:09:55 NVME-init kernel: Hardware name: Supermicro Super Server/X10DRL-
i, BIOS 2.0 12/18/2015
Mar  6 10:09:55 NVME-init kernel: task: ffff881028191c40 task.stack: ffff880ffdf
00000
Mar  6 10:09:55 NVME-init kernel: RIP: 0010:lpfc_nvme_update_localport+0x23/0xd0
 [lpfc]
Mar  6 10:09:55 NVME-init kernel: RSP: 0018:ffff880ffdf03c20 EFLAGS: 00010202
Mar  6 10:09:55 NVME-init kernel: RAX: 0000000000000003 RBX: ffff88103285b7d0 RC
X: 0000000000000001
Mar  6 10:09:55 NVME-init kernel: RDX: ffff881031c13400 RSI: 0000000000000292 RD
I: ffff88103285b7d0
Mar  6 10:09:55 NVME-init kernel: RBP: ffff880ffdf03c40 R08: 0000000000fffffc R0
9: ffff880fff6c66c0
Mar  6 10:09:55 NVME-init kernel: R10: ffff880fff01f200 R11: ffff880fff6c6680 R1
2: 0000000000000000
Mar  6 10:09:55 NVME-init kernel: R13: ffff8810308ac000 R14: 0000000000000000 R1
5: 0000000000000028
Mar  6 10:09:55 NVME-init kernel: FS:  0000000000000000(0000) GS:ffff88103f20000
0(0000) knlGS:0000000000000000
Mar  6 10:09:55 NVME-init kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050
033
Mar  6 10:09:55 NVME-init kernel: CR2: 0000000000000018 CR3: 0000000001009000 CR
4: 00000000001406f0

Cause: As the initiator driver completes discovery at different stages, it call
lpfc_nvme_update_localport to hint that the DID and role may have changed.  In
the implementation of lpfc_nvme_update_localport, the driver was not
validating the localport or the lport during the execution
of the update_localport routine.  With the recent upstream additions to
the driver, the create_localport routine didn't run and so the localport
was NULL causing the page-fault Oops.

Fix: Add the CONFIG_LPFC_NVME_INITIATOR preprocessor inclusions to
lpfc_nvme_update_localport to turn off all routine processing when
the running kernel does not have NVME configured.  Add NULL pointer
checks on the localport and lport in lpfc_nvme_update_localport and
dump messages if they are NULL and just exit.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_nvme.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 6465aa6..9726c95 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -2264,12 +2264,23 @@ lpfc_nvme_destroy_localport(struct lpfc_vport *vport)
 void
 lpfc_nvme_update_localport(struct lpfc_vport *vport)
 {
+#ifdef CONFIG_LPFC_NVME_INITIATOR
 	struct nvme_fc_local_port *localport;
 	struct lpfc_nvme_lport *lport;
 
 	localport = vport->localport;
+	if (!localport) {
+		lpfc_printf_vlog(vport, KERN_WARNING, LOG_NVME,
+				 "6710 Update NVME fail. No localport\n");
+		return;
+	}
 	lport = (struct lpfc_nvme_lport *)localport->private;
-
+	if (!lport) {
+		lpfc_printf_vlog(vport, KERN_WARNING, LOG_NVME,
+				 "6171 Update NVME fail. localP %p, No lport\n",
+				 localport);
+		return;
+	}
 	lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME,
 			 "6012 Update NVME lport %p did x%x\n",
 			 localport, vport->fc_myDID);
@@ -2283,7 +2294,7 @@ lpfc_nvme_update_localport(struct lpfc_vport *vport)
 	lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
 			 "6030 bound lport %p to DID x%06x\n",
 			 lport, localport->port_id);
-
+#endif
 }
 
 int
-- 
2.1.0

  parent reply	other threads:[~2017-04-04 17:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 17:16 [lpfc 00/19] lpfc updates Dick Kennedy
2017-04-04 17:16 ` [lpfc 01/19] Fix advertised max_sgl_segment count for NVMET Dick Kennedy
2017-04-05  7:08   ` Johannes Thumshirn
2017-04-04 17:16 ` [lpfc 02/19] Fixes after reviewing last set of patches. Minor fixes to previous patches Dick Kennedy
2017-04-05  7:10   ` Johannes Thumshirn
2017-04-04 17:16 ` [lpfc 03/19] Fix spelling in comments Dick Kennedy
2017-04-05  7:12   ` Johannes Thumshirn
2017-04-04 17:16 ` [lpfc 04/19] Fix PRLI ACC rsp for NVME Dick Kennedy
2017-04-05  7:15   ` Johannes Thumshirn
2017-04-04 17:16 ` [lpfc 05/19] Fix driver unload/reload operation Dick Kennedy
2017-04-05  7:20   ` Johannes Thumshirn
2017-04-05 13:30   ` Mauricio Faria de Oliveira
2017-04-04 17:16 ` [lpfc 06/19] Fix discovery error handling in NVME initiator Dick Kennedy
2017-04-04 17:17 ` [lpfc 07/19] Fix driver usage of 128B WQEs when WQ_CREATE is V1 Dick Kennedy
2017-04-04 17:17 ` Dick Kennedy [this message]
2017-04-04 17:17 ` [lpfc 09/19] Fix Kconfig defines Dick Kennedy
2017-04-04 17:17 ` [lpfc 10/19] Remove hba lock from NVMET isssue WQE Dick Kennedy
2017-04-04 17:17 ` [lpfc 11/19] Add NVMET changes to interface with 4.11 kernel Dick Kennedy
2017-04-04 17:17 ` [lpfc 12/19] cannot establish connection with target that sends PRLI in PT2PT Dick Kennedy
2017-04-04 17:17 ` [lpfc 13/19] Fix driver load issues when MRQ=8 Dick Kennedy
2017-04-04 17:17 ` [lpfc 14/19] Fix crash after issuing lip reset Dick Kennedy
2017-04-04 17:17 ` [lpfc 15/19] Fix max_sgl_segments settings for NVME / NVMET Dick Kennedy
2017-04-04 17:17 ` [lpfc 16/19] Add Fabric assigned WWN support Dick Kennedy
2017-04-04 17:17 ` [lpfc 17/19] Fix implicit logo and RSCN handling for NVMET Dick Kennedy
2017-04-04 17:17 ` [lpfc 18/19] Update ABORT processing " Dick Kennedy
2017-04-04 17:17 ` [lpfc 19/19] lpfc revison 11.2.0.12 Dick Kennedy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491326232-11255-9-git-send-email-rkennedy@broadcom.com \
    --to=dick.kennedy@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.