Skip to content

Commit 744b9a0

Browse files
author
Marc Zyngier
committed
ACPI: irq: Allow acpi_gsi_to_irq() to have an arch-specific fallback
It appears that the generic version of acpi_gsi_to_irq() doesn't fallback to establishing a mapping if there is no pre-existing one while the x86 version does. While arm64 seems unaffected by it, LoongArch is relying on the x86 behaviour. In an effort to prevent new architectures from reinventing the proverbial wheel, provide an optional callback that the arch code can set to restore the x86 behaviour. Hopefully we can eventually get rid of this in the future once the expected behaviour has been clarified. Reported-by: Jianmin Lv <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Jianmin Lv <[email protected]> Tested-by: Hanjun Guo <[email protected]> Reviewed-by: Hanjun Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7327b16 commit 744b9a0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

drivers/acpi/irq.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
enum acpi_irq_model_id acpi_irq_model;
1414

1515
static struct fwnode_handle *(*acpi_get_gsi_domain_id)(u32 gsi);
16+
static u32 (*acpi_gsi_to_irq_fallback)(u32 gsi);
1617

1718
/**
1819
* acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI
@@ -32,9 +33,12 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
3233
DOMAIN_BUS_ANY);
3334
*irq = irq_find_mapping(d, gsi);
3435
/*
35-
* *irq == 0 means no mapping, that should
36-
* be reported as a failure
36+
* *irq == 0 means no mapping, that should be reported as a
37+
* failure, unless there is an arch-specific fallback handler.
3738
*/
39+
if (!*irq && acpi_gsi_to_irq_fallback)
40+
*irq = acpi_gsi_to_irq_fallback(gsi);
41+
3842
return (*irq > 0) ? 0 : -EINVAL;
3943
}
4044
EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
@@ -301,6 +305,16 @@ void __init acpi_set_irq_model(enum acpi_irq_model_id model,
301305
acpi_get_gsi_domain_id = fn;
302306
}
303307

308+
/**
309+
* acpi_set_gsi_to_irq_fallback - Register a GSI transfer
310+
* callback to fallback to arch specified implementation.
311+
* @fn: arch-specific fallback handler
312+
*/
313+
void __init acpi_set_gsi_to_irq_fallback(u32 (*fn)(u32))
314+
{
315+
acpi_gsi_to_irq_fallback = fn;
316+
}
317+
304318
/**
305319
* acpi_irq_create_hierarchy - Create a hierarchical IRQ domain with the default
306320
* GSI domain as its parent.

include/linux/acpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi);
357357

358358
void acpi_set_irq_model(enum acpi_irq_model_id model,
359359
struct fwnode_handle *(*)(u32));
360+
void acpi_set_gsi_to_irq_fallback(u32 (*)(u32));
360361

361362
struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags,
362363
unsigned int size,

0 commit comments

Comments
 (0)