Lines Matching refs:table
258 int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj) in mlx4_table_get() argument
260 u32 i = (obj & (table->num_obj - 1)) / in mlx4_table_get()
261 (MLX4_TABLE_CHUNK_SIZE / table->obj_size); in mlx4_table_get()
264 mutex_lock(&table->mutex); in mlx4_table_get()
266 if (table->icm[i]) { in mlx4_table_get()
267 ++table->icm[i]->refcount; in mlx4_table_get()
271 table->icm[i] = mlx4_alloc_icm(dev, MLX4_TABLE_CHUNK_SIZE >> PAGE_SHIFT, in mlx4_table_get()
272 (table->lowmem ? GFP_KERNEL : GFP_HIGHUSER) | in mlx4_table_get()
273 __GFP_NOWARN, table->coherent); in mlx4_table_get()
274 if (!table->icm[i]) { in mlx4_table_get()
279 if (mlx4_MAP_ICM(dev, table->icm[i], table->virt + in mlx4_table_get()
281 mlx4_free_icm(dev, table->icm[i], table->coherent); in mlx4_table_get()
282 table->icm[i] = NULL; in mlx4_table_get()
287 ++table->icm[i]->refcount; in mlx4_table_get()
290 mutex_unlock(&table->mutex); in mlx4_table_get()
294 void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj) in mlx4_table_put() argument
299 i = (obj & (table->num_obj - 1)) / (MLX4_TABLE_CHUNK_SIZE / table->obj_size); in mlx4_table_put()
301 mutex_lock(&table->mutex); in mlx4_table_put()
303 if (--table->icm[i]->refcount == 0) { in mlx4_table_put()
305 mlx4_UNMAP_ICM(dev, table->virt + offset, in mlx4_table_put()
307 mlx4_free_icm(dev, table->icm[i], table->coherent); in mlx4_table_put()
308 table->icm[i] = NULL; in mlx4_table_put()
311 mutex_unlock(&table->mutex); in mlx4_table_put()
314 void *mlx4_table_find(struct mlx4_icm_table *table, u32 obj, in mlx4_table_find() argument
323 if (!table->lowmem) in mlx4_table_find()
326 mutex_lock(&table->mutex); in mlx4_table_find()
328 idx = (u64) (obj & (table->num_obj - 1)) * table->obj_size; in mlx4_table_find()
329 icm = table->icm[idx / MLX4_TABLE_CHUNK_SIZE]; in mlx4_table_find()
340 if (table->coherent) { in mlx4_table_find()
378 mutex_unlock(&table->mutex); in mlx4_table_find()
382 int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, in mlx4_table_get_range() argument
385 int inc = MLX4_TABLE_CHUNK_SIZE / table->obj_size; in mlx4_table_get_range()
390 err = mlx4_table_get(dev, table, i); in mlx4_table_get_range()
400 mlx4_table_put(dev, table, i); in mlx4_table_get_range()
406 void mlx4_table_put_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, in mlx4_table_put_range() argument
411 for (i = start; i <= end; i += MLX4_TABLE_CHUNK_SIZE / table->obj_size) in mlx4_table_put_range()
412 mlx4_table_put(dev, table, i); in mlx4_table_put_range()
415 int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, in mlx4_init_icm_table() argument
430 table->icm = kvcalloc(num_icm, sizeof(*table->icm), GFP_KERNEL); in mlx4_init_icm_table()
431 if (!table->icm) in mlx4_init_icm_table()
433 table->virt = virt; in mlx4_init_icm_table()
434 table->num_icm = num_icm; in mlx4_init_icm_table()
435 table->num_obj = nobj; in mlx4_init_icm_table()
436 table->obj_size = obj_size; in mlx4_init_icm_table()
437 table->lowmem = use_lowmem; in mlx4_init_icm_table()
438 table->coherent = use_coherent; in mlx4_init_icm_table()
439 mutex_init(&table->mutex); in mlx4_init_icm_table()
448 table->icm[i] = mlx4_alloc_icm(dev, chunk_size >> PAGE_SHIFT, in mlx4_init_icm_table()
451 if (!table->icm[i]) in mlx4_init_icm_table()
453 if (mlx4_MAP_ICM(dev, table->icm[i], virt + i * MLX4_TABLE_CHUNK_SIZE)) { in mlx4_init_icm_table()
454 mlx4_free_icm(dev, table->icm[i], use_coherent); in mlx4_init_icm_table()
455 table->icm[i] = NULL; in mlx4_init_icm_table()
463 ++table->icm[i]->refcount; in mlx4_init_icm_table()
470 if (table->icm[i]) { in mlx4_init_icm_table()
473 mlx4_free_icm(dev, table->icm[i], use_coherent); in mlx4_init_icm_table()
476 kvfree(table->icm); in mlx4_init_icm_table()
481 void mlx4_cleanup_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table) in mlx4_cleanup_icm_table() argument
485 for (i = 0; i < table->num_icm; ++i) in mlx4_cleanup_icm_table()
486 if (table->icm[i]) { in mlx4_cleanup_icm_table()
487 mlx4_UNMAP_ICM(dev, table->virt + i * MLX4_TABLE_CHUNK_SIZE, in mlx4_cleanup_icm_table()
489 mlx4_free_icm(dev, table->icm[i], table->coherent); in mlx4_cleanup_icm_table()
492 kvfree(table->icm); in mlx4_cleanup_icm_table()