aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2023-12-29 03:14:56 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2024-01-11 16:47:51 +0000
commita85df799787b8c441bf7d7238f02ca057b7378e5 (patch)
treebd2e0115c319154dc6bda105e575333b8eb1c278
parenta20522d9ae20610bd266c99dab75f58d7b3ee22b (diff)
downloadsrc-a85df799787b8c441bf7d7238f02ca057b7378e5.tar.gz
src-a85df799787b8c441bf7d7238f02ca057b7378e5.zip
mlx5(4): only detach IOV children if iov was successfully initialized
(cherry picked from commit 987446fa39e8f6887ea16ad49f00f699b2efd210)
-rw-r--r--sys/dev/mlx5/driver.h2
-rw-r--r--sys/dev/mlx5/mlx5_core/mlx5_main.c11
2 files changed, 10 insertions, 3 deletions
diff --git a/sys/dev/mlx5/driver.h b/sys/dev/mlx5/driver.h
index 958b4a7df747..d866e40372ab 100644
--- a/sys/dev/mlx5/driver.h
+++ b/sys/dev/mlx5/driver.h
@@ -708,6 +708,8 @@ struct mlx5_core_dev {
bool dump_copyout;
struct mtx dump_lock;
+ bool iov_pf;
+
struct sysctl_ctx_list sysctl_ctx;
int msix_eqvec;
int pwr_status;
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_main.c b/sys/dev/mlx5/mlx5_core/mlx5_main.c
index 2e0aa2a00cd5..0a05d559072f 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_main.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_main.c
@@ -1702,7 +1702,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);
@@ -1736,8 +1738,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)) {