From: Michael Baum <michaelba@nvidia.com>
To: dev@dpdk.org
Cc: Matan Azrad <matan@nvidia.com>,
Raslan Darawsheh <rasland@nvidia.com>,
David Marchand <david.marchand@redhat.com>,
stable@dpdk.org
Subject: [dpdk-stable] [PATCH 1/2] net/mlx4: fix device detach
Date: Wed, 13 Jan 2021 16:28:52 +0000 [thread overview]
Message-ID: <1610555333-18961-2-git-send-email-michaelba@nvidia.com> (raw)
In-Reply-To: <1610555333-18961-1-git-send-email-michaelba@nvidia.com>
When mlx4 device is probed, 2 different ethdev ports may be created for
the 2 physical ports of the device.
Wrongly, when the device is removed, the created ports are not released.
Close and release the ethdev ports in remove process.
Fixes: 7fae69eeff13 ("mlx4: new poll mode driver")
Cc: stable@dpdk.org
Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx4/mlx4.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index d5d8c96..7460afa 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -375,8 +375,10 @@ struct mlx4_conf {
struct mlx4_priv *priv = dev->data->dev_private;
unsigned int i;
- if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+ rte_eth_dev_release_port(dev);
return 0;
+ }
DEBUG("%p: closing device \"%s\"",
(void *)dev,
((priv->ctx != NULL) ? priv->ctx->device->name : ""));
@@ -1123,6 +1125,36 @@ struct mlx4_conf {
return -err;
}
+/**
+ * DPDK callback to remove a PCI device.
+ *
+ * This function removes all Ethernet devices belong to a given PCI device.
+ *
+ * @param[in] pci_dev
+ * Pointer to the PCI device.
+ *
+ * @return
+ * 0 on success, the function cannot fail.
+ */
+static int
+mlx4_pci_remove(struct rte_pci_device *pci_dev)
+{
+ uint16_t port_id;
+ int ret = 0;
+
+ RTE_ETH_FOREACH_DEV_OF(port_id, &pci_dev->device) {
+ /*
+ * mlx4_dev_close() is not registered to secondary process,
+ * call the close function explicitly for secondary process.
+ */
+ if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+ ret |= mlx4_dev_close(&rte_eth_devices[port_id]);
+ else
+ ret |= rte_eth_dev_close(port_id);
+ }
+ return ret == 0 ? 0 : -EIO;
+}
+
static const struct rte_pci_id mlx4_pci_id_map[] = {
{
RTE_PCI_DEVICE(PCI_VENDOR_ID_MELLANOX,
@@ -1147,6 +1179,7 @@ struct mlx4_conf {
},
.id_table = mlx4_pci_id_map,
.probe = mlx4_pci_probe,
+ .remove = mlx4_pci_remove,
.drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV,
};
--
1.8.3.1
next parent reply other threads:[~2021-01-13 16:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1610555333-18961-1-git-send-email-michaelba@nvidia.com>
2021-01-13 16:28 ` Michael Baum [this message]
2021-01-14 8:32 ` [dpdk-stable] [dpdk-dev] " David Marchand
2021-01-14 10:41 ` David Marchand
[not found] ` <1611130491-19129-1-git-send-email-michaelba@nvidia.com>
2021-01-20 8:14 ` [dpdk-stable] [PATCH v2 " Michael Baum
2021-01-20 8:14 ` [dpdk-stable] [PATCH v2 2/2] net/mlx4: fix PCI probe error flow Michael Baum
2021-01-13 16:28 ` [dpdk-stable] [PATCH " Michael Baum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1610555333-18961-2-git-send-email-michaelba@nvidia.com \
--to=michaelba@nvidia.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=rasland@nvidia.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).