]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hwdb: Permit unsetting power/persist for USB devices
authorBenjamin Berg <bberg@redhat.com>
Wed, 15 Sep 2021 16:37:24 +0000 (18:37 +0200)
committerBenjamin Berg <bberg@redhat.com>
Tue, 21 Sep 2021 18:28:10 +0000 (20:28 +0200)
The USB persist feature allows devices that can retain their state when
powered down to work across suspend/resume. This is in particular useful
for USB drives.

However, the persist feature can get in the way for devices that are
unable to retain their state when power is lost. An example of such
stateful devices are fingerprint readers where USB persist should be
disabled to ensure userspace can detect whether the USB device had a
power loss during system suspend.

This will initially be used by the libfprint autosuspend hwdb.

Closes: #20754
hwdb.d/60-autosuspend.hwdb
hwdb.d/parse_hwdb.py
rules.d/60-autosuspend.rules

index 15dcc2f1eef0b40c3432bb83e7324d9308c6abd8..e9304f440de7f1e722c394d49aa61caa12664149 100644 (file)
 #
 # Allowed properties are:
 #    ID_AUTOSUSPEND=1
+#    ID_PERSIST=0
+#
+# ID_PERSIST=0 allows disabling the kernels USB "persist" feature, which allows
+# the continued use of devices after a power loss (due to suspend). Disable it
+# if the device will loose state without a USB power session and the driver
+# is unable to recover the state when resuming. See
+#   https://www.kernel.org/doc/html/latest/driver-api/usb/persist.html
 
 # Sort by brand, model
 
index dea71acfe93309f96928ad2676b1c19eda68a9e0..f385e526281ae8b77ff325da1357684f1ee7ce0d 100755 (executable)
@@ -134,6 +134,7 @@ def property_grammar():
              ('MOUSE_WHEEL_CLICK_COUNT', INTEGER),
              ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER),
              ('ID_AUTOSUSPEND', Or((Literal('0'), Literal('1')))),
+             ('ID_PERSIST', Or((Literal('0'), Literal('1')))),
              ('ID_INPUT', Or((Literal('0'), Literal('1')))),
              ('ID_INPUT_ACCELEROMETER', Or((Literal('0'), Literal('1')))),
              ('ID_INPUT_JOYSTICK', Or((Literal('0'), Literal('1')))),
index 1f9ebef631d1d900eaca7fc5089f01759371afed..332d052caa3bf7a893b1f8ec9d519a04f3866259 100644 (file)
@@ -11,4 +11,8 @@ SUBSYSTEM=="i2c", ATTR{name}=="cyapa", \
 ENV{ID_AUTOSUSPEND}=="1", TEST=="power/control", \
   ATTR{power/control}="auto"
 
+# Disable USB persist if hwdb says so.
+ENV{ID_PERSIST}=="0", TEST=="power/persist", \
+  ATTR{power/persist}="0"
+
 LABEL="autosuspend_end"