irqchip/gic-v3: workaround for ASR8601 when reading mpidr
PATCH 1/1 irqchip/gic-v3: workaround for ASR8601 when reading mpidr
This patch add workaround for ASR8601, which uses an armv8.2 processor with a gic-500. ARMv8.2 uses Multiprocessor Affinity Register to identify the logical address of the core by | cluster | core | thread |.
However, gic-500 only supports topologies with affinity levels less than 2 as
| cluster | core|.
So it needs this patch to shift the MPIDR values
to ensure proper functionality
--- drivers/irqchip/irq-gic-v3.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +27 -1
@@ -39,6 +39,7 @@#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_MPIDR_ASR8601 (1ULL << 2)#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)
@@ -659,6 +660,9 @@ static u64 gic_mpidr_to_affinity(unsigned long mpidr) {u64 aff; +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ; + aff = ((u64)MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |
@@ -970,6 +974,9 @@ static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr)* Convert affinity to a 32bit value that can be matched to * GICR_TYPER bits [63:32]. */ +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ; + aff = (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 24 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |
@@ -1265,6 +1272,8 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask,unsigned long mpidr =cpu_logical_map (cpu);u16 tlist =0 ; +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ;while (cpu < nr_cpu_ids) { tlist |=1 << (mpidr &0xf );
@@ -1274,7 +1283,8 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, cpu = next_cpu; mpidr =cpu_logical_map (cpu); - +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ;if (cluster_id !=MPIDR_TO_SGI_CLUSTER_ID (mpidr)) { cpu--; goto out;
@@ -1321,6 +1331,8 @@ static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask)u64 cluster_id =MPIDR_TO_SGI_CLUSTER_ID (cpu_logical_map (cpu));u16 tlist; +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + cluster_id =MPIDR_TO_SGI_CLUSTER_ID (cpu_logical_map (cpu) >>8 ); tlist =gic_compute_target_list (&cpu, mask, cluster_id);gic_send_sgi (cluster_id, tlist, d->hwirq); }
@@ -1729,6 +1741,15 @@ static bool gic_enable_quirk_cavium_38539(void *data)return true; } +static bool gic_enable_quirk_asr8601 (void *data) +{ +struct gic_chip_data *d = data; + + d->flags |=FLAGS_WORKAROUND_MPIDR_ASR8601 ; + +return true; +} +static bool gic_enable_quirk_hip06_07 (void *data) {struct gic_chip_data *d = data;
@@ -1823,6 +1844,11 @@ static const struct gic_quirk gic_quirks[] = { .mask = 0xffffffff, .init = gic_enable_quirk_nvidia_t241, }, + { + .desc = "GICv3: ASR 8601 MPIDR SHIFT", + .compatible = "asr,asr8601-gic-v3", + .init = gic_enable_quirk_asr8601, + }, { } };
Signature · 1 line
2.25.1
Marc Zyngier
maintainerQuoted 5 lines · zhengyan
This patch add workaround for ASR8601, which uses an armv8.2 processor with a gic-500. ARMv8.2 uses Multiprocessor Affinity Register to identify the logical address of the core by | cluster | core | thread |.
Not quite. The ARMv8.2 architecture doesn't say *any* of that. It is ARM's *implementations* that follow this scheme.
Quoted 17 lines
However, gic-500 only supports topologies with
affinity levels less than 2 as
| cluster | core|.So it needs this patch to shift the MPIDR values
to ensure proper functionalitySigned-off-by zhengyan <[email protected]>--- drivers/irqchip/irq-gic-v3.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)drivers/irqchip/irq-gic-v3.c +0
-0
drivers/irqchip/irq-gic-v3.c line 42
Quoted 4 lines
drivers/irqchip/irq-gic-v3.c +1
-0@@ -39,6 +39,7 @@#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_MPIDR_ASR8601 (1ULL << 2)
What is ASR8601? Is it a system? Or an erratum number? For issues that are the result of a HW integration issue, please provide an official erratum number, and update Documentation/arm64/silicon-errata.rst.
Quoted 43 lines
drivers/irqchip/irq-gic-v3.c +10
-1#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)@@ -659,6 +660,9 @@ static u64 gic_mpidr_to_affinity(unsigned long mpidr) {u64 aff; +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ; + aff = ((u64)MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |@@ -970,6 +974,9 @@ static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr)* Convert affinity to a 32bit value that can be matched to * GICR_TYPER bits [63:32]. */ +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ; + aff = (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 24 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |@@ -1265,6 +1272,8 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask,unsigned long mpidr =cpu_logical_map (cpu);u16 tlist =0 ; +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ;while (cpu < nr_cpu_ids) { tlist |=1 << (mpidr &0xf );@@ -1274,7 +1283,8 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, cpu = next_cpu; mpidr =cpu_logical_map (cpu); - +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ;if (cluster_id !=MPIDR_TO_SGI_CLUSTER_ID (mpidr)) { cpu--; goto out;
drivers/irqchip/irq-gic-v3.c static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask) · line 1335
Quoted 5 lines
drivers/irqchip/irq-gic-v3.c +2
-0@@ -1321,6 +1331,8 @@ static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask)u64 cluster_id =MPIDR_TO_SGI_CLUSTER_ID (cpu_logical_map (cpu));u16 tlist; +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + cluster_id =MPIDR_TO_SGI_CLUSTER_ID (cpu_logical_map (cpu) >>8 );
You've written the same check 5 times. Maybe you could start by refactoring that code so that the hack can be in a single place?
Quoted 20 lines
drivers/irqchip/irq-gic-v3.c +9
-0tlist =gic_compute_target_list (&cpu, mask, cluster_id);gic_send_sgi (cluster_id, tlist, d->hwirq); }@@ -1729,6 +1741,15 @@ static bool gic_enable_quirk_cavium_38539(void *data)return true; } +static bool gic_enable_quirk_asr8601 (void *data) +{ +struct gic_chip_data *d = data; + + d->flags |=FLAGS_WORKAROUND_MPIDR_ASR8601 ; + +return true; +} +static bool gic_enable_quirk_hip06_07 (void *data) {struct gic_chip_data *d = data;
drivers/irqchip/irq-gic-v3.c static const struct gic_quirk gic_quirks[] = { · line 1848
Quoted 5 lines
drivers/irqchip/irq-gic-v3.c +2
-0@@ -1823,6 +1844,11 @@ static const struct gic_quirk gic_quirks[] = { .mask = 0xffffffff, .init = gic_enable_quirk_nvidia_t241, }, + { + .desc = "GICv3: ASR 8601 MPIDR SHIFT",
s/SHIFT/shift/
drivers/irqchip/irq-gic-v3.c static const struct gic_quirk gic_quirks[] = { · line 1849
Quoted 1 line
drivers/irqchip/irq-gic-v3.c +1
-0+ .compatible = "asr,asr8601-gic-v3",
So ASR8601 *is* a system... Is it DT only?
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Quoted 15 lines
-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: Wednesday, May 17, 2023 4:32 PM
To: Yan Zheng(严政) <[email protected]>
Cc: [email protected]; [email protected]; Gao Meitao(高玫涛) <[email protected]>; Zhou Qiao(周侨) <[email protected]>; Zhang Zhizhou(张治洲) <[email protected]>
Subject: Re: [PATCH] irqchip/gic-v3: workaround for ASR8601 when reading mpidrQuoted 1 line · zhengyan
Quoted 8 lines
Quoted 4 lines
This patch add workaround for ASR8601, which uses an armv8.2 processor with a gic-500. ARMv8.2 uses Multiprocessor Affinity Register to identify the logical address of the core by
| cluster | core | thread |.Not quite. The ARMv8.2 architecture doesn't say *any* of that. It is ARM's *implementations* that follow this scheme.
Really thank you for rapid response,
Yes, as arm documents https://developer.arm.com/docuentation/ka002107/latest said It comes from armv8.2 get 3 types for affinity (arm v8.0 cpus only get 2 types) And it's an implementations issue.
Quoted 18 lines
Quoted 18 lines
However, gic-500 only supports topologies with affinity levels less than 2 as
| cluster | core|.So it needs this patch to shift the MPIDR values to ensure proper functionality
Signed-off-by zhengyan <[email protected]>--- drivers/irqchip/irq-gic-v3.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/irqchip/irq-gic-v3.cindex6fcee221f201..435b98a8641e100644drivers/irqchip/irq-gic-v3.c +0
-0@@ -39,6 +39,7 @@
Quoted 8 lines
drivers/irqchip/irq-gic-v3.c line 42
Quoted 3 lines
drivers/irqchip/irq-gic-v3.c +1
-0#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_MPIDR_ASR8601 (1ULL << 2)What is ASR8601? Is it a system? Or an erratum number? For issues that are the result of a HW integration issue, please provide an official erratum number, and update
Documentation/arm64/silicon-errata.rst.
ASR8601 is our soc's name, and yes it’s a kind of HW integration issue But maybe it’s not an erratum since our HW design is like that, although Arm doesn't recommend this way.
And I would like to add more comments
Under the next part before *desc = "GICv3: ASR 8601 MPIDR shift"*
Maybe this is a better way? Or add something under Documentation?
Quoted 52 lines
drivers/irqchip/irq-gic-v3.c static u64 gic_mpidr_to_affinity(unsigned long · line 668
Quoted 13 lines
drivers/irqchip/irq-gic-v3.c +3
-0#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)@@ -659,6 +660,9 @@ static u64 gic_mpidr_to_affinity(unsigned long mpidr) {u64 aff; +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ; + aff = ((u64 )MPIDR_AFFINITY_LEVEL (mpidr,3 ) <<32 |MPIDR_AFFINITY_LEVEL (mpidr,2 ) <<16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 | @@ -970,6 +974,9@@
Quoted 1 line
static int __gic_populate_rdist(struct
redist_region*region, void__iomem*ptr)
drivers/irqchip/irq-gic-v3.c static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr)
Quoted 9 lines
drivers/irqchip/irq-gic-v3.c +3
-0* Convert affinity to a 32bit value that can be matched to * GICR_TYPER bits [63:32]. */ +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ; + aff = (MPIDR_AFFINITY_LEVEL (mpidr,3 ) <<24 |MPIDR_AFFINITY_LEVEL (mpidr,2 ) <<16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 | @@ -1265,6 +1272,8@@
Quoted 1 line
static u16 gic_compute_target_list(int
*base_cpu, const struct cpumask*mask,
drivers/irqchip/irq-gic-v3.c static u16 gic_compute_target_list(int *base_cpu,
Quoted 9 lines
drivers/irqchip/irq-gic-v3.c +2
-0unsigned long mpidr =cpu_logical_map (cpu);u16 tlist =0 ; +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ;while (cpu < nr_cpu_ids) { tlist |=1 << (mpidr &0xf );@@ -1274,7 +1283,8 @@ static u16 gic_compute_target_list(int *base_cpu,const struct cpumask *mask,
drivers/irqchip/irq-gic-v3.c static void gic_ipi_send_mask(struct irq_data *d,
Quoted 10 lines
drivers/irqchip/irq-gic-v3.c +2
-1cpu = next_cpu; mpidr =cpu_logical_map (cpu); - +if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + mpidr >>=8 ;if (cluster_id !=MPIDR_TO_SGI_CLUSTER_ID (mpidr)) { cpu--; goto out;@@ -1321,6 +1331,8 @@ static void gic_ipi_send_mask(struct irq_data *d,const struct cpumask *mask)
Quoted 3 lines
drivers/irqchip/irq-gic-v3.c +0
-0u64 cluster_id =MPIDR_TO_SGI_CLUSTER_ID (cpu_logical_map (cpu));u16 tlist;
Quoted 7 lines
drivers/irqchip/irq-gic-v3.c static void gic_ipi_send_mask(struct irq_data *d, · line 1335
Quoted 2 lines
drivers/irqchip/irq-gic-v3.c +2
-0+if (gic_data.flags &FLAGS_WORKAROUND_MPIDR_ASR8601 ) + cluster_id =
MPIDR_TO_SGI_CLUSTER_ID(cpu_logical_map(cpu) >> 8);You've written the same check 5 times. Maybe you could start by refactoring that code so that the hack can be in a single place?
Okay, I'll try to refactor it
Quoted 18 lines
drivers/irqchip/irq-gic-v3.c static bool gic_enable_quirk_cavium_38539(void
Quoted 4 lines
drivers/irqchip/irq-gic-v3.c +0
-0tlist =gic_compute_target_list (&cpu, mask, cluster_id);gic_send_sgi (cluster_id, tlist, d->hwirq); }@@ -1729,6 +1741,15 @@ static bool gic_enable_quirk_cavium_38539(void*data)
Quoted 13 lines
drivers/irqchip/irq-gic-v3.c +8
-0return true; } +static bool gic_enable_quirk_asr8601 (void *data) { +struct gic_chip_data *d = data; + + d->flags |=FLAGS_WORKAROUND_MPIDR_ASR8601 ; + +return true; +} +static bool gic_enable_quirk_hip06_07 (void *data) {struct gic_chip_data *d = data;
Quoted 9 lines
drivers/irqchip/irq-gic-v3.c static const struct gic_quirk gic_quirks[] = { · line 1848
Quoted 6 lines
drivers/irqchip/irq-gic-v3.c +2
-0@@ -1823,6 +1844,11 @@ static const struct gic_quirk gic_quirks[] = { .mask = 0xffffffff, .init = gic_enable_quirk_nvidia_t241, }, + { + .desc = "GICv3: ASR 8601 MPIDR SHIFT",s/SHIFT/shift/
Okay
Quoted 10 lines
drivers/irqchip/irq-gic-v3.c static const struct gic_quirk gic_quirks[] = { · line 1849
Quoted 1 line
drivers/irqchip/irq-gic-v3.c +1
-0+ .compatible = "asr,asr8601-gic-v3",So ASR8601 *is* a system... Is it DT only?
Thanks,
M.--
Without deviation from the norm, progress is not possible.
Yes, asr8601 is our soc, and we want to use compatible node in devices-tree to control it, As I mentioned at previous part, it might works well under
armv8.2(3 types of affinity) with gic500, but these code get strongly order with HW integration
Thanks again,
Marc Zyngier
maintainerQuoted 21 lines · Yan Zheng(严政)
Quoted 21 lines
-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: Wednesday, May 17, 2023 4:32 PM
To: Yan Zheng(严政) <[email protected]>
Cc: [email protected]; [email protected]; Gao Meitao(高玫涛) <[email protected]>; Zhou Qiao(周侨) <[email protected]>; Zhang Zhizhou(张治洲) <[email protected]>
Subject: Re: [PATCH] irqchip/gic-v3: workaround for ASR8601 when reading mpidrQuoted 5 lines · zhengyan
This patch add workaround for ASR8601, which uses an armv8.2 processor with a gic-500. ARMv8.2 uses Multiprocessor Affinity Register to identify the logical address of the core by
| cluster | core | thread |.
Quoted 7 lines
Quoted 3 lines
Not quite. The ARMv8.2 architecture doesn't say *any* of that. It is ARM's *implementations* that follow this scheme.
Really thank you for rapid response,
Yes, as arm documents
https://developer.arm.com/docuentation/ka002107/latest said
This page doesn't exist.
Quoted 2 lines
It comes from armv8.2 get 3 types for affinity (arm v8.0 cpus only get 2 types) And it's an implementations issue.
Again, this has nothing to do with the ARMv8.2 architecture. Nor the ARMv8.0 architecture. Please read the ARM ARM, which says absolutely *nothing* of what the various affinity levels are for.
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
However, gic-500 only supports topologies with affinity levels less than 2 as
| cluster | core|.So it needs this patch to shift the MPIDR values to ensure proper functionality
Signed-off-by zhengyan <[email protected]>--- drivers/irqchip/irq-gic-v3.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/irqchip/irq-gic-v3.cindex6fcee221f201..435b98a8641e100644drivers/irqchip/irq-gic-v3.c +0
-0@@ -39,6 +39,7 @@Quoted 8 lines
drivers/irqchip/irq-gic-v3.c line 42
Quoted 3 lines
drivers/irqchip/irq-gic-v3.c +1
-0#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_MPIDR_ASR8601 (1ULL << 2)What is ASR8601? Is it a system? Or an erratum number? For issues that are the result of a HW integration issue, please provide an official erratum number, and update
Documentation/arm64/silicon-errata.rst.
Quoted 3 lines
ASR8601 is our soc's name, and yes it’s a kind of HW integration issue But maybe it’s not an erratum since our HW design is like that, although Arm doesn't recommend this way.
Yes, for a good reason: it doesn't work. So this is *definitely* an erratum, no ifs, no buts.
Quoted 3 lines
And I would like to add more comments
Under the next part before *desc = "GICv3: ASR 8601 MPIDR shift"*
Maybe this is a better way? Or add something under Documentation?
Documentation/arm64/silicon-errata.rst is the place to put it. Nowhere else.
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Quoted 41 lines
-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: Wednesday, May 17, 2023 8:59 PM
To: Yan Zheng(严政) <[email protected]>
Cc: [email protected]; [email protected]; Gao Meitao(高玫涛) <[email protected]>; Zhou Qiao(周侨) <[email protected]>; Zhang Zhizhou(张治洲) <[email protected]>
Subject: Re: [PATCH] irqchip/gic-v3: workaround for ASR8601 when reading mpidrQuoted 27 lines · Yan Zheng(严政)
Quoted 26 lines
-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: Wednesday, May 17, 2023 4:32 PM
To: Yan Zheng(严政) <[email protected]>
Cc: [email protected]; [email protected]; Gao Meitao(高玫涛)
<[email protected]>; Zhou Qiao(周侨) <[email protected]>; Zhang Zhizhou(张治洲) <[email protected]>
Subject: Re: [PATCH] irqchip/gic-v3: workaround for ASR8601 when reading mpidrQuoted 5 lines · zhengyan
This patch add workaround for ASR8601, which uses an armv8.2 processor with a gic-500. ARMv8.2 uses Multiprocessor Affinity Register to identify the logical address of the core by | cluster | core | thread |.
Not quite. The ARMv8.2 architecture doesn't say *any* of that. It is ARM's
*implementations* that follow this scheme.
Quoted 6 lines
Quoted 3 lines
Really thank you for rapid response,
Yes, as arm documents
https://developer.arm.com/docuentation/ka002107/latest saidThis page doesn't exist.
Sorry for my mistake,
https://developer.arm.com/documentation/ka002107/latest
extract from the docs:
The Arm-v8.0 CPUs use affinity 0 for a CPU and affinity 1 for a cluster. All Arm-v8.2 CPUs use affinity 2 for a cluster, 1 for a CPU, and 0 for a thread. The GIC-500 does not support affinity 2. Therefore, the GIC-500 cannot route Shared Peripheral Interrupts (SPIs) or Software Generated Interrupts (SGIs) correctly for Arm-v8.2 CPUs.
The GIC-500 does not have correct buses to connect the system together.
Quoted 7 lines
Quoted 2 lines
It comes from armv8.2 get 3 types for affinity (arm v8.0 cpus only get 2 types) And it's an implementations issue.
Again, this has nothing to do with the ARMv8.2 architecture. Nor the ARMv8.0 architecture. Please read the ARM ARM, which says absolutely *nothing* of what the various affinity levels are for.
As the extract from pervious part mentioned,
It seems like this issue related to that? I just want to mention that this issue is cause by HW choice in the commit message.
Quoted 32 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
However, gic-500 only supports topologies with affinity levels less than 2 as
| cluster | core|.So it needs this patch to shift the MPIDR values to ensure proper functionality
Signed-off-by zhengyan <[email protected]>--- drivers/irqchip/irq-gic-v3.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)Quoted 8 lines
Quoted 8 lines
drivers/irqchip/irq-gic-v3.c line 40
Quoted 8 lines
(quoted diff) +0
-0
b/drivers/irqchip/irq-gic-v3.cindex6fcee221f201..435b98a8641e100644drivers/irqchip/irq-gic-v3.c +0
-0@@ -39,6 +39,7 @@#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL <<0)
Quoted 1 line
Quoted 1 line
drivers/irqchip/irq-gic-v3.c line 41
Quoted 1 line
drivers/irqchip/irq-gic-v3.c +0
-0#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL <<1)
Quoted 5 lines
Quoted 5 lines
drivers/irqchip/irq-gic-v3.c line 42
Quoted 1 line
drivers/irqchip/irq-gic-v3.c +1
-0+#define FLAGS_WORKAROUND_MPIDR_ASR8601 (1ULL << 2)What is ASR8601? Is it a system? Or an erratum number? For issues that are the result of a HW integration issue, please provide an official erratum number, and update
Documentation/arm64/silicon-errata.rst.Quoted 2 lines
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
ASR8601 is our soc's name, and yes it’s a kind of HW integration issue But maybe it’s not an erratum since our HW design is like that, although Arm doesn't recommend this way.
Yes, for a good reason: it doesn't work. So this is *definitely* an erratum, no ifs, no buts.
Okay, I agree with you. Thanks for your advices.
Quoted 10 lines
Quoted 3 lines
And I would like to add more comments
Under the next part before *desc = "GICv3: ASR 8601 MPIDR shift"*
Maybe this is a better way? Or add something under Documentation?
Documentation/arm64/silicon-errata.rstis the place to put it. Nowhere else.M.--
Without deviation from the norm, progress is not possible.
Marc Zyngier
maintainerQuoted 49 lines · Yan Zheng(严政)
Quoted 42 lines
-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: Wednesday, May 17, 2023 8:59 PM
To: Yan Zheng(严政) <[email protected]>
Cc: [email protected]; [email protected]; Gao Meitao(高玫涛) <[email protected]>; Zhou Qiao(周侨) <[email protected]>; Zhang Zhizhou(张治洲) <[email protected]>
Subject: Re: [PATCH] irqchip/gic-v3: workaround for ASR8601 when reading mpidrQuoted 27 lines · Yan Zheng(严政)
Quoted 26 lines
-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: Wednesday, May 17, 2023 4:32 PM
To: Yan Zheng(严政) <[email protected]>
Cc: [email protected]; [email protected]; Gao Meitao(高玫涛)
<[email protected]>; Zhou Qiao(周侨) <[email protected]>; Zhang Zhizhou(张治洲) <[email protected]>
Subject: Re: [PATCH] irqchip/gic-v3: workaround for ASR8601 when reading mpidrQuoted 5 lines · zhengyan
This patch add workaround for ASR8601, which uses an armv8.2 processor with a gic-500. ARMv8.2 uses Multiprocessor Affinity Register to identify the logical address of the core by | cluster | core | thread |.
Not quite. The ARMv8.2 architecture doesn't say *any* of that. It is ARM's
*implementations* that follow this scheme.Quoted 6 lines
Quoted 3 lines
Really thank you for rapid response,
Yes, as arm documents
https://developer.arm.com/docuentation/ka002107/latest saidThis page doesn't exist.
Quoted 9 lines
Sorry for my mistake,
https://developer.arm.com/documentation/ka002107/latest
extract from the docs:
The Arm-v8.0 CPUs use affinity 0 for a CPU and affinity 1 for a cluster. All Arm-v8.2 CPUs use affinity 2 for a cluster, 1 for a CPU, and 0 for a thread. The GIC-500 does not support affinity 2. Therefore, the GIC-500 cannot route Shared Peripheral Interrupts (SPIs) or Software Generated Interrupts (SGIs) correctly for Arm-v8.2 CPUs.
The GIC-500 does not have correct buses to connect the system together.
All these are implementations. Nothing to do with the architecture (which only mentions the notion of 'cluster' when talking about caches).
Anyway, let's move on.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
It comes from armv8.2 get 3 types for affinity (arm v8.0 cpus only get 2 types) And it's an implementations issue.
Quoted 8 lines
Quoted 4 lines
Again, this has nothing to do with the ARMv8.2 architecture. Nor the ARMv8.0 architecture. Please read the ARM ARM, which says absolutely *nothing* of what the various affinity levels are for.
As the extract from pervious part mentioned,
It seems like this issue related to that? I just want to mention that this issue is cause by HW choice in the commit message.
You can say that GIC500 is incompatible with ARMv8.2 implementations from ARM, and that a workaround is needed for that.
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
PATCH v2 1/1 irqchip/gic-v3: workaround for ASR8601 when reading mpidr
In reply to zhengyanThis patch add workaround for ASR8601, which uses an armv8.2 processor with a gic-500. But gic-500 is incompatible with ARMv8.2 implementations from ARM.
ARMv8.2 from ARM implementation uses Multiprocessor Affinity Register to identify the logical address of the core by | cluster | core | thread |.
However, gic-500 only supports topologies with affinity levels less than 2 as
| cluster | core|.
So we need this patch as workaround to shift the MPIDR values to ensure proper functionality
--- Documentation/arm64/silicon-errata.rst | 4 ++++ drivers/irqchip/irq-gic-v3.c | 30 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
Documentation/arm64/silicon-errata.rst +4 -0
@@ -214,3 +214,7 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | Fujitsu | A64FX | E#010001 | FUJITSU_ERRATUM_010001 | +----------------+-----------------+-----------------+-----------------------------+ + ++----------------+-----------------+-----------------+-----------------------------+ +| ASR | ASR8601 | #8601001 | N/A | ++----------------+-----------------+-----------------+-----------------------------+
drivers/irqchip/irq-gic-v3.c +30 -0
@@ -39,6 +39,9 @@#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 2) + +#define ASR8601_AFF_QUIRK (aff) (aff >> 8)#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)
@@ -659,6 +662,9 @@ static u64 gic_mpidr_to_affinity(unsigned long mpidr) {u64 aff; +if (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ) + mpidr =ASR8601_AFF_QUIRK (mpidr); + aff = ((u64)MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |
@@ -970,6 +976,9 @@ static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr)* Convert affinity to a 32bit value that can be matched to * GICR_TYPER bits [63:32]. */ +if (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ) + mpidr =ASR8601_AFF_QUIRK (mpidr); + aff = (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 24 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |
@@ -1265,6 +1274,9 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask,unsigned long mpidr =cpu_logical_map (cpu);u16 tlist =0 ; +if (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ) + mpidr =ASR8601_AFF_QUIRK (mpidr); +while (cpu < nr_cpu_ids) { tlist |=1 << (mpidr &0xf );
@@ -1275,6 +1287,8 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, mpidr =cpu_logical_map (cpu); +if (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ) + mpidr =ASR8601_AFF_QUIRK (mpidr);if (cluster_id !=MPIDR_TO_SGI_CLUSTER_ID (mpidr)) { cpu--; goto out;
@@ -1321,6 +1335,8 @@ static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask)u64 cluster_id =MPIDR_TO_SGI_CLUSTER_ID (cpu_logical_map (cpu));u16 tlist; +if (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ) + cluster_id =MPIDR_TO_SGI_CLUSTER_ID (ASR8601_AFF_QUIRK (cpu_logical_map (cpu))); tlist =gic_compute_target_list (&cpu, mask, cluster_id);gic_send_sgi (cluster_id, tlist, d->hwirq); }
@@ -1786,6 +1802,15 @@ static bool gic_enable_quirk_nvidia_t241(void *data)return true; } +static bool gic_enable_quirk_asr8601 (void *data) +{ +struct gic_chip_data *d = data; + + d->flags |=FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ; + +return true; +} +static const struct gic_quirk gic_quirks[] = { { .desc ="GICv3: Qualcomm MSM8996 broken firmware" ,
@@ -1823,6 +1848,11 @@ static const struct gic_quirk gic_quirks[] = { .mask = 0xffffffff, .init = gic_enable_quirk_nvidia_t241, }, + { + .desc = "GICv3: ASR erratum 8601001", + .compatible = "asr,asr8601-gic-v3", + .init = gic_enable_quirk_asr8601, + }, { } };
Signature · 1 line
2.25.1
Marc Zyngier
maintainerQuoted 38 lines · zhengyan
This patch add workaround for ASR8601, which uses an armv8.2 processor with a gic-500. But gic-500 is incompatible with ARMv8.2 implementations from ARM.
ARMv8.2 from ARM implementation uses Multiprocessor Affinity Register to identify the logical address of the core by | cluster | core | thread |.
However, gic-500 only supports topologies with affinity levels less than 2 as
| cluster | core|.So we need this patch as workaround to shift the MPIDR values to ensure proper functionality
Signed-off-by zhengyan <[email protected]>--- Documentation/arm64/silicon-errata.rst | 4 ++++ drivers/irqchip/irq-gic-v3.c | 30 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)Documentation/arm64/silicon-errata.rst +4
-0@@ -214,3 +214,7 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | Fujitsu | A64FX | E#010001 | FUJITSU_ERRATUM_010001 | +----------------+-----------------+-----------------+-----------------------------+ + ++----------------+-----------------+-----------------+-----------------------------+ +| ASR | ASR8601 | #8601001 | N/A | ++----------------+-----------------+-----------------+-----------------------------+drivers/irqchip/irq-gic-v3.c +0
-0
drivers/irqchip/irq-gic-v3.c line 44
Quoted 6 lines
drivers/irqchip/irq-gic-v3.c +3
-0@@ -39,6 +39,9 @@#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 2) + +#define ASR8601_AFF_QUIRK (aff) (aff >> 8)
This is wrong. There are more than just affinity bits in MPIDR, and you're making a mess of the result.
Quoted 14 lines
drivers/irqchip/irq-gic-v3.c +3
-0#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)@@ -659,6 +662,9 @@ static u64 gic_mpidr_to_affinity(unsigned long mpidr) {u64 aff; +if (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ) + mpidr =ASR8601_AFF_QUIRK (mpidr); + aff = ((u64)MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |
drivers/irqchip/irq-gic-v3.c static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr) · line 980
Quoted 5 lines
drivers/irqchip/irq-gic-v3.c +2
-0@@ -970,6 +976,9 @@ static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr)* Convert affinity to a 32bit value that can be matched to * GICR_TYPER bits [63:32]. */ +if (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ) + mpidr =ASR8601_AFF_QUIRK (mpidr);
It really wasn't what I had in mind when I asked you to place this inside a helper. The whole thing looks horrible, and I really don't want to have to maintain anything like it.
I came up with the following patch, which keeps the workaround *in a single spot*.
Let me know if that works for you.
M.
drivers/irqchip/irq-gic-v3.c +32 -8
@@ -39,6 +39,7 @@#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 2)#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)
@@ -655,10 +656,16 @@ static int gic_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu)return 0 ; } -static u64 gic_mpidr_to_affinity (unsigned long mpidr) +static u64 gic_cpu_to_affinity (int cpu) { +u64 mpidr =cpu_logical_map (cpu);u64 aff; +/* ASR8601 needs to have its affinities shifted down... */ +if (unlikely (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 )) + mpidr = (MPIDR_AFFINITY_LEVEL (mpidr,1 ) | + (MPIDR_AFFINITY_LEVEL (mpidr,2 ) <<8 )); + aff = ((u64)MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |
@@ -913,7 +920,7 @@ static void __init gic_dist_init(void)* Set all global interrupts to the boot CPU only. ARE must be * enabled. */ - affinity =gic_mpidr_to_affinity (cpu_logical_map (smp_processor_id ())); + affinity =gic_cpu_to_affinity (smp_processor_id ());for (i =32 ; i <GIC_LINE_NR ; i++)gic_write_irouter (affinity, base +GICD_IROUTER + i *8 );
@@ -962,7 +969,7 @@ static int gic_iterate_rdists(int (*fn)(struct redist_region *, void __iomem *))static int __gic_populate_rdist (struct redist_region *region,void __iomem *ptr) { -unsigned long mpidr =cpu_logical_map (smp_processor_id ()); +unsigned long mpidr;u64 typer;u32 aff;
@@ -970,6 +977,8 @@ static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr)* Convert affinity to a 32bit value that can be matched to * GICR_TYPER bits [63:32]. */ + mpidr =gic_cpu_to_affinity (smp_processor_id ()); + aff = (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 24 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |
@@ -1262,9 +1271,11 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, unsigned long cluster_id) {int next_cpu, cpu = *base_cpu; -unsigned long mpidr =cpu_logical_map (cpu); +unsigned long mpidr;u16 tlist =0 ; + mpidr =gic_cpu_to_affinity (cpu); +while (cpu < nr_cpu_ids) { tlist |=1 << (mpidr &0xf );
@@ -1273,8 +1284,7 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, goto out; cpu = next_cpu; - mpidr =cpu_logical_map (cpu); - + mpidr =gic_cpu_to_affinity (cpu);if (cluster_id !=MPIDR_TO_SGI_CLUSTER_ID (mpidr)) { cpu--; goto out;
@@ -1318,7 +1328,7 @@ static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask)dsb (ishst);for_each_cpu (cpu, mask) { -u64 cluster_id =MPIDR_TO_SGI_CLUSTER_ID (cpu_logical_map (cpu)); +u64 cluster_id =MPIDR_TO_SGI_CLUSTER_ID (gic_cpu_to_affinity (cpu));u16 tlist; tlist =gic_compute_target_list (&cpu, mask, cluster_id);
@@ -1376,7 +1386,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, offset =convert_offset_index (d,GICD_IROUTER , &index); reg =gic_dist_base (d) + offset + (index *8 ); - val =gic_mpidr_to_affinity (cpu_logical_map (cpu)); + val =gic_cpu_to_affinity (cpu);gic_write_irouter (val, reg);
@@ -1786,6 +1796,15 @@ static bool gic_enable_quirk_nvidia_t241(void *data)return true; } +static bool gic_enable_quirk_asr8601 (void *data) +{ +struct gic_chip_data *d = data; + + d->flags |=FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ; + +return true; +} +static const struct gic_quirk gic_quirks[] = { { .desc ="GICv3: Qualcomm MSM8996 broken firmware" ,
@@ -1823,6 +1842,11 @@ static const struct gic_quirk gic_quirks[] = { .mask = 0xffffffff, .init = gic_enable_quirk_nvidia_t241, }, + { + .desc = "GICv3: ASR erratum 8601001", + .compatible = "asr,asr8601-gic-v3", + .init = gic_enable_quirk_asr8601, + }, { } };
Signature · 1 line
Without deviation from the norm, progress is not possible.
Quoted 59 lines
-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: Monday, May 29, 2023 11:02 PM
To: Yan Zheng(严政) <[email protected]>
Cc: [email protected]; Gao Meitao(高玫涛) <[email protected]>; Zhou Qiao(周侨) <[email protected]>; [email protected]; Zhang Zhizhou(张治洲) <[email protected]>
Subject: Re: [PATCH v2] irqchip/gic-v3: workaround for ASR8601 when reading mpidrQuoted 12 lines · zhengyan
This patch add workaround for ASR8601, which uses an armv8.2 processor with a gic-500. But gic-500 is incompatible with
ARMv8.2 implementations from ARM.ARMv8.2 from ARM implementation uses Multiprocessor Affinity Register to identify the logical address of the core by
| cluster | core | thread |.
However, gic-500 only supports topologies with affinity levels less than 2 as
| cluster | core|.Quoted 7 lines
So we need this patch as workaround to shift the MPIDR values to ensure proper functionality
Signed-off-by zhengyan <[email protected]>--- Documentation/arm64/silicon-errata.rst | 4 ++++ drivers/irqchip/irq-gic-v3.c | 30++++++++++++++++++++++++++
Documentation/arm64/silicon-errata.rst stable kernels. · line 215
Quoted 10 lines
2 files changed, 34 insertions(+)Documentation/arm64/silicon-errata.rst +0
-0@@ -214,3 +214,7 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | Fujitsu | A64FX | E#010001 |
FUJITSU_ERRATUM_010001|Documentation/arm64/silicon-errata.rst stable kernels. · line 219
Quoted 6 lines
Documentation/arm64/silicon-errata.rst +4
-1+----------------+-----------------+-----------------+---------------- -------------+ + ++----------------+-----------------+-----------------+-----------------------------+ +| ASR | ASR8601 | #8601001 | N/A|
Quoted 7 lines
Documentation/arm64/silicon-errata.rst +1
-0++----------------+-----------------+-----------------+-----------------------------+(quoted diff) +0
-0
b/drivers/irqchip/irq-gic-v3.cindex6fcee221f201..cf64783dfe70100644drivers/irqchip/irq-gic-v3.c +0
-0@@ -39,6 +39,9 @@
Quoted 9 lines
drivers/irqchip/irq-gic-v3.c
Quoted 5 lines
drivers/irqchip/irq-gic-v3.c +3
-0#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 2) + +#define ASR8601_AFF_QUIRK (aff) (aff >> 8)This is wrong. There are more than just affinity bits in MPIDR, and you're making a mess of the result.
Yes, I made a mistake here.
Quoted 26 lines
drivers/irqchip/irq-gic-v3.c static u64 gic_mpidr_to_affinity(unsigned long · line 670
Quoted 13 lines
drivers/irqchip/irq-gic-v3.c +3
-0#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)@@ -659,6 +662,9 @@ static u64 gic_mpidr_to_affinity(unsigned long mpidr) {u64 aff; +if (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ) + mpidr =ASR8601_AFF_QUIRK (mpidr); + aff = ((u64 )MPIDR_AFFINITY_LEVEL (mpidr,3 ) <<32 |MPIDR_AFFINITY_LEVEL (mpidr,2 ) <<16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 | @@ -970,6 +976,9@@
Quoted 1 line
static int __gic_populate_rdist(struct
redist_region*region, void__iomem*ptr)
drivers/irqchip/irq-gic-v3.c static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr)
Quoted 5 lines
drivers/irqchip/irq-gic-v3.c +2
-0* Convert affinity to a 32bit value that can be matched to * GICR_TYPER bits [63:32]. */ +if (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ) + mpidr =ASR8601_AFF_QUIRK (mpidr);It really wasn't what I had in mind when I asked you to place this inside a helper. The whole thing looks horrible, and I really don't want to have to maintain anything like it.
Quoted 7 lines
I came up with the following patch, which keeps the workaround *in a single spot*.
Let me know if that works for you.
M.
Really thanks for your help, this patch works well for us.
My previous patch was too ugly, this one looks better. I didn't find this good solution. Should I send a patch for v3, considering that you're the author?
Quoted 139 lines
drivers/irqchip/irq-gic-v3.c index renamed from drivers/irqchip/irq-gic-v3.c +0
-0
6fcee221f201..b7d69ef4da9f100644drivers/irqchip/irq-gic-v3.c +8
-1@@ -39,6 +39,7 @@#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 2)#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)@@ -655,10 +656,16 @@ static int gic_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu)return 0 ; } -static u64 gic_mpidr_to_affinity (unsigned long mpidr) +static u64 gic_cpu_to_affinity (int cpu) { +u64 mpidr =cpu_logical_map (cpu);u64 aff; +/* ASR8601 needs to have its affinities shifted down... */ +if (unlikely (gic_data.flags &FLAGS_WORKAROUND_ASR_ERRATUM_8601001 )) + mpidr = (MPIDR_AFFINITY_LEVEL (mpidr,1 ) | + (MPIDR_AFFINITY_LEVEL (mpidr,2 ) <<8 )); + aff = ((u64)MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 |drivers/irqchip/irq-gic-v3.c +0
-0MPIDR_AFFINITY_LEVEL (mpidr,2 ) <<16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 | @@ -913,7 +920,7@@ static void
__initgic_dist_init(void)drivers/irqchip/irq-gic-v3.c +4
-2* Set all global interrupts to the boot CPU only. ARE must be * enabled. */ - affinity =gic_mpidr_to_affinity (cpu_logical_map (smp_processor_id ())); + affinity =gic_cpu_to_affinity (smp_processor_id ());for (i =32 ; i <GIC_LINE_NR ; i++)gic_write_irouter (affinity, base +GICD_IROUTER + i *8 );@@ -962,7 +969,7 @@ static int gic_iterate_rdists(int (*fn)(struct redist_region *, void __iomem *))static int __gic_populate_rdist (struct redist_region *region,void __iomem *ptr) { -unsigned long mpidr =cpu_logical_map (smp_processor_id ()); +unsigned long mpidr;u64 typer;u32 aff;@@ -970,6 +977,8 @@ static int __gic_populate_rdist(struct redist_region*region, void __iomem *ptr) * Convert affinity to a 32bit value that can be matched to * GICR_TYPER bits [63:32]. */ + mpidr =gic_cpu_to_affinity (smp_processor_id ()); + aff = (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 24 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 |
MPIDR_AFFINITY_LEVEL(mpidr, 1)<< 8 | @@ -1262,9 +1271,11
@@ static u16 gic_compute_target_list(int*base_cpu, const struct cpumask *mask,drivers/irqchip/irq-gic-v3.c +4
-3unsigned long cluster_id) {int next_cpu, cpu = *base_cpu; -unsigned long mpidr =cpu_logical_map (cpu); +unsigned long mpidr;u16 tlist =0 ; + mpidr =gic_cpu_to_affinity (cpu); +while (cpu < nr_cpu_ids) { tlist |=1 << (mpidr &0xf );@@ -1273,8 +1284,7 @@ static u16 gic_compute_target_list(int *base_cpu,const struct cpumask *mask, goto out; cpu = next_cpu; - mpidr =cpu_logical_map (cpu); - + mpidr =gic_cpu_to_affinity (cpu);if (cluster_id !=MPIDR_TO_SGI_CLUSTER_ID (mpidr)) { cpu--;drivers/irqchip/irq-gic-v3.c +1
-1goto out;@@ -1318,7 +1328,7 @@ static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask)dsb (ishst );for_each_cpu (cpu, mask) { -u64 cluster_id =MPIDR_TO_SGI_CLUSTER_ID (cpu_logical_map (cpu)); +u64 cluster_id =MPIDR_TO_SGI_CLUSTER_ID (gic_cpu_to_affinity (cpu));u16 tlist;tlist =
gic_compute_target_list(&cpu, mask, cluster_id); @@ -1376,7
+1386,7 @@ static int gic_set_affinity(structirq_data*d, const struct cpumask*mask_val,drivers/irqchip/irq-gic-v3.c +14
-2offset =convert_offset_index (d,GICD_IROUTER , &index); reg =gic_dist_base (d) + offset + (index *8 ); - val =gic_mpidr_to_affinity (cpu_logical_map (cpu)); + val =gic_cpu_to_affinity (cpu);gic_write_irouter (val, reg);@@ -1786,6 +1796,15 @@ static bool gic_enable_quirk_nvidia_t241(void *data)return true; } +static bool gic_enable_quirk_asr8601 (void *data) { +struct gic_chip_data *d = data; + + d->flags |=FLAGS_WORKAROUND_ASR_ERRATUM_8601001 ; + +return true; +} +static const struct gic_quirk gic_quirks[] = { { .desc ="GICv3: Qualcomm MSM8996 broken firmware" ,@@ -1823,6 +1842,11 @@ static const struct gic_quirk gic_quirks[] = { .mask = 0xffffffff, .init = gic_enable_quirk_nvidia_t241, }, + { + .desc = "GICv3: ASR erratum 8601001", + .compatible = "asr,asr8601-gic-v3", + .init = gic_enable_quirk_asr8601, + }, { } }; --Without deviation from the norm, progress is not possible.
Marc Zyngier
maintainerQuoted 4 lines · Yan Zheng(严政)
Quoted 4 lines
I came up with the following patch, which keeps the workaround *in a single spot*.
Quoted 8 lines
Quoted 4 lines
Let me know if that works for you.
M.Really thanks for your help, this patch works well for us.
My previous patch was too ugly, this one looks better. I didn't find this good solution. Should I send a patch for v3, considering that you're the author?
See [1]. I've split the refactoring in its own patch, and kept your authorship for what is left of the workaround code.
No need to resend, I'll queue that for 6.5.
M.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=irq/gic-v3-asr8601
Signature · 1 line
Without deviation from the norm, progress is not possible.