[PATCH v1 09/17] xen/riscv: add helper to check APLIC MSI mode
Oleksii Kurochko <[email protected]>
| Newsgroups | org.xenproject.lists.xen-devel |
|---|---|
| Message-ID | <c6c5b05886520586041ca4f50ae554c3536ee662.1784560663.git.oleksii.kurochko@gmail.com> |
This helper can be used outside aplic.c to determine whether MSI mode is enabled. A follow-up patch uses it to decide whether the guest IMSIC state should be saved/restored. Signed-off-by: Oleksii Kurochko <[email protected]> --- xen/arch/riscv/aplic.c | 9 +++++++-- xen/arch/riscv/include/asm/aplic.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index 87f2134bc561..1ce844cd2162 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -93,6 +93,11 @@ void aplic_hw_write_reg(unsigned int offset, uint32_t value) spin_unlock_irqrestore(&aplic.lock, flags); } +bool has_msi_support(void) +{ + return readl(&aplic.regs->domaincfg) & APLIC_DOMAINCFG_DM; +} + static void __init aplic_init_hw_interrupts(void) { unsigned int i; @@ -185,7 +190,7 @@ static void cf_check aplic_irq_enable(struct irq_desc *desc) * If APLIC without MSI interrupts is required in the future, * this function will need to be updated accordingly. */ - ASSERT(readl(&aplic.regs->domaincfg) & APLIC_DOMAINCFG_DM); + ASSERT(has_msi_support()); ASSERT(spin_is_locked(&desc->lock)); @@ -216,7 +221,7 @@ static void cf_check aplic_irq_disable(struct irq_desc *desc) * If APLIC without MSI interrupts is required in the future, * this function will need to be updated accordingly. */ - ASSERT(readl(&aplic.regs->domaincfg) & APLIC_DOMAINCFG_DM); + ASSERT(has_msi_support()); ASSERT(spin_is_locked(&desc->lock)); diff --git a/xen/arch/riscv/include/asm/aplic.h b/xen/arch/riscv/include/asm/aplic.h index 4ae5fb8f26d1..9a0b23351154 100644 --- a/xen/arch/riscv/include/asm/aplic.h +++ b/xen/arch/riscv/include/asm/aplic.h @@ -144,4 +144,6 @@ struct aplic_regs { uint32_t aplic_hw_read_reg(unsigned int offset, uint32_t mask); void aplic_hw_write_reg(unsigned int offset, uint32_t value); +bool has_msi_support(void); + #endif /* ASM_RISCV_APLIC_H */ -- 2.54.0