Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip/gic-v3: Remove the ISB between AP0Rn and AP1Rn
@ 2026-08-24  2:34 Li Dou
  2026-08-24 16:34 ` Marc Zyngier
  0 siblings, 1 reply; 4+ messages in thread
From: Li Dou @ 2026-08-24  2:34 UTC (permalink / raw)
  To: maz; +Cc: tglx, radu, linux-arm-kernel, linux-kernel, li8d6kernel

ARM GICv3 specification says(in section 4.8.4 "System register access to
the Active Priorities registers"):

	an ISB is not required between each write to ICC_AP0R<n>_EL1,
	Secure ICC_AP1R<n>_EL1, and Non-secure ICC_AP1R<n>_EL1.

It means we can use one ISB after resetting AP0Rn and AP1Rn for context
synchronization. So just remove the previous one.

Signed-off-by: Li Dou <li8d6kernel@163.com>
---
 drivers/irqchip/irq-gic-v3.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 6e1fa5b247fc..3c48f46abb25 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -1205,8 +1205,6 @@ static void gic_cpu_sys_reg_init(void)
 		case 4:
 			write_gicreg(0, ICC_AP0R0_EL1);
 		}
-
-		isb();
 	}
 
 	switch(pribits) {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] irqchip/gic-v3: Remove the ISB between AP0Rn and AP1Rn
  2026-08-24  2:34 [PATCH] irqchip/gic-v3: Remove the ISB between AP0Rn and AP1Rn Li Dou
@ 2026-08-24 16:34 ` Marc Zyngier
  2026-08-25  3:04   ` Li Dou
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Zyngier @ 2026-08-24 16:34 UTC (permalink / raw)
  To: Li Dou; +Cc: tglx, radu, linux-arm-kernel, linux-kernel

On Mon, 24 Aug 2026 03:34:03 +0100,
Li Dou <li8d6kernel@163.com> wrote:
> 
> ARM GICv3 specification says(in section 4.8.4 "System register access to
> the Active Priorities registers"):
> 
> 	an ISB is not required between each write to ICC_AP0R<n>_EL1,
> 	Secure ICC_AP1R<n>_EL1, and Non-secure ICC_AP1R<n>_EL1.
> 
> It means we can use one ISB after resetting AP0Rn and AP1Rn for context
> synchronization. So just remove the previous one.

I'm afraid you have misinterpreted the spec.

Within each of the AP0Rn, Secure AP1Rn and Non-Secure AP1Rn classes,
for any value of 'n', there is no need for any synchronisation.

However, between classes, you absolutely need an ISB. And this is the
reason why, just above the note you quote:

<quote>
Writes to these registers in any order other than the following can
result in UNPREDICTABLE behavior:

1. ICC_AP0R<n>_EL1.
2. Secure ICC_AP1R<n>_EL1.
3. Non-secure ICC_AP1R<n>_EL1.
</quote>

While you can perfectly write each individual register of (1), (2) or
(3) without any synchronisation, you absolutely must have a CSE
*between* each of (1), (2) and (3). Linux being non-secure only, you
only deal with (1) and (3), and you must have an ISB in between.
Without it, reordering can happen and you end-up violating the above
rule.

To conclude, this patch does not optimise anything. Not only this is
something that only happens once per CPU boot (aka *never*), it
instead introduces a very subtle ordering bug.

It therefore must not be applied.

	M.

-- 
Jazz isn't dead. It just smells funny.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] irqchip/gic-v3: Remove the ISB between AP0Rn and AP1Rn
  2026-08-24 16:34 ` Marc Zyngier
@ 2026-08-25  3:04   ` Li Dou
  2026-08-25  7:25     ` Marc Zyngier
  0 siblings, 1 reply; 4+ messages in thread
From: Li Dou @ 2026-08-25  3:04 UTC (permalink / raw)
  To: maz; +Cc: li8d6kernel, linux-arm-kernel, linux-kernel, radu, tglx

Hi Marc,

On Mon, 24 Aug 2026 17:34:34 +0100, Marc Zyngier wrote:
>On Mon, 24 Aug 2026 03:34:03 +0100,
>Li Dou <li8d6kernel@163.com> wrote:
>> 
>> ARM GICv3 specification says(in section 4.8.4 "System register access to
>> the Active Priorities registers"):
>> 
>> 	an ISB is not required between each write to ICC_AP0R<n>_EL1,
>> 	Secure ICC_AP1R<n>_EL1, and Non-secure ICC_AP1R<n>_EL1.
>> 
>> It means we can use one ISB after resetting AP0Rn and AP1Rn for context
>> synchronization. So just remove the previous one.
>
>I'm afraid you have misinterpreted the spec.
>
>Within each of the AP0Rn, Secure AP1Rn and Non-Secure AP1Rn classes,
>for any value of 'n', there is no need for any synchronisation.
>
>However, between classes, you absolutely need an ISB. And this is the
>reason why, just above the note you quote:
>
><quote>
>Writes to these registers in any order other than the following can
>result in UNPREDICTABLE behavior:
>
>1. ICC_AP0R<n>_EL1.
>2. Secure ICC_AP1R<n>_EL1.
>3. Non-secure ICC_AP1R<n>_EL1.
></quote>
>
>While you can perfectly write each individual register of (1), (2) or
>(3) without any synchronisation, you absolutely must have a CSE
>*between* each of (1), (2) and (3). Linux being non-secure only, you
>only deal with (1) and (3), and you must have an ISB in between.
>Without it, reordering can happen and you end-up violating the above
>rule.

The spec sometimes is overly convoluted. Thanks for the clarification.

Best regards,
Li



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] irqchip/gic-v3: Remove the ISB between AP0Rn and AP1Rn
  2026-08-25  3:04   ` Li Dou
@ 2026-08-25  7:25     ` Marc Zyngier
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2026-08-25  7:25 UTC (permalink / raw)
  To: Li Dou; +Cc: linux-arm-kernel, linux-kernel, radu, tglx

On Tue, 25 Aug 2026 04:04:54 +0100,
Li Dou <li8d6kernel@163.com> wrote:
> 
> Hi Marc,
> 
> On Mon, 24 Aug 2026 17:34:34 +0100, Marc Zyngier wrote:
> >On Mon, 24 Aug 2026 03:34:03 +0100,
> >Li Dou <li8d6kernel@163.com> wrote:
> >> 
> >> ARM GICv3 specification says(in section 4.8.4 "System register access to
> >> the Active Priorities registers"):
> >> 
> >> 	an ISB is not required between each write to ICC_AP0R<n>_EL1,
> >> 	Secure ICC_AP1R<n>_EL1, and Non-secure ICC_AP1R<n>_EL1.
> >> 
> >> It means we can use one ISB after resetting AP0Rn and AP1Rn for context
> >> synchronization. So just remove the previous one.
> >
> >I'm afraid you have misinterpreted the spec.
> >
> >Within each of the AP0Rn, Secure AP1Rn and Non-Secure AP1Rn classes,
> >for any value of 'n', there is no need for any synchronisation.
> >
> >However, between classes, you absolutely need an ISB. And this is the
> >reason why, just above the note you quote:
> >
> ><quote>
> >Writes to these registers in any order other than the following can
> >result in UNPREDICTABLE behavior:
> >
> >1. ICC_AP0R<n>_EL1.
> >2. Secure ICC_AP1R<n>_EL1.
> >3. Non-secure ICC_AP1R<n>_EL1.
> ></quote>
> >
> >While you can perfectly write each individual register of (1), (2) or
> >(3) without any synchronisation, you absolutely must have a CSE
> >*between* each of (1), (2) and (3). Linux being non-secure only, you
> >only deal with (1) and (3), and you must have an ISB in between.
> >Without it, reordering can happen and you end-up violating the above
> >rule.
> 
> The spec sometimes is overly convoluted. Thanks for the clarification.

The spec is pretty clear in this particular case. It outlines the
order by which group of registers must be written to, and therefore
there is only one way to interpret the accompanying note.

As for any spec, you need to read the whole thing, and not take a
particular statement out of context.

Thanks,

	M.

-- 
Jazz isn't dead. It just smells funny.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-25  7:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24  2:34 [PATCH] irqchip/gic-v3: Remove the ISB between AP0Rn and AP1Rn Li Dou
2026-08-24 16:34 ` Marc Zyngier
2026-08-25  3:04   ` Li Dou
2026-08-25  7:25     ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox