Issue Description
When running Android R10.4 on MX51 BBG, the system can not resume sometimes by following the test steps:
1) Enable CLAA-WVGA lcd panel - single display.
2) Play a video in Gallery.
3) Press power key to suspend the system.
4) Press power key to resume the system.
5) Do 3) and 4) continuously.
Debug Details
When adding the following debug information into vpu_resume function in file drivers/mxc/vpu/mxc_vpu.c, the system gets hang into while loop with the log "VPU Blocking 1**************":
static int vpu_resume(struct platform_device *pdev) {
int i;
WRITE_REG(BITVAL_PIC_RUN, BIT_INT_ENABLE);
WRITE_REG(0x1, BIT_BUSY_FLAG);
WRITE_REG(0x1, BIT_CODE_RUN);
while (READ_REG(BIT_BUSY_FLAG)) {
printk("VPU Blocking 1**************\r\n");
};
}
Root Cause
In some use cases, VPU power gating didn't happen after vpu_suspend() returned successfully because some other devices refused to suspend or other reasons. So vpu_resume() ran FW init code when VPU was idle instead of power off, which could keep BIT_BUSY_FLAG always be 1.
Solution
In vpu_resume(), if VPU PC is not 0, which means VPU is still running, skip running FW init code. See attached patch based on R10.4.