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

Doesn't work after waking up from suspend #13

Open
ilgiznurgaliev opened this issue Jan 11, 2022 · 7 comments
Open

Doesn't work after waking up from suspend #13

ilgiznurgaliev opened this issue Jan 11, 2022 · 7 comments
Assignees

Comments

@ilgiznurgaliev
Copy link

Hi,

Below is log after waking up. Systemd tries to restart it several times, but it still crashes with the same output:

amdfan[10910]: [19:01:09] INFO     Starting amdfan                                amdfan.py:216
amdfan[10910]: ╭───────────────────── Traceback (most recent call last) ──────────────────────╮
amdfan[10910]: │                                                                              │
amdfan[10910]: │ /usr/bin/amdfan:33 in <module>                                               │
amdfan[10910]: │                                                                              │
amdfan[10910]: │   30                                                                         │
amdfan[10910]: │   31 if __name__ == '__main__':                                              │
amdfan[10910]: │   32 │   sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])   │
amdfan[10910]: │ ❱ 33 │   sys.exit(load_entry_point('amdfan==0.1.15', 'console_scripts', 'amd │
amdfan[10910]: │   34                                                                         │
amdfan[10910]: │ /usr/lib/python3.10/site-packages/click/core.py:1128 in __call__             │
amdfan[10910]: │                                                                              │
amdfan[10910]: │   1125 │                                                                     │
amdfan[10910]: │   1126 │   def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:       │
amdfan[10910]: │   1127 │   │   """Alias for :meth:`main`."""                                 │
amdfan[10910]: │ ❱ 1128 │   │   return self.main(*args, **kwargs)                             │
amdfan[10910]: │   1129                                                                       │
amdfan[10910]: │   1130                                                                       │
amdfan[10910]: │   1131 class Command(BaseCommand):                                           │
amdfan[10910]: │                                                                              │
amdfan[10910]: │ /usr/lib/python3.10/site-packages/click/core.py:1053 in main                 │
amdfan[10910]: │                                                                              │
amdfan[10910]: │   1050 │   │   try:                                                          │
amdfan[10910]: │   1051 │   │   │   try:                                                      │
amdfan[10910]: │   1052 │   │   │   │   with self.make_context(prog_name, args, **extra) as c │
amdfan[10910]: │ ❱ 1053 │   │   │   │   │   rv = self.invoke(ctx)                             │
amdfan[10910]: │   1054 │   │   │   │   │   if not standalone_mode:                           │
amdfan[10910]: │   1055 │   │   │   │   │   │   return rv                                     │
amdfan[10910]: │   1056 │   │   │   │   │   # it's not safe to `ctx.exit(rv)` here!           │
amdfan[10910]: │                                                                              │
amdfan[10910]: │ /usr/lib/python3.10/site-packages/click/core.py:1395 in invoke               │
amdfan[10910]: │                                                                              │
amdfan[10910]: │   1392 │   │   │   echo(style(message, fg="red"), err=True)                  │
amdfan[10910]: │   1393 │   │                                                                 │
amdfan[10910]: │   1394 │   │   if self.callback is not None:                                 │
amdfan[10910]: │ ❱ 1395 │   │   │   return ctx.invoke(self.callback, **ctx.params)            │
amdfan[10910]: │   1396 │                                                                     │
amdfan[10910]: │   1397 │   def shell_complete(self, ctx: Context, incomplete: str) -> t.List │
amdfan[10910]: │   1398 │   │   """Return a list of completions for the incomplete value. Loo │
amdfan[10910]: │                                                                              │
amdfan[10910]: │ /usr/lib/python3.10/site-packages/click/core.py:754 in invoke                │
amdfan[10910]: │                                                                              │
amdfan[10910]: │    751 │   │                                                                 │
amdfan[10910]: │    752 │   │   with augment_usage_errors(__self):                            │
amdfan[10910]: │    753 │   │   │   with ctx:                                                 │
amdfan[10910]: │ ❱  754 │   │   │   │   return __callback(*args, **kwargs)                    │
amdfan[10910]: │    755 │                                                                     │
amdfan[10910]: │    756 │   def forward(                                                      │
amdfan[10910]: │    757 │   │   __self, __cmd: "Command", *args: t.Any, **kwargs: t.Any  # no │
amdfan[10910]: │                                                                              │
amdfan[10910]: │ /usr/lib/python3.10/site-packages/amdfan/amdfan.py:343 in cli                │
amdfan[10910]: │                                                                              │
amdfan[10910]: │   340 │   daemon: bool, monitor: bool, manual: bool, configuration: bool, se │
amdfan[10910]: │   341 ) -> None:                                                             │
amdfan[10910]: │   342 │   if daemon:                                                         │
amdfan[10910]: │ ❱ 343 │   │   run_as_daemon()                                                │
amdfan[10910]: │   344 │   elif monitor:                                                      │
amdfan[10910]: │   345 │   │   monitor_cards()                                                │
amdfan[10910]: │   346 │   elif manual:                                                       │
amdfan[10910]: │                                                                              │
amdfan[10910]: │ /usr/lib/python3.10/site-packages/amdfan/amdfan.py:371 in run_as_daemon      │
amdfan[10910]: │                                                                              │
amdfan[10910]: │   368 │   │                                                                  │
amdfan[10910]: │   369 │   │   config = load_config(CONFIG_LOCATIONS[-1])                     │
amdfan[10910]: │   370 │                                                                      │
amdfan[10910]: │ ❱ 371 │   FanController(config).main()                                       │
amdfan[10910]: │   372                                                                        │
amdfan[10910]: │   373                                                                        │
amdfan[10910]: │   374 def show_table(cards: Dict) -> Table:                                  │
amdfan[10910]: │                                                                              │
amdfan[10910]: │ /usr/lib/python3.10/site-packages/amdfan/amdfan.py:235 in main               │
amdfan[10910]: │                                                                              │
amdfan[10910]: │   232 │   │   │   │   │   temp,                                              │
amdfan[10910]: │   233 │   │   │   │   │   self._last_temp,                                   │
amdfan[10910]: │   234 │   │   │   │   │   speed,                                             │
amdfan[10910]: │ ❱ 235 │   │   │   │   │   card.fan_speed,                                    │
amdfan[10910]: │   236 │   │   │   │   │   card.fan_min,                                      │
amdfan[10910]: │   237 │   │   │   │   │   card.fan_max,                                      │
amdfan[10910]: │   238 │   │   │   │   )                                                      │
amdfan[10910]: │                                                                              │
amdfan[10910]: │ /usr/lib/python3.10/site-packages/amdfan/amdfan.py:136 in fan_speed          │
amdfan[10910]: │                                                                              │
amdfan[10910]: │   133 │   @property                                                          │
amdfan[10910]: │   134 │   def fan_speed(self) -> int:                                        │
amdfan[10910]: │   135 │   │   try:                                                           │
amdfan[10910]: │ ❱ 136 │   │   │   return int(self.read_endpoint("fan1_input"))               │
amdfan[10910]: │   137 │   │   except KeyError:  # better to return no speed then explode     │
amdfan[10910]: │   138 │   │   │   return 0                                                   │
amdfan[10910]: │   139                                                                        │
amdfan[10910]: │                                                                              │
amdfan[10910]: │ /usr/lib/python3.10/site-packages/amdfan/amdfan.py:123 in read_endpoint      │
amdfan[10910]: │                                                                              │
amdfan[10910]: │   120 │                                                                      │
amdfan[10910]: │   121 │   def read_endpoint(self, endpoint: str) -> str:                     │
amdfan[10910]: │   122 │   │   with open(self._endpoints[endpoint], "r") as endpoint_file:    │
amdfan[10910]: │ ❱ 123 │   │   │   return endpoint_file.read()                                │
amdfan[10910]: │   124 │                                                                      │
amdfan[10910]: │   125 │   def write_endpoint(self, endpoint: str, data: int) -> int:         │
amdfan[10910]: │   126 │   │   try:                                                           │
amdfan[10910]: ╰──────────────────────────────────────────────────────────────────────────────╯
amdfan[10910]: OSError: [Errno 22] Invalid argument
@mcgillij mcgillij self-assigned this Jan 11, 2022
@mcgillij
Copy link
Owner

Interesting, are the files in /sys/class/drm/card* not present after your sleep? All this does is basically look at those values.

@ilgiznurgaliev
Copy link
Author

Thanks for quick response @mcgillij. The files are there. All I need to make it work is to manually start it using systemctl start amdfan.

@mcgillij
Copy link
Owner

Hum, maybe there's some systemd flag I can add to the systemd config file for it, to make it do an actual restart vs whatever it's doing now when recovering from sleep.

@ilgiznurgaliev
Copy link
Author

Did some tests today and found out that it hapens randomly. Waked up three times since yesterday and all three time it restarted by itself. Couldn't find why sometimes it fails to restart. I will update this thread if I find something else.

@mcgillij
Copy link
Owner

Sounds good, thanks.

@camel1cz
Copy link

camel1cz commented Jul 13, 2022

I had this issue even w/o suspend.
It seems to be caused by some cards/drivers not ready to report fan speed.
To fix it, catch OSError exception on line 137. It should be something like:
except (KeyError, OSError): # better to return no speed then explode

@mcgillij
Copy link
Owner

I'll push up a new version shortly.

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

3 participants