Skip to content

Commit 321b5e9

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: only try to get to PCIe ctrl memory if BARs are wide enough
For accessing PCIe ctrl memory we depend on the BAR aperture being large enough to reach all registers. Since the BAR aperture can be set in the flash make sure the driver won't oops the kernel when the PCIe configuration is unusual. Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 09b8579 commit 321b5e9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@
119119
#define NFP_PCIE_EM 0x020000
120120
#define NFP_PCIE_SRAM 0x000000
121121

122+
/* Minimal size of the PCIe cfg memory we depend on being mapped,
123+
* queue controller and DMA controller don't have to be covered.
124+
*/
125+
#define NFP_PCI_MIN_MAP_SIZE 0x080000
126+
122127
#define NFP_PCIE_P2C_FIXED_SIZE(bar) (1 << (bar)->bitsize)
123128
#define NFP_PCIE_P2C_BULK_SIZE(bar) (1 << (bar)->bitsize)
124129
#define NFP_PCIE_P2C_GENERAL_TARGET_OFFSET(bar, x) ((x) << ((bar)->bitsize - 2))
@@ -628,8 +633,9 @@ static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
628633

629634
/* Configure, and lock, BAR0.0 for General Target use (MSI-X SRAM) */
630635
bar = &nfp->bar[0];
631-
bar->iomem = ioremap_nocache(nfp_bar_resource_start(bar),
632-
nfp_bar_resource_len(bar));
636+
if (nfp_bar_resource_len(bar) >= NFP_PCI_MIN_MAP_SIZE)
637+
bar->iomem = ioremap_nocache(nfp_bar_resource_start(bar),
638+
nfp_bar_resource_len(bar));
633639
if (bar->iomem) {
634640
dev_info(nfp->dev,
635641
"BAR0.0 RESERVED: General Mapping/MSI-X SRAM\n");

0 commit comments

Comments
 (0)