[PATCH 5.10 040/120] net/mlx5: Fix function calculation for page trees

From: Greg Kroah-Hartman
Date: Mon Feb 08 2021 - 12:05:25 EST


From: Daniel Jurgens <danielj@xxxxxxxxxx>

[ Upstream commit ed5e83a3c02948dad9dc4e68fb4e535baa5da630 ]

The function calculation always results in a value of 0. This works
generally, but when the release all pages feature is enabled it will
result in crashes.

Fixes: 0aa128475d33 ("net/mlx5: Maintain separate page trees for ECPF and PF functions")
Signed-off-by: Daniel Jurgens <danielj@xxxxxxxxxx>
Reported-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
Signed-off-by: Saeed Mahameed <saeedm@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
index a3e0c71831928..a44a2bad5bbb5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
@@ -76,7 +76,7 @@ enum {

static u32 get_function(u16 func_id, bool ec_function)
{
- return func_id & (ec_function << 16);
+ return (u32)func_id | (ec_function << 16);
}

static struct rb_root *page_root_per_function(struct mlx5_core_dev *dev, u32 function)
--
2.27.0