aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mlx5/mlx5_core
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2023-12-29 03:14:56 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2024-01-05 04:52:39 +0000
commit987446fa39e8f6887ea16ad49f00f699b2efd210 (patch)
treedd91ebc4ec0f8ae4eed5c6dc57c9d0e6bc18a87f /sys/dev/mlx5/mlx5_core
parent069ac18495ad8fde2748bc94b0f80a50250bb01d (diff)
mlx5(4): only detach IOV children if iov was successfully initialized
Reported by: jwd Sponsored by: NVidia networking MFC after: 1 week
Diffstat (limited to 'sys/dev/mlx5/mlx5_core')
-rw-r--r--sys/dev/mlx5/mlx5_core/mlx5_main.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_main.c b/sys/dev/mlx5/mlx5_core/mlx5_main.c
index f6dc1158f085..6b9b63a24714 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_main.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_main.c
@@ -1719,7 +1719,9 @@ static int init_one(struct pci_dev *pdev,
pci_iov_schema_add_uint64(vf_schema, iov_port_guid_name,
0, 0);
err = pci_iov_attach(bsddev, pf_schema, vf_schema);
- if (err != 0) {
+ if (err == 0) {
+ dev->iov_pf = true;
+ } else {
device_printf(bsddev,
"Failed to initialize SR-IOV support, error %d\n",
err);
@@ -1753,8 +1755,11 @@ static void remove_one(struct pci_dev *pdev)
struct mlx5_priv *priv = &dev->priv;
#ifdef PCI_IOV
- pci_iov_detach(pdev->dev.bsddev);
- mlx5_eswitch_disable_sriov(priv->eswitch);
+ if (dev->iov_pf) {
+ pci_iov_detach(pdev->dev.bsddev);
+ mlx5_eswitch_disable_sriov(priv->eswitch);
+ dev->iov_pf = false;
+ }
#endif
if (mlx5_unload_one(dev, priv, true)) {