]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mlx4_core: change resource quotas to enable supporting upstream-kernel guests
authorJack Morgenstein <jackm@dev.mellanox.co.il>
Mon, 18 Feb 2013 10:34:59 +0000 (12:34 +0200)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 7 Jul 2015 21:45:08 +0000 (14:45 -0700)
The resource-quota code passed non-power-of-2 quotas to guests.
In the upstream kernel (bugs), resource quotas for MPTs and QPs
are assumed to be powers-of-2. In MPT case, mlx4_init_mr_table
checks for num_mpts being a power-of-2 before checking if it
is running as a slave.

In the QP case, procedure mlx4_qp_alloc() assumes that
(num_qps - 1) is a power-of-2 when calling radix_tree_insert()
and radix_tree_delete().

In the MPT case, mlx4_init_mr_table() failed on the guest,
causing abort of the guest driver bringup.

In the QP case, although create-qp succeeded on the
hypervisor, the radix_tree_insert() call failed, resulting
in failure to create QPs with certain qp numbers.

The fix, for both cases, is to round-up the quota to the
next power-of-2 for guests for MPTs and QPs.  This does no
harm, as these two resources were not really meant to be
limited by an upper quota.  The guaranteed resources for QPs
and MPTs per VF/PF are not affected by this change.
The only effect is that no guest will ever be able to
actually reach its max-quota for QPs and MPTs.

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/resource_tracker.c

index bafe2180cf0c413c4d971f8043e401a018dc8100..ec431c92822886d50850a8be3d1ca5dd9487d4b8 100644 (file)
@@ -417,6 +417,11 @@ static inline void initialize_res_quotas(struct mlx4_dev *dev,
        res_alloc->guaranteed[vf] = num_instances /
                                    (2 * (dev->persist->num_vfs + 1));
        res_alloc->quota[vf] = (num_instances / 2) + res_alloc->guaranteed[vf];
+
+       /* upstream kernel code required that num_mpts and num_qps be power-of-2 */
+       if (res_type == RES_MPT || res_type == RES_QP)
+               res_alloc->quota[vf] = roundup_pow_of_two(res_alloc->quota[vf]);
+
        if (vf == mlx4_master_func_num(dev)) {
                res_alloc->res_free = num_instances;
                if (res_type == RES_MTT) {