hv: pirq: refactor irq num alloc/free

This commit refactors the alloc/free irq num, two functions are defined:
- uint32_t alloc_irq_num(uint32_t irq)
  - if irq is valid, mark the irq_desc as used; if it's IRQ_INVALID,
    alloc a free irq, or else do nothing;
  - return: irq num on success, or IRQ_INVALID on failure.

- void free_irq_num(uint32_t irq)
  - free the irq num allocated via alloc_irq_num();

And a global spinlock to protect it from concurrent allocation/free.

Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Yan, Like
2018-08-16 16:50:57 +08:00
committed by lijinxia
parent f77d885d7e
commit 1bf2fc342a
4 changed files with 45 additions and 41 deletions

View File

@@ -361,7 +361,7 @@ void setup_ioapic_irq(void)
}
/* pinned irq before use it */
if (irq_mark_used(gsi) >= NR_IRQS) {
if (alloc_irq_num(gsi) == IRQ_INVALID) {
pr_err("failed to alloc IRQ[%d]", gsi);
gsi++;
continue;