Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux PM: RPC call break system sleep #82

Open
hanshu830 opened this issue Jan 18, 2021 · 3 comments
Open

Linux PM: RPC call break system sleep #82

hanshu830 opened this issue Jan 18, 2021 · 3 comments

Comments

@hanshu830
Copy link

hanshu830 commented Jan 18, 2021

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:

  • CA process invoke command into TA.
  • TA use RPC call to tee-supplicant.
  • TA(CA context) wait tee-supplicant result in OP-TEE Driver.
  • User trigger system sleep(echo mem > /sys/power/state).
  • tee-supplicant be frozen by linux freezer.
  • Here is the issue, tee-supplicant be frozen first, so the TA(CA context) has no chance to back to CA.
  • The freezer keep polling CA state wait its PF_FROZEN be set, until system suspend timeout and abort.

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!

@hanshu830 hanshu830 changed the title Linux PM: system sleep abort, CA process can't be frozen Linux PM: RPC call break system sleep Jan 18, 2021
@jenswi-linaro
Copy link

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

Patches are welcome! I can help reviewing.

@hanshu830
Copy link
Author

hanshu830 commented Jan 19, 2021

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
Copy link
Author

@jenswi-linaro

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants