From bd37360a210603cb2c27feb7602008c71ca2ab67 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Wed, 15 Sep 2021 18:37:24 +0200 Subject: [PATCH 1/2] hwdb: Permit unsetting power/persist for USB devices 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 | 7 +++++++ hwdb.d/parse_hwdb.py | 1 + rules.d/60-autosuspend.rules | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/hwdb.d/60-autosuspend.hwdb b/hwdb.d/60-autosuspend.hwdb index 15dcc2f1ee..e9304f440d 100644 --- a/hwdb.d/60-autosuspend.hwdb +++ b/hwdb.d/60-autosuspend.hwdb @@ -24,6 +24,13 @@ # # 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 diff --git a/hwdb.d/parse_hwdb.py b/hwdb.d/parse_hwdb.py index dea71acfe9..f385e52628 100755 --- a/hwdb.d/parse_hwdb.py +++ b/hwdb.d/parse_hwdb.py @@ -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')))), diff --git a/rules.d/60-autosuspend.rules b/rules.d/60-autosuspend.rules index 1f9ebef631..332d052caa 100644 --- a/rules.d/60-autosuspend.rules +++ b/rules.d/60-autosuspend.rules @@ -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" From e68220221c3f0b6b0103e8db82f7222b29e18784 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Fri, 17 Sep 2021 12:57:31 +0200 Subject: [PATCH 2/2] hwdb: update fingerprint autosuspend rules This pulls in a few new devices and adds ID_PERSIST=0. --- hwdb.d/60-autosuspend-fingerprint-reader.hwdb | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hwdb.d/60-autosuspend-fingerprint-reader.hwdb b/hwdb.d/60-autosuspend-fingerprint-reader.hwdb index c1485e1256..631c8c35b7 100644 --- a/hwdb.d/60-autosuspend-fingerprint-reader.hwdb +++ b/hwdb.d/60-autosuspend-fingerprint-reader.hwdb @@ -8,6 +8,7 @@ # Supported by libfprint driver aes1610 usb:v08FFp1600* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver aes1660 usb:v08FFp1660* @@ -28,16 +29,19 @@ usb:v08FFp168D* usb:v08FFp168E* usb:v08FFp168F* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver aes2501 usb:v08FFp2500* usb:v08FFp2580* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver aes2550 usb:v08FFp2550* usb:v08FFp2810* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver aes2660 usb:v08FFp2660* @@ -59,19 +63,23 @@ usb:v08FFp268E* usb:v08FFp268F* usb:v08FFp2691* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver aes3500 usb:v08FFp5731* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver aes4000 usb:v5501p08FF* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver egis0570 usb:v1C7Ap0570* usb:v1C7Ap0571* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver elan usb:v04F3p0903* @@ -133,15 +141,19 @@ usb:v04F3p0C4D* usb:v04F3p0C4F* usb:v04F3p0C63* usb:v04F3p0C6E* +usb:v04F3p0C58* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver elanmoc usb:v04F3p0C7E* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver etes603 usb:v1C7Ap0603* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver goodixmoc usb:v27C6p5840* @@ -149,6 +161,7 @@ usb:v27C6p609C* usb:v27C6p60A2* usb:v27C6p639C* usb:v27C6p63AC* +usb:v27C6p63BC* usb:v27C6p6496* usb:v27C6p6584* usb:v27C6p658C* @@ -157,10 +170,12 @@ usb:v27C6p6594* usb:v27C6p659C* usb:v27C6p6A94* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver nb1010 usb:v298Dp1010* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver synaptics usb:v06CBp00BD* @@ -172,22 +187,29 @@ usb:v06CBp00C9* usb:v06CBp0100* usb:v06CBp00F0* usb:v06CBp0103* +usb:v06CBp0123* +usb:v06CBp0126* +usb:v06CBp0129* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver upeksonly usb:v147Ep2016* usb:v147Ep1000* usb:v147Ep1001* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver upektc usb:v0483p2015* usb:v147Ep3001* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver upektc_img usb:v147Ep2020* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver uru4000 usb:v045Ep00BC* @@ -197,23 +219,28 @@ usb:v05BAp0007* usb:v05BAp0008* usb:v05BAp000A* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver vcom5s usb:v061Ap0110* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver vfs0050 usb:v138Ap0050* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver vfs101 usb:v138Ap0001* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver vfs301 usb:v138Ap0005* usb:v138Ap0008* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver vfs5011 usb:v138Ap0010* @@ -222,10 +249,12 @@ usb:v138Ap0015* usb:v138Ap0017* usb:v138Ap0018* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Supported by libfprint driver vfs7552 usb:v138Ap0091* ID_AUTOSUSPEND=1 + ID_PERSIST=0 # Known unsupported devices usb:v04F3p036B* @@ -248,6 +277,7 @@ usb:v06CBp00C4* usb:v06CBp00CB* usb:v06CBp00D8* usb:v06CBp00DA* +usb:v06CBp00E7* usb:v06CBp00E9* usb:v0A5Cp5801* usb:v0A5Cp5805* @@ -256,6 +286,7 @@ usb:v0A5Cp5840* usb:v0A5Cp5841* usb:v0A5Cp5842* usb:v0A5Cp5843* +usb:v0A5Cp5844* usb:v0A5Cp5845* usb:v10A5p0007* usb:v1188p9545* @@ -298,3 +329,4 @@ usb:v2808p9338* usb:v298Dp2033* usb:v3538p0930* ID_AUTOSUSPEND=1 + ID_PERSIST=0