]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mlx4_core: log_num_mtt handling
authorYishai Hadas <yishaih@mellanox.com>
Thu, 15 Nov 2012 15:47:11 +0000 (17:47 +0200)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 7 Jul 2015 21:38:08 +0000 (14:38 -0700)
Fixed a bug when calculating based on system RAM size
limit of 25 was fixed - was set to 28

V2: adjusted for rebase to kernel 3.7-rc4.
In this kernel, part of the patch appears as commit 89dd86d

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
(Ported from Mellanox OFED 2.4)

Signed-off-by: Mukesh Kacker <mukesh.kacker@oracle.com>
drivers/net/ethernet/mellanox/mlx4/main.c

index 7622ffd1fa874bd92826646061300175595aae68..481978f288a23acc6779348c34c0be5ec88b0910 100644 (file)
@@ -160,6 +160,10 @@ struct mlx4_port_config {
 static atomic_t pf_loading = ATOMIC_INIT(0);
 
 #define MLX4_LOG_NUM_MTT 20
+/* When a higher value than 28 is used we get a failure via initializing
+     the event queue table.
+*/
+#define MLX4_MAX_LOG_NUM_MTT 28
 static struct mlx4_profile mod_param_profile = {
        .num_qp         = 18,
        .num_srq        = 16,
@@ -226,9 +230,11 @@ static void process_mod_param_profile(struct mlx4_profile *profile)
        else {
                si_meminfo(&si);
                profile->num_mtt =
-                       roundup_pow_of_two(max_t(unsigned, 1 << MLX4_LOG_NUM_MTT,
-                                                min(1UL << 31,
-                                                    si.totalram >> (log_mtts_per_seg - 1))));
+                       roundup_pow_of_two(max_t(unsigned,
+                                               1 << MLX4_LOG_NUM_MTT,
+                                               min(1UL << MLX4_MAX_LOG_NUM_MTT,
+                                               (si.totalram << 1)
+                                               >> log_mtts_per_seg)));
        }
 }
 
@@ -3811,6 +3817,11 @@ static int __init mlx4_verify_params(void)
                return -1;
        }
 
+       if (mod_param_profile.num_mtt > MLX4_MAX_LOG_NUM_MTT) {
+               pr_warning("mlx4_core: too high log_num_mtt: %d\n",
+                          mod_param_profile.num_mtt);
+               return -1;
+       }
        return 0;
 }