summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/netronome/nfp/nfp_main.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-07-26 08:17:45 +0300
committerDavid S. Miller <davem@davemloft.net>2018-07-26 08:17:45 +0300
commitf53753058488295344e7fcdba3da4c33a49b70ac (patch)
tree4179e0924b2d71193267da4cc6d9a2e97dbd12fb /drivers/net/ethernet/netronome/nfp/nfp_main.c
parentb24dbfe9ce03d9f83306616f22fb0e04e8960abe (diff)
parent5ea14712d7a22703645217c5296e72cb5adba0a6 (diff)
downloadlinux-f53753058488295344e7fcdba3da4c33a49b70ac.tar.xz
Merge branch 'nfp-protect-from-theoretical-size-overflows-and-SR-IOV-errors'
Jakub Kicinski says: ==================== nfp: protect from theoretical size overflows and SR-IOV errors This small set changes the handling of pci_sriov_set_totalvfs() errors. nfp is the only driver which fails probe on pci_sriov_set_totalvfs() errors. It turns out some BIOS configurations may break SR-IOV and users who don't use that feature should not suffer. Remaining patches makes sure we use overflow-safe function for ring allocation, even though ring sizes are limited. It won't hurt and we can also enable fallback to vmalloc() if memory is tight while at it. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/netronome/nfp/nfp_main.c')
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_main.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c
index 152283d7e59c..4a540c5e27fe 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c
@@ -236,16 +236,20 @@ static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf)
int err;
pf->limit_vfs = nfp_rtsym_read_le(pf->rtbl, "nfd_vf_cfg_max_vfs", &err);
- if (!err)
- return pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs);
+ if (err) {
+ /* For backwards compatibility if symbol not found allow all */
+ pf->limit_vfs = ~0;
+ if (err == -ENOENT)
+ return 0;
- pf->limit_vfs = ~0;
- /* Allow any setting for backwards compatibility if symbol not found */
- if (err == -ENOENT)
- return 0;
+ nfp_warn(pf->cpp, "Warning: VF limit read failed: %d\n", err);
+ return err;
+ }
- nfp_warn(pf->cpp, "Warning: VF limit read failed: %d\n", err);
- return err;
+ err = pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs);
+ if (err)
+ nfp_warn(pf->cpp, "Failed to set VF count in sysfs: %d\n", err);
+ return 0;
}
static int nfp_pcie_sriov_enable(struct pci_dev *pdev, int num_vfs)