From 04babbea355b571bbea83428d69658ef13c847bd Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Sun, 18 Nov 2018 02:23:22 +0100 Subject: [PATCH] vtophys: remove internal device refcount This was dead code. Registering the same device more than once has never been possible within a single process. Change-Id: I04fa2a62cd9f3d7f99ff799ea4504c49a2232da4 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/433866 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris Chandler-Test-Pool: SPDK Automated Test System --- lib/env_dpdk/vtophys.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/lib/env_dpdk/vtophys.c b/lib/env_dpdk/vtophys.c index 908ad3166..67572ea5b 100644 --- a/lib/env_dpdk/vtophys.c +++ b/lib/env_dpdk/vtophys.c @@ -103,7 +103,6 @@ static struct vfio_cfg g_vfio = { struct spdk_vtophys_pci_device { struct rte_pci_device *pci_device; TAILQ_ENTRY(spdk_vtophys_pci_device) tailq; - uint64_t ref; }; static pthread_mutex_t g_vtophys_pci_devices_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -518,26 +517,15 @@ void spdk_vtophys_pci_device_added(struct rte_pci_device *pci_device) { struct spdk_vtophys_pci_device *vtophys_dev; - bool found = false; pthread_mutex_lock(&g_vtophys_pci_devices_mutex); - TAILQ_FOREACH(vtophys_dev, &g_vtophys_pci_devices, tailq) { - if (vtophys_dev->pci_device == pci_device) { - vtophys_dev->ref++; - found = true; - break; - } - } - if (!found) { - vtophys_dev = calloc(1, sizeof(*vtophys_dev)); - if (vtophys_dev) { - vtophys_dev->pci_device = pci_device; - vtophys_dev->ref = 1; - TAILQ_INSERT_TAIL(&g_vtophys_pci_devices, vtophys_dev, tailq); - } else { - DEBUG_PRINT("Memory allocation error\n"); - } + vtophys_dev = calloc(1, sizeof(*vtophys_dev)); + if (vtophys_dev) { + vtophys_dev->pci_device = pci_device; + TAILQ_INSERT_TAIL(&g_vtophys_pci_devices, vtophys_dev, tailq); + } else { + DEBUG_PRINT("Memory allocation error\n"); } pthread_mutex_unlock(&g_vtophys_pci_devices_mutex); @@ -579,11 +567,8 @@ spdk_vtophys_pci_device_removed(struct rte_pci_device *pci_device) pthread_mutex_lock(&g_vtophys_pci_devices_mutex); TAILQ_FOREACH(vtophys_dev, &g_vtophys_pci_devices, tailq) { if (vtophys_dev->pci_device == pci_device) { - assert(vtophys_dev->ref > 0); - if (--vtophys_dev->ref == 0) { - TAILQ_REMOVE(&g_vtophys_pci_devices, vtophys_dev, tailq); - free(vtophys_dev); - } + TAILQ_REMOVE(&g_vtophys_pci_devices, vtophys_dev, tailq); + free(vtophys_dev); break; } }