Lines Matching refs:uar

145 int mlx4_uar_alloc(struct mlx4_dev *dev, struct mlx4_uar *uar)  in mlx4_uar_alloc()  argument
149 uar->index = mlx4_bitmap_alloc(&mlx4_priv(dev)->uar_table.bitmap); in mlx4_uar_alloc()
150 if (uar->index == -1) in mlx4_uar_alloc()
154 offset = uar->index % ((int)pci_resource_len(dev->persist->pdev, in mlx4_uar_alloc()
158 offset = uar->index; in mlx4_uar_alloc()
159 uar->pfn = (pci_resource_start(dev->persist->pdev, 2) >> PAGE_SHIFT) in mlx4_uar_alloc()
161 uar->map = NULL; in mlx4_uar_alloc()
166 void mlx4_uar_free(struct mlx4_dev *dev, struct mlx4_uar *uar) in mlx4_uar_free() argument
168 mlx4_bitmap_free(&mlx4_priv(dev)->uar_table.bitmap, uar->index, MLX4_USE_RR); in mlx4_uar_free()
175 struct mlx4_uar *uar; in mlx4_bf_alloc() local
184 uar = list_entry(priv->bf_list.next, struct mlx4_uar, bf_list); in mlx4_bf_alloc()
190 uar = kmalloc_node(sizeof(*uar), GFP_KERNEL, node); in mlx4_bf_alloc()
191 if (!uar) { in mlx4_bf_alloc()
192 uar = kmalloc(sizeof(*uar), GFP_KERNEL); in mlx4_bf_alloc()
193 if (!uar) { in mlx4_bf_alloc()
198 err = mlx4_uar_alloc(dev, uar); in mlx4_bf_alloc()
202 uar->map = ioremap(uar->pfn << PAGE_SHIFT, PAGE_SIZE); in mlx4_bf_alloc()
203 if (!uar->map) { in mlx4_bf_alloc()
208 uar->bf_map = io_mapping_map_wc(priv->bf_mapping, in mlx4_bf_alloc()
209 uar->index << PAGE_SHIFT, in mlx4_bf_alloc()
211 if (!uar->bf_map) { in mlx4_bf_alloc()
215 uar->free_bf_bmap = 0; in mlx4_bf_alloc()
216 list_add(&uar->bf_list, &priv->bf_list); in mlx4_bf_alloc()
219 idx = ffz(uar->free_bf_bmap); in mlx4_bf_alloc()
220 uar->free_bf_bmap |= 1 << idx; in mlx4_bf_alloc()
221 bf->uar = uar; in mlx4_bf_alloc()
224 bf->reg = uar->bf_map + idx * dev->caps.bf_reg_size; in mlx4_bf_alloc()
225 if (uar->free_bf_bmap == (1 << dev->caps.bf_regs_per_page) - 1) in mlx4_bf_alloc()
226 list_del_init(&uar->bf_list); in mlx4_bf_alloc()
231 bf->uar = NULL; in mlx4_bf_alloc()
232 iounmap(uar->map); in mlx4_bf_alloc()
235 mlx4_uar_free(dev, uar); in mlx4_bf_alloc()
238 kfree(uar); in mlx4_bf_alloc()
251 if (!bf->uar || !bf->uar->bf_map) in mlx4_bf_free()
255 idx = (bf->reg - bf->uar->bf_map) / dev->caps.bf_reg_size; in mlx4_bf_free()
256 bf->uar->free_bf_bmap &= ~(1 << idx); in mlx4_bf_free()
257 if (!bf->uar->free_bf_bmap) { in mlx4_bf_free()
258 if (!list_empty(&bf->uar->bf_list)) in mlx4_bf_free()
259 list_del(&bf->uar->bf_list); in mlx4_bf_free()
261 io_mapping_unmap(bf->uar->bf_map); in mlx4_bf_free()
262 iounmap(bf->uar->map); in mlx4_bf_free()
263 mlx4_uar_free(dev, bf->uar); in mlx4_bf_free()
264 kfree(bf->uar); in mlx4_bf_free()
265 } else if (list_empty(&bf->uar->bf_list)) in mlx4_bf_free()
266 list_add(&bf->uar->bf_list, &priv->bf_list); in mlx4_bf_free()