Selective Suspend mode issue with Timer FD

Hi,

Facing an issue with Selective Suspend after removing the USB OTG Cable of the device expected the device to go into Sleep mode but it is seen that the device is not entering the selective suspend mode.

Attached are the logs, from the logs it is seen that the Active wakeup source is timerfd, eventfd and signal fd. Would like to understand is there a way to identify the wakeup source from the system?

Currently there is no timer used in the application. attached is the sample app which is used for testing the scenario.
logs wakeup source.txt (655.8 KB)

Thanks

Pankaj

app.c (1.6 KB)

you can see the wakeup source here:
cat /sys/power/wake_lock

@jyijyi ,

Connected the USB CF3 to check the wakelock and it is showing empty :

root@swi-mdm9x28-wp:~# cat /sys/kernel/debug/wakeup_sources | awk ‘{print $6 “\t” $1 }’ | grep -v “^0”
active_since name
132491 msm_otg
root@swi-mdm9x28-wp:~# cat /sys/power/wake_lock

root@swi-mdm9x28-wp:~# cat /sys/power/wake_unlock

Any other way to check what else is hoding the wakelock?

my test here with mangoh green board:
if USB OTG cable is connected to the mangoh board, it won’t go to sleep mode.
if USB OTG cable is disconnected, it will immediately go to sleep mode.

@jyijyi,

In case if the issue is faced how do we know what is holding the wakeup source?

Is there a way to investigate the timer FD or event FD which is holding the wakeup source?

Selective suspend mode should be for USB client.
So if problem happens after USB OTG disconnect, can you try if you still see this issue after connecting to host PC?

@jyijyi ,

After removing the USB expected the device to go into sleep mode, but it did not. When replugged the USB and checked the logs this is what we see.

Would like to know how do we know which services are using the timerfd or evenpollfd? do we need to completely stop legato application?

you can stop the legato by “legato stop”

BTW, do you connect again to host PC to indicate this is USB client?

Yes if the device does not enter selective suspend only then I am connecting the USB to check for why the device did not enter suspend mode.

Also is it necessary to stop legato? In that case how will wake up and do some activity when GPIO is triggered?

Didn’t you say you want to completely stop legato app? In this case, only yocto linux is running

@jyijyi ,

I meant stopping only the application using app stop but I want the legato framework running.

btw how can we know what is that wakeup source which is active? Do we have a chart of what legato services may hold a wakeup source?

Thanks & Regards,

Pankaj Sant

If you stop the legato, issue still happens, that means it is not related to legato

Two things you can do to narrow down the root cause:

  1. see if this issue is only related to USB OTG only. I believe selective suspend should be working fine for USB client mode.

  2. if this is related to USB OTG only, see if this issue is related to legato framework. You can stop the legato framework by “legato stop”.

Here is my testing on mangoh green board with WP76 FW16:

  1. before power on the board, connect the USB OTG cable with USB thumb drive

  2. power on the mangoh green board

  3. after boot up, the USB thumb drive content can be seen

  4. unplug the USB OTG cable together with the USB thumb drive, the board does not sleep as it is still in host mode

  5. plug the USB cable from PC to the board to indicate it is USB client

  6. wait for 10 seconds

  7. disconnect the USB cable, the board goes to sleep mode

I am finding a similar problem with WP7702. I found this in Legato Documentation that points to the possible problem. But it doesn’t explain how to remove this system wake lock:

A wakeup source is being held
Test
Dump contents of /sys/kernel/debug/wakeup_sources to find the fields that have a non-zero active_since field. Also dump contents of /sys/power/wake_lock to find active user-space wakeup sources.
Command
cat /sys/kernel/debug/wakeup_sources |sed -e s/"^ "/“unnamed”/ | awk ‘{print $6 “\t” $1}’ | grep -v “^0” |sort -n
cat /sys/power/wake_lock

Since I do see a wakeup source that matches the description: msm_otg, with a non-zero active since, I would like to try getting rid of it. Sadly the Legato doc does not describe how to delete the system wakeup_sources. Probably very simple. Any suggestions?

how about le_pm_Relax()?

Thank you jyijyi for responding. By using le_pm_Relax() I am now confident that there are no wakeup sources in the user space. That leaves system wakeup sources, and I think I have found one, but do not know how to relax it, as the le_pm_Relax command does nothing to it.

Another similar possibility that the Legato document provides a way to diagnose, but not to clear it when found. Any suggestion for that? Here is the entry in the Power Manager doc that seems to apply to my case:

Under the same Troubleshooting section, it says:

"System perpetually suspends and resumes.

Probable cause

Interrupt is constantly triggered.

Test

Dump contents of /proc/interrupts to find the IRQ that’s constantly incrementing.

Command

cat /proc/interrupts
— end of documentation —

On repeating the “cat /proc/interrupts” command, saving the output to successive files, I do see some interrupts that are constantly incrementing. They are not ones that I believe to be related to our hardware, so I assume they are system-related interrupts.

That is the end of the documentation. I wish it added a sentence to explain how to remove or turn off an interrupt found by the “cat /proc/interrupts” command.

Thanks Jyijyi for all of your ongoing help.

Sorry, i have no idea how to cancel the wakeup lock from usb otg

Probably need to think a way to go back to usb client mode

Ok no worries. Also BTW in researching this, I did find a way to cancel the wakeup source(s) from /sys/power/wake_lock. It doesn’t work to simply echo nil into that file. Instead, one must

  1. cat /sys/power/wake_lock to see what is in there, multiple items separated by space might be there.
  2. write the same string into /sys/power/wake_unlock
    For example, if “cat /sys/power/wake_lock” shows NO_SLEEP then
    echo “NO_SLEEP” > /sys/power/wake_unlock
    is needed to remove the wake_lock.
    I add this so that others might find it by googling Sierra Wireless wake_lock.
    I always hope that someone might direct me to a treasure trove of documentation about arcana like this :slight_smile: