From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81D75606A31A for ; Wed, 2 Dec 2026 08:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=S3wIFHVG Received: from list by lists.xenproject.org with outflank-mailman.1509597.1702217 (Exim 4.92) (envelope-from ) id 1xYfh1-0007yG-A6; Wed, 02 Dec 2026 08:27:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1509597.1702217; Wed, 02 Dec 2026 08:27:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xYfh1-0007y9-6z; Wed, 02 Dec 2026 08:27:59 +0000 Received: by outflank-mailman (input) for mailman id 1509597; Wed, 02 Dec 2026 08:27:58 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xYfh0-0007xz-0z for xen-devel@lists.xenproject.org; Wed, 02 Dec 2026 08:27:58 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xYfgz-00F9oD-DO for xen-devel@lists.xenproject.org; Wed, 02 Dec 2026 09:27:57 +0100 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6b0fd686-e002-0a2a0a5209dd-0a2a4508ea0a-30 for ; Wed, 02 Dec 2026 09:27:57 +0100 Received: from [209.85.221.44] (helo=mail-wr1-f44.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6b0fd68d-f659-0a2a45080019-d155dd2ced30-3 for ; Wed, 02 Dec 2026 09:27:57 +0100 Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-4a68190a2a7so10606889f8f.1 for ; Wed, 02 Dec 2026 00:27:57 -0800 (PST) Received: from [192.168.1.6] (user-109-243-65-71.play-internet.pl. [109.243.65.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8538b2c5sm1045524945e9.5.2026.12.02.00.27.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2026 00:27:56 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Post: List-Help: List-Subscribe: , Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796200077; x=1796804877; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HII3aepsT4z5aEgBZ330j2huVm8/WDLPLe7VHbczGVo=; b=S3wIFHVGQq+WcujdQGmfLzmsLQAxQgQjTUxUzDl0Wveg0ygdeJs1zO47VIjLuLeTbL zl7DzC8DiODx+FB84GuxT1YzPEl9lI2J5ffG/385ya7ls4HzhpZATlWMtbeOnVhOQvA/ ZWQJJLvSP+2sOHTICNEeJ2TMJ2S5aBTfVKQtt/guSofIuwDZ/pa/9gUTEKF+YiJKxa+b cvY5p/83/scpkiu812+iqa41JjmIvx0lR1dgRPAJaD9ZdinxmNRHNjeRTA3X8oyVHSz3 rAxq/HolGVc7hzNJpNGMgp/gD2hPfM5pkP2NQ0Y3zq/zBsiCqDGFUulYyGRyZAVeNArG 9KRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796200077; x=1796804877; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HII3aepsT4z5aEgBZ330j2huVm8/WDLPLe7VHbczGVo=; b=XHbwWA9BTpgTVPNV047iP09hYtGEFoQ+tapm+QJd+r7JtcghANs6LjDdMGtWZ4QgeK qdd1EzJy4W5xudtjCWFS7Fg4iz3fPP6EypRubbt3CCzxgFQO3x/D5vIm4pn5hFoyBCxs IQnGzLXIf8d6qbp9Z+zE+1WDzKl0GgTqG4/2QPU4f9/s5TPhQfWsnok2D36aVNw3Ga8S GckmrgPOuskjgDzAkD6vo50Xhuls1f20GXW0LBaT+sMawnQwUsNbVwpZpkaq/n/2ZjOc mi/F8jZoRaOCT8Wyy53OXFxbqkYsNuCjezUq2qfqqNPRu+9xODugdw3LQPBfxDUHIrO5 Ay5Q== X-Gm-Message-State: APuU4Z/5Qh7IK8VElAH4+9EM+Lbsb5b7Ldi7w1zXz7ZwT0EWNxJlM7I8 pfaBYQYYFnTv73kWrPZDAZjVq7XonQLKkWZAm5J+DdwZlx5I/2CtI0+6 X-Gm-Gg: AZFdTZeAUrPU/AgLW2rOENiGnLkoye/yrLAPsPPmTRDlaj3IJydKv4jM9BjOvLL1zzf 9+RuRuO4pjFgpKqjetSQz8dppcXmPn0DV8k/ffiPGqrf3ZvR0Xo1FpbR437sVlw4nVpPqZbZgm0 aWt9Zc22ZQgdKXlA7iR/8BU8pz79pp/XF8S0aksphZgPMQpMBJwpM2mkct0nKICODw8BjaFy2uF UNZSO/PyPBkw7rg+GtLva4FGWxIKbmgd3EQmPKcWGyGyRIi4J0uHDb0w9i/CgJ6/nG0mlSsWIAm SJ6mLWOVnGXqszs14jU9PMvAVFNS9/S1IXLhB49vDFyA61fonZHI48r8TJsWGwBFLbHFHEn80J1 3NvrnLZ2M79SfZfmoNX5Gs1WVVKJ5CLnaUG35osW5iGvoyw3y8KGtS/ue5gBcmcWIFX34NfPz+D KvaZ/8KgFcIbuvRqc9JH4uKXW2cwSBoXiV9Y5E12h3OkHhiOwoFdcN1atEVKQXqYjtkk+meFvXy iccGKulVPQbpmCQanBl2hIBejDN1eGWVBnpERrF2U0q0CbyKjqJ3jtX1bM0Mw4NL5tnkyI71I/w d79DROUUFuEu4+Op2kT+l2YnNiGvCputllNE050If7lu/ikBRbbqrGGq6hJaJEP0Rr9U8PVtBnN w X-Received: by 2002:a05:600d:8402:b0:4a3:5a91:5f61 with SMTP id 5b1f17b1804b1-4bb88806287mr638529535e9.14.1796200076638; Wed, 02 Dec 2026 00:27:56 -0800 (PST) Message-ID: Date: Wed, 2 Dec 2026 09:27:55 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 04/42] xen/riscv: define the IPRIO field of the APLIC target register To: Baptiste Le Duc Cc: xen-devel@lists.xenproject.org, Romain Caritey , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini References: <1ea5498253b6b786edbc8f69d15f06f6daafa139.1794562488.git.oleksii.kurochko@gmail.com> <1795793029.8631fc262581453bbf619ec5b2062170.1a21d9b08eb0004767@vates.tech> Content-Language: en-US From: Oleksii Kurochko In-Reply-To: <1795793029.8631fc262581453bbf619ec5b2062170.1a21d9b08eb0004767@vates.tech> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-purgate-ID: tlsNG-c1860d/1796200077-DF8D587B-84505FFE/10/73395122804 X-purgate-type: spam X-purgate-size: 4727 X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 , 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 > > 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 >> #include >> >> -#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