]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
mlx4_core: Reserve the correct number of MTT segments
authorRoland Dreier <rolandd@cisco.com>
Wed, 10 Oct 2007 02:59:16 +0000 (19:59 -0700)
committerRoland Dreier <rolandd@cisco.com>
Wed, 10 Oct 2007 02:59:16 +0000 (19:59 -0700)
Taking ilog2(dev->caps.reserved_mtts) to find out the order to pass to
the MTT buddy allocator will do the wrong thing if reserved_mtts is ever
not a power of 2.  Be safe and use fls(dev->caps.reserved_mtts - 1).

Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/net/mlx4/mr.c

index 5b87183e62ce47c292f2b95234d5d4896369503d..60a6ee27cfd49f927acf16d75d4e0fe9ad8317a5 100644 (file)
@@ -444,7 +444,7 @@ int __devinit mlx4_init_mr_table(struct mlx4_dev *dev)
                goto err_buddy;
 
        if (dev->caps.reserved_mtts) {
-               if (mlx4_alloc_mtt_range(dev, ilog2(dev->caps.reserved_mtts)) == -1) {
+               if (mlx4_alloc_mtt_range(dev, fls(dev->caps.reserved_mtts - 1)) == -1) {
                        mlx4_warn(dev, "MTT table of order %d is too small.\n",
                                  mr_table->mtt_buddy.max_order);
                        err = -ENOMEM;