Lines Matching +full:irqs +full:- +full:reserved
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2006-2008, Michael Ellerman, IBM Corporation.
19 spin_lock_irqsave(&bmp->lock, flags); in msi_bitmap_alloc_hwirqs()
21 offset = bitmap_find_next_zero_area(bmp->bitmap, bmp->irq_count, 0, in msi_bitmap_alloc_hwirqs()
22 num, (1 << order) - 1); in msi_bitmap_alloc_hwirqs()
23 if (offset > bmp->irq_count) in msi_bitmap_alloc_hwirqs()
26 bitmap_set(bmp->bitmap, offset, num); in msi_bitmap_alloc_hwirqs()
27 spin_unlock_irqrestore(&bmp->lock, flags); in msi_bitmap_alloc_hwirqs()
33 spin_unlock_irqrestore(&bmp->lock, flags); in msi_bitmap_alloc_hwirqs()
34 return -ENOMEM; in msi_bitmap_alloc_hwirqs()
46 spin_lock_irqsave(&bmp->lock, flags); in msi_bitmap_free_hwirqs()
47 bitmap_clear(bmp->bitmap, offset, num); in msi_bitmap_free_hwirqs()
48 spin_unlock_irqrestore(&bmp->lock, flags); in msi_bitmap_free_hwirqs()
58 spin_lock_irqsave(&bmp->lock, flags); in msi_bitmap_reserve_hwirq()
59 bitmap_allocate_region(bmp->bitmap, hwirq, 0); in msi_bitmap_reserve_hwirq()
60 spin_unlock_irqrestore(&bmp->lock, flags); in msi_bitmap_reserve_hwirq()
64 * msi_bitmap_reserve_dt_hwirqs - Reserve irqs specified in the device tree.
68 * irqs can be used for MSI. If found those irqs reserved in the device tree
69 * are reserved in the bitmap.
79 if (!bmp->of_node) in msi_bitmap_reserve_dt_hwirqs()
82 p = of_get_property(bmp->of_node, "msi-available-ranges", &len); in msi_bitmap_reserve_dt_hwirqs()
84 pr_debug("msi_bitmap: no msi-available-ranges property " \ in msi_bitmap_reserve_dt_hwirqs()
85 "found on %pOF\n", bmp->of_node); in msi_bitmap_reserve_dt_hwirqs()
90 printk(KERN_WARNING "msi_bitmap: Malformed msi-available-ranges" in msi_bitmap_reserve_dt_hwirqs()
91 " property on %pOF\n", bmp->of_node); in msi_bitmap_reserve_dt_hwirqs()
92 return -EINVAL; in msi_bitmap_reserve_dt_hwirqs()
95 bitmap_allocate_region(bmp->bitmap, 0, get_count_order(bmp->irq_count)); in msi_bitmap_reserve_dt_hwirqs()
97 spin_lock(&bmp->lock); in msi_bitmap_reserve_dt_hwirqs()
103 bitmap_release_region(bmp->bitmap, *p + j, 0); in msi_bitmap_reserve_dt_hwirqs()
106 spin_unlock(&bmp->lock); in msi_bitmap_reserve_dt_hwirqs()
117 return -EINVAL; in msi_bitmap_alloc()
122 bmp->bitmap_from_slab = slab_is_available(); in msi_bitmap_alloc()
123 if (bmp->bitmap_from_slab) in msi_bitmap_alloc()
124 bmp->bitmap = kzalloc(size, GFP_KERNEL); in msi_bitmap_alloc()
126 bmp->bitmap = memblock_alloc(size, SMP_CACHE_BYTES); in msi_bitmap_alloc()
127 if (!bmp->bitmap) in msi_bitmap_alloc()
131 kmemleak_not_leak(bmp->bitmap); in msi_bitmap_alloc()
134 if (!bmp->bitmap) { in msi_bitmap_alloc()
136 return -ENOMEM; in msi_bitmap_alloc()
139 /* We zalloc'ed the bitmap, so all irqs are free by default */ in msi_bitmap_alloc()
140 spin_lock_init(&bmp->lock); in msi_bitmap_alloc()
141 bmp->of_node = of_node_get(of_node); in msi_bitmap_alloc()
142 bmp->irq_count = irq_count; in msi_bitmap_alloc()
149 if (bmp->bitmap_from_slab) in msi_bitmap_free()
150 kfree(bmp->bitmap); in msi_bitmap_free()
151 of_node_put(bmp->of_node); in msi_bitmap_free()
152 bmp->bitmap = NULL; in msi_bitmap_free()
162 /* Can't allocate a bitmap of 0 irqs */ in test_basics()
172 /* With no node, there's no msi-available-ranges, so expect > 0 */ in test_basics()
193 msi_bitmap_free_hwirqs(&bmp, 3, size - 3); in test_basics()
213 /* Clients may WARN_ON bitmap == NULL for "not-allocated" */ in test_basics()
220 const char *expected_str = "0-9,20-24,28-39,41-99,220-255"; in test_of_node()
221 char *prop_name = "msi-available-ranges"; in test_of_node()
236 /* No msi-available-ranges, so expect > 0 */ in test_of_node()
244 /* Now create a fake msi-available-ranges property */ in test_of_node()
254 /* msi-available-ranges, so expect == 0 */ in test_of_node()
267 printk(KERN_DEBUG "Running MSI bitmap self-tests ...\n"); in msi_bitmap_selftest()