Esempio n. 1
0
void msi_bitmap_reserve_hwirq(struct msi_bitmap *bmp, unsigned int hwirq)
{
    unsigned long flags;

    pr_debug("msi_bitmap: reserving hwirq 0x%x\n", hwirq);

    spin_lock_irqsave(&bmp->lock, flags);
    bitmap_allocate_region(bmp->bitmap, hwirq, 0);
    spin_unlock_irqrestore(&bmp->lock, flags);
}
Esempio n. 2
0
static int cxgb4_set_ftid(struct tid_info *t, int fidx, int family,
			  unsigned int chip_ver)
{
	spin_lock_bh(&t->ftid_lock);

	if (test_bit(fidx, t->ftid_bmap)) {
		spin_unlock_bh(&t->ftid_lock);
		return -EBUSY;
	}

	if (family == PF_INET) {
		__set_bit(fidx, t->ftid_bmap);
	} else {
		if (chip_ver < CHELSIO_T6)
			bitmap_allocate_region(t->ftid_bmap, fidx, 2);
		else
			bitmap_allocate_region(t->ftid_bmap, fidx, 1);
	}

	spin_unlock_bh(&t->ftid_lock);
	return 0;
}
Esempio n. 3
0
void *dma_mark_declared_memory_occupied(struct device *dev,
                    dma_addr_t device_addr, size_t size)
{
    struct dma_coherent_mem *mem = dev->dma_mem;
    int pos, err;
    int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1);

    pages >>= PAGE_SHIFT;

    if (!mem)
        return ERR_PTR(-EINVAL);

    pos = (device_addr - mem->device_base) >> PAGE_SHIFT;
    err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages));
    if (err != 0)
        return ERR_PTR(err);
    return mem->virt_base + (pos << PAGE_SHIFT);
}
Esempio n. 4
0
/**
 * msi_bitmap_reserve_dt_hwirqs - Reserve irqs specified in the device tree.
 * @bmp: pointer to the MSI bitmap.
 *
 * Looks in the device tree to see if there is a property specifying which
 * irqs can be used for MSI. If found those irqs reserved in the device tree
 * are reserved in the bitmap.
 *
 * Returns 0 for success, < 0 if there was an error, and > 0 if no property
 * was found in the device tree.
 **/
int msi_bitmap_reserve_dt_hwirqs(struct msi_bitmap *bmp)
{
    int i, j, len;
    const u32 *p;

    if (!bmp->of_node)
        return 1;

    p = of_get_property(bmp->of_node, "msi-available-ranges", &len);
    if (!p) {
        pr_debug("msi_bitmap: no msi-available-ranges property " \
                 "found on %s\n", bmp->of_node->full_name);
        return 1;
    }

    if (len % (2 * sizeof(u32)) != 0) {
        printk(KERN_WARNING "msi_bitmap: Malformed msi-available-ranges"
               " property on %s\n", bmp->of_node->full_name);
        return -EINVAL;
    }

    bitmap_allocate_region(bmp->bitmap, 0, get_count_order(bmp->irq_count));

    spin_lock(&bmp->lock);

    /* Format is: (<u32 start> <u32 count>)+ */
    len /= 2 * sizeof(u32);
    for (i = 0; i < len; i++, p += 2) {
        for (j = 0; j < *(p + 1); j++)
            bitmap_release_region(bmp->bitmap, *p + j, 0);
    }

    spin_unlock(&bmp->lock);

    return 0;
}