Skip to content

Commit cef7dde

Browse files
mikijoyrleon
authored andcommitted
net/mlx5: Expand mkey page size to support 6 bits
Protect the usage of the 6th bit with the relevant capability to ensure we are using the new page sizes with FW that supports the bit extension. Signed-off-by: Michael Guralnik <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent f4ccc0a commit cef7dde

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,6 @@ __mlx5_log_page_size_to_bitmap(unsigned int log_pgsz_bits,
6363
return GENMASK(largest_pg_shift, pgsz_shift);
6464
}
6565

66-
/*
67-
* For mkc users, instead of a page_offset the command has a start_iova which
68-
* specifies both the page_offset and the on-the-wire IOVA
69-
*/
70-
#define mlx5_umem_find_best_pgsz(umem, typ, log_pgsz_fld, pgsz_shift, iova) \
71-
ib_umem_find_best_pgsz(umem, \
72-
__mlx5_log_page_size_to_bitmap( \
73-
__mlx5_bit_sz(typ, log_pgsz_fld), \
74-
pgsz_shift), \
75-
iova)
76-
7766
static __always_inline unsigned long
7867
__mlx5_page_offset_to_bitmask(unsigned int page_offset_bits,
7968
unsigned int offset_shift)
@@ -1724,4 +1713,20 @@ static inline u32 smi_to_native_portnum(struct mlx5_ib_dev *dev, u32 port)
17241713
return (port - 1) / dev->num_ports + 1;
17251714
}
17261715

1716+
/*
1717+
* For mkc users, instead of a page_offset the command has a start_iova which
1718+
* specifies both the page_offset and the on-the-wire IOVA
1719+
*/
1720+
static __always_inline unsigned long
1721+
mlx5_umem_mkc_find_best_pgsz(struct mlx5_ib_dev *dev, struct ib_umem *umem,
1722+
u64 iova)
1723+
{
1724+
int page_size_bits =
1725+
MLX5_CAP_GEN_2(dev->mdev, umr_log_entity_size_5) ? 6 : 5;
1726+
unsigned long bitmap =
1727+
__mlx5_log_page_size_to_bitmap(page_size_bits, 0);
1728+
1729+
return ib_umem_find_best_pgsz(umem, bitmap, iova);
1730+
}
1731+
17271732
#endif /* MLX5_IB_H */

drivers/infiniband/hw/mlx5/mr.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,8 +1120,7 @@ static struct mlx5_ib_mr *alloc_cacheable_mr(struct ib_pd *pd,
11201120
if (umem->is_dmabuf)
11211121
page_size = mlx5_umem_dmabuf_default_pgsz(umem, iova);
11221122
else
1123-
page_size = mlx5_umem_find_best_pgsz(umem, mkc, log_page_size,
1124-
0, iova);
1123+
page_size = mlx5_umem_mkc_find_best_pgsz(dev, umem, iova);
11251124
if (WARN_ON(!page_size))
11261125
return ERR_PTR(-EINVAL);
11271126

@@ -1426,8 +1425,8 @@ static struct ib_mr *create_real_mr(struct ib_pd *pd, struct ib_umem *umem,
14261425
mr = alloc_cacheable_mr(pd, umem, iova, access_flags,
14271426
MLX5_MKC_ACCESS_MODE_MTT);
14281427
} else {
1429-
unsigned int page_size = mlx5_umem_find_best_pgsz(
1430-
umem, mkc, log_page_size, 0, iova);
1428+
unsigned int page_size =
1429+
mlx5_umem_mkc_find_best_pgsz(dev, umem, iova);
14311430

14321431
mutex_lock(&dev->slow_path_mutex);
14331432
mr = reg_create(pd, umem, iova, access_flags, page_size,
@@ -1745,8 +1744,7 @@ static bool can_use_umr_rereg_pas(struct mlx5_ib_mr *mr,
17451744
if (!mlx5r_umr_can_load_pas(dev, new_umem->length))
17461745
return false;
17471746

1748-
*page_size =
1749-
mlx5_umem_find_best_pgsz(new_umem, mkc, log_page_size, 0, iova);
1747+
*page_size = mlx5_umem_mkc_find_best_pgsz(dev, new_umem, iova);
17501748
if (WARN_ON(!*page_size))
17511749
return false;
17521750
return (mr->mmkey.cache_ent->rb_key.ndescs) >=

drivers/infiniband/hw/mlx5/odp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static int pagefault_dmabuf_mr(struct mlx5_ib_mr *mr, size_t bcnt,
693693
struct ib_umem_dmabuf *umem_dmabuf = to_ib_umem_dmabuf(mr->umem);
694694
u32 xlt_flags = 0;
695695
int err;
696-
unsigned int page_size;
696+
unsigned long page_size;
697697

698698
if (flags & MLX5_PF_FLAGS_ENABLE)
699699
xlt_flags |= MLX5_IB_UPD_XLT_ENABLE;

include/linux/mlx5/mlx5_ifc.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,9 @@ struct mlx5_ifc_cmd_hca_cap_2_bits {
19881988
u8 migratable[0x1];
19891989
u8 reserved_at_81[0x11];
19901990
u8 query_vuid[0x1];
1991-
u8 reserved_at_93[0xd];
1991+
u8 reserved_at_93[0x5];
1992+
u8 umr_log_entity_size_5[0x1];
1993+
u8 reserved_at_99[0x7];
19921994

19931995
u8 max_reformat_insert_size[0x8];
19941996
u8 max_reformat_insert_offset[0x8];
@@ -4212,8 +4214,7 @@ struct mlx5_ifc_mkc_bits {
42124214

42134215
u8 reserved_at_1c0[0x19];
42144216
u8 relaxed_ordering_read[0x1];
4215-
u8 reserved_at_1d9[0x1];
4216-
u8 log_page_size[0x5];
4217+
u8 log_page_size[0x6];
42174218

42184219
u8 reserved_at_1e0[0x20];
42194220
};

0 commit comments

Comments
 (0)