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, uar->index << PAGE_SHIFT); in mlx4_bf_alloc()
209 if (!uar->bf_map) { in mlx4_bf_alloc()
213 uar->free_bf_bmap = 0; in mlx4_bf_alloc()
214 list_add(&uar->bf_list, &priv->bf_list); in mlx4_bf_alloc()
217 idx = ffz(uar->free_bf_bmap); in mlx4_bf_alloc()
218 uar->free_bf_bmap |= 1 << idx; in mlx4_bf_alloc()
219 bf->uar = uar; in mlx4_bf_alloc()
222 bf->reg = uar->bf_map + idx * dev->caps.bf_reg_size; in mlx4_bf_alloc()
223 if (uar->free_bf_bmap == (1 << dev->caps.bf_regs_per_page) - 1) in mlx4_bf_alloc()
224 list_del_init(&uar->bf_list); in mlx4_bf_alloc()
229 bf->uar = NULL; in mlx4_bf_alloc()
230 iounmap(uar->map); in mlx4_bf_alloc()
233 mlx4_uar_free(dev, uar); in mlx4_bf_alloc()
236 kfree(uar); in mlx4_bf_alloc()
249 if (!bf->uar || !bf->uar->bf_map) in mlx4_bf_free()
253 idx = (bf->reg - bf->uar->bf_map) / dev->caps.bf_reg_size; in mlx4_bf_free()
254 bf->uar->free_bf_bmap &= ~(1 << idx); in mlx4_bf_free()
255 if (!bf->uar->free_bf_bmap) { in mlx4_bf_free()
256 if (!list_empty(&bf->uar->bf_list)) in mlx4_bf_free()
257 list_del(&bf->uar->bf_list); in mlx4_bf_free()
259 io_mapping_unmap(bf->uar->bf_map); in mlx4_bf_free()
260 iounmap(bf->uar->map); in mlx4_bf_free()
261 mlx4_uar_free(dev, bf->uar); in mlx4_bf_free()
262 kfree(bf->uar); in mlx4_bf_free()
263 } else if (list_empty(&bf->uar->bf_list)) in mlx4_bf_free()
264 list_add(&bf->uar->bf_list, &priv->bf_list); in mlx4_bf_free()