From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Oleksandr Tyshchenko <olekstysh@gmail.com>
Cc: Leonid Komarianskyi <Leonid_Komarianskyi@epam.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Michal Orzel <michal.orzel@amd.com>
Subject: Re: [PATCH v6 10/12] xen/arm: vgic-v3: add emulation of GICv3.1 eSPI registers
Date: Wed, 3 Sep 2025 21:37:46 +0000 [thread overview]
Message-ID: <87plc7tdxx.fsf@epam.com> (raw)
In-Reply-To: <cb34378c-95c7-4618-8aeb-a7b7c5c97f2d@gmail.com> (Oleksandr Tyshchenko's message of "Wed, 3 Sep 2025 22:27:07 +0300")
Hi Oleksandr,
Oleksandr Tyshchenko <olekstysh@gmail.com> writes:
[...]
>> +static inline uint32_t vgic_get_reg_offset(uint32_t reg, uint32_t spi_base,
>> + uint32_t espi_base)
>> +{
>> + if ( reg < espi_base )
>> + return reg - spi_base;
>> + else
>> + return reg - espi_base;
>> +}
>
> I am wondering (I do not request a change) whether
> vgic_get_reg_offset() is really helpfull,
> e.g. is
> offset = vgic_get_reg_offset(reg, GICD_IPRIORITYR, GICD_IPRIORITYRnE);
> much better than:
> offset = reg < GICD_IPRIORITYRnE ? reg - GICD_IPRIORITYR : reg -
> GICD_IPRIORITYRnE;
>
IMO, it is easy to make a mistake, because you need to write register
name 3 times. Can cause errors during copy-pasting. But I saw clever
trick by Mykola Kvach, something like this:
#define vgic_get_reg_offset(addr, reg_name) ( addr < reg_name##nE ? \
addr - reg_name : addr - reg_name##nE )
And then you can just use this as
offset = vgic_get_reg_offset(reg, GICD_IPRIORITYR)
I don't know what maintainers think about this type of preprocessor
trickery, but in my opinion it is justified in this case, because it
leaves less room for a mistake.
--
WBR, Volodymyr
next prev parent reply other threads:[~2025-09-03 21:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 14:29 [PATCH v6 00/12] Introduce eSPI support Leonid Komarianskyi
2025-09-03 14:29 ` [PATCH v6 01/12] xen/arm: gicv3: refactor obtaining GIC addresses for common operations Leonid Komarianskyi
2025-09-03 14:29 ` [PATCH v6 02/12] xen/arm: gic: implement helper functions for INTID checks Leonid Komarianskyi
2025-09-03 14:29 ` [PATCH v6 03/12] xen/arm: vgic: implement helper functions for virq checks Leonid Komarianskyi
2025-09-03 14:29 ` [PATCH v6 04/12] xen/arm/irq: add handling for IRQs in the eSPI range Leonid Komarianskyi
2025-09-03 20:56 ` Volodymyr Babchuk
2025-09-03 21:16 ` Leonid Komarianskyi
2025-09-04 12:27 ` Julien Grall
2025-09-04 13:09 ` Leonid Komarianskyi
2025-09-04 14:06 ` Julien Grall
2025-09-04 17:34 ` Leonid Komarianskyi
2025-09-03 14:30 ` [PATCH v6 05/12] xen/arm: gicv3: implement handling of GICv3.1 eSPI Leonid Komarianskyi
2025-09-04 14:37 ` Oleksandr Tyshchenko
2025-09-04 15:10 ` Leonid Komarianskyi
2025-09-04 15:34 ` Oleksandr Tyshchenko
2025-09-03 14:30 ` [PATCH v6 06/12] xen/arm/irq: allow eSPI processing in the gic_interrupt function Leonid Komarianskyi
2025-09-03 14:30 ` [PATCH v6 07/12] xen/arm: gicv3: modify ICH_LR_PHYSICAL_MASK to allow eSPI processing Leonid Komarianskyi
2025-09-03 20:58 ` Volodymyr Babchuk
2025-09-03 14:30 ` [PATCH v6 08/12] xen/arm: vgic: add resource management for extended SPIs Leonid Komarianskyi
2025-09-03 21:24 ` Volodymyr Babchuk
2025-09-04 6:20 ` Leonid Komarianskyi
2025-09-04 18:12 ` Oleksandr Tyshchenko
2025-09-04 18:23 ` Leonid Komarianskyi
2025-09-03 14:30 ` [PATCH v6 09/12] xen/arm: domain_build/dom0less-build: adjust domains config to support eSPIs Leonid Komarianskyi
2025-09-03 14:30 ` [PATCH v6 10/12] xen/arm: vgic-v3: add emulation of GICv3.1 eSPI registers Leonid Komarianskyi
2025-09-03 19:27 ` Oleksandr Tyshchenko
2025-09-03 21:37 ` Volodymyr Babchuk [this message]
2025-09-03 23:04 ` Julien Grall
2025-09-04 5:52 ` Leonid Komarianskyi
2025-09-04 11:17 ` Oleksandr Tyshchenko
2025-09-04 10:49 ` Oleksandr Tyshchenko
2025-09-04 6:15 ` Leonid Komarianskyi
2025-09-03 14:30 ` [PATCH v6 11/12] doc/man: update description for nr_spis with eSPI Leonid Komarianskyi
2025-09-03 14:30 ` [PATCH v6 12/12] CHANGELOG.md: add mention of GICv3.1 eSPI support Leonid Komarianskyi
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=87plc7tdxx.fsf@epam.com \
--to=volodymyr_babchuk@epam.com \
--cc=Leonid_Komarianskyi@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=olekstysh@gmail.com \
--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.