RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
From: Colin Cross <[email protected]>
ARM errata 727915 for PL310 has been updated to include a new workaround required for PL310 r2p0 for l2x0_flush_all, which also affects l2x0_clean_all in my testing. For r2p0, clean or flush each set/way individually. For r3p0 or greater, use the debug register for cleaning and flushing.
Requires exporting the cache_id, sets and ways detected in the init function for later use.
---
I found this thing in the Android tree, it looks like it could be pretty serious so I'm mailing it out. If it is correct I guess it should even be tagged for -stable?
v2: what about actually git commit --amend in the rebase changes for -rc7? Sorry for the screwup...
--- arch/arm/include/asm/hardware/cache-l2x0.h | 3 ++ arch/arm/mm/cache-l2x0.c | 68 ++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 13 deletions(-)
arch/arm/include/asm/hardware/cache-l2x0.h +3 -0
@@ -66,6 +66,7 @@#define L2X0_STNDBY_MODE_EN (1 << 0)/* Registers shifts and masks */ +#define L2X0_CACHE_ID_REV_MASK (0x3f)#define L2X0_CACHE_ID_PART_MASK (0xf << 6)#define L2X0_CACHE_ID_PART_L210 (1 << 6)#define L2X0_CACHE_ID_PART_L310 (3 << 6)
@@ -102,6 +103,8 @@#define L2X0_ADDR_FILTER_EN 1 +#define REV_PL310_R2P0 4 +#ifndef __ASSEMBLY__extern void __init l2x0_init (void __iomem *base,u32 aux_val,u32 aux_mask);#if defined(CONFIG_CACHE_L2X0 ) && defined(CONFIG_OF )
arch/arm/mm/cache-l2x0.c +55 -13
154 lines not on this page · raw message
Signature · 1 line
1.7.9.2
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 16 lines · Linus Walleij
From: Colin Cross <[email protected]>
ARM errata 727915 for PL310 has been updated to include a new workaround required for PL310 r2p0 for
l2x0_flush_all, which also affectsl2x0_clean_allin my testing. For r2p0, clean or flush each set/way individually. For r3p0 or greater, use the debug register for cleaning and flushing.Requires exporting the
cache_id, sets and ways detected in the init function for later use.Cc Will Deacon <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Per Fransson <[email protected]>Signed-off-by Colin Cross <[email protected]>Signed-off-by Linus Walleij <[email protected]>
Quoted 8 lines
---
I found this thing in the Android tree, it looks like it could be pretty serious so I'm mailing it out. If it is correct I guess it should even be tagged for -stable?v2: what about actually git commit --amend in the rebase changes for -rc7? Sorry for the screwup...
---
This was observed on OMAP4460 devices. Though the errata document doesn't support it, the issue seen with l2 clean was indeed fixed $subject fix.
Regards
Santosh
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 3 lines · Santosh
This was observed on OMAP4460 devices. Though the errata document doesn't support it, the issue seen with l2 clean was indeed fixed $subject fix.
Is that an Acked-by for OMAP4? :-)
Yours,
Linus Walleij
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 9 lines · Linus Walleij
Quoted 3 lines · Santosh
This was observed on OMAP4460 devices. Though the errata document doesn't support it, the issue seen with l2 clean was indeed fixed $subject fix.
Is that an Acked-by for OMAP4? :-)
Yes.
Regards
Santosh
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
In reply to Shilimkar, SantoshHi Santosh,
Quoted 23 lines · Santosh
Quoted 21 lines · Linus Walleij
From: Colin Cross <[email protected]>
ARM errata 727915 for PL310 has been updated to include a new workaround required for PL310 r2p0 for
l2x0_flush_all, which also affectsl2x0_clean_allin my testing. For r2p0, clean or flush each set/way individually. For r3p0 or greater, use the debug register for cleaning and flushing.Requires exporting the
cache_id, sets and ways detected in the init function for later use.Cc Will Deacon <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Per Fransson <[email protected]>Signed-off-by Colin Cross <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
I found this thing in the Android tree, it looks like it could be pretty serious so I'm mailing it out. If it is correct I guess it should even be tagged for -stable?
Quoted 6 lines
Quoted 3 lines
v2: what about actually git commit --amend in the rebase changes for -rc7? Sorry for the screwup...
---This was observed on OMAP4460 devices. Though the errata document doesn't support it, the issue seen with l2 clean was indeed fixed $subject fix.
I'm not sure I follow. Which version of the PL310 is in OMAP4460? Are you saying that the current workaround didn't work but the one in this patch did? Do you have a testcase?
Cheers,
Will
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 29 lines · Will Deacon
Hi Santosh,
Quoted 26 lines · Santosh
Quoted 24 lines · Linus Walleij
From: Colin Cross <[email protected]>
ARM errata 727915 for PL310 has been updated to include a new workaround required for PL310 r2p0 for
l2x0_flush_all, which also affectsl2x0_clean_allin my testing. For r2p0, clean or flush each set/way individually. For r3p0 or greater, use the debug register for cleaning and flushing.Requires exporting the
cache_id, sets and ways detected in the init function for later use.Cc Will Deacon <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Per Fransson <[email protected]>Signed-off-by Colin Cross <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
I found this thing in the Android tree, it looks like it could be pretty serious so I'm mailing it out. If it is correct I guess it should even be tagged for -stable?v2: what about actually git commit --amend in the rebase changes for -rc7? Sorry for the screwup...
---
Quoted 8 lines
Quoted 3 lines
This was observed on OMAP4460 devices. Though the errata document doesn't support it, the issue seen with l2 clean was indeed fixed $subject fix.
I'm not sure I follow. Which version of the PL310 is in OMAP4460? Are you saying that the current workaround didn't work but the one in this patch did? Do you have a testcase?
It's r3p1.
IIRC, the errata fix I did(debug register) was only for flush (clean & inv) but Colin found in his testing that it's needed for clean_all as well.
I don't have testcase. Colin might be able to suggest one.
Regards
santosh
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 9 lines · Santosh Shilimkar
Quoted 4 lines · Will Deacon
I'm not sure I follow. Which version of the PL310 is in OMAP4460? Are you saying that the current workaround didn't work but the one in this patch did? Do you have a testcase?
It's r3p1.
IIRC, the errata fix I did(debug register) was only for flush (clean & inv) but Colin found in his testing that it's needed forclean_allas well.
Ok, interesting.
Quoted 1 line
I don't have testcase. Colin might be able to suggest one.
That would be ideal. Then I can take it up with the hardware guys since I'd like to confirm we're not just hiding a different bug with those writes.
Cheers,
Will
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 11 lines · Will Deacon
Quoted 9 lines · Santosh Shilimkar
Quoted 4 lines · Will Deacon
I'm not sure I follow. Which version of the PL310 is in OMAP4460? Are you saying that the current workaround didn't work but the one in this patch did? Do you have a testcase?
It's r3p1.
IIRC, the errata fix I did(debug register) was only for flush (clean & inv) but Colin found in his testing that it's needed forclean_allas well.
Quoted 6 lines
Ok, interesting.
Quoted 1 line
I don't have testcase. Colin might be able to suggest one.
That would be ideal. Then I can take it up with the hardware guys since I'd like to confirm we're not just hiding a different bug with those writes.
I was using an omap 4430, triggering l2x0_clean_all from a GPU ioctl by calling outer_clean_range(0, ULONG_MAX). The problem was very reproducible at the time, and using the persistent_trace code I posted a while back I was able to narrow it down to hanging the cpu (not an infinite loop) inside cache_wait_way. It was 100% reproducible just booting a development version of Android, but not if I called l2x0_clean_all during boot, so it may depend on cache state or load.
outer_clean_range() will often get called on a 1080p frame, which is 8MB of data. Even the set/way clean all is likely to be faster than cleaning 8MB by MVA in a 1MB L2.
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 7 lines · Colin Cross
I was using an omap 4430, triggering
l2x0_clean_allfrom a GPU ioctl by callingouter_clean_range(0, ULONG_MAX). The problem was very reproducible at the time, and using thepersistent_tracecode I posted a while back I was able to narrow it down to hanging the cpu (not an infinite loop) insidecache_wait_way. It was 100% reproducible just booting a development version of Android, but not if I calledl2x0_clean_allduring boot, so it may depend on cache state or load.
Right, ok. This is definitely a different problem though. Firstly, r3p1 is not affected by the original erratum and secondly the symptoms do not include deadlock. The clean during boot also sounds highly suspicious -- is there a chance you boot the kernel with a dirty L2? Is the L2 enabled or disabled when entering the kernel [I think u8500 has it enabled]?
Will
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 9 lines · Will Deacon
Quoted 7 lines · Colin Cross
I was using an omap 4430, triggering
l2x0_clean_allfrom a GPU ioctl by callingouter_clean_range(0, ULONG_MAX). ?The problem was very reproducible at the time, and using thepersistent_tracecode I posted a while back I was able to narrow it down to hanging the cpu (not an infinite loop) insidecache_wait_way. ?It was 100% reproducible just booting a development version of Android, but not if I calledl2x0_clean_allduring boot, so it may depend on cache state or load.
Quoted 5 lines
Right, ok. This is definitely a different problem though. Firstly, r3p1 is not affected by the original erratum and secondly the symptoms do not include deadlock. The clean during boot also sounds highly suspicious -- is there a chance you boot the kernel with a dirty L2? Is the L2 enabled or disabled when entering the kernel [I think u8500 has it enabled]?
In a previous thread, I wrote that the 4430 I was using had r2p0. I can't verify the accuracy of that claim right now, but my patch was based on that assumption. Where are you getting r3p1 from?
When I said I couldn't reproduce the issue with clean during boot, I meant that I couldn't trigger the issue during boot by calling clean repeatedly. I could still reproduce the issue after boot even if the cache was cleaned during boot.
The reference to 727915 came from discussions with TI, but given that it is a deadlock and not a memory corruption, you're probably right that it is not the same issue.
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Hi Colin,
Quoted 10 lines · Colin Cross
Quoted 5 lines · Will Deacon
Right, ok. This is definitely a different problem though. Firstly, r3p1 is not affected by the original erratum and secondly the symptoms do not include deadlock. The clean during boot also sounds highly suspicious -- is there a chance you boot the kernel with a dirty L2? Is the L2 enabled or disabled when entering the kernel [I think u8500 has it enabled]?
In a previous thread, I wrote that the 4430 I was using had r2p0. I can't verify the accuracy of that claim right now, but my patch was based on that assumption. Where are you getting r3p1 from?
Apologies, that's what Santosh mentioned here:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-May/101302.html
so, assuming that it's the same problem, it seems that both r3p1 and r2p0 are affected.
Quoted 4 lines
When I said I couldn't reproduce the issue with clean during boot, I meant that I couldn't trigger the issue during boot by calling clean repeatedly. I could still reproduce the issue after boot even if the cache was cleaned during boot.
Ok, that's interesting. I wonder if erratum #769419 is to blame? We now have a workaround in the kernel for that, so you could give it a try if you're in a position to do so.
Cheers,
Will
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 10 lines · Will Deacon
Hi Colin,
Quoted 7 lines · Colin Cross
Quoted 5 lines · Will Deacon
Right, ok. This is definitely a different problem though. Firstly, r3p1 is not affected by the original erratum and secondly the symptoms do not include deadlock. The clean during boot also sounds highly suspicious -- is there a chance you boot the kernel with a dirty L2? Is the L2 enabled or disabled when entering the kernel [I think u8500 has it enabled]?
Quoted 8 lines
Quoted 3 lines
In a previous thread, I wrote that the 4430 I was using had r2p0. ?I can't verify the accuracy of that claim right now, but my patch was based on that assumption. ?Where are you getting r3p1 from?
Apologies, that's what Santosh mentioned here:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-May/101302.html
I was mainly talking about OMAP4460 and the WA extension needed for clean_all along with clean and invalidate.
May be since patch has both changes, for r3px and r2px, the confusion came in.
Regards
Santosh
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
In reply to Will DeaconQuoted 14 lines · Will Deacon
Hi Colin,
Quoted 10 lines · Colin Cross
Quoted 5 lines · Will Deacon
Right, ok. This is definitely a different problem though. Firstly, r3p1 is not affected by the original erratum and secondly the symptoms do not include deadlock. The clean during boot also sounds highly suspicious -- is there a chance you boot the kernel with a dirty L2? Is the L2 enabled or disabled when entering the kernel [I think u8500 has it enabled]?
In a previous thread, I wrote that the 4430 I was using had r2p0. ?I can't verify the accuracy of that claim right now, but my patch was based on that assumption. ?Where are you getting r3p1 from?
Quoted 6 lines
Apologies, that's what Santosh mentioned here:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-May/101302.html
so, assuming that it's the same problem, it seems that both r3p1 and r2p0 are affected.
Ah, I missed that. The issue I was seeing only affected 4430 (r2p0).
Quoted 8 lines
Quoted 4 lines
When I said I couldn't reproduce the issue with clean during boot, I meant that I couldn't trigger the issue during boot by calling clean repeatedly. ?I could still reproduce the issue after boot even if the cache was cleaned during boot.
Ok, that's interesting. I wonder if erratum #769419 is to blame? We now have a workaround in the kernel for that, so you could give it a try if you're in a position to do so.
I don't have any 4430 devices any more.
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
In reply to Linus WalleijHi Linus,
Quoted 10 lines · Linus Walleij
From: Colin Cross <[email protected]>
ARM errata 727915 for PL310 has been updated to include a new workaround required for PL310 r2p0 for
l2x0_flush_all, which also affectsl2x0_clean_allin my testing. For r2p0, clean or flush each set/way individually. For r3p0 or greater, use the debug register for cleaning and flushing.Requires exporting the
cache_id, sets and ways detected in the init function for later use.
[...]
Quoted 21 lines
arch/arm/mm/cache-l2x0.c +17
-0+#ifdef CONFIG_PL310_ERRATA_727915 +static void l2x0_for_each_set_way (void __iomem *reg) +{ +int set; +int way; +unsigned long flags; + +for (way =0 ; way < l2x0_ways; way++) { +raw_spin_lock_irqsave (&l2x0_lock, flags); +for (set =0 ; set < l2x0_sets; set++) +writel_relaxed ((way <<28 ) | (set <<5 ), reg); +cache_sync (); +raw_spin_unlock_irqrestore (&l2x0_lock, flags); + } +} +#endif +static void __l2x0_flush_all (void ) {debug_writel (0x03 );
arch/arm/mm/cache-l2x0.c static void l2x0_flush_all(void) · line 178
Quoted 9 lines
arch/arm/mm/cache-l2x0.c +6
-0@@ -143,6 +170,13 @@ static void l2x0_flush_all(void) {unsigned long flags; +#ifdef CONFIG_PL310_ERRATA_727915 +if (is_pl310_rev (REV_PL310_R2P0 )) { +l2x0_for_each_set_way (l2x0_base +L2X0_CLEAN_INV_LINE_IDX ); +return ; + } +#endif
If we're adding code like this to flush_all, maybe we'd be better off just assigning a different function to outer_cache.flush_all if we detect that the current outer cache is an affected PL310 variant. However, note that __l2x0_flush_all is called on the disable path. Do we need to intercept that too?
arch/arm/mm/cache-l2x0.c static void l2x0_clean_all(void) · line 195
Quoted 10 lines
arch/arm/mm/cache-l2x0.c +6
-0@@ -153,11 +187,20 @@ static void l2x0_clean_all(void) {unsigned long flags; +#ifdef CONFIG_PL310_ERRATA_727915 +if (is_pl310_rev (REV_PL310_R2P0 )) { +l2x0_for_each_set_way (l2x0_base +L2X0_CLEAN_LINE_IDX ); +return ; + } +#endif
clean_all is only called as an optimisation when cleaning a large range. Since the workaround resorts back to cleaning each set and way, it's questionable whether the optimisation pays off. I'd be inclined just to predicate the optimisation on the erratum not being set.
arch/arm/mm/cache-l2x0.c static void l2x0_clean_all(void) · line 205
Quoted 9 lines
arch/arm/mm/cache-l2x0.c +2
-0/* clean all ways */ raw_spin_lock_irqsave (&l2x0_lock, flags); +debug_writel (0x03 );writel_relaxed (l2x0_way_mask, l2x0_base +L2X0_CLEAN_WAY );cache_wait_way (l2x0_base +L2X0_CLEAN_WAY , l2x0_way_mask);cache_sync (); +debug_writel (0x00 );raw_spin_unlock_irqrestore (&l2x0_lock, flags); }
What are these new debug writes for? I thought only clean and invalidate was affected?
Will
PATCH v2 1/1 RFC: ARM: cache-l2x0: update workaround for PL310 errata 727915
Quoted 4 lines · Will Deacon
Quoted 4 lines
+#ifdef
CONFIG_PL310_ERRATA_727915
+ ? ? if (is_pl310_rev(REV_PL310_R2P0)) {
+ ? ? ? ? ? ?l2x0_for_each_set_way(l2x0_base + L2X0_CLEAN_INV_LINE_IDX);
+ ? ? ? ? ? ? return;
Quoted 8 lines
Quoted 2 lines
+ ? ? }
+#endifIf we're adding code like this to
flush_all, maybe we'd be better off just assigning a different function to outer_cache.flush_all if we detect that the current outer cache is an affected PL310 variant. However, note that__l2x0_flush_allis called on the disable path. Do we need to intercept that too?
No idea. I was mainly forwarding the patch after findng it in the Android tree. I'm hoping Colin and Santosh can help us hash this out...
The thing is that since this is in the Android tree and vendors tend to use that as a base for development rather than using kernel.org, we will see this code deployed in a large number of systems, so I wanted to expose it to the kernel community.
Yours,
Linus Walleij