aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mlx5
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2017-01-27 11:19:06 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2017-01-27 11:19:06 +0000
commit44a03e91f3f1d660a3baaf00dce6f05dd1fb3ebf (patch)
tree9eb7e783506b6abddd1bea005f17fe50525570a6 /sys/dev/mlx5
parent310804912af897fca22615c8dee4f41aec8b8d67 (diff)
downloadsrc-44a03e91f3f1d660a3baaf00dce6f05dd1fb3ebf.tar.gz
src-44a03e91f3f1d660a3baaf00dce6f05dd1fb3ebf.zip
Wait for all VFs pages to be reclaimed before closing EQ pages.
MFC after: 1 week Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/head/; revision=312880
Diffstat (limited to 'sys/dev/mlx5')
-rw-r--r--sys/dev/mlx5/driver.h4
-rw-r--r--sys/dev/mlx5/mlx5_core/mlx5_main.c1
-rw-r--r--sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c29
3 files changed, 32 insertions, 2 deletions
diff --git a/sys/dev/mlx5/driver.h b/sys/dev/mlx5/driver.h
index 8063e6eedd2f..b7293defea9a 100644
--- a/sys/dev/mlx5/driver.h
+++ b/sys/dev/mlx5/driver.h
@@ -43,6 +43,7 @@
#include <dev/mlx5/doorbell.h>
#define MLX5_QCOUNTER_SETS_NETDEV 64
+#define MLX5_MAX_NUMBER_OF_VFS 128
enum {
MLX5_BOARD_ID_LEN = 64,
@@ -521,7 +522,7 @@ struct mlx5_priv {
s64 fw_pages;
atomic_t reg_pages;
struct list_head free_list;
-
+ s64 pages_per_func[MLX5_MAX_NUMBER_OF_VFS];
struct mlx5_core_health health;
struct mlx5_srq_table srq_table;
@@ -850,6 +851,7 @@ void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
s32 npages);
int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
+s64 mlx5_wait_for_reclaim_vfs_pages(struct mlx5_core_dev *dev);
void mlx5_register_debugfs(void);
void mlx5_unregister_debugfs(void);
int mlx5_eq_init(struct mlx5_core_dev *dev);
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_main.c b/sys/dev/mlx5/mlx5_core/mlx5_main.c
index 776e2a6a605a..a213f6f328fd 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_main.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_main.c
@@ -853,6 +853,7 @@ static void mlx5_dev_cleanup(struct mlx5_core_dev *dev)
mlx5_cleanup_qp_table(dev);
mlx5_cleanup_cq_table(dev);
unmap_bf_area(dev);
+ mlx5_wait_for_reclaim_vfs_pages(dev);
free_comp_eqs(dev);
mlx5_stop_eqs(dev);
mlx5_free_uuars(dev, &priv->uuari);
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c b/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c
index 15b782ab5bc9..61cbc7d678d6 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c
@@ -27,6 +27,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/delay.h>
#include <dev/mlx5/driver.h>
#include "mlx5_core.h"
@@ -282,6 +283,7 @@ retry:
goto out_alloc;
}
dev->priv.fw_pages += npages;
+ dev->priv.pages_per_func[func_id] += npages;
if (out.hdr.status) {
err = mlx5_cmd_status_to_err(&out.hdr);
@@ -355,7 +357,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
*nclaimed = num_claimed;
dev->priv.fw_pages -= num_claimed;
-
+ dev->priv.pages_per_func[func_id] -= num_claimed;
for (i = 0; i < num_claimed; i++) {
addr = be64_to_cpu(out->pas[i]);
free_4k(dev, addr);
@@ -423,6 +425,31 @@ enum {
MLX5_BLKS_FOR_RECLAIM_PAGES = 12
};
+s64 mlx5_wait_for_reclaim_vfs_pages(struct mlx5_core_dev *dev)
+{
+ int end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS);
+ s64 prevpages = 0;
+ s64 npages = 0;
+
+ while (!time_after(jiffies, end)) {
+ /* exclude own function, VFs only */
+ npages = dev->priv.fw_pages - dev->priv.pages_per_func[0];
+ if (!npages)
+ break;
+
+ if (npages != prevpages)
+ end = end + msecs_to_jiffies(100);
+
+ prevpages = npages;
+ msleep(1);
+ }
+
+ if (npages)
+ mlx5_core_warn(dev, "FW did not return all VFs pages, will cause to memory leak\n");
+
+ return -npages;
+}
+
static int optimal_reclaimed_pages(void)
{
struct mlx5_cmd_prot_block *block;