Cannot enter suspend state with rtcwake

Hi,

  • I am using 4.9.20 kernel on hikey620

  • I tried suspend to ram with rtcwake as

rtcwake -m mem -s 15

  • But the system does not complete suspend and gives

rtcwake: write error

  • I tracked the error in kernel source to suspend_enter:

error = suspend_ops->enter(state);

The return value is -1. I have seen led trigger causing suspend problems, but I have already reverted the patch of led-trigger

suspend-ops-enter error=-1

  • I have enabled CONFIG_RTC_DRV_PL031 and CONFIG_SUSPEND in config already

  • Below is the log:

rtcwake: assuming RTC uses UTC …
rtcwake: wakeup from “mem” using /dev/rtc0 at Thu Feb 11 16:28:29 2016
[ 29.620800] PM: Syncing filesystems … done.
[ 29.626092] Freezing user space processes … (elapsed 0.001 seconds) done.
[ 29.634717] Freezing remaining freezable tasks … (elapsed 0.001 seconds) done.
[ 29.670620] PM: suspend of devices complete after 26.687 msecs
[ 29.677339] PM: late suspend of devices complete after 0.852 msecs
[ 29.684321] PM: noirq suspend of devices complete after 0.790 msecs
[ 29.691034] Disabling non-boot CPUs …
[ 29.717732] CPU1: shutdown
[ 29.720437] psci: CPU1 killed.
[ 29.773571] CPU2: shutdown
[ 29.776282] psci: CPU2 killed.
[ 29.833438] IRQ6 no longer affine to CPU3
[ 29.833538] CPU3: shutdown
[ 29.840264] psci: CPU3 killed.
[ 29.889622] CPU4: shutdown
[ 29.892332] psci: CPU4 killed.
[ 29.949540] CPU5: shutdown
[ 29.952251] psci: CPU5 killed.
[ 29.985506] CPU6: shutdown
[ 29.988218] psci: CPU6 killed.
[ 30.025478] CPU7: shutdown
[ 30.028187] psci: CPU7 killed.
[ 30.046409] PM: Calling ledtrig_cpu_syscore_suspend+0x0/0x20
[ 30.052072] PM: Calling sched_clock_suspend+0x0/0x38
[ 30.057028] PM: Calling timekeeping_suspend+0x0/0x1e8
[ 30.057028] PM: Calling irq_gc_suspend+0x0/0x78
[ 30.057028] PM: Calling kvm_suspend+0x0/0x38
[ 30.057028] PM: Calling fw_suspend+0x0/0x10
[ 30.057028] PM: Calling samsung_pinctrl_suspend+0x0/0x100
[ 30.057028] PM: Calling cpu_pm_suspend+0x0/0x20
[ 30.057028] PM: Calling cpu_pm_resume+0x0/0x18
[ 30.057028] PM: Calling samsung_pinctrl_resume+0x0/0xf8
[ 30.057028] PM: Calling kvm_resume+0x0/0x50
[ 30.057028] PM: Calling irq_gc_resume+0x0/0x78
[ 30.057028] PM: Calling irq_pm_syscore_resume+0x0/0x18
[ 30.057028] PM: Calling timekeeping_resume+0x0/0x1a8
[ 30.057028] PM: Calling sched_clock_resume+0x0/0x50
[ 30.057040] PM: Calling ledtrig_cpu_syscore_resume+0x0/0x18
[ 30.062747] Enabling non-boot CPUs …
[ 30.075985] Detected VIPT I-cache on CPU1
[ 30.076037] CPU1: Booted secondary processor [410fd033]
[ 30.076263] cache: parent cpu1 should not be sleeping
[ 30.090898] CPU1 is up
[ 30.107981] Detected VIPT I-cache on CPU2
[ 30.108008] CPU2: Booted secondary processor [410fd033]
[ 30.108193] cache: parent cpu2 should not be sleeping
[ 30.122772] CPU2 is up
[ 30.144133] Detected VIPT I-cache on CPU3
[ 30.144160] CPU3: Booted secondary processor [410fd033]
[ 30.144339] cache: parent cpu3 should not be sleeping
[ 30.158930] CPU3 is up
[ 30.180325] Detected VIPT I-cache on CPU4
[ 30.180371] CPU4: Booted secondary processor [410fd033]
[ 30.180620] cache: parent cpu4 should not be sleeping
[ 30.195250] CPU4 is up
[ 30.232351] Detected VIPT I-cache on CPU5
[ 30.232376] CPU5: Booted secondary processor [410fd033]
[ 30.232547] cache: parent cpu5 should not be sleeping
[ 30.247197] CPU5 is up
[ 30.276479] Detected VIPT I-cache on CPU6
[ 30.276504] CPU6: Booted secondary processor [410fd033]
[ 30.276691] cache: parent cpu6 should not be sleeping
[ 30.291318] CPU6 is up
[ 30.328609] Detected VIPT I-cache on CPU7
[ 30.328634] CPU7: Booted secondary processor [410fd033]
[ 30.328809] cache: parent cpu7 should not be sleeping
[ 30.343449] CPU7 is up
[ 30.346330] PM: noirq resume of devices complete after 0.521 msecs
[ 30.353254] PM: early resume of devices complete after 0.481 msecs
[ 30.360118] Suspended for 10.213 seconds
[ 30.667326] usb 1-1: reset high-speed USB device number 2 using dwc2
[ 31.179290] usb 1-1.2: reset high-speed USB device number 3 using dwc2
[ 31.294442] asix 1-1.2:1.0 eth0: unregister ‘asix’ usb-f72c0000.usb-1.2, ASIX AX88772 USB 2.0 Ethernet
[ 31.319335] PM: resume of devices complete after 959.869 msecs
[ 31.325237] usb 1-1.2:1.0: rebind failed: -517
[ 31.330248] Restarting tasks … done.
rtcwake: write error

Any help would be appreciated.

Thanks,
Ivid

What happens when:

  1. just call suspend:
    $ echo mem > /sys/power/state

  2. Enable alarm and go to suspend:
    $ echo +10 > /sys/class/rtc/rtc0/wakealarm; echo mem > /sys/power/state

Hi Loic,

rtcwake does the same thing as you have mentioned above. There is no difference, is there?
I have tried your suggestions, and in 1st case I cannot come back from sleep, and in 2nd case output is same as I mentioned before, but this time got below error:

-bash: echo: write error: Operation not supported

Thanks,
IVID

Yes, wanted to know if issue was related to suspend itself or RTC/alarm. If only one subsystem/driver suspend function fails, all the suspend procedure is aborted and device is resumed, this does not seem the case here.

pl031 driver is supposed to support alarm but something clearly goes wrong here.
Are you using Android ?

No I am not using android.I have some doubt regarding led-triggers

Hi Loic,

With initcall_debug in bootargs, I get following trace:

[ 44.879885] psci: CPU7 killed.
[ 44.894007] PM: Calling ledtrig_cpu_syscore_suspend+0x0/0x20
[ 44.899671] PM: Calling sched_clock_suspend+0x0/0x38
[ 44.904628] PM: Calling timekeeping_suspend+0x0/0x1e8
[ 44.904628] PM: Calling irq_gc_suspend+0x0/0x78
[ 44.904628] PM: Calling kvm_suspend+0x0/0x38
[ 44.904628] PM: Calling fw_suspend+0x0/0x10
[ 44.904628] PM: Calling samsung_pinctrl_suspend+0x0/0x100
[ 44.904628] PM: Calling cpu_pm_suspend+0x0/0x20
[ 44.904628]
[ 44.904628] suspend ops=-95
[ 44.904628] PM: Calling cpu_pm_resume+0x0/0x18
[ 44.904628] PM: Calling samsung_pinctrl_resume+0x0/0xf8
[ 44.904628] PM: Calling kvm_resume+0x0/0x50
[ 44.904628] PM: Calling irq_gc_resume+0x0/0x78
[ 44.904628] PM: Calling irq_pm_syscore_resume+0x0/0x18
[ 44.904628] PM: Calling timekeeping_resume+0x0/0x1a8
[ 44.904628] Suspended for 0.131 seconds
[ 44.904628] PM: Calling sched_clock_resume+0x0/0x50
[ 44.904642] PM: Calling ledtrig_cpu_syscore_resume+0x0/0x18
[ 44.910351] Enabling non-boot CPUs …

  • As seen from the trace, suspend_ops is returning -95. I had added a printk statement in kernel/suspend.c:suspend_enter

  • Could you make out anything from -95 error value?

Thanks,
Ivid

Is it a suspend triggered by rtcwake as well ? -95 is errno EOPNOTSUPP (operation not supported).
I don’t see any initcall_debug related msg, could you please increase console debug level (dmesg -n 8) before triggering suspend.

@leo-yan, i see that you already tested rtc wake-alarm on hikey, is it something which is known as working 4.9 ?

Yeah, I think 4.9 has supported suspend/resume. I checked the rtc DT binding has been merged at 4.8 kernel and other mainly setting is in latest ARM-TF.

So could you check if kernel config has “CONFIG_RTC_DRV_PL031=y”? And Please check if ARM-TF has used the latest images: https://builds.96boards.org/snapshots/reference-platform/components/uefi-staging/31/hikey/?

@Loic

@leo-yan Yes I have enabled the rtc config. After some debugging, I found the path of issue. It is in

arch/arm64/kernel/suspend.c in cpu_suspend function.

  • Below is the description of the code that is causing this error:
            /*
             * Never gets here, unless the suspend finisher fails.
             * Successful cpu_suspend() should return from cpu_resume(),
             * returning through this code path is considered an error
             * If the return value is set to 0 force ret = -EOPNOTSUPP
             * to make sure a proper error condition is propagated
             */
            if (!ret)
                    ret = -EOPNOTSUPP;
  • Something is causing the suspend finisher to halt. I checked with 4.4 kernel and it is fine with no issues.

Thanks,
Ivid

@ivid, what I understand is that your suspend path is ok since the following command successfully suspends your board:
$ echo mem > /sys/power/state
Then your board never resume, but it’s normal since there is no wakeup source configured.

I think you should concentrate on why this command fails on your side:
$ echo +10 > /sys/class/rtc/rtc0/wakealarm

Could you try to debug the failure path as well ? :wink:

I noted that it is required to provide -m mem or the write error will occur. Are you sure that you provided it?