Audio Codec prevents suspend mod

When I examined suspend_stats, I noticed that device 4-001a (audio codec) prevents suspend mod. What could be the reason for this?

/sys/kernel/debug/suspend_stats
success: 99
fail: 29
failed_freeze: 3
failed_prepare: 0
failed_suspend: 23
failed_suspend_late: 1
failed_suspend_noirq: 2
failed_resume: 103
failed_resume_early: 0
failed_resume_noirq: 0
failures:
  last_failed_dev:      4-001a
                        4-001a
  last_failed_errno:    -16
                        -16
  last_failed_step:     resume
                        resume

What is the actual problem on this?

I’m trying to reduce power consumption in sleep mode. I’ve observed the following: when I check the logs as the device enters sleep mode, I consistently encounter this issue. Moreover, the number of failures keeps increasing. Is this normal?

[  412.171539] sierra_rtc_wake
[  412.171548] sierra_rtc_wake: sierra_rtc_wake
[  412.174007] PM: early resume of devices complete after 1.873 msecs
[  412.191776] wm8944 4-001a: Unable to sync registers 0x6-0x6. -107
[  412.191804] wm8944 4-001a: Failed to restore register map: -107
[  412.191846] dpm_run_callback(): i2c_device_pm_resume+0x0/0x28 returns -107
[  412.191873] PM: Device 4-001a failed to resume: error -107
[  412.278377] PM: resume of devices complete after 104.258 msecs
[  412.318387] PM: Finishing wakeup.
[  412.318413] Restarting tasks ... done.
[  412.337507] sierra_pm_resume
[  412.338018] PM: suspend exit 2023-12-20 16:28:26.498003379 UTC
[  412.338121] PM: suspend entry 2023-12-20 16:28:26.498119467 UTC
[  412.338147] PM: Syncing filesystems ... done.
[  412.359032] PM: Preparing system for mem sleep
[  412.361384] Freezing user space processes ... (elapsed 0.008 seconds) done.
[  412.370154] Freezing remaining freezable tasks ... (elapsed 0.003 seconds) done.
[  412.373736] PM: Entering mem sleep
[  412.373770] Suspending console(s) (use no_console_suspend to debug)
[  412.393526] wm8944 4-001a: Unable to sync registers 0x2-0x2. -107
[  412.402499] wm8944_suspend - START
[  412.403911] wm8944_suspend - OK
[  412.414148] PM: suspend of devices complete after 38.690 msecs
[  412.416704] PM: late suspend of devices complete after 2.512 msecs
[  412.420694] PM: noirq suspend of devices complete after 3.944 msecs
[  412.420775] suspend ns:     412420758180     suspend cycles:     104044837534
[  412.420758] CPU0:msm_cpu_pm_enter_sleep mode:3 during suspend
[  412.420758] resume cycles:     104193602563
[  412.423045] PM: noirq resume of devices complete after 1.715 msecs
[  412.423652] sierra_rtc_wake

How much current is affected?

How to reproduce this in mangoh board with official firmware?

Is this related to your application?

It consumes 15mA current in suspend mode. I’m not sure how much I can reduce it. I don’t think it’s related to my application. I have removed everything related to audio and checked, but still encountered the same error. I also think it’s related to the audio error topic I created earlier. (The audio file does not play after suspend mode. Audio pcm error) I don’t know how to resolve this audio codec error. I’m unsure whether this error is related to the driver or something else.

Is this related to particular hardware?
How to reproduce this in mangoh board with official firmware?

I am using the Mangoh Yellow board. I have tested it on several devices, and the result is the same. To allow it to enter sleep mode, I use system(“echo mem > /sys/power/autosleep”);

legato.version: 19.11.6
Legato Ver: 19.11.6_b956fb2cc8e7684dc88bd661446038dd_modified
Yocto Ver:  SWI9X07Y_02.37.10.02 2023-09-12_11:11:57
OS Ver: Linux version 3.18.140 (oe-user@oe-host) (gcc version 7.3.0 (GCC) ) #1 PREEMPT Tue Sep 12 11:10:13 UTC 2023
LK Ver: SWI9X07Y_02.37.07.00
RootFS Ver: SWI9X07Y_02.37.10.02 2023-09-12_11:11:57
UserFS Ver: unknown
MCU Ver: 002.015

I am using the default R16.3 FW with WP7608, no problem is found on mangoh green board:

Poky (Yocto Project Reference Distro) 2.5.3 fx30 /dev/ttyHSL1

fx30 login: root
root@fx30:~# cat /sys/power/autosleep
mem
root@fx30:~# cm info
Device:                        WP7608
IMEI:                          352913090512345
IMEISV:                        12
FSN:                           XG207430712345
Firmware Version:              SWI9X07Y_02.37.06.05 b15b59 jenkins 2022/09/27 07:54:33
Bootloader Version:            SWI9X07Y_02.37.06.05 b15b59 jenkins 2022/09/27 07:54:33
MCU Version:                   002.015
PRI Part Number (PN):          9908665
PRI Revision:                  001.004
Carrier PRI Name:              GENERIC
Carrier PRI Revision:          002.121_002
SKU:                           1104194
Last Reset Cause:              Power Down
Resets Count:                  Expected: 530    Unexpected: 0
root@fx30:~# legato version
19.11.6_225ac9b7882467c5c7f9e0bf4cdb5523_modified
root@fx30:~# [   68.267718] Freezing of tasks aborted after 0.006 seconds
[   68.345938] Freezing of tasks aborted after 0.005 seconds
[   71.630932] PM: Some devices failed to suspend, or early wake event detected

Thank you so much for your response. Can you try this command:

cat /sys/kernel/debug/suspend_stats

This file indicates the number of times the board has been suspended successfully, the
number of times that suspend has failed and for what reason it failed

just tried twice, the failed reason is not the same as your i2c.


root@fx30:~# cat /sys/kernel/debug/suspend_stats
success: 4
fail: 4
failed_freeze: 3
failed_prepare: 0
failed_suspend: 1
failed_suspend_late: 0
failed_suspend_noirq: 0
failed_resume: 0
failed_resume_early: 0
failed_resume_noirq: 0
failures:
  last_failed_dev:      alarmtimer

  last_failed_errno:    -16
                        -16
  last_failed_step:     freeze
                        freeze
root@fx30:~#

The result I have is this.

root@swi-mdm9x28-wp:~# cat /sys/kernel/debug/suspend_stats
success: 2
fail: 1
failed_freeze: 0
failed_prepare: 0
failed_suspend: 1
failed_suspend_late: 0
failed_suspend_noirq: 0
failed_resume: 2
failed_resume_early: 0
failed_resume_noirq: 0
failures:
  last_failed_dev:      alarmtimer
                        4-001a
  last_failed_errno:    -16
                        0
  last_failed_step:     suspend
                        resume

Let me do exactly what you did, and then compare the results.

Hi @jyijyi.

I noticed that this error occurs when I disable 3v3, and the problem is resolved when I enable it. However, I need to disable power to reduce power consumption. I added a delay before the disable, but the issue persists. What else can I do before disabling 3v3?

Thanks.

What do you mean by disable 3v3?
How much power can by saved by this action?

Did you follow the recommendation here?

I used this le_gpio41_Deactivate api. I saw this post. We will continue in this way for now.

What do you want to set for gpio41? High or low?
How much power can by saved by setting gpio41?

I set power disable using le_gpio41_Deactivate api. I am not sure 10mA approximately.

you might need to configure the GPIO41 after these lines:

[  412.393526] wm8944 4-001a: Unable to sync registers 0x2-0x2. -107
[  412.402499] wm8944_suspend - START
[  412.403911] wm8944_suspend - OK

Probably you need to control it in driver layer, not in application layer with legato api

Is it possible to disable the audio codec? It would be a solution for me if I could activate it only when I want to play a file. Audio is not something I use constantly.

No idea…
you can see whether you can unload the kernel driver, but I still think you should modify the wm8944 driver to trigger the GPIO41

By the way, how do you know you can save 10mA if you never make it work successfully to suspend?