mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Liao, Chang" <liaochang1@huawei.com>
To: Marc Zyngier <maz@kernel.org>
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 16:14:34 +0800	[thread overview]
Message-ID: <33b6be1d-ac8f-1511-480a-0f2d609af115@huawei.com> (raw)
In-Reply-To: <8634p6ka7j.wl-maz@kernel.org>



在 2024/6/21 15:48, Marc Zyngier 写道:
> 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.

You are right, it is BIT(8-gic_get_pribits()) decides gic_read_pmr() must return zero
if SCR_EL3.FIQ is set, there is no need to overcomplicate things.

> 
> 	M.
> 

-- 
BR
Liao, Chang

  reply	other threads:[~2024-06-21  8:14 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
2024-06-21  8:14       ` Liao, Chang [this message]
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=33b6be1d-ac8f-1511-480a-0f2d609af115@huawei.com \
    --to=liaochang1@huawei.com \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --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

all inboxes | Powered by JetHome®