MGS-3848-2 [#imx-854] fix events stuck issue when clock off
authorXianzhong <xianzhong.li@nxp.com>
Wed, 25 Apr 2018 19:56:08 +0000 (03:56 +0800)
committerXianzhong <xianzhong.li@nxp.com>
Thu, 26 Apr 2018 15:39:13 +0000 (23:39 +0800)
commit01b102fbc553608cf567a4f2a1932627a84d9af9
tree9f6ca0659369c23d1dba4c13362a296d5492d4d1
parentc5f6e4280a78aa6ae25b67dea948c412b4c7c196
MGS-3848-2 [#imx-854] fix events stuck issue when clock off

When pm (SetPowerManagementState) is running power ON to
SUSPEND_BROADCAST, it only checks wait-link FE, but not Async FE. Clock
can be off when read AsyncFE Acknowledge register and other.

pm thread:
    ...
    check commit atom ok
    >> check idle OK
    (former stopIsr before cl144673 is here)
    set GPU clock off
    ...

isr:
    gcmkONERROR(ReadRegister(AQ_INTR_ACKNOWLEDGE_Address));
    gckEVENT_Interrupt
    >>> here, at this point, all interrupt comes, check idle in
    >>> pm thread can pass.
    gcmkONERROR(ReadRegister(AQ_INTR_ACKNOWLEDGE_EX_Address));
    gckFE_UpdateAvaiable -> ReadRegister(GCREG_FE_ASYNC_STATUS_Address)

If gcmkONERROR(ReadRegister(AQ_INTR_ACKNOWLEDGE_EX_Address))
fail of clock off, then gckHARDWARE_Interrupt fails. In isrRoutine, it
won't wake up threadRoutine. Then it's stuck!
ReadRegister(GCREG_FE_ASYNC_STATUS_Address) failure can cause
unexpected behavior, too.

Former stopIsr (free_irq, before cl144673) can remove isr before
GPU clock off. So the issue is hidden.

To fix:
1. We should return success when either FE or AsyncFE reports
correct interrupts, so that isr can wake up threadRoutine for either FE.
That means, only need return ERROR when both FEs reports ERROR.
2. Add check for status of
ReadRegister(GCREG_FE_ASYNC_STATUS_Address).

Fix bug #19216, #19230.

merged BUG#19216 BUG#19230 CL152073 add missing part for CL151955

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
(cherry picked from commit 274841e0b05704726e28cc10185b6fb5973969f4)
drivers/mxc/gpu-viv/hal/kernel/arch/gc_hal_kernel_hardware.c