From fb51565a59f5613b497127ef04617f38149590b5 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Mon, 25 Mar 2019 21:17:23 +0100 Subject: [PATCH] env/dpdk: add spdk_pci_fini() It's mostly needed for the next patch, but even now it provides some value by printing errors if there any leaked (still attached) PCI devices at shutdown. Change-Id: I8459a6049b3c6612d9f1d99444bf3acfd474a839 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449082 Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Tested-by: SPDK CI Jenkins --- lib/env_dpdk/env_internal.h | 1 + lib/env_dpdk/init.c | 2 ++ lib/env_dpdk/pci.c | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/lib/env_dpdk/env_internal.h b/lib/env_dpdk/env_internal.h index 5f8d96215..39ba35371 100644 --- a/lib/env_dpdk/env_internal.h +++ b/lib/env_dpdk/env_internal.h @@ -78,6 +78,7 @@ int spdk_pci_device_init(struct rte_pci_driver *driver, struct rte_pci_device *d int spdk_pci_device_fini(struct rte_pci_device *device); void spdk_pci_init(void); +void spdk_pci_fini(void); int spdk_mem_map_init(void); int spdk_vtophys_init(void); diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index d712bb18d..ed349d258 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -385,6 +385,8 @@ spdk_env_dpdk_post_init(void) void spdk_env_dpdk_post_fini(void) { + spdk_pci_fini(); + spdk_free_args(g_eal_cmdline, g_eal_cmdline_argcount); } diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index cf76cbd36..657d95ecd 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -147,6 +147,20 @@ spdk_pci_init(void) #endif } +void +spdk_pci_fini(void) +{ + struct spdk_pci_device *dev; + char bdf[32]; + + TAILQ_FOREACH(dev, &g_pci_devices, internal.tailq) { + if (dev->internal.attached) { + spdk_pci_addr_fmt(bdf, sizeof(bdf), &dev->addr); + fprintf(stderr, "Device %s is still attached at shutdown!\n", bdf); + } + } +} + int spdk_pci_device_init(struct rte_pci_driver *_drv, struct rte_pci_device *_dev)