|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v4 04/42] xen/riscv: define the IPRIO field of the APLIC target register
> aplic_init_hw_interrupts() initialises the IPRIO field of the target
> registers with APLIC_DEFAULT_PRIORITY, a constant private to aplic.c,
> whereas, since commit 60004aa6da75 ("xen/riscv: add missing APLIC
> register offsets, masks to asm/aplic.h"), the fields of each APLIC
> register and the values they take are defined in <asm/aplic.h>, right
> below the register's offset, as described at the top of that header.
>
> Define APLIC_TARGET_IPRIO and APLIC_TARGET_IPRIO_DEFAULT there
> accordingly and use the latter instead of APLIC_DEFAULT_PRIORITY. As
> the layout of the target register depends on the delivery mode, and
> IPRIO overlaps with EIID, also note which fields exist in which mode.
>
> No functional change.
>
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
Unlike v2, where the vAPLIC emulated direct delivery mode and used
it too, nothing in this series uses either macro outside of
aplic.c anymore. Is there a reason to move them beyond the header
convention?
> [ ... 10 lines skipped ... ]
> diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c
> index 79bbc0e864..bffa29bb21 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,
> };
> @@ -58,9 +56,9 @@ static void __init aplic_init_hw_interrupts(void)
> /*
> * 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.
> + * Thereby they are initialized to APLIC_TARGET_IPRIO_DEFAULT.
> */
> - writel(APLIC_DEFAULT_PRIORITY, &aplic.regs->target[i]);
> + writel(APLIC_TARGET_IPRIO_DEFAULT, &aplic.regs->target[i]);
> }
>
> writel(APLIC_DOMAINCFG_IE | APLIC_DOMAINCFG_DM, &aplic.regs->domaincfg);
>
Furthermore, is the write needed at all? sourcecfg[i] is set to 0
just above, i.e. D = 0 and SM = Inactive, and AIA 4.5.16 says: "If
interrupt source i is inactive in this domain, register target[i]
is read-only zero." So the write is ignored. Also, domaincfg.DM is
forced to 1 (MSI delivery mode) right after, where IPRIO does not
exist and the low bits are EIID. As Xen doesn't use direct delivery
mode, is a default priority needed at all? (Btw, a comment saying
that MSI mode is forced there would help.)
Wouldn't it be simpler to drop the write, the comment and
APLIC_TARGET_IPRIO{,_DEFAULT} instead of moving the constant?
Another question: is the clrie loop needed? Making a source inactive
already makes its enable bit read-only zero. If the intention is to
not have an interrupt fire before its sourcecfg[] is cleared, then
clearing domaincfg.IE first looks simpler. Something like:
@@ -222,21 +222,18 @@ 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 so that no source left active by firmware can raise
+ * an interrupt while the sources are being made inactive.
+ */
+ writel(0, &aplic.regs->domaincfg);
- /* Set interrupt type and default priority for all interrupts */
+ /*
+ * Make all sources inactive by writing 0 to sourcecfg[i]. Per the AIA
+ * spec, target[i] then becomes 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_TARGET_IPRIO_DEFAULT.
- */
- writel(APLIC_TARGET_IPRIO_DEFAULT, &aplic.regs->target[i]);
- }
writel(APLIC_DOMAINCFG_IE | APLIC_DOMAINCFG_DM, &aplic.regs->domaincfg);
}
--
Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |