All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: netdev@vger.kernel.org
Cc: oss-drivers@netronome.com, Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next 03/12] nfp: don't set aux pointers if ioremap failed
Date: Sat, 27 May 2017 17:34:02 -0700	[thread overview]
Message-ID: <20170528003411.17603-4-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20170528003411.17603-1-jakub.kicinski@netronome.com>

If ioremap of PCIe ctrl memory failed we can still get to it through
PCI config space, therefore we allow ioremap() to fail.  When if fails,
however, we must leave all the IOMEM pointers as NULL.  Currently we
would calculate csr and em pointers, adding offsets to the potential
NULL value and therefore making the NULL-checks throughout the code
ineffective.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 .../ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c    | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
index 43dc68e01274..1fde213d5b83 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
@@ -639,19 +639,23 @@ static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
 		nfp6000_bar_write(nfp, bar, barcfg_msix_general);
 
 		nfp->expl.data = bar->iomem + NFP_PCIE_SRAM + 0x1000;
+
+		if (nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP4000 ||
+		    nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP6000) {
+			nfp->iomem.csr = bar->iomem + NFP_PCIE_BAR(0);
+		} else {
+			int pf = nfp->pdev->devfn & 7;
+
+			nfp->iomem.csr = bar->iomem + NFP_PCIE_BAR(pf);
+		}
+		nfp->iomem.em = bar->iomem + NFP_PCIE_EM;
 	}
 
 	if (nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP4000 ||
-	    nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP6000) {
-		nfp->iomem.csr = bar->iomem + NFP_PCIE_BAR(0);
+	    nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP6000)
 		expl_groups = 4;
-	} else {
-		int pf = nfp->pdev->devfn & 7;
-
-		nfp->iomem.csr = bar->iomem + NFP_PCIE_BAR(pf);
+	else
 		expl_groups = 1;
-	}
-	nfp->iomem.em = bar->iomem + NFP_PCIE_EM;
 
 	/* Configure, and lock, BAR0.1 for PCIe XPB (MSI-X PBA) */
 	bar = &nfp->bar[1];
-- 
2.11.0

  parent reply	other threads:[~2017-05-28  0:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-28  0:33 [PATCH net-next 00/12] nfp: pci core, hwmon, live mac addr change Jakub Kicinski
2017-05-28  0:34 ` [PATCH net-next 01/12] nfp: add set_mac_address support while the interface is up Jakub Kicinski
2017-05-28  0:34 ` [PATCH net-next 02/12] nfp: set driver VF limit Jakub Kicinski
2017-05-28 14:49   ` Mintz, Yuval
2017-05-28 21:16     ` Jakub Kicinski
2017-05-28  0:34 ` Jakub Kicinski [this message]
2017-05-28  0:34 ` [PATCH net-next 04/12] nfp: only try to get to PCIe ctrl memory if BARs are wide enough Jakub Kicinski
2017-05-28  0:34 ` [PATCH net-next 05/12] nfp: support long reads and writes with the cpp helpers Jakub Kicinski
2017-05-28  0:34 ` [PATCH net-next 06/12] nfp: shorten CPP core probe logs Jakub Kicinski
2017-05-28  0:34 ` [PATCH net-next 07/12] nfp: support variable NSP response lengths Jakub Kicinski
2017-05-28  0:34 ` [PATCH net-next 08/12] nfp: add hwmon support Jakub Kicinski
2017-05-28 18:50   ` kbuild test robot
2017-05-28  0:34 ` [PATCH net-next 09/12] nfp: don't wait for resources indefinitely Jakub Kicinski
2017-05-28  0:34 ` [PATCH net-next 10/12] nfp: fix print format for ring pointers in ring dumps Jakub Kicinski
2017-05-31 10:33   ` David Laight
2017-05-28  0:34 ` [PATCH net-next 11/12] nfp: don't add ring size to index calculations Jakub Kicinski
2017-05-28  0:34 ` [PATCH net-next 12/12] nfp: don't keep count for free buffers delayed kick Jakub Kicinski

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=20170528003411.17603-4-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    /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.