linaro-swg / linux

Linux kernel source tree
Other
41 stars 79 forks source link

Linux PM: RPC call break system sleep #82

Open hanshu830 opened 3 years ago

hanshu830 commented 3 years ago

Hello, I was just encountered an issue with CA break linux system suspend operation. Linux freezer reports the corresponding CA process can't be froze. Here is the scenario:

I just noted that linux freezer has some help functions to avoid this happened(refer to include/linux/freezer.h). e.g.

    freezer_do_not_count()
    wait_for_completion(x)
    freezer_count()

Check with the latest OP-TEE Driver seems doesn't utilize this kind of help function. Not sure this is the correct way or OP-TEE Driver has other consideration of this. So do we have plan to update OP-TEE Driver more friendly with linux freezer ?

Thanks!

jenswi-linaro commented 3 years ago

So do we have plan to update OP-TEE Driver more friendly with linux freezer ?

Patches are welcome! I can help reviewing.

hanshu830 commented 3 years ago

Patches are welcome! I can help reviewing.

Okay, I will try on this.

Meanwhile, update related information regarding to this issue.

Duplicate script

 cat << EOF > issue82.sh
 #!/bin/sh

 # 
 # Since open session  will use RPC call, here raise more open session
 # the duplicate rate will be more higher. 
 #
 xtest 4001 &
 xtest 4002 &
 xtest 4003 &

 # Platform specific wake up source
 echo +10 > /sys/class/rtc/rtc0/wakealarm

 # Raise system sleep
 echo mem > /sys/power/state

Phenomena

[   41.234263] Freezing user space processes ...
[   61.241939] Freezing of tasks failed after 20.003 seconds (3 tasks refusing to freeze, wq_busy=0):
[   61.250801] xtest           R  running task        0  1915   1914 0x00000009
[   61.257754] Call trace:
[   61.260162] [<ffffff8008085a94>] __switch_to+0xa4/0xb8
[   61.265237] [<          (null)>]           (null)
[   61.269878] xtest           D    0  1916   1914 0x00000001
[   61.275295] Call trace:
[   61.277704] [<ffffff8008085a94>] __switch_to+0xa4/0xb8
[   61.282783] [<ffffff8008a05a70>] __schedule+0x1a8/0x5c8
[   61.287940] [<ffffff8008a05ebc>] schedule+0x2c/0x90
[   61.292756] [<ffffff8008a093c8>] schedule_timeout+0x1b0/0x298
[   61.298433] [<ffffff8008a06b90>] wait_for_common+0x98/0x140
[   61.303939] [<ffffff8008a06c4c>] wait_for_completion+0x14/0x20
[   61.309701] [<ffffff8008794554>] optee_handle_rpc+0x45c/0x4f0
[   61.315374] [<ffffff8008793984>] optee_do_call_with_arg+0xe4/0xf8
[   61.321394] [<ffffff8008793b74>] optee_open_session+0xe4/0x1b0
[   61.327158] [<ffffff800879206c>] tee_ioctl+0xbc4/0xd58
[   61.332232] [<ffffff80081aef6c>] do_vfs_ioctl+0xa4/0x7b0
[   61.337476] [<ffffff80081af6bc>] SyS_ioctl+0x44/0x78
hanshu830 commented 3 years ago

@jenswi-linaro

Just create a pull request #84, not sure this is enough, please help to review, thanks!