DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tiwei Bie <tiwei.bie@intel.com>
To: maxime.coquelin@redhat.com, zhihong.wang@intel.com, dev@dpdk.org
Cc: stable@dpdk.org
Subject: [dpdk-dev] [PATCH 3/5] net/virtio: unmap device on initialization error
Date: Wed,  5 Jun 2019 17:43:40 +0800	[thread overview]
Message-ID: <20190605094342.17563-4-tiwei.bie@intel.com> (raw)
In-Reply-To: <20190605094342.17563-1-tiwei.bie@intel.com>

We should unmap the device when we failed to initialize the device.

Fixes: 6ba1f63b5ab0 ("virtio: support specification 1.0")
Cc: stable@dpdk.org

Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 12 +++++++++---
 drivers/net/virtio/virtio_pci.c    |  1 +
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index a2cedcc87..46d2e4ac6 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1857,17 +1857,23 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	if (!hw->virtio_user_dev) {
 		ret = vtpci_init(RTE_ETH_DEV_TO_PCI(eth_dev), hw);
 		if (ret)
-			goto out;
+			goto err_vtpci_init;
 	}
 
 	/* reset device and negotiate default features */
 	ret = virtio_init_device(eth_dev, VIRTIO_PMD_DEFAULT_GUEST_FEATURES);
 	if (ret < 0)
-		goto out;
+		goto err_virtio_init;
 
 	return 0;
 
-out:
+err_virtio_init:
+	if (!hw->virtio_user_dev) {
+		rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));
+		if (!hw->modern)
+			rte_pci_ioport_unmap(VTPCI_IO(hw));
+	}
+err_vtpci_init:
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 	return ret;
diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index adc02f96a..4468e89cb 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -678,6 +678,7 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
 
 	PMD_INIT_LOG(INFO, "trying with legacy virtio pci.");
 	if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
+		rte_pci_unmap_device(dev);
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
 		    (!dev->device.devargs ||
 		     dev->device.devargs->bus !=
-- 
2.17.1


  parent reply	other threads:[~2019-06-05  9:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05  9:43 [dpdk-dev] [PATCH 0/5] virtio: release port upon close Tiwei Bie
2019-06-05  9:43 ` [dpdk-dev] [PATCH 1/5] net/virtio: fix queue memory leak on error Tiwei Bie
2019-06-05 12:35   ` Maxime Coquelin
2019-06-05  9:43 ` [dpdk-dev] [PATCH 2/5] net/virtio: unmap port IO for legacy device Tiwei Bie
2019-06-05 14:31   ` Maxime Coquelin
2019-06-05  9:43 ` Tiwei Bie [this message]
2019-06-05 14:33   ` [dpdk-dev] [PATCH 3/5] net/virtio: unmap device on initialization error Maxime Coquelin
2019-06-05  9:43 ` [dpdk-dev] [PATCH 4/5] net/virtio: release port upon close Tiwei Bie
2019-06-17 14:42   ` Maxime Coquelin
2019-06-05  9:43 ` [dpdk-dev] [PATCH 5/5] app/testpmd: drop the workaround for virtio-user Tiwei Bie
2019-06-17 14:44   ` Maxime Coquelin
2019-06-20  9:59 ` [dpdk-dev] [PATCH 0/5] virtio: release port upon close Maxime Coquelin

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=20190605094342.17563-4-tiwei.bie@intel.com \
    --to=tiwei.bie@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    --cc=zhihong.wang@intel.com \
    /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).