Comments (13)
Looks like an issue with the driver itself. @aymanbagabas, ideas?
from matebook-applet.
It's not the driver, it might be a race condition as @n3vu0r stated. I would try adding another udev rule with ACTION=='change' and see if this solves it.
from matebook-applet.
@n3vu0r Can you test? If the solution works, we may add a second udev rule to this repo.
from matebook-applet.
Ah okay, i'm testing it.
from matebook-applet.
It seems to work with both, add and change event rules. A change event rule only does not work.
But doesn't this mean that the driver adds the sysfs device before its attributes are set? Is it possible to do this atomically, so that an add event is enough @aymanbagabas?
from matebook-applet.
It seems to work with both, add and change event rules. A change event rule only does not work.
But doesn't this mean that the driver adds the sysfs device before its attributes are set? Is it possible to do this atomically, so that an add event is enough @aymanbagabas?
Indeed, it seems to be a race condition at least according to [1], [2], [3], and [4].
This is now should be fixed in master branch. Now using one "add" rule should be sufficient.
Side note: a default value charge threshold value can be set using something like
SUBSYSTEM=="platform", DRIVER=="huawei-wmi", ATTR{charge_thresholds}="40 70"
from matebook-applet.
Wow, great! I will test it with the original udev rule which went into the race condition.
(Initially, I used this ATTR
assignment, but wanted it to be configured by the applet by delegating the event to systemd with TAG+="systemd")
from matebook-applet.
Wow, great! I will test it with the original udev rule which went into the race condition.
(Initially, I used this
ATTR
assignment, but wanted it to be configured by the applet by delegating the event to systemd with TAG+="systemd")
Reverted back to sysfs. It turns out that this actually won't fix! Actually, using device_add_group during probing is the same as using sysfs_create_group. The provided solution is for static variables/attributes, while the driver creates these attributes only if the corresponding WMI GUID is found which makes it rather dynamic.
An alternative solution could be to use devtmpfs or systemd instead of udev rules. For now, two udev rules needed.
from matebook-applet.
@n3vu0r What's the status on this? I'm not shipping udev rule since 1.3.1 and actually rely on your work instead. Should this issue be closed or transfered?
from matebook-applet.
Sorry, I'm late. Thanks for the effort @aymanbagabas, pity it wouldn't fix it.
I haven't observed any race condition with following workarounds:
- Two udev rules:
add
event fails sometimes but gets recovered bychange
event. - One udev rule plus systemd unit:
add
event always worked so far but could fail in theory and then there won't be achange
event because systemdWantedBy
only cares about anadd
event. Im not sure why this always works: either this mechanism is just slow enough or there is some extra magic. Thechange
event triggers a reload on the systemd device unit and could be caught byReloadPropagatedFrom=
andExecReload=
but this gets ugly. Instead I would like to addRestart=on-failure
to be on the safe side. With default settings it will restart the unit up to 5 times with 100 ms between the restarts, this should easily cover the race condition.
To summarize, both solutions solve this issue. I prefer the systemd solution for simple logging and enabling/disabling the two services separately. I will add Restart=on-failure
to the huawei-wmi-privilege
unit and release the package version 1.0.0
. For this I want to figure out if suspend-then-hibernate.target
should be added to WantedBy
or if it is already covered by a more general hibernate.target
.
If @aymanbagabas has plans to eliminate the race condition at the driver level in future, we might transfer the issue there instead of closing it?
from matebook-applet.
or if it is already covered by a more general
hibernate.target
Even if it is (which I doubt) adding it explicitly shouldn't hurt as far a I understand.
we might transfer the issue there instead of closing it?
I was rather thinking of transferring it to you, actually, since you're the one maintaining udev rules now ;)
from matebook-applet.
Ahh, fine with that :D
For both user space repos the issue is solved, so we can close it (or transfer and close).
Restart=on-failure
is not supported yet for Type=oneshot
units. This will do the same in the end:
ExecStart=sh -c '[ -e ${SYS}/charge_thresholds -a -e ${SYS}/fn_lock_state ] || sleep 1'
from matebook-applet.
Allright, closing it now.
from matebook-applet.
Related Issues (20)
- ERROR: neither a support version of huawei-wmi driver or any of the required scripts are properly installed HOT 5
- [linux 5.5] Driver interface is readable but not writeable. HOT 5
- Fedora HOT 6
- Driver interface is readable but not writeable. HOT 2
- Error setting thresholds on Matebook 14 2020 AMD HOT 22
- Applet Icon HOT 2
- applet not able to change battery settings on matebook-2020 (intel i7) HOT 2
- BP thresholds don't make sense: min 0%, max 0% HOT 8
- Support MacOS HOT 97
- Migrate to the Ayatana (App)Indicator(s) for newer Debian versions HOT 8
- Every time restart, the settings are invalid @Matebook 2020(R5) HOT 4
- error while loading shared libraries: libayatana-appindicator3.so.1 on Fedora 34 HOT 4
- Cannot run last applet on Archlinux HOT 4
- KDE Plasma system tray applet HOT 7
- How is the battery protection different from generic limits? HOT 8
- Unable to locate package matebook-applet HOT 2
- cannot find module providing package embed HOT 2
- Функционал по ограничению порогов заряда/разряда батареи не работает HOT 4
- This application for Windows HOT 1
- Error setting thresholds on Matebook 16 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matebook-applet.