Flushing L3 cache may need variable time depending upon cache line
allocation.

Coming up with a proper timeout value would be best handled by
simulations under multiple scenarios in your actual system.
From the purely HN-F point of view, the flush would take ~15 cycles for
a clean line, and ~22 cycles for a dirty line.  For the dirty line case,
there are many variables outside the HN-F that will increase the
duration per line.  For example, a *DBIDResp from the SN-F/SBSX,
memory controller latency, SN-F/SBSX RetryAck responses, CCN ring
congestion, CCN ring hops, etc, etc.  The worst-case timeout would
have to factor in all of these variables plus the HN-F cycles for
every line in the L3, and assuming all lines are dirty

In case if L3 is not flushed properly, system behaviour will be
erratic.

Add loop to check status of L3 cache, it insures that L3 is flushed
properly.

System will stuck in while loop if there is some issue in L3 cache
flushing.

Signed-off-by: Udit Kumar <[email protected]>
Signed-off-by: Meenakshi Aggarwal <[email protected]>

---
changed for v2:
        - An increase in timeout doesn't ensure completion of
          L3 cache flushing operation. So checking the L3 cache
          status till it succedd.
---
 arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S 
b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
index 6721a57..2ba1a51 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
+++ b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
@@ -414,19 +414,23 @@ ENTRY(__asm_flush_l3_dcache)
        mov     x0, #0x1                /* HNFPSTAT_SFONLY */
        bl      hnf_set_pstate
 
+loop1:
        mov     x0, #0x4                /* SFONLY status */
        bl      hnf_pstate_poll
        cbz     x0, 1f
        mov     x8, #1                  /* timeout */
+       b      loop1
 1:
        dsb     sy
        mov     x0, #0x3                /* HNFPSTAT_FAM */
        bl      hnf_set_pstate
 
+loop2:
        mov     x0, #0xc                /* FAM status */
        bl      hnf_pstate_poll
        cbz     x0, 1f
        add     x8, x8, #0x2
+       b      loop2
 1:
        mov     x0, x8
        mov     lr, x29
-- 
1.9.1

_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to