|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] xen/riscv: simplify aplic_init_hw_interrupts()
aplic_init_hw_interrupts() clears all enable bits via clrie[], then
writes 0 to sourcecfg[i] and APLIC_DEFAULT_PRIORITY to target[i] for
each source. However, writing 0 to sourcecfg[i] makes source i inactive
(D = 0, SM = Inactive) and, per the AIA spec, the pending and enable
bits and target[i] of an inactive source are read-only zero. Thus the
clrie[] loop is redundant and the target[i] write is ignored. Moreover,
domaincfg.DM is set right after, and in MSI delivery mode the low bits
of target[i] are EIID rather than IPRIO, so a default priority isn't
needed at all.
Drop the clrie[] loop, the target[i] write and APLIC_DEFAULT_PRIORITY.
To still prevent a source left active by firmware from raising an
interrupt while the sources are being made inactive, clear domaincfg.IE
first, keeping DM so as not to switch the delivery mode.
Also, as domaincfg.DM is WARL and Xen supports only MSI delivery mode,
check that DM reads back as 1 and panic otherwise, instead of relying
on the ASSERT()s in the IRQ paths.
Suggested-by: Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
---
xen/arch/riscv/aplic.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c
index 20be48d4e658..8d54ebe31647 100644
--- a/xen/arch/riscv/aplic.c
+++ b/xen/arch/riscv/aplic.c
@@ -28,8 +28,6 @@
#include <asm/io.h>
#include <asm/riscv_encoding.h>
-#define APLIC_DEFAULT_PRIORITY 1
-
static struct aplic_priv aplic = {
.lock = SPIN_LOCK_UNLOCKED,
};
@@ -131,23 +129,23 @@ static void __init aplic_init_hw_interrupts(void)
{
unsigned int i;
- /* Disable all interrupts */
- for ( i = 0; i < ARRAY_SIZE(aplic.regs->clrie); i++)
- writel(~0U, &aplic.regs->clrie[i]);
+ /*
+ * Stop delivery, keeping the delivery mode, so that no source left
+ * active by firmware can raise an interrupt while being made inactive.
+ */
+ writel(APLIC_DOMAINCFG_DM, &aplic.regs->domaincfg);
- /* Set interrupt type and default priority for all interrupts */
+ /*
+ * Make all sources inactive. Per the AIA spec, the pending and enable
+ * bits and target[i] of an inactive source are then read-only zero.
+ */
for ( i = 0; i < aplic_info.num_irqs; i++ )
- {
writel(0, &aplic.regs->sourcecfg[i]);
- /*
- * Low bits of target register contains Interrupt Priority bits which
- * can't be zero according to AIA spec.
- * Thereby they are initialized to APLIC_DEFAULT_PRIORITY.
- */
- writel(APLIC_DEFAULT_PRIORITY, &aplic.regs->target[i]);
- }
+ /* Xen supports only MSI delivery mode, so force it. */
writel(APLIC_DOMAINCFG_IE | APLIC_DOMAINCFG_DM, &aplic.regs->domaincfg);
+ if ( !aplic_msi_mode() )
+ panic("APLIC: MSI delivery mode isn't supported\n");
}
static int __init cf_check aplic_init(void)
--
2.56.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |