iMX8mm suspend end event

Using Linux Yocto custom build based to Toradex Yocto reference project (and latest BSP 5.6.0). I’m using suspend to RAM state as described here: Suspend/Resume (Linux) | Toradex Developer Center. Qt application is integrated same manner as in Toradex reference project.

I try to catch event into application when suspend end happen. Qt API’s does not provide this info, neither Linux signal is working. Asked this from Qt but they think this is more Toradex HW/BSP issue.

Code snipped used when I tried to catch SIGCONT signal from Linux kernel.

#include "signal.h"

void handler (int signum) {

    if (signum == SIGCONT)
    {
        printf("@@@: handler called\n");
    }
}

void main () {
    if (signal(SIGCONT, handler) == SIG_IGN)
    {
        signal (SIGCONT, SIG_IGN);
    }
    else
    {
        printf("@@@ handler installed correctly\n");
    }
}

With Qt API I’m able to receive signal Qt::ApplicationActive into QGuiApplication when application is started immediately after Linux boot, nothing else ever

Br Vesa

Hi @veskola ,

Just for the record, could you please state the HW version of the module that you’re using?

Furthermore, what carrier board is the module placed in? Is it a Toradex carrier board? If so, what version is the carrier?

It would be helpful as well if you could attach a dmesg log of the test you are doing, so we can have a look at it.

Best Regards
Kevin

Hello Kevin,

SOM: Verdin iMX8MM Q 2GB WB IT, V1.1A 06827688
Carrier board: Our own design, it contain Type-C USB charging solution with one Type-C connector, sn65dsi84 bridge chip connected with Evervision LVDS display which have integrated touch.

Carrier board and display panel has following I2C chips: charging chip: bq25611d, CC chip: ptn5150, fuel gauge: bq27441, touch chip: ev-ft5726. Kernel and linux tree modified to support these (bq256xx_charger.c added, extcon-ptn5150.c, edt-ft5x06.c, bq27xxx_battery.c modified)

Br Vesa

dmesg:

[32293.607137] Freezing user space processes ... (elapsed 0.001 seconds) done.
[32293.615488] OOM killer disabled.
[32293.618724] Freezing remaining freezable tasks ... (elapsed 0.087 seconds) done.
[32293.713379] printk: Suspending console(s) (use no_console_suspend to debug)

<< Suspend state, from QT app suspen requested and it works fine, wakeup done with uart key click >>

[32293.870977] imx-drm soc@0:bus@32c00000:display-subsystem: sn65dsi83_bridge_disable
[32293.870984] sn65dsi83 3-002c: sn65dsi83_brg_stop_stream
[32293.871260] sn65dsi83 3-002c: sn65dsi83_brg_power_off
[32293.896455] Disabling non-boot CPUs ...
[32293.896900] CPU1: shutdown
[32293.896904] psci: CPU1 killed (polled 0 ms)
[32293.899789] IRQ 6: no longer affine to CPU2
[32293.899927] CPU2: shutdown
[32293.900948] psci: CPU2 killed (polled 0 ms)
[32293.903899] CPU3: shutdown
[32293.903907] psci: CPU3 killed (polled 0 ms)
[32293.906315] Enabling non-boot CPUs ...
[32293.906711] Detected VIPT I-cache on CPU1
[32293.906731] GICv3: CPU1: found redistributor 1 region 0:0x00000000388a0000
[32293.906767] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[32293.907175] CPU1 is up
[32293.907516] Detected VIPT I-cache on CPU2
[32293.907529] GICv3: CPU2: found redistributor 2 region 0:0x00000000388c0000
[32293.907548] CPU2: Booted secondary processor 0x0000000002 [0x410fd034]
[32293.907812] CPU2 is up
[32293.908157] Detected VIPT I-cache on CPU3
[32293.908169] GICv3: CPU3: found redistributor 3 region 0:0x00000000388e0000
[32293.908189] CPU3: Booted secondary processor 0x0000000003 [0x410fd034]
[32293.908460] CPU3 is up
[32293.911598] imx-drm soc@0:bus@32c00000:display-subsystem: sn65dsi83_bridge_mode_set: mode: 800*480@29700
[32293.914317] imx-drm soc@0:bus@32c00000:display-subsystem: sn65dsi83_bridge_enable
[32293.914322] sn65dsi83 3-002c: sn65dsi83_brg_setup
[32293.914325] sn65dsi83 3-002c: sn65dsi83_brg_power_on
[32293.945420] sn65dsi83 3-002c: DSI clock [ 89100000 ] Hz
[32293.945423] sn65dsi83 3-002c: GeoMetry [ 800 x 480 ] Hz
[32293.946762] sn65dsi83 3-002c: client 0x00000000c638de7c
[32293.956945] sn65dsi83 3-002c: sn65dsi83_brg_start_stream
[32294.161684] sn65dsi83 3-002c: client 0x00000000c638de7c
[32294.161982] sn65dsi83 3-002c: CHA (0xe5) = 0x89
[32294.179104] caam 30900000.crypto: registering rng-caam
[32294.789545] OOM killer enabled.
[32294.792683] Restarting tasks ... done.
[32294.802272] PM: suspend exit

<< Nothing in application side about suspend exit, kernel side detect suspend exit correctly as seen in last line >>

Hi @veskola !

I am not aware of signal(s) that Linux might send to applications/use space by default when entering suspend mode or when waking up.

In fact, I tried to capture several different signals during suspension/wake up, but I saw nothing. I used this C source code: A C application that logs some received signals to a file · GitHub

But I could make it work for my signal_test_arm64 (compiled from the source in the link above) application by creating 2 services:

  • One that sends signal before the suspension
[Unit]
Description=Sends signal to my signal test
Before=sleep.target

[Service]
Type=oneshot
ExecStart=killall -11 signal_test_arm64
User=root

[Install]
RequiredBy=sleep.target
  • Another that sends signal after wake
[Unit]
Description=Sends signal to my signal test AFTER WAKE
After=sleep.target

[Service]
Type=oneshot
ExecStart=killall -12 signal_test_arm64
User=root

[Install]
RequiredBy=sleep.target

Also, maybe this can help you:

https://www.linuxfromscratch.org/blfs/view/8.0/general/pm-utils.html

Let us know if this helps you :slight_smile:

Best regards,

1 Like

Hello @henrique.tx

Great trick, I got it working fine with separate service, and was able to catch SIGUSR2 signal in application when sleep terminates. Thank You.

Br Vesa

1 Like

Hi @veskola!

Great that it worked for you!

I just would like to say that my C code example uses signal.h, and according to signal(2) documentation (signal(2): ANSI C signal handling - Linux man page), sigaction(2) should be used instead.

Best regards,