Re: [PATCH v3 6/6] lib: sbi_irqchip: fix MSI EIID gap and tail allocation logic in register_msi
Anup Patel <[email protected]> Fri, 17 Jul 2026 13:54:30 +0530
| Newsgroups | org.infradead.lists.opensbi |
|---|---|
| Message-ID | <CABBgwmtya3EfO9CJDCEr6cEvdPVkea_=NpH89pi6n9cQJzJrOw@mail.gmail.com> |
On Sun, Jul 12, 2026 at 1:44 AM Pawandeep Oza <[email protected]> wrote: > > Fix sbi_irqchip_register_msi() that prevented contiguous EIID allocation: > > - Gap check condition was inverted: the original `h->first_hwirq - > hwirq < num_hwirq` incorrectly set `found = true` when the gap was > too small to fit num_hwirq entries. Correct to `>= num_hwirq` so > allocation only proceeds when sufficient space exists between > registered handlers. > > - Tail-space check `!found && !hwirq` never triggered after iteration > Replace with `(chip->num_hwirq - hwirq) >= num_hwirq` to correctly > allocate if handler list is empty. > > Fixes: 79e63bc8348d ("irqchip: add sbi_irqchip_register_msi support") > > Signed-off-by: Oza Pawandeep <[email protected]> LGTM. Reviewed-by: Anup Patel <[email protected]> Thanks, Anup > --- > lib/sbi/sbi_irqchip.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c > index d124c194..941f4514 100644 > --- a/lib/sbi/sbi_irqchip.c > +++ b/lib/sbi/sbi_irqchip.c > @@ -362,7 +362,7 @@ int sbi_irqchip_register_msi(struct sbi_irqchip_device *chip, u32 num_hwirq, > if (h->first_hwirq <= hwirq && hwirq < (h->first_hwirq + h->num_hwirq)) { > hwirq = h->first_hwirq + h->num_hwirq; > } else if (hwirq < h->first_hwirq) { > - if (h->first_hwirq - hwirq < num_hwirq) { > + if (h->first_hwirq - hwirq >= num_hwirq) { > found = true; > break; > } else { > @@ -370,7 +370,7 @@ int sbi_irqchip_register_msi(struct sbi_irqchip_device *chip, u32 num_hwirq, > } > } > } > - if (!found && !hwirq) > + if (!found && (chip->num_hwirq - hwirq) >= num_hwirq) > found = true; > if (!found) > return SBI_ENOSPC; > -- > 2.43.0 > > > -- > opensbi mailing list > [email protected] > http://lists.infradead.org/mailman/listinfo/opensbi -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi