Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06f6c339 authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

genirq: Implement irq reservation



Mark a range of interrupts as allocated. In the SPARSE_IRQ=n case we
need this to update the bitmap for the legacy irqs so the enumerator
via irq_get_next_irq() works.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent a98d24b7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -400,6 +400,7 @@ static inline struct irq_2_iommu *irq_data_get_iommu(struct irq_data *d)

int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node);
void irq_free_descs(unsigned int irq, unsigned int cnt);
int irq_reserve_irqs(unsigned int from, unsigned int cnt);

static inline int irq_alloc_desc(int node)
{
+26 −0
Original line number Diff line number Diff line
@@ -463,6 +463,32 @@ err:
	return ret;
}

/**
 * irq_reserve_irqs - mark irqs allocated
 * @from:	mark from irq number
 * @cnt:	number of irqs to mark
 *
 * Returns 0 on success or an appropriate error code
 */
int irq_reserve_irqs(unsigned int from, unsigned int cnt)
{
	unsigned long flags;
	unsigned int start;
	int ret = 0;

	if (!cnt || (from + cnt) > nr_irqs)
		return -EINVAL;

	raw_spin_lock_irqsave(&sparse_irq_lock, flags);
	start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
	if (start == from)
		bitmap_set(allocated_irqs, start, cnt);
	else
		ret = -EEXIST;
	raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
	return ret;
}

/**
 * irq_get_next_irq - get next allocated irq number
 * @offset:	where to start the search