forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/mellanox/mlx5/core/uar.c
....@@ -34,17 +34,16 @@
3434 #include <linux/module.h>
3535 #include <linux/io-mapping.h>
3636 #include <linux/mlx5/driver.h>
37
-#include <linux/mlx5/cmd.h>
3837 #include "mlx5_core.h"
3938
4039 int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn)
4140 {
42
- u32 out[MLX5_ST_SZ_DW(alloc_uar_out)] = {0};
43
- u32 in[MLX5_ST_SZ_DW(alloc_uar_in)] = {0};
41
+ u32 out[MLX5_ST_SZ_DW(alloc_uar_out)] = {};
42
+ u32 in[MLX5_ST_SZ_DW(alloc_uar_in)] = {};
4443 int err;
4544
4645 MLX5_SET(alloc_uar_in, in, opcode, MLX5_CMD_OP_ALLOC_UAR);
47
- err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
46
+ err = mlx5_cmd_exec_inout(dev, alloc_uar, in, out);
4847 if (!err)
4948 *uarn = MLX5_GET(alloc_uar_out, out, uar);
5049 return err;
....@@ -53,12 +52,11 @@
5352
5453 int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn)
5554 {
56
- u32 out[MLX5_ST_SZ_DW(dealloc_uar_out)] = {0};
57
- u32 in[MLX5_ST_SZ_DW(dealloc_uar_in)] = {0};
55
+ u32 in[MLX5_ST_SZ_DW(dealloc_uar_in)] = {};
5856
5957 MLX5_SET(dealloc_uar_in, in, opcode, MLX5_CMD_OP_DEALLOC_UAR);
6058 MLX5_SET(dealloc_uar_in, in, uar, uarn);
61
- return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
59
+ return mlx5_cmd_exec_in(dev, dealloc_uar, in);
6260 }
6361 EXPORT_SYMBOL(mlx5_cmd_free_uar);
6462
....@@ -79,7 +77,7 @@
7977 else
8078 system_page_index = index;
8179
82
- return (pci_resource_start(mdev->pdev, 0) >> PAGE_SHIFT) + system_page_index;
80
+ return (mdev->bar_addr >> PAGE_SHIFT) + system_page_index;
8381 }
8482
8583 static void up_rel_func(struct kref *kref)
....@@ -90,8 +88,8 @@
9088 iounmap(up->map);
9189 if (mlx5_cmd_free_uar(up->mdev, up->index))
9290 mlx5_core_warn(up->mdev, "failed to free uar index %d\n", up->index);
93
- kfree(up->reg_bitmap);
94
- kfree(up->fp_bitmap);
91
+ bitmap_free(up->reg_bitmap);
92
+ bitmap_free(up->fp_bitmap);
9593 kfree(up);
9694 }
9795
....@@ -110,11 +108,11 @@
110108 return ERR_PTR(err);
111109
112110 up->mdev = mdev;
113
- up->reg_bitmap = kcalloc(BITS_TO_LONGS(bfregs), sizeof(unsigned long), GFP_KERNEL);
111
+ up->reg_bitmap = bitmap_zalloc(bfregs, GFP_KERNEL);
114112 if (!up->reg_bitmap)
115113 goto error1;
116114
117
- up->fp_bitmap = kcalloc(BITS_TO_LONGS(bfregs), sizeof(unsigned long), GFP_KERNEL);
115
+ up->fp_bitmap = bitmap_zalloc(bfregs, GFP_KERNEL);
118116 if (!up->fp_bitmap)
119117 goto error1;
120118
....@@ -157,8 +155,8 @@
157155 if (mlx5_cmd_free_uar(mdev, up->index))
158156 mlx5_core_warn(mdev, "failed to free uar index %d\n", up->index);
159157 error1:
160
- kfree(up->fp_bitmap);
161
- kfree(up->reg_bitmap);
158
+ bitmap_free(up->fp_bitmap);
159
+ bitmap_free(up->reg_bitmap);
162160 kfree(up);
163161 return ERR_PTR(err);
164162 }