Skip to content

Commit

Permalink
T5949: Disable USB autosuspend
Browse files Browse the repository at this point in the history
  • Loading branch information
HollyGurza committed Jun 18, 2024
1 parent 2224890 commit 3bc4768
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/templates/system/40_usb_autosuspend.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% set autosuspend = "-1" %}
{% if enable_usb_autosuspend is vyos_defined %}
{% set autosuspend = "auto" %}
{% endif %}
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="{{ autosuspend }}"
6 changes: 6 additions & 0 deletions interface-definitions/system_option.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@
</properties>
<defaultValue>12-hour</defaultValue>
</leafNode>
<leafNode name="enable-usb-autosuspend">
<properties>
<help>Enable autosuspend for all USB devices</help>
<valueless/>
</properties>
</leafNode>
</children>
</node>
</children>
Expand Down
5 changes: 5 additions & 0 deletions src/conf_mode/system_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
curlrc_config = r'/etc/curlrc'
ssh_config = r'/etc/ssh/ssh_config.d/91-vyos-ssh-client-options.conf'
systemd_action_file = '/lib/systemd/system/ctrl-alt-del.target'
usb_autosuspend = r'/etc/udev/rules.d/40-usb-autosuspend.rules'
time_format_to_locale = {
'12-hour': 'en_US.UTF-8',
'24-hour': 'en_GB.UTF-8'
Expand Down Expand Up @@ -85,6 +86,7 @@ def verify(options):
def generate(options):
render(curlrc_config, 'system/curlrc.j2', options)
render(ssh_config, 'system/ssh_config.j2', options)
render(usb_autosuspend, 'system/40_usb_autosuspend.j2', options)

cmdline_options = []
if 'kernel' in options:
Expand Down Expand Up @@ -155,6 +157,9 @@ def apply(options):
time_format = time_format_to_locale.get(options['time_format'])
cmd(f'localectl set-locale LC_TIME={time_format}')

cmd('udevadm control --reload-rules')


if __name__ == '__main__':
try:
c = get_config()
Expand Down
1 change: 1 addition & 0 deletions src/etc/udev/rules.d/40-usb-autosuspend.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="-1"

0 comments on commit 3bc4768

Please sign in to comment.