ioat copy engine: free the registered io device.
The registered io_device by spdk_ioat_copy_engine is not freed, and we should free it. Since spdk_ioat_copy_engine is a static variable, which can not be referenced by the function defined before this variable. So we also adjust the location of copy_engine_ioat_exit. Change-Id: Ic196fe3234655c81364b3b4ceccd715979545f8e Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478838 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
7961de4341
commit
232756e119
@ -45,6 +45,7 @@
|
||||
#include "spdk/ioat.h"
|
||||
|
||||
static bool g_ioat_enable = false;
|
||||
static bool g_ioat_initialized = false;
|
||||
|
||||
struct ioat_probe_ctx {
|
||||
int num_whitelist_devices;
|
||||
@ -128,21 +129,6 @@ SPDK_COPY_MODULE_REGISTER(copy_engine_ioat_init, copy_engine_ioat_exit,
|
||||
copy_engine_ioat_config_text,
|
||||
copy_engine_ioat_get_ctx_size)
|
||||
|
||||
static void
|
||||
copy_engine_ioat_exit(void *ctx)
|
||||
{
|
||||
struct ioat_device *dev;
|
||||
|
||||
while (!TAILQ_EMPTY(&g_devices)) {
|
||||
dev = TAILQ_FIRST(&g_devices);
|
||||
TAILQ_REMOVE(&g_devices, dev, tailq);
|
||||
spdk_ioat_detach(dev->ioat);
|
||||
ioat_free_device(dev);
|
||||
free(dev);
|
||||
}
|
||||
spdk_copy_engine_module_finish();
|
||||
}
|
||||
|
||||
static void
|
||||
ioat_done(void *cb_arg)
|
||||
{
|
||||
@ -383,6 +369,7 @@ copy_engine_ioat_init(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_ioat_initialized = true;
|
||||
SPDK_INFOLOG(SPDK_LOG_COPY_IOAT, "Ioat Copy Engine Offload Enabled\n");
|
||||
spdk_copy_engine_register(&ioat_copy_engine);
|
||||
spdk_io_device_register(&ioat_copy_engine, ioat_create_cb, ioat_destroy_cb,
|
||||
@ -390,6 +377,25 @@ copy_engine_ioat_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
copy_engine_ioat_exit(void *ctx)
|
||||
{
|
||||
struct ioat_device *dev;
|
||||
|
||||
if (g_ioat_initialized) {
|
||||
spdk_io_device_unregister(&ioat_copy_engine, NULL);
|
||||
}
|
||||
|
||||
while (!TAILQ_EMPTY(&g_devices)) {
|
||||
dev = TAILQ_FIRST(&g_devices);
|
||||
TAILQ_REMOVE(&g_devices, dev, tailq);
|
||||
spdk_ioat_detach(dev->ioat);
|
||||
ioat_free_device(dev);
|
||||
free(dev);
|
||||
}
|
||||
spdk_copy_engine_module_finish();
|
||||
}
|
||||
|
||||
#define COPY_ENGINE_IOAT_HEADER_TMPL \
|
||||
"[Ioat]\n" \
|
||||
" # Users may not want to use offload even it is available.\n" \
|
||||
|
Loading…
Reference in New Issue
Block a user