aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2012-03-05 13:05:28 -0500
committerRoland Dreier <roland@purestorage.com>2012-03-12 19:24:59 -0400
commitdb5a7a65c05867cb6ff5cb6d556a0edfce631d2d (patch)
treefdb7cb84d4ae634303c5337203ce482ae4c83c97 /drivers
parent096335b3f9830b90d13aee77252cf6f5f12a258c (diff)
mlx4_core: Scale size of MTT table with system RAM
The current driver defaults to 1M MTT segments, where each segment holds 8 MTT entries. This limits the total memory registered to 8M * PAGE_SIZE which is 32GB with 4K pages. Since systems that have much more memory are pretty common now (at least among systems with InfiniBand hardware), this limit ends up getting hit in practice quite a bit. Handle this by having the driver allocate at least enough MTT entries to cover 2 * totalram pages. Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/profile.c19
2 files changed, 20 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 1aa362181a09..cb17af4d9abd 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -403,7 +403,7 @@ struct mlx4_profile {
403 int num_cq; 403 int num_cq;
404 int num_mcg; 404 int num_mcg;
405 int num_mpt; 405 int num_mpt;
406 int num_mtt; 406 unsigned num_mtt;
407}; 407};
408 408
409struct mlx4_fw { 409struct mlx4_fw {
diff --git a/drivers/net/ethernet/mellanox/mlx4/profile.c b/drivers/net/ethernet/mellanox/mlx4/profile.c
index 1129677daa62..06e5adeb76f7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/profile.c
+++ b/drivers/net/ethernet/mellanox/mlx4/profile.c
@@ -83,12 +83,31 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
83 u64 total_size = 0; 83 u64 total_size = 0;
84 struct mlx4_resource *profile; 84 struct mlx4_resource *profile;
85 struct mlx4_resource tmp; 85 struct mlx4_resource tmp;
86 struct sysinfo si;
86 int i, j; 87 int i, j;
87 88
88 profile = kcalloc(MLX4_RES_NUM, sizeof(*profile), GFP_KERNEL); 89 profile = kcalloc(MLX4_RES_NUM, sizeof(*profile), GFP_KERNEL);
89 if (!profile) 90 if (!profile)
90 return -ENOMEM; 91 return -ENOMEM;
91 92
93 /*
94 * We want to scale the number of MTTs with the size of the
95 * system memory, since it makes sense to register a lot of
96 * memory on a system with a lot of memory. As a heuristic,
97 * make sure we have enough MTTs to cover twice the system
98 * memory (with PAGE_SIZE entries).
99 *
100 * This number has to be a power of two and fit into 32 bits
101 * due to device limitations, so cap this at 2^31 as well.
102 * That limits us to 8TB of memory registration per HCA with
103 * 4KB pages, which is probably OK for the next few months.
104 */
105 si_meminfo(&si);
106 request->num_mtt =
107 roundup_pow_of_two(max_t(unsigned, request->num_mtt,
108 min(1UL << 31,
109 si.totalram >> (log_mtts_per_seg - 1))));
110
92 profile[MLX4_RES_QP].size = dev_cap->qpc_entry_sz; 111 profile[MLX4_RES_QP].size = dev_cap->qpc_entry_sz;
93 profile[MLX4_RES_RDMARC].size = dev_cap->rdmarc_entry_sz; 112 profile[MLX4_RES_RDMARC].size = dev_cap->rdmarc_entry_sz;
94 profile[MLX4_RES_ALTC].size = dev_cap->altc_entry_sz; 113 profile[MLX4_RES_ALTC].size = dev_cap->altc_entry_sz;