From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Baptiste Le Duc <baptiste.le-duc@vates.tech>
Cc: xen-devel@lists.xenproject.org,
"Romain Caritey" <Romain.Caritey@microchip.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Connor Davis" <connojdavis@gmail.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger@xenproject.org>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: Re: [PATCH v4 04/42] xen/riscv: define the IPRIO field of the APLIC target register
Date: Wed, 2 Dec 2026 09:27:55 +0100 [thread overview]
Message-ID: <a2945487-71cd-415e-9108-298886104dab@gmail.com> (raw)
In-Reply-To: <1795793029.8631fc262581453bbf619ec5b2062170.1a21d9b08eb0004767@vates.tech>
On 11/27/26 4:23 PM, Baptiste Le Duc wrote:
>> 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@gmail.com>
>
> 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?
Probably, it isn't. Lets keep it in *.c file while it won't be a really
sense to move it to header.
>
>> [ ... 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?
I thought about that. It would be really simpler. So lets drop it + ...
>
> 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);
> }
>
... apply this suggestion.
I will send a separate patch outside of this patch series as it doesn't
affect the work of virtual interrupt controller at all.
Thanks.
~ Oleksii
next prev parent reply other threads:[~2026-12-02 8:28 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1794562488.git.oleksii.kurochko@gmail.com>
2026-11-13 15:48 ` [PATCH v4 01/42] xen/riscv: add helper to check APLIC MSI mode Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 02/42] xen/riscv: address violation of MISRA C Rule 20.12 in csr_write64() Oleksii Kurochko
2026-11-18 9:50 ` Baptiste Le Duc
2026-11-18 10:51 ` Jan Beulich
2026-11-13 15:48 ` [PATCH v4 03/42] xen/riscv: introduce csr_volatile_read64() Oleksii Kurochko
2026-11-18 9:50 ` Baptiste Le Duc
2026-11-18 10:49 ` Jan Beulich
2026-11-18 10:57 ` Jan Beulich
2026-11-25 8:48 ` Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 04/42] xen/riscv: define the IPRIO field of the APLIC target register Oleksii Kurochko
2026-11-27 15:23 ` Baptiste Le Duc
2026-12-02 8:27 ` Oleksii Kurochko [this message]
2026-11-13 15:48 ` [PATCH v4 05/42] xen/riscv: build the target hart index via aplic_hart_index() Oleksii Kurochko
2026-11-27 16:00 ` Baptiste Le Duc
2026-11-30 8:40 ` Jan Beulich
2026-11-30 9:25 ` Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 06/42] xen/riscv: introduce CPU_NONE Oleksii Kurochko
2026-11-27 16:08 ` Baptiste Le Duc
2026-11-30 8:41 ` Jan Beulich
2026-11-13 15:48 ` [PATCH v4 07/42] xen/riscv: introduce device-agnostic MMIO emulation dispatch Oleksii Kurochko
2026-11-27 16:42 ` Baptiste Le Duc
2026-11-13 15:48 ` [PATCH v4 08/42] xen/riscv: distinguish h/w and virtual vINTC sources Oleksii Kurochko
2026-12-01 12:54 ` Baptiste Le Duc
2026-11-13 15:48 ` [PATCH v4 09/42] xen/riscv: implement virtual APLIC MMIO emulation Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 10/42] xen/riscv: leave the h/w source of an IRQ routed to a guest inactive Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 11/42] xen/riscv: implement vCPU context switching Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 12/42] xen/riscv: save and restore vsiselect on vCPU context switch Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 13/42] xen/riscv: introduce vintc_ctxt_switch_{from,to}() Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 14/42] xen/riscv: extend exception tables with type and data fields Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 15/42] xen/riscv: add guest page fault handling stub Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 16/42] xen/riscv: implement trap redirection to a guest Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 17/42] xen/riscv: detect Shtvala Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 18/42] xen/riscv: resolve the faulting guest physical address Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 19/42] xen/riscv: add guest memory read helper Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 20/42] xen/riscv: add helpers for decoding a trapped load or store Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 21/42] xen/riscv: add guest load emulation for trapped MMIO accesses Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 22/42] xen/riscv: add guest store " Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 23/42] xen/riscv: set the guest's XLEN explicitly in hstatus.VSXL Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 24/42] xen/riscv: implement continue_new_vcpu() Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 25/42] xen/riscv: add basic VGEIN management for AIA guests Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 26/42] xen/riscv: map IMSIC interrupt file for vCPUs Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 27/42] xen/riscv: introduce vaplic_reconfigure_target() Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 28/42] xen/riscv: introduce IMSIC h/w interrupt file attaching to vcpu Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 29/42] xen/riscv: wake up a descheduled vCPU on a guest external interrupt Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 30/42] xen/riscv: implement APLIC-IMSIC-hart sync barrier for vCPU migration Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 31/42] xen/riscv: introduce imsic_migrate_vcpu() Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 32/42] xen/riscv: remap interrupts to new IMSIC VS-file Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 33/42] xen/riscv: save and clear the old IMSIC VS-file on vCPU migration Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 34/42] xen/riscv: restore register state in the new IMSIC VS-file Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 35/42] xen/riscv: move a vCPU's guest interrupt file on its way to the guest Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 36/42] xen/riscv: send MSIs to a vCPU's guest interrupt file Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 37/42] xen/riscv: sync with IMSIC VS-file injections on vCPU migration Oleksii Kurochko
2026-11-13 15:48 ` [PATCH v4 38/42] xen/riscv: emulate the vAPLIC genmsi register Oleksii Kurochko
2026-11-13 15:49 ` [PATCH v4 39/42] xen/riscv: emulate vAPLIC sourcecfg[], setie[] and domaincfg.IE Oleksii Kurochko
2026-11-13 15:49 ` [PATCH v4 40/42] xen/riscv: emulate target[] of virtual vAPLIC sources Oleksii Kurochko
2026-11-13 15:49 ` [PATCH v4 41/42] xen/riscv: emulate the pending bits and MSIs " Oleksii Kurochko
2026-11-13 15:49 ` [PATCH v4 42/42] xen/riscv: drive the line of a virtual vAPLIC source Oleksii Kurochko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a2945487-71cd-415e-9108-298886104dab@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=Romain.Caritey@microchip.com \
--cc=alistair.francis@wdc.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=baptiste.le-duc@vates.tech \
--cc=connojdavis@gmail.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger@xenproject.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.