| .. | .. |
|---|
| 34 | 34 | #include <linux/module.h> |
|---|
| 35 | 35 | #include <linux/io-mapping.h> |
|---|
| 36 | 36 | #include <linux/mlx5/driver.h> |
|---|
| 37 | | -#include <linux/mlx5/cmd.h> |
|---|
| 38 | 37 | #include "mlx5_core.h" |
|---|
| 39 | 38 | |
|---|
| 40 | 39 | int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn) |
|---|
| 41 | 40 | { |
|---|
| 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)] = {}; |
|---|
| 44 | 43 | int err; |
|---|
| 45 | 44 | |
|---|
| 46 | 45 | 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); |
|---|
| 48 | 47 | if (!err) |
|---|
| 49 | 48 | *uarn = MLX5_GET(alloc_uar_out, out, uar); |
|---|
| 50 | 49 | return err; |
|---|
| .. | .. |
|---|
| 53 | 52 | |
|---|
| 54 | 53 | int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn) |
|---|
| 55 | 54 | { |
|---|
| 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)] = {}; |
|---|
| 58 | 56 | |
|---|
| 59 | 57 | MLX5_SET(dealloc_uar_in, in, opcode, MLX5_CMD_OP_DEALLOC_UAR); |
|---|
| 60 | 58 | 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); |
|---|
| 62 | 60 | } |
|---|
| 63 | 61 | EXPORT_SYMBOL(mlx5_cmd_free_uar); |
|---|
| 64 | 62 | |
|---|
| .. | .. |
|---|
| 79 | 77 | else |
|---|
| 80 | 78 | system_page_index = index; |
|---|
| 81 | 79 | |
|---|
| 82 | | - return (pci_resource_start(mdev->pdev, 0) >> PAGE_SHIFT) + system_page_index; |
|---|
| 80 | + return (mdev->bar_addr >> PAGE_SHIFT) + system_page_index; |
|---|
| 83 | 81 | } |
|---|
| 84 | 82 | |
|---|
| 85 | 83 | static void up_rel_func(struct kref *kref) |
|---|
| .. | .. |
|---|
| 90 | 88 | iounmap(up->map); |
|---|
| 91 | 89 | if (mlx5_cmd_free_uar(up->mdev, up->index)) |
|---|
| 92 | 90 | 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); |
|---|
| 95 | 93 | kfree(up); |
|---|
| 96 | 94 | } |
|---|
| 97 | 95 | |
|---|
| .. | .. |
|---|
| 110 | 108 | return ERR_PTR(err); |
|---|
| 111 | 109 | |
|---|
| 112 | 110 | 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); |
|---|
| 114 | 112 | if (!up->reg_bitmap) |
|---|
| 115 | 113 | goto error1; |
|---|
| 116 | 114 | |
|---|
| 117 | | - up->fp_bitmap = kcalloc(BITS_TO_LONGS(bfregs), sizeof(unsigned long), GFP_KERNEL); |
|---|
| 115 | + up->fp_bitmap = bitmap_zalloc(bfregs, GFP_KERNEL); |
|---|
| 118 | 116 | if (!up->fp_bitmap) |
|---|
| 119 | 117 | goto error1; |
|---|
| 120 | 118 | |
|---|
| .. | .. |
|---|
| 157 | 155 | if (mlx5_cmd_free_uar(mdev, up->index)) |
|---|
| 158 | 156 | mlx5_core_warn(mdev, "failed to free uar index %d\n", up->index); |
|---|
| 159 | 157 | error1: |
|---|
| 160 | | - kfree(up->fp_bitmap); |
|---|
| 161 | | - kfree(up->reg_bitmap); |
|---|
| 158 | + bitmap_free(up->fp_bitmap); |
|---|
| 159 | + bitmap_free(up->reg_bitmap); |
|---|
| 162 | 160 | kfree(up); |
|---|
| 163 | 161 | return ERR_PTR(err); |
|---|
| 164 | 162 | } |
|---|