Lines Matching +full:msi +full:- +full:x
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2006-2008, Michael Ellerman, IBM Corporation.
20 spin_lock_irqsave(&bmp->lock, flags); in msi_bitmap_alloc_hwirqs()
22 offset = bitmap_find_next_zero_area(bmp->bitmap, bmp->irq_count, 0, in msi_bitmap_alloc_hwirqs()
23 num, (1 << order) - 1); in msi_bitmap_alloc_hwirqs()
24 if (offset > bmp->irq_count) in msi_bitmap_alloc_hwirqs()
27 bitmap_set(bmp->bitmap, offset, num); in msi_bitmap_alloc_hwirqs()
28 spin_unlock_irqrestore(&bmp->lock, flags); in msi_bitmap_alloc_hwirqs()
30 pr_debug("msi_bitmap: allocated 0x%x at offset 0x%x\n", num, offset); in msi_bitmap_alloc_hwirqs()
34 spin_unlock_irqrestore(&bmp->lock, flags); in msi_bitmap_alloc_hwirqs()
35 return -ENOMEM; in msi_bitmap_alloc_hwirqs()
44 pr_debug("msi_bitmap: freeing 0x%x at offset 0x%x\n", in msi_bitmap_free_hwirqs()
47 spin_lock_irqsave(&bmp->lock, flags); in msi_bitmap_free_hwirqs()
48 bitmap_clear(bmp->bitmap, offset, num); in msi_bitmap_free_hwirqs()
49 spin_unlock_irqrestore(&bmp->lock, flags); in msi_bitmap_free_hwirqs()
57 pr_debug("msi_bitmap: reserving hwirq 0x%x\n", hwirq); in msi_bitmap_reserve_hwirq()
59 spin_lock_irqsave(&bmp->lock, flags); in msi_bitmap_reserve_hwirq()
60 bitmap_allocate_region(bmp->bitmap, hwirq, 0); in msi_bitmap_reserve_hwirq()
61 spin_unlock_irqrestore(&bmp->lock, flags); in msi_bitmap_reserve_hwirq()
65 * msi_bitmap_reserve_dt_hwirqs - Reserve irqs specified in the device tree.
66 * @bmp: pointer to the MSI bitmap.
69 * irqs can be used for MSI. If found those irqs reserved in the device tree
80 if (!bmp->of_node) in msi_bitmap_reserve_dt_hwirqs()
83 p = of_get_property(bmp->of_node, "msi-available-ranges", &len); in msi_bitmap_reserve_dt_hwirqs()
85 pr_debug("msi_bitmap: no msi-available-ranges property " \ in msi_bitmap_reserve_dt_hwirqs()
86 "found on %pOF\n", bmp->of_node); in msi_bitmap_reserve_dt_hwirqs()
91 printk(KERN_WARNING "msi_bitmap: Malformed msi-available-ranges" in msi_bitmap_reserve_dt_hwirqs()
92 " property on %pOF\n", bmp->of_node); in msi_bitmap_reserve_dt_hwirqs()
93 return -EINVAL; in msi_bitmap_reserve_dt_hwirqs()
96 bitmap_allocate_region(bmp->bitmap, 0, get_count_order(bmp->irq_count)); in msi_bitmap_reserve_dt_hwirqs()
98 spin_lock(&bmp->lock); in msi_bitmap_reserve_dt_hwirqs()
104 bitmap_release_region(bmp->bitmap, *p + j, 0); in msi_bitmap_reserve_dt_hwirqs()
107 spin_unlock(&bmp->lock); in msi_bitmap_reserve_dt_hwirqs()
118 return -EINVAL; in msi_bitmap_alloc()
121 pr_debug("msi_bitmap: allocator bitmap size is 0x%x bytes\n", size); in msi_bitmap_alloc()
123 bmp->bitmap_from_slab = slab_is_available(); in msi_bitmap_alloc()
124 if (bmp->bitmap_from_slab) in msi_bitmap_alloc()
125 bmp->bitmap = kzalloc(size, GFP_KERNEL); in msi_bitmap_alloc()
127 bmp->bitmap = memblock_alloc(size, SMP_CACHE_BYTES); in msi_bitmap_alloc()
128 if (!bmp->bitmap) in msi_bitmap_alloc()
132 kmemleak_not_leak(bmp->bitmap); in msi_bitmap_alloc()
135 if (!bmp->bitmap) { in msi_bitmap_alloc()
137 return -ENOMEM; in msi_bitmap_alloc()
141 spin_lock_init(&bmp->lock); in msi_bitmap_alloc()
142 bmp->of_node = of_node_get(of_node); in msi_bitmap_alloc()
143 bmp->irq_count = irq_count; in msi_bitmap_alloc()
150 if (bmp->bitmap_from_slab) in msi_bitmap_free()
151 kfree(bmp->bitmap); in msi_bitmap_free()
152 of_node_put(bmp->of_node); in msi_bitmap_free()
153 bmp->bitmap = NULL; in msi_bitmap_free()
173 /* With no node, there's no msi-available-ranges, so expect > 0 */ in test_basics()
194 msi_bitmap_free_hwirqs(&bmp, 3, size - 3); in test_basics()
214 /* Clients may WARN_ON bitmap == NULL for "not-allocated" */ in test_basics()
221 const char *expected_str = "0-9,20-24,28-39,41-99,220-255"; in test_of_node()
222 char *prop_name = "msi-available-ranges"; in test_of_node()
237 /* No msi-available-ranges, so expect > 0 */ in test_of_node()
245 /* Now create a fake msi-available-ranges property */ in test_of_node()
255 /* msi-available-ranges, so expect == 0 */ in test_of_node()
268 printk(KERN_DEBUG "Running MSI bitmap self-tests ...\n"); in msi_bitmap_selftest()