Skip to content

Commit 09b8579

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: don't set aux pointers if ioremap failed
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 651e1f2 commit 09b8579

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,19 +639,23 @@ static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
639639
nfp6000_bar_write(nfp, bar, barcfg_msix_general);
640640

641641
nfp->expl.data = bar->iomem + NFP_PCIE_SRAM + 0x1000;
642+
643+
if (nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP4000 ||
644+
nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP6000) {
645+
nfp->iomem.csr = bar->iomem + NFP_PCIE_BAR(0);
646+
} else {
647+
int pf = nfp->pdev->devfn & 7;
648+
649+
nfp->iomem.csr = bar->iomem + NFP_PCIE_BAR(pf);
650+
}
651+
nfp->iomem.em = bar->iomem + NFP_PCIE_EM;
642652
}
643653

644654
if (nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP4000 ||
645-
nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP6000) {
646-
nfp->iomem.csr = bar->iomem + NFP_PCIE_BAR(0);
655+
nfp->pdev->device == PCI_DEVICE_ID_NETRONOME_NFP6000)
647656
expl_groups = 4;
648-
} else {
649-
int pf = nfp->pdev->devfn & 7;
650-
651-
nfp->iomem.csr = bar->iomem + NFP_PCIE_BAR(pf);
657+
else
652658
expl_groups = 1;
653-
}
654-
nfp->iomem.em = bar->iomem + NFP_PCIE_EM;
655659

656660
/* Configure, and lock, BAR0.1 for PCIe XPB (MSI-X PBA) */
657661
bar = &nfp->bar[1];

0 commit comments

Comments
 (0)