All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr Tyshchenko <olekstysh@gmail.com>
To: Volodymyr Babchuk <Volodymyr_Babchuk@epam.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: Thu, 4 Sep 2025 13:49:09 +0300	[thread overview]
Message-ID: <9d40e91c-5e9a-441b-85ad-8dddf4427cdb@gmail.com> (raw)
In-Reply-To: <87plc7tdxx.fsf@epam.com>



On 04.09.25 00:37, Volodymyr Babchuk wrote:
> Hi Oleksandr,

Hello Volodymyr

> 
> 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.

I got it

  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)

 From my PoV, the idea looks good

> 
> 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.
> 
> 



  parent reply	other threads:[~2025-09-04 10:49 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
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 [this message]
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=9d40e91c-5e9a-441b-85ad-8dddf4427cdb@gmail.com \
    --to=olekstysh@gmail.com \
    --cc=Leonid_Komarianskyi@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.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.