• Home
  • Raw
  • Download

Lines Matching refs:table

254 int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj,  in mlx4_table_get()  argument
257 u32 i = (obj & (table->num_obj - 1)) / in mlx4_table_get()
258 (MLX4_TABLE_CHUNK_SIZE / table->obj_size); in mlx4_table_get()
261 mutex_lock(&table->mutex); in mlx4_table_get()
263 if (table->icm[i]) { in mlx4_table_get()
264 ++table->icm[i]->refcount; in mlx4_table_get()
268 table->icm[i] = mlx4_alloc_icm(dev, MLX4_TABLE_CHUNK_SIZE >> PAGE_SHIFT, in mlx4_table_get()
269 (table->lowmem ? gfp : GFP_HIGHUSER) | in mlx4_table_get()
270 __GFP_NOWARN, table->coherent); in mlx4_table_get()
271 if (!table->icm[i]) { in mlx4_table_get()
276 if (mlx4_MAP_ICM(dev, table->icm[i], table->virt + in mlx4_table_get()
278 mlx4_free_icm(dev, table->icm[i], table->coherent); in mlx4_table_get()
279 table->icm[i] = NULL; in mlx4_table_get()
284 ++table->icm[i]->refcount; in mlx4_table_get()
287 mutex_unlock(&table->mutex); in mlx4_table_get()
291 void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj) in mlx4_table_put() argument
296 i = (obj & (table->num_obj - 1)) / (MLX4_TABLE_CHUNK_SIZE / table->obj_size); in mlx4_table_put()
298 mutex_lock(&table->mutex); in mlx4_table_put()
300 if (--table->icm[i]->refcount == 0) { in mlx4_table_put()
302 mlx4_UNMAP_ICM(dev, table->virt + offset, in mlx4_table_put()
304 mlx4_free_icm(dev, table->icm[i], table->coherent); in mlx4_table_put()
305 table->icm[i] = NULL; in mlx4_table_put()
308 mutex_unlock(&table->mutex); in mlx4_table_put()
311 void *mlx4_table_find(struct mlx4_icm_table *table, u32 obj, in mlx4_table_find() argument
320 if (!table->lowmem) in mlx4_table_find()
323 mutex_lock(&table->mutex); in mlx4_table_find()
325 idx = (u64) (obj & (table->num_obj - 1)) * table->obj_size; in mlx4_table_find()
326 icm = table->icm[idx / MLX4_TABLE_CHUNK_SIZE]; in mlx4_table_find()
354 mutex_unlock(&table->mutex); in mlx4_table_find()
358 int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, in mlx4_table_get_range() argument
361 int inc = MLX4_TABLE_CHUNK_SIZE / table->obj_size; in mlx4_table_get_range()
366 err = mlx4_table_get(dev, table, i, GFP_KERNEL); in mlx4_table_get_range()
376 mlx4_table_put(dev, table, i); in mlx4_table_get_range()
382 void mlx4_table_put_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, in mlx4_table_put_range() argument
387 for (i = start; i <= end; i += MLX4_TABLE_CHUNK_SIZE / table->obj_size) in mlx4_table_put_range()
388 mlx4_table_put(dev, table, i); in mlx4_table_put_range()
391 int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, in mlx4_init_icm_table() argument
404 table->icm = kcalloc(num_icm, sizeof *table->icm, GFP_KERNEL); in mlx4_init_icm_table()
405 if (!table->icm) in mlx4_init_icm_table()
407 table->virt = virt; in mlx4_init_icm_table()
408 table->num_icm = num_icm; in mlx4_init_icm_table()
409 table->num_obj = nobj; in mlx4_init_icm_table()
410 table->obj_size = obj_size; in mlx4_init_icm_table()
411 table->lowmem = use_lowmem; in mlx4_init_icm_table()
412 table->coherent = use_coherent; in mlx4_init_icm_table()
413 mutex_init(&table->mutex); in mlx4_init_icm_table()
422 table->icm[i] = mlx4_alloc_icm(dev, chunk_size >> PAGE_SHIFT, in mlx4_init_icm_table()
425 if (!table->icm[i]) in mlx4_init_icm_table()
427 if (mlx4_MAP_ICM(dev, table->icm[i], virt + i * MLX4_TABLE_CHUNK_SIZE)) { in mlx4_init_icm_table()
428 mlx4_free_icm(dev, table->icm[i], use_coherent); in mlx4_init_icm_table()
429 table->icm[i] = NULL; in mlx4_init_icm_table()
437 ++table->icm[i]->refcount; in mlx4_init_icm_table()
444 if (table->icm[i]) { in mlx4_init_icm_table()
447 mlx4_free_icm(dev, table->icm[i], use_coherent); in mlx4_init_icm_table()
450 kfree(table->icm); in mlx4_init_icm_table()
455 void mlx4_cleanup_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table) in mlx4_cleanup_icm_table() argument
459 for (i = 0; i < table->num_icm; ++i) in mlx4_cleanup_icm_table()
460 if (table->icm[i]) { in mlx4_cleanup_icm_table()
461 mlx4_UNMAP_ICM(dev, table->virt + i * MLX4_TABLE_CHUNK_SIZE, in mlx4_cleanup_icm_table()
463 mlx4_free_icm(dev, table->icm[i], table->coherent); in mlx4_cleanup_icm_table()
466 kfree(table->icm); in mlx4_cleanup_icm_table()