Skip to contentSkip to conversation

irqchip/gic-v3: Fix IPRIORITYR can't perform byte operations in GIC-600

PATCH In review Lecopzer Chen 3 participants 6 messages Mar 30, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/gic-v3: Fix IPRIORITYR can't perform byte operations in GIC-600

When pseudo-NMI enabled, register_nmi() set priority of specific IRQ by byte ops, and this doesn't work in GIC-600.

We have asked ARM Support [1]:

Quoted 8 lines

Please refer to following description in
"2.1.2 Distributor ACE-Lite slave interface" of GIC-600 TRM for the GIC600 ACE-lite slave interface supported sizes:
"The GIC-600 only accepts single beat accesses of the sizes for each register that are shown in the Programmers model, see Chapter 4 Programmer's model on page 4-102.
All other accesses are rejected and given either an
OKAY or SLVERR response that is based on the GICT_ERR0CTLR.UE bit.".

Thus the register needs to be written by double word operation and the step will be: read 32bit, set byte and write it back.

[1] https://services.arm.com/support/s/case/5003t00001L4Pba

---
 drivers/irqchip/irq-gic-v3.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +12 -1
index eb0ee356a629..cfc5a6ad30dc 100644
@@ -440,10 +440,21 @@ static void gic_irq_set_prio(struct irq_data *d, u8 prio)
 {
 	void __iomem *base = gic_dist_base(d);
 	u32 offset, index;
+	u32 val, prio_offset_mask, prio_offset_shift;
 
 	offset = convert_offset_index(d, GICD_IPRIORITYR, &index);
 
-	writeb_relaxed(prio, base + offset + index);
+	/*
+	 * GIC-600 memory mapping register doesn't support byte opteration,
+	 * thus read 32-bits from register, set bytes and wtire back to it.
+	 */
+	prio_offset_shift = (index & 0x3) * 8;
+	prio_offset_mask = GENMASK(prio_offset_shift + 7, prio_offset_shift);
+	index &= ~0x3;
+	val = readl_relaxed(base + offset + index);
+	val &= ~prio_offset_mask;
+	val |= prio << prio_offset_shift;
+	writel_relaxed(val, base + offset + index);
 }
 
 static u32 gic_get_ppi_index(struct irq_data *d)
Signature · 1 line
2.18.0
maintainer
#1 lore raw

[+Lorenzo, +Julien on an actual email address]

Quoted 14 lines · Lecopzer Chen

When pseudo-NMI enabled, register_nmi() set priority of specific IRQ by byte ops, and this doesn't work in GIC-600.

We have asked ARM Support [1]:

Quoted 8 lines

Please refer to following description in
"2.1.2 Distributor ACE-Lite slave interface" of GIC-600 TRM for the GIC600 ACE-lite slave interface supported sizes:
"The GIC-600 only accepts single beat accesses of the sizes for each register that are shown in the Programmers model, see Chapter 4 Programmer's model on page 4-102.
All other accesses are rejected and given either an
OKAY or SLVERR response that is based on the GICT_ERR0CTLR.UE bit.".

Quoted 4 lines

Thus the register needs to be written by double word operation and the step will be: read 32bit, set byte and write it back.

[1] https://services.arm.com/support/s/case/5003t00001L4Pba

You do realise that this link:

- is unusable for most people as it is behind a registration interface
- discloses confidential information to other people

I strongly suggest you stop posting such links.

Quoted 23 lines
---
 drivers/irqchip/irq-gic-v3.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +5 -1
index eb0ee356a629..cfc5a6ad30dc 100644
@@ -440,10 +440,21 @@ static void gic_irq_set_prio(struct irq_data *d, u8 prio)
 {
 	void __iomem *base = gic_dist_base(d);
 	u32 offset, index;
+	u32 val, prio_offset_mask, prio_offset_shift;
 
 	offset = convert_offset_index(d, GICD_IPRIORITYR, &index);
 
-	writeb_relaxed(prio, base + offset + index);
+	/*
+	 * GIC-600 memory mapping register doesn't support byte opteration,
+	 * thus read 32-bits from register, set bytes and wtire back to it.
+	 */

drivers/irqchip/irq-gic-v3.c static void gic_irq_set_prio(struct irq_data *d, u8 prio) · line 460

Quoted 10 lines
drivers/irqchip/irq-gic-v3.c +7 -0
+	prio_offset_shift = (index & 0x3) * 8;
+	prio_offset_mask = GENMASK(prio_offset_shift + 7, prio_offset_shift);
+	index &= ~0x3;
+	val = readl_relaxed(base + offset + index);
+	val &= ~prio_offset_mask;
+	val |= prio << prio_offset_shift;
+	writel_relaxed(val, base + offset + index);
 }
 
 static u32 gic_get_ppi_index(struct irq_data *d)

From the architecture spec:

<quote>
11.1.3 GIC memory-mapped register access

In any system, access to the following registers must be supported:

[...]
* Byte accesses to:
- GICD_IPRIORITYR<n>.
- GICD_ITARGETSR<n>.
- GICD_SPENDSGIR<n>.
- GICD_CPENDSGIR<n>.
- GICR_IPRIORITYR<n>.
</quote>

So if GIC600 doesn't follow this architectural requirement, this is a HW erratum, and I want an actual description of the HW issue together with an erratum number.

Lorenzo, can you please investigate on your side?

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#2 lore raw
Quoted 80 lines · Marc Zyngier

[+Lorenzo, +Julien on an actual email address]

Quoted 14 lines · Lecopzer Chen

When pseudo-NMI enabled, register_nmi() set priority of specific IRQ by byte ops, and this doesn't work in GIC-600.

We have asked ARM Support [1]:

Quoted 8 lines

Please refer to following description in
"2.1.2 Distributor ACE-Lite slave interface" of GIC-600 TRM for the GIC600 ACE-lite slave interface supported sizes:
"The GIC-600 only accepts single beat accesses of the sizes for each register that are shown in the Programmers model, see Chapter 4 Programmer's model on page 4-102.
All other accesses are rejected and given either an
OKAY or SLVERR response that is based on the GICT_ERR0CTLR.UE bit.".

Quoted 4 lines

Thus the register needs to be written by double word operation and the step will be: read 32bit, set byte and write it back.

[1] https://services.arm.com/support/s/case/5003t00001L4Pba

You do realise that this link:

- is unusable for most people as it is behind a registration interface
- discloses confidential information to other people

I strongly suggest you stop posting such links.

Quoted 23 lines
---
 drivers/irqchip/irq-gic-v3.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +5 -1
index eb0ee356a629..cfc5a6ad30dc 100644
@@ -440,10 +440,21 @@ static void gic_irq_set_prio(struct irq_data *d, u8 prio)
 {
 	void __iomem *base = gic_dist_base(d);
 	u32 offset, index;
+	u32 val, prio_offset_mask, prio_offset_shift;
 
 	offset = convert_offset_index(d, GICD_IPRIORITYR, &index);
 
-	writeb_relaxed(prio, base + offset + index);
+	/*
+	 * GIC-600 memory mapping register doesn't support byte opteration,
+	 * thus read 32-bits from register, set bytes and wtire back to it.
+	 */

drivers/irqchip/irq-gic-v3.c static void gic_irq_set_prio(struct irq_data *d, u8 prio) · line 460

Quoted 10 lines
drivers/irqchip/irq-gic-v3.c +7 -0
+	prio_offset_shift = (index & 0x3) * 8;
+	prio_offset_mask = GENMASK(prio_offset_shift + 7, prio_offset_shift);
+	index &= ~0x3;
+	val = readl_relaxed(base + offset + index);
+	val &= ~prio_offset_mask;
+	val |= prio << prio_offset_shift;
+	writel_relaxed(val, base + offset + index);
 }
 
 static u32 gic_get_ppi_index(struct irq_data *d)

From the architecture spec:

<quote>
11.1.3 GIC memory-mapped register access

In any system, access to the following registers must be supported:

[...]
* Byte accesses to:
- GICD_IPRIORITYR<n>.
- GICD_ITARGETSR<n>.
- GICD_SPENDSGIR<n>.
- GICD_CPENDSGIR<n>.
- GICR_IPRIORITYR<n>.
</quote>

Quoted 5 lines

So if GIC600 doesn't follow this architectural requirement, this is a HW erratum, and I want an actual description of the HW issue together with an erratum number.

Lorenzo, can you please investigate on your side?

Sure - I will look into it and report back.

Thanks,
Lorenzo

#3 lore raw
Quoted 81 lines · Lorenzo Pieralisi
Quoted 80 lines · Marc Zyngier

[+Lorenzo, +Julien on an actual email address]

Quoted 14 lines · Lecopzer Chen

When pseudo-NMI enabled, register_nmi() set priority of specific IRQ by byte ops, and this doesn't work in GIC-600.

We have asked ARM Support [1]:

Quoted 8 lines

Please refer to following description in
"2.1.2 Distributor ACE-Lite slave interface" of GIC-600 TRM for the GIC600 ACE-lite slave interface supported sizes:
"The GIC-600 only accepts single beat accesses of the sizes for each register that are shown in the Programmers model, see Chapter 4 Programmer's model on page 4-102.
All other accesses are rejected and given either an
OKAY or SLVERR response that is based on the GICT_ERR0CTLR.UE bit.".

Quoted 4 lines

Thus the register needs to be written by double word operation and the step will be: read 32bit, set byte and write it back.

[1] https://services.arm.com/support/s/case/5003t00001L4Pba

You do realise that this link:

- is unusable for most people as it is behind a registration interface
- discloses confidential information to other people

I strongly suggest you stop posting such links.

Quoted 23 lines
---
 drivers/irqchip/irq-gic-v3.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +5 -1
index eb0ee356a629..cfc5a6ad30dc 100644
@@ -440,10 +440,21 @@ static void gic_irq_set_prio(struct irq_data *d, u8 prio)
 {
 	void __iomem *base = gic_dist_base(d);
 	u32 offset, index;
+	u32 val, prio_offset_mask, prio_offset_shift;
 
 	offset = convert_offset_index(d, GICD_IPRIORITYR, &index);
 
-	writeb_relaxed(prio, base + offset + index);
+	/*
+	 * GIC-600 memory mapping register doesn't support byte opteration,
+	 * thus read 32-bits from register, set bytes and wtire back to it.
+	 */

drivers/irqchip/irq-gic-v3.c static void gic_irq_set_prio(struct irq_data *d, u8 prio) · line 460

Quoted 10 lines
drivers/irqchip/irq-gic-v3.c +7 -0
+	prio_offset_shift = (index & 0x3) * 8;
+	prio_offset_mask = GENMASK(prio_offset_shift + 7, prio_offset_shift);
+	index &= ~0x3;
+	val = readl_relaxed(base + offset + index);
+	val &= ~prio_offset_mask;
+	val |= prio << prio_offset_shift;
+	writel_relaxed(val, base + offset + index);
 }
 
 static u32 gic_get_ppi_index(struct irq_data *d)

From the architecture spec:

<quote>
11.1.3 GIC memory-mapped register access

In any system, access to the following registers must be supported:

[...]
* Byte accesses to:
- GICD_IPRIORITYR<n>.
- GICD_ITARGETSR<n>.
- GICD_SPENDSGIR<n>.
- GICD_CPENDSGIR<n>.
- GICR_IPRIORITYR<n>.
</quote>

Quoted 7 lines
Quoted 5 lines

So if GIC600 doesn't follow this architectural requirement, this is a HW erratum, and I want an actual description of the HW issue together with an erratum number.

Lorenzo, can you please investigate on your side?

Sure - I will look into it and report back.

Checked - I don't think this patch is needed so it should be dropped and a follow-up discussion can continue in the relevant/appropriate forum - if there is anything left to discuss.

Thanks,
Lorenzo

maintainer
#4 lore raw
Quoted 87 lines · Lorenzo Pieralisi
Quoted 85 lines · Lorenzo Pieralisi
Quoted 84 lines · Marc Zyngier

[+Lorenzo, +Julien on an actual email address]

Quoted 14 lines · Lecopzer Chen

When pseudo-NMI enabled, register_nmi() set priority of specific IRQ by byte ops, and this doesn't work in GIC-600.

We have asked ARM Support [1]:

Quoted 8 lines

Please refer to following description in
"2.1.2 Distributor ACE-Lite slave interface" of GIC-600 TRM for the GIC600 ACE-lite slave interface supported sizes:
"The GIC-600 only accepts single beat accesses of the sizes for each register that are shown in the Programmers model, see Chapter 4 Programmer's model on page 4-102.
All other accesses are rejected and given either an
OKAY or SLVERR response that is based on the GICT_ERR0CTLR.UE bit.".

Quoted 4 lines

Thus the register needs to be written by double word operation and the step will be: read 32bit, set byte and write it back.

[1] https://services.arm.com/support/s/case/5003t00001L4Pba

You do realise that this link:

- is unusable for most people as it is behind a registration interface
- discloses confidential information to other people

I strongly suggest you stop posting such links.

Quoted 23 lines
---
 drivers/irqchip/irq-gic-v3.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +5 -1
index eb0ee356a629..cfc5a6ad30dc 100644
@@ -440,10 +440,21 @@ static void gic_irq_set_prio(struct irq_data *d, u8 prio)
 {
 	void __iomem *base = gic_dist_base(d);
 	u32 offset, index;
+	u32 val, prio_offset_mask, prio_offset_shift;
 
 	offset = convert_offset_index(d, GICD_IPRIORITYR, &index);
 
-	writeb_relaxed(prio, base + offset + index);
+	/*
+	 * GIC-600 memory mapping register doesn't support byte opteration,
+	 * thus read 32-bits from register, set bytes and wtire back to it.
+	 */

drivers/irqchip/irq-gic-v3.c static void gic_irq_set_prio(struct irq_data *d, u8 prio) · line 460

Quoted 10 lines
drivers/irqchip/irq-gic-v3.c +7 -0
+	prio_offset_shift = (index & 0x3) * 8;
+	prio_offset_mask = GENMASK(prio_offset_shift + 7, prio_offset_shift);
+	index &= ~0x3;
+	val = readl_relaxed(base + offset + index);
+	val &= ~prio_offset_mask;
+	val |= prio << prio_offset_shift;
+	writel_relaxed(val, base + offset + index);
 }
 
 static u32 gic_get_ppi_index(struct irq_data *d)

From the architecture spec:

<quote>
11.1.3 GIC memory-mapped register access

In any system, access to the following registers must be supported:

[...]
* Byte accesses to:
- GICD_IPRIORITYR<n>.
- GICD_ITARGETSR<n>.
- GICD_SPENDSGIR<n>.
- GICD_CPENDSGIR<n>.
- GICR_IPRIORITYR<n>.
</quote>

So if GIC600 doesn't follow this architectural requirement, this is a HW erratum, and I want an actual description of the HW issue together with an erratum number.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Lorenzo, can you please investigate on your side?

Sure - I will look into it and report back.

Checked - I don't think this patch is needed so it should be dropped and a follow-up discussion can continue in the relevant/appropriate forum - if there is anything left to discuss.

Thanks for having had a look. This really smells like an integration issue rather than an actual GIC bug.

Lecopzer, please check with your HW people and potentially ARM, as I think you are looking at the wrong problem.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#5 lore raw

[...]

Quoted 29 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

From the architecture spec:

<quote>
11.1.3 GIC memory-mapped register access

In any system, access to the following registers must be supported:

[...]
* Byte accesses to:
- GICD_IPRIORITYR<n>.
- GICD_ITARGETSR<n>.
- GICD_SPENDSGIR<n>.
- GICD_CPENDSGIR<n>.
- GICR_IPRIORITYR<n>.
</quote>

So if GIC600 doesn't follow this architectural requirement, this is a HW erratum, and I want an actual description of the HW issue together with an erratum number.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Lorenzo, can you please investigate on your side?

Sure - I will look into it and report back.

Checked - I don't think this patch is needed so it should be dropped and a follow-up discussion can continue in the relevant/appropriate forum - if there is anything left to discuss.

Quoted 5 lines

Thanks for having had a look. This really smells like an integration issue rather than an actual GIC bug.

Lecopzer, please check with your HW people and potentially ARM, as I think you are looking at the wrong problem.

Thanks a lot for the suggestion and checking,

I think I'll back to disscuss with ARM and our HW team to figure out the previous answer from ARM Support in detail.

Thanks again!

Lecopzer