From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Mykola Kvach <xakep.amatop@gmail.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Mykola Kvach <Mykola_Kvach@epam.com>,
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 1/4] xen/arm: its: collect quirk flags and honor dma-noncoherent
Date: Wed, 25 Mar 2026 14:42:46 +0000 [thread overview]
Message-ID: <87bjgcvul6.fsf@epam.com> (raw)
In-Reply-To: <5b68fa0a8403ea60db3047f6505876bc03a41f3f.1774431310.git.mykola_kvach@epam.com> (Mykola Kvach's message of "Wed, 25 Mar 2026 12:38:30 +0200")
Hi Mykola,
Mykola Kvach <xakep.amatop@gmail.com> writes:
> From: Mykola Kvach <mykola_kvach@epam.com>
>
> Replace the per-quirk init callback with declarative flags in
> struct its_quirk, and introduce gicv3_its_collect_quirks() to gather
> the effective workaround flags from both the IIDR-matched quirk entry
> and the "dma-noncoherent" device-tree property.
>
> This lets non-coherent platforms force non-cacheable ITS table
> attributes even when no IIDR quirk entry matches.
>
> Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
> ---
> xen/arch/arm/gic-v3-its.c | 70 ++++++++++++++++++++++++---------------
> 1 file changed, 43 insertions(+), 27 deletions(-)
>
> diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
> index 9ba068c46f..00524b43a3 100644
> --- a/xen/arch/arm/gic-v3-its.c
> +++ b/xen/arch/arm/gic-v3-its.c
> @@ -57,71 +57,87 @@ struct its_device {
> */
> struct its_quirk {
> const char *desc;
> - bool (*init)(struct host_its *hw_its);
> uint32_t iidr;
> uint32_t mask;
> + uint32_t flags;
> };
>
> static uint32_t __ro_after_init its_quirk_flags;
>
> -static bool gicv3_its_enable_quirk_gen4(struct host_its *hw_its)
> -{
> - its_quirk_flags |= HOST_ITS_WORKAROUND_NC_NS |
> - HOST_ITS_WORKAROUND_32BIT_ADDR;
> -
> - return true;
> -}
> -
> static const struct its_quirk its_quirks[] = {
> {
> - .desc = "R-Car Gen4",
> - .iidr = 0x0201743b,
> - .mask = 0xffffffffU,
> - .init = gicv3_its_enable_quirk_gen4,
> + .desc = "R-Car Gen4",
> + .iidr = 0x0201743b,
> + .mask = 0xffffffffU,
> + .flags = HOST_ITS_WORKAROUND_NC_NS |
> + HOST_ITS_WORKAROUND_32BIT_ADDR,
> },
> {
> /* Sentinel. */
> }
> };
>
> -static struct its_quirk* gicv3_its_find_quirk(uint32_t iidr)
> +static const struct its_quirk *gicv3_its_find_quirk(uint32_t iidr)
> {
> - const struct its_quirk *quirks = its_quirks;
> + const struct its_quirk *quirk = its_quirks;
>
> - for ( ; quirks->desc; quirks++ )
> + for ( ; quirk->desc; quirk++ )
> {
> - if ( quirks->iidr == (quirks->mask & iidr) )
> - return (struct its_quirk *)quirks;
> + if ( quirk->iidr != (quirk->mask & iidr) )
> + continue;
> +
> + return quirk;
> }
>
> return NULL;
> }
>
> -static void gicv3_its_enable_quirks(struct host_its *hw_its)
> +static uint32_t gicv3_its_collect_quirks(const struct host_its *hw_its,
> + const struct its_quirk **matched_quirk)
> {
> + const struct its_quirk *quirk;
> + uint32_t flags = 0;
> uint32_t iidr = readl_relaxed(hw_its->its_base + GITS_IIDR);
> - const struct its_quirk *quirk = gicv3_its_find_quirk(iidr);
>
> - if ( quirk && quirk->init(hw_its) )
> + quirk = gicv3_its_find_quirk(iidr);
> + if ( quirk )
> + flags |= quirk->flags;
> +
> + if ( hw_its->dt_node &&
> + dt_property_read_bool(hw_its->dt_node, "dma-noncoherent") )
> + flags |= HOST_ITS_WORKAROUND_NC_NS;
> +
> + if ( matched_quirk )
> + *matched_quirk = quirk;
> +
> + return flags;
> +}
> +
> +static void gicv3_its_enable_quirks(struct host_its *hw_its)
> +{
> + const struct its_quirk *quirk;
> +
> + its_quirk_flags = gicv3_its_collect_quirks(hw_its, &quirk);
> +
> + if ( quirk )
> printk("GICv3: enabling workaround for ITS: %s\n", quirk->desc);
> }
>
> static void gicv3_its_validate_quirks(void)
> {
> - const struct its_quirk *quirk = NULL, *prev = NULL;
> + uint32_t quirks, prev_quirks;
> const struct host_its *hw_its;
>
> if ( list_empty(&host_its_list) )
> return;
>
> hw_its = list_first_entry(&host_its_list, struct host_its, entry);
> - prev = gicv3_its_find_quirk(readl_relaxed(hw_its->its_base + GITS_IIDR));
> + prev_quirks = gicv3_its_collect_quirks(hw_its, NULL);
>
> - list_for_each_entry(hw_its, &host_its_list, entry)
> + list_for_each_entry_continue(hw_its, &host_its_list, entry)
> {
> - quirk = gicv3_its_find_quirk(readl_relaxed(hw_its->its_base + GITS_IIDR));
> - BUG_ON(quirk != prev);
> - prev = quirk;
> + quirks = gicv3_its_collect_quirks(hw_its, NULL);
> + BUG_ON(quirks != prev_quirks);
I know it was in the previous version, but as you are already touching
this... This is not Xen BUG(). This is a platform problem. So you need
to panic here. Something like
if (quirks != prev_quirks)
panic("Different ITS instances has different quirks")
Also, I want to point out that you are not validating "dma-noncoherent"
quirk here. I mean, some ITS entries can have this property, some other
- don't. This makes me think that you need to promote this
"dma-noncoherent" quirk from open coded check to a `struct
its_quirk` entry, so it will be handled in generic way.
--
WBR, Volodymyr
next prev parent reply other threads:[~2026-03-25 14:43 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 10:38 [PATCH 0/4] xen/arm: ITS quirk handling fixes and board-specific matches Mykola Kvach
2026-03-25 10:38 ` [PATCH 1/4] xen/arm: its: collect quirk flags and honor dma-noncoherent Mykola Kvach
2026-03-25 14:42 ` Volodymyr Babchuk [this message]
2026-03-25 15:47 ` Mykola Kvach
2026-03-30 23:44 ` Volodymyr Babchuk
2026-04-28 18:42 ` Oleksandr Tyshchenko
2026-05-04 5:42 ` Mykola Kvach
2026-03-25 10:38 ` [PATCH 2/4] xen/arm: its: add platform match callback for ITS quirks Mykola Kvach
2026-03-25 14:45 ` Volodymyr Babchuk
2026-03-25 16:34 ` Mykola Kvach
2026-03-31 0:26 ` Volodymyr Babchuk
2026-03-31 8:15 ` Mykola Kvach
2026-04-02 16:50 ` Volodymyr Babchuk
2026-03-25 10:38 ` [PATCH 3/4] xen/arm: its: add Orange Pi 5 ITS quirk Mykola Kvach
2026-03-25 10:38 ` [PATCH 4/4] xen/arm: its: pre-initialize ITS quirks before LPI setup Mykola Kvach
2026-04-02 17:02 ` Volodymyr Babchuk
2026-04-28 16:31 ` Oleksandr Tyshchenko
2026-05-04 6:33 ` Mykola Kvach
2026-04-28 12:25 ` Ping: Re: [PATCH 0/4] xen/arm: ITS quirk handling fixes and board-specific matches Mykola Kvach
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=87bjgcvul6.fsf@epam.com \
--to=volodymyr_babchuk@epam.com \
--cc=Mykola_Kvach@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--cc=xakep.amatop@gmail.com \
--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.