From 40240f7e9dc3c5f701908b55de03da8cd60637b7 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Wed, 6 Feb 2019 13:34:08 +0100 Subject: [PATCH] bdev/crypto: release qpairs on module finish We setup the qpairs on module init but never released them. Some memory was leaked, although since it was allocated with rte_malloc() it couldn't be picked up by ASAN. rte_cryptodev API offers rte_cryptodev_queue_pair_setup() to setup a qpair, but there's no equivalent function to release it. We have to access the rte_cryptodev structure directly and call a qpair release function ptr that's stored inside. It seems very very hacky, but the entire rte_cryptodev structure is a part of the public API and the global array of all such devices is an exported symbol. Change-Id: I17ac73d1098ca9a92d2dfd52e0f905e2c2b5488f Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/443561 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/bdev/crypto/vbdev_crypto.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/bdev/crypto/vbdev_crypto.c b/lib/bdev/crypto/vbdev_crypto.c index dcb041f12..e0e9f92b1 100644 --- a/lib/bdev/crypto/vbdev_crypto.c +++ b/lib/bdev/crypto/vbdev_crypto.c @@ -1288,6 +1288,7 @@ vbdev_crypto_finish(void) struct bdev_names *name; struct vbdev_dev *device; struct device_qp *dev_qp; + unsigned i; while ((name = TAILQ_FIRST(&g_bdev_names))) { TAILQ_REMOVE(&g_bdev_names, name, link); @@ -1299,8 +1300,20 @@ vbdev_crypto_finish(void) } while ((device = TAILQ_FIRST(&g_vbdev_devs))) { + struct rte_cryptodev *rte_dev; + TAILQ_REMOVE(&g_vbdev_devs, device, link); rte_cryptodev_stop(device->cdev_id); + + assert(device->cdev_id < RTE_CRYPTO_MAX_DEVS); + rte_dev = &rte_cryptodevs[device->cdev_id]; + + if (rte_dev->dev_ops->queue_pair_release != NULL) { + for (i = 0; i < device->cdev_info.max_nb_queue_pairs; i++) { + rte_dev->dev_ops->queue_pair_release(rte_dev, i); + } + } + free(device); }