From: Marc Zyngier <maz@kernel.org>
To: "Liao, Chang" <liaochang1@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
<linux-arm-kernel@lists.infradead.org>,
<alexandru.elisei@arm.com>, <catalin.marinas@arm.com>,
<linux-kernel@vger.kernel.org>, <tglx@linutronix.de>,
<will@kernel.org>
Subject: Re: [PATCH v2 5/5] arm64: irqchip/gic-v3: Select priorities at boot time
Date: Fri, 21 Jun 2024 08:48:32 +0100 [thread overview]
Message-ID: <8634p6ka7j.wl-maz@kernel.org> (raw)
In-Reply-To: <39b2bce8-3bc1-b1d9-3e4a-8132a92059c6@huawei.com>
On Fri, 21 Jun 2024 07:23:54 +0100,
"Liao, Chang" <liaochang1@huawei.com> wrote:
>
>
>
> 在 2024/6/17 19:18, Mark Rutland 写道:
> > cpus_have_group0 = gic_has_group0();
>
> > +#define __gicv3_prio_to_ns(p) (0xff & ((p) << 1))
> > +#define __gicv3_ns_to_prio(ns) (0x80 | ((ns) >> 1))
>
> What about refactoring the gic_has_group0() using the mapping macros
> between PMR priority and GIC priority like this:
>
> ---------------%<-----------------
> --- a/drivers/irqchip/irq-gic-v3.c
> +++ b/drivers/irqchip/irq-gic-v3.c
> @@ -882,6 +882,7 @@ static bool gic_has_group0(void)
> {
> u32 val;
> u32 old_pmr;
> + u32 prio = BIT(8 - gic_get_pribits());
>
> old_pmr = gic_read_pmr();
>
> @@ -896,12 +897,12 @@ static bool gic_has_group0(void)
> * becomes 0x80. Reading it back returns 0, indicating that
> * we're don't have access to Group0.
> */
> - gic_write_pmr(BIT(8 - gic_get_pribits()));
> + gic_write_pmr(prio);
> val = gic_read_pmr();
>
> gic_write_pmr(old_pmr);
>
> - return val != 0;
> + return val != (__gicv3_prio_to_ns(__gicv3_ns_to_prio(prio)));
> }
> --------------->%-----------------
No, that's terrible, and makes it simply impossible to understand what
is happening without looking at 3 layers of indirection.
Read the comment, and realise that the code implements exactly that.
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2024-06-21 7:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 11:18 [PATCH v2 0/5] arm64: irqchip/gic-v3: Use compiletime constant PMR values Mark Rutland
2024-06-17 11:18 ` [PATCH v2 1/5] wordpart.h: Add REPEAT_BYTE_U32() Mark Rutland
2024-06-17 11:18 ` [PATCH v2 2/5] irqchip/gic-common: Remove sync_access callback Mark Rutland
2024-06-21 2:22 ` Jinjie Ruan
2024-06-21 11:17 ` Mark Rutland
2024-06-17 11:18 ` [PATCH v2 3/5] irqchip/gic-v3: Make distributor priorities variables Mark Rutland
2024-06-17 11:18 ` [PATCH v2 4/5] irqchip/gic-v3: Detect GICD_CTRL.DS and SCR_EL3.FIQ earlier Mark Rutland
2024-06-17 11:18 ` [PATCH v2 5/5] arm64: irqchip/gic-v3: Select priorities at boot time Mark Rutland
2024-06-21 6:23 ` Liao, Chang
2024-06-21 7:48 ` Marc Zyngier [this message]
2024-06-21 8:14 ` Liao, Chang
2024-06-21 17:26 ` [PATCH v2 0/5] arm64: irqchip/gic-v3: Use compiletime constant PMR values Catalin Marinas
2024-06-22 21:29 ` Thomas Gleixner
2024-06-24 18:22 ` Catalin Marinas
2024-06-24 18:12 ` Catalin Marinas
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=8634p6ka7j.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=alexandru.elisei@arm.com \
--cc=catalin.marinas@arm.com \
--cc=liaochang1@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox