Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit e13cd45

Browse files
elic307imstsirkin
authored andcommitted
vdpa/mlx5: Support creating resources with uid == 0
Currently all resources must be created with uid != 0 which is essential when userspace processes are allocating virtquueue resources. Since this is a kernel implementation, it is perfectly legal to open resources with uid == 0. In case firmware supports, avoid allocating user context. Signed-off-by: Eli Cohen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 71ab6a7 commit e13cd45

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

drivers/vdpa/mlx5/core/resources.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ static int create_uctx(struct mlx5_vdpa_dev *mvdev, u16 *uid)
5454
void *in;
5555
int err;
5656

57+
if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0))
58+
return 0;
59+
5760
/* 0 means not supported */
5861
if (!MLX5_CAP_GEN(mvdev->mdev, log_max_uctx))
5962
return -EOPNOTSUPP;
@@ -79,6 +82,9 @@ static void destroy_uctx(struct mlx5_vdpa_dev *mvdev, u32 uid)
7982
u32 out[MLX5_ST_SZ_DW(destroy_uctx_out)] = {};
8083
u32 in[MLX5_ST_SZ_DW(destroy_uctx_in)] = {};
8184

85+
if (!uid)
86+
return;
87+
8288
MLX5_SET(destroy_uctx_in, in, opcode, MLX5_CMD_OP_DESTROY_UCTX);
8389
MLX5_SET(destroy_uctx_in, in, uid, uid);
8490

include/linux/mlx5/mlx5_ifc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
15121512
u8 uar_4k[0x1];
15131513
u8 reserved_at_241[0x9];
15141514
u8 uar_sz[0x6];
1515-
u8 reserved_at_250[0x8];
1515+
u8 reserved_at_248[0x2];
1516+
u8 umem_uid_0[0x1];
1517+
u8 reserved_at_250[0x5];
15161518
u8 log_pg_sz[0x8];
15171519

15181520
u8 bf[0x1];

0 commit comments

Comments
 (0)