mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-07-26 15:51:38 +01:00
lib: sbi_irqchip: fix device lookup by caps when first is NULL
When called with first == NULL, sbi_irqchip_find_device_by_caps() should
scan the device list from the start. Instead it always returns NULL: "found"
starts false and only flips true when an entry equals "first", but no entry
ever equals NULL, so every entry hits "else continue" and nothing is checked.
This breaks MSI detection in sbi_mpxy, which calls it with first == NULL:
ms->msi_avail = !!sbi_irqchip_find_device_by_caps(SBI_IRQCHIP_CAPS_MSI, NULL);
msi_avail is therefore always false, so mpxy_write_std_attr() silently drops
the MSI attributes (MSI_ADDR_LO/HI, MSI_DATA, MSI_CONTROL) while still
returning success, and MSI-based MPXY notifications are never delivered.
Initialize "found" from "first" so a NULL "first" scans from the beginning,
and always continue in the pre-match branch so a non-NULL "first" resumes
after the given device.
Fixes: 8570b93844 ("lib: sbi_irqchip: Allow irqchip drivers advertise capabilities")
Signed-off-by: David E. Garcia Porras <david.garcia@aheadcomputing.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260701181334.969877-1-david.garcia@aheadcomputing.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
committed by
Anup Patel
parent
262571217c
commit
92bea7bdb2
@@ -412,14 +412,13 @@ struct sbi_irqchip_device *sbi_irqchip_find_device_by_caps(unsigned long caps,
|
||||
struct sbi_irqchip_device *first)
|
||||
{
|
||||
struct sbi_irqchip_device *chip;
|
||||
bool found = false;
|
||||
bool found = (first == NULL);
|
||||
|
||||
sbi_list_for_each_entry(chip, &irqchip_list, node) {
|
||||
if (!found) {
|
||||
if (first == chip)
|
||||
found = true;
|
||||
else
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
if ((chip->caps & caps) == caps)
|
||||
return chip;
|
||||
|
||||
Reference in New Issue
Block a user