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
interfaces: add pwm-control interface #12347
base: master
Are you sure you want to change the base?
Conversation
a28c237
to
5e3bc4c
Compare
@degville shall I write a documentation snippet about this interface on the forum? |
I just had a quick look, and my main question is what are the cases that the existing |
@mardy the relation between the (so far missing) |
Yes please! I'll edit it there if needed. I think it's great to see usernames attached to the work they're responsible for. |
5e3bc4c
to
b145c91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but since this is a new interface I think we need @pedronis 's review as well :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, as parallel to gpio-control for PWM this looks fine to me
interfaces/builtin/pwm_control.go
Outdated
|
||
/sys/class/pwm/pwmchip[0-9]*/{,un}export rw, | ||
/sys/class/pwm/pwmchip[0-9]*/npwm r, | ||
/sys/class/pwm/pwmchip[0-9]*/pwm[0-9]*/{period,duty_cycle,polarity,enable} rw, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaict pwm itself, used /*
for the last component here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can adjust that. I just wanted to be precise, as it is easier to extend but harder to take the permissions away.
If you want I can change that to the general glob.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but given the choice for pwm itself, I think it's better to be consistent at this point, also it would be strange for the -control
variant to be more restricted in this way than the non-control one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, I'll send an update in a moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedronis done. I have also added the k
permission to match the pwm
interface better (k
allows locking AFAIR).
I've created https://forum.snapcraft.io/t/the-pwm-control-interface/32908 based on the documentation of the gpio-control interface. I think both interfaces could use some technical details. I'll do another round of proposed updates to those threads to see what you think @degville EDIT: I think the sort of thing now present on under the "developer details" section of the PWM interface is what I was thinking of. |
The pwm-control interface is similar in spirit to the gpio-control interface, allowing access to any and all pulse-width-modulation channels. The interface is equally privileged. The only difference as compared to GPIO control is the set of permissions granted. Those are modeled after the kernel documentation referenced from a code comment. Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
b145c91
to
27c16ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Please hold on with merging this. I had to apply one more change for this to really work. I totally missed the fact that sysfs is full of symlinks. I made a change that looks almost identical to what |
I'll pick this up mid next week. I have an urgent thing to address outside of the scope of snapd. |
I still have a few things to do but I will push an update with the new look of the code for possible feedback. |
# potentially impact the system and other snaps, and allows privileged access | ||
# to hardware. | ||
|
||
/sys/class/pwm/pwmchip[0-9]*/{,un}export rw, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The three patterns look good, but fail on the symlink:
On a random Raspberry Pi 5:
zyga@pi5-1:/sys/class/pwm$ ls -ld pwmchip*
lrwxrwxrwx 1 root root 0 Nov 8 18:38 pwmchip0 -> ../../devices/platform/axi/1000120000.pcie/1f0009c000.pwm/pwm/pwmchip0
lrwxrwxrwx 1 root root 0 Feb 6 23:48 pwmchip4 -> ../../devices/platform/soc/107d517a80.pwm/pwm/pwmchip4
So this pattern alone would not work.
This needs re-design to avoid the problem of symlinks and apparmor. |
The pwm-control interface is similar in spirit to the gpio-control interface, allowing access to any and all pulse-width-modulation channels.
The interface is equally privileged. The only difference as compared to GPIO control is the set of permissions granted. Those are modeled after the kernel documentation referenced from a code comment.
Signed-off-by: Zygmunt Krynicki me@zygoon.pl