Lines Matching full:chunk
47 * per chunk. Note that the chunks are not necessarily in contiguous
55 static void mlx4_free_icm_pages(struct mlx4_dev *dev, struct mlx4_icm_chunk *chunk) in mlx4_free_icm_pages() argument
59 if (chunk->nsg > 0) in mlx4_free_icm_pages()
60 dma_unmap_sg(&dev->persist->pdev->dev, chunk->sg, chunk->npages, in mlx4_free_icm_pages()
63 for (i = 0; i < chunk->npages; ++i) in mlx4_free_icm_pages()
64 __free_pages(sg_page(&chunk->sg[i]), in mlx4_free_icm_pages()
65 get_order(chunk->sg[i].length)); in mlx4_free_icm_pages()
68 static void mlx4_free_icm_coherent(struct mlx4_dev *dev, struct mlx4_icm_chunk *chunk) in mlx4_free_icm_coherent() argument
72 for (i = 0; i < chunk->npages; ++i) in mlx4_free_icm_coherent()
74 chunk->buf[i].size, in mlx4_free_icm_coherent()
75 chunk->buf[i].addr, in mlx4_free_icm_coherent()
76 chunk->buf[i].dma_addr); in mlx4_free_icm_coherent()
81 struct mlx4_icm_chunk *chunk, *tmp; in mlx4_free_icm() local
86 list_for_each_entry_safe(chunk, tmp, &icm->chunk_list, list) { in mlx4_free_icm()
88 mlx4_free_icm_coherent(dev, chunk); in mlx4_free_icm()
90 mlx4_free_icm_pages(dev, chunk); in mlx4_free_icm()
92 kfree(chunk); in mlx4_free_icm()
136 struct mlx4_icm_chunk *chunk = NULL; in mlx4_alloc_icm() local
160 if (!chunk) { in mlx4_alloc_icm()
161 chunk = kzalloc_node(sizeof(*chunk), in mlx4_alloc_icm()
165 if (!chunk) { in mlx4_alloc_icm()
166 chunk = kzalloc(sizeof(*chunk), in mlx4_alloc_icm()
169 if (!chunk) in mlx4_alloc_icm()
172 chunk->coherent = coherent; in mlx4_alloc_icm()
175 sg_init_table(chunk->sg, MLX4_ICM_CHUNK_LEN); in mlx4_alloc_icm()
176 list_add_tail(&chunk->list, &icm->chunk_list); in mlx4_alloc_icm()
188 &chunk->buf[chunk->npages], in mlx4_alloc_icm()
191 ret = mlx4_alloc_icm_pages(&chunk->sg[chunk->npages], in mlx4_alloc_icm()
202 ++chunk->npages; in mlx4_alloc_icm()
205 ++chunk->nsg; in mlx4_alloc_icm()
206 else if (chunk->npages == MLX4_ICM_CHUNK_LEN) { in mlx4_alloc_icm()
207 chunk->nsg = dma_map_sg(&dev->persist->pdev->dev, in mlx4_alloc_icm()
208 chunk->sg, chunk->npages, in mlx4_alloc_icm()
211 if (!chunk->nsg) in mlx4_alloc_icm()
215 if (chunk->npages == MLX4_ICM_CHUNK_LEN) in mlx4_alloc_icm()
216 chunk = NULL; in mlx4_alloc_icm()
221 if (!coherent && chunk) { in mlx4_alloc_icm()
222 chunk->nsg = dma_map_sg(&dev->persist->pdev->dev, chunk->sg, in mlx4_alloc_icm()
223 chunk->npages, DMA_BIDIRECTIONAL); in mlx4_alloc_icm()
225 if (!chunk->nsg) in mlx4_alloc_icm()
319 struct mlx4_icm_chunk *chunk; in mlx4_table_find() local
335 list_for_each_entry(chunk, &icm->chunk_list, list) { in mlx4_table_find()
336 for (i = 0; i < chunk->npages; ++i) { in mlx4_table_find()
341 len = chunk->buf[i].size; in mlx4_table_find()
342 dma_addr = chunk->buf[i].dma_addr; in mlx4_table_find()
343 addr = chunk->buf[i].addr; in mlx4_table_find()
347 len = sg_dma_len(&chunk->sg[i]); in mlx4_table_find()
348 dma_addr = sg_dma_address(&chunk->sg[i]); in mlx4_table_find()
355 page = sg_page(&chunk->sg[i]); in mlx4_table_find()
460 * Add a reference to this ICM chunk so that it never in mlx4_init_icm_table()