提交 321b5e9a 编写于 作者: J Jakub Kicinski 提交者: David S. Miller

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: NJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 09b85794
...@@ -119,6 +119,11 @@ ...@@ -119,6 +119,11 @@
#define NFP_PCIE_EM 0x020000 #define NFP_PCIE_EM 0x020000
#define NFP_PCIE_SRAM 0x000000 #define NFP_PCIE_SRAM 0x000000
/* Minimal size of the PCIe cfg memory we depend on being mapped,
* queue controller and DMA controller don't have to be covered.
*/
#define NFP_PCI_MIN_MAP_SIZE 0x080000
#define NFP_PCIE_P2C_FIXED_SIZE(bar) (1 << (bar)->bitsize) #define NFP_PCIE_P2C_FIXED_SIZE(bar) (1 << (bar)->bitsize)
#define NFP_PCIE_P2C_BULK_SIZE(bar) (1 << (bar)->bitsize) #define NFP_PCIE_P2C_BULK_SIZE(bar) (1 << (bar)->bitsize)
#define NFP_PCIE_P2C_GENERAL_TARGET_OFFSET(bar, x) ((x) << ((bar)->bitsize - 2)) #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) ...@@ -628,8 +633,9 @@ static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
/* Configure, and lock, BAR0.0 for General Target use (MSI-X SRAM) */ /* Configure, and lock, BAR0.0 for General Target use (MSI-X SRAM) */
bar = &nfp->bar[0]; bar = &nfp->bar[0];
bar->iomem = ioremap_nocache(nfp_bar_resource_start(bar), if (nfp_bar_resource_len(bar) >= NFP_PCI_MIN_MAP_SIZE)
nfp_bar_resource_len(bar)); bar->iomem = ioremap_nocache(nfp_bar_resource_start(bar),
nfp_bar_resource_len(bar));
if (bar->iomem) { if (bar->iomem) {
dev_info(nfp->dev, dev_info(nfp->dev,
"BAR0.0 RESERVED: General Mapping/MSI-X SRAM\n"); "BAR0.0 RESERVED: General Mapping/MSI-X SRAM\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册