MLK-10647 armv7: Fix Dcache disable issue on i.MX7
authorYe.Li <B37916@freescale.com>
Mon, 13 Apr 2015 09:18:14 +0000 (17:18 +0800)
committerYe Li <ye.li@nxp.com>
Fri, 24 May 2019 11:28:30 +0000 (04:28 -0700)
commit742cd01a7bbe3e355569be2d1d454f4f268390a9
tree9b2afe40d78eca86448822f634259049a7a78591
parent682b705b402827f6041839d92a717887a2a9649d
MLK-10647 armv7: Fix Dcache disable issue on i.MX7

The issue on the i.MX7D is that, there is one cache-able memory access
between the L1 and L2 cache flush by calling the flush_dache_all->
v7_maint_dcache_all() [Flush L1 and L2 cache) which written in the C code.

L1-cache-flush            -> This will flush L1 cache to L2 cache in the end.
Cache-able memory access  -> This will have the chance cause the L1 line-fill
                             with dirty data from L2 cache(L1 cache-line dirty,
                             L2 clean)
L2-cache-flush            -> This will only flush L2 cache to L3, but still
                             some dirty data on the L1 cacheline.

After C & M bit clean,    -> The dirty data on the L1 cache line lost, which will
                             cause memory coherent issue if that dirty cache line
                             has some useful data

This patch should works fine on the i.MX6 and i.MX7.

The second cache flush have zero impact on the i.MX6, but this is really need for
the i.MX7D platform due to the L1 line-fill during the first dcache_flush.

And the second flush will not bring in the L1 dirty cache line due to the C bit is
clear now, which means the dcache is disabled.

Acked-by: Jason Liu<r64343@freescale.com>
Reviewed-by: Jason Liu<r64343@freescale.com>
Signed-off-by: Ye.Li <B37916@freescale.com>
(cherry picked from commit f5d5f07fba936c4bb05c887de9d72fb75b3dc0f2)
(cherry picked from commit 86c784cf4c4b633d37a76de7d47155c08f75dc82)
(cherry picked from commit d85cd484e6825631aa1ab572e5e0539f2191d795)
(cherry picked from commit 2b29c1873c2293abe1c4b361392521223b9c9ecf)
(cherry picked from commit 3eaf56494f3000f841531e8c219cf3dd9ca024f7)
(cherry picked from commit fd1ecbfba9ba0fb52a757a70a2fcbeb325508be2)
arch/arm/lib/cache-cp15.c