# Selective Suspend mode issue with Timer FD

**URL:** <https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916>\
**Category:** Legato Application Framework\
**Created:** [August 2, 2021, 6:46am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916 "2021-08-02T06:46:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [August 2, 2021, 6:46am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/1 "2021-08-02T06:46:01Z")

</div>

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](https://forum.legato.io/uploads/short-url/27oiLNoboDR1FUpPR1U4XmfXVkm.txt) (655.8 KB)

Thanks

Pankaj

[app.c](https://forum.legato.io/uploads/short-url/2ISfVby9qNvEh9n2Kd2L5Ft1D3N.c) (1.6 KB)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 2, 2021, 7:02am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/2 "2021-08-02T07:02:09Z")

</div>

you can see the wakeup source here:  
cat /sys/power/wake\_lock

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [August 2, 2021, 7:06am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/3 "2021-08-02T07:06:28Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 2, 2021, 7:12am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/4 "2021-08-02T07:12:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [August 4, 2021, 6:18am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/5 "2021-08-04T06:18:30Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 4, 2021, 6:26am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/6 "2021-08-04T06:26:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [August 4, 2021, 9:40am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/7 "2021-08-04T09:40:25Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 4, 2021, 9:53am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/8 "2021-08-04T09:53:53Z")

</div>

you can stop the legato by “legato stop”

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

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [August 4, 2021, 10:07am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/9 "2021-08-04T10:07:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 4, 2021, 10:11am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/10 "2021-08-04T10:11:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [August 4, 2021, 10:41am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/11 "2021-08-04T10:41:51Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 4, 2021, 10:43am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/12 "2021-08-04T10:43:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 5, 2021, 5:48am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/13 "2021-08-05T05:48:04Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 6, 2021, 6:19am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/14 "2021-08-06T06:19:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jimdotter](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jimdotter](https://forum.legato.io/u/jimdotter)\
**Post date:** [October 19, 2023, 9:45pm UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/15 "2023-10-19T21:45:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [October 20, 2023, 1:51am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/16 "2023-10-20T01:51:49Z")

</div>

how about le\_pm\_Relax()?

> **[Power Manager - Legato Docs](https://docs.legato.io/latest/c_pm.html)**
>
> legato™ is an open source Linux-based embedded platform designed to simplify connected IoT application development

---

<div class="post-metadata">

**Author:** ![jimdotter](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jimdotter](https://forum.legato.io/u/jimdotter)\
**Post date:** [October 20, 2023, 1:22pm UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/17 "2023-10-20T13:22:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [October 20, 2023, 2:25pm UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/18 "2023-10-20T14:25:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jimdotter](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jimdotter](https://forum.legato.io/u/jimdotter)\
**Post date:** [October 20, 2023, 3:34pm UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/19 "2023-10-20T15:34:15Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [May 6, 2025, 3:22am UTC](https://forum.legato.io/t/selective-suspend-mode-issue-with-timer-fd/5916/20 "2025-05-06T03:22:53Z")

</div>

Other user can make WP76 (FW R16.3) go to sleep mode after connecting to USB OTG device:

> **[Entering KSLEEP=0 after triggering OTG Host is broken](https://forum.sierrawireless.com/t/entering-ksleep-0-after-triggering-otg-host-is-broken/34806/11)**
>
> Hi, sorry for the late response, the company was on break. I took a step back and reassessed if the bug was caused by the manual hsusb-otg-otg-control, so I asked my colleagues for a OTG cable with a switch on the ID pin, so that I could control...
