aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx4/icm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/icm.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/icm.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c
index 88b7b3e75ab1..daf417923661 100644
--- a/drivers/net/ethernet/mellanox/mlx4/icm.c
+++ b/drivers/net/ethernet/mellanox/mlx4/icm.c
@@ -358,13 +358,14 @@ void mlx4_table_put_range(struct mlx4_dev *dev, struct mlx4_icm_table *table,
358} 358}
359 359
360int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, 360int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table,
361 u64 virt, int obj_size, int nobj, int reserved, 361 u64 virt, int obj_size, u32 nobj, int reserved,
362 int use_lowmem, int use_coherent) 362 int use_lowmem, int use_coherent)
363{ 363{
364 int obj_per_chunk; 364 int obj_per_chunk;
365 int num_icm; 365 int num_icm;
366 unsigned chunk_size; 366 unsigned chunk_size;
367 int i; 367 int i;
368 u64 size;
368 369
369 obj_per_chunk = MLX4_TABLE_CHUNK_SIZE / obj_size; 370 obj_per_chunk = MLX4_TABLE_CHUNK_SIZE / obj_size;
370 num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk; 371 num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk;
@@ -380,10 +381,12 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table,
380 table->coherent = use_coherent; 381 table->coherent = use_coherent;
381 mutex_init(&table->mutex); 382 mutex_init(&table->mutex);
382 383
384 size = (u64) nobj * obj_size;
383 for (i = 0; i * MLX4_TABLE_CHUNK_SIZE < reserved * obj_size; ++i) { 385 for (i = 0; i * MLX4_TABLE_CHUNK_SIZE < reserved * obj_size; ++i) {
384 chunk_size = MLX4_TABLE_CHUNK_SIZE; 386 chunk_size = MLX4_TABLE_CHUNK_SIZE;
385 if ((i + 1) * MLX4_TABLE_CHUNK_SIZE > nobj * obj_size) 387 if ((i + 1) * MLX4_TABLE_CHUNK_SIZE > size)
386 chunk_size = PAGE_ALIGN(nobj * obj_size - i * MLX4_TABLE_CHUNK_SIZE); 388 chunk_size = PAGE_ALIGN(size -
389 i * MLX4_TABLE_CHUNK_SIZE);
387 390
388 table->icm[i] = mlx4_alloc_icm(dev, chunk_size >> PAGE_SHIFT, 391 table->icm[i] = mlx4_alloc_icm(dev, chunk_size >> PAGE_SHIFT,
389 (use_lowmem ? GFP_KERNEL : GFP_HIGHUSER) | 392 (use_lowmem ? GFP_KERNEL : GFP_HIGHUSER) |