From 8614578a1b6de7c88f45383fdb654d99fef3dc0f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 14 Oct 2024 12:28:27 +0200 Subject: [PATCH] 4.19-stable patches added patches: hid-plantronics-workaround-for-an-unexcepted-opposite-volume-key.patch revert-usb-yurex-replace-snprintf-with-the-safer-scnprintf-variant.patch usb-storage-ignore-bogus-device-raised-by-jieli-br21-usb-sound-chip.patch usb-xhci-fix-problem-with-xhci-resume-from-suspend.patch --- ...or-an-unexcepted-opposite-volume-key.patch | 91 +++++++++++++++++++ ...ntf-with-the-safer-scnprintf-variant.patch | 67 ++++++++++++++ queue-4.19/series | 4 + ...-raised-by-jieli-br21-usb-sound-chip.patch | 46 ++++++++++ ...roblem-with-xhci-resume-from-suspend.patch | 44 +++++++++ 5 files changed, 252 insertions(+) create mode 100644 queue-4.19/hid-plantronics-workaround-for-an-unexcepted-opposite-volume-key.patch create mode 100644 queue-4.19/revert-usb-yurex-replace-snprintf-with-the-safer-scnprintf-variant.patch create mode 100644 queue-4.19/usb-storage-ignore-bogus-device-raised-by-jieli-br21-usb-sound-chip.patch create mode 100644 queue-4.19/usb-xhci-fix-problem-with-xhci-resume-from-suspend.patch diff --git a/queue-4.19/hid-plantronics-workaround-for-an-unexcepted-opposite-volume-key.patch b/queue-4.19/hid-plantronics-workaround-for-an-unexcepted-opposite-volume-key.patch new file mode 100644 index 00000000000..17406d2d63b --- /dev/null +++ b/queue-4.19/hid-plantronics-workaround-for-an-unexcepted-opposite-volume-key.patch @@ -0,0 +1,91 @@ +From 87b696209007b7c4ef7bdfe39ea0253404a43770 Mon Sep 17 00:00:00 2001 +From: Wade Wang +Date: Mon, 16 Sep 2024 16:56:00 +0800 +Subject: HID: plantronics: Workaround for an unexcepted opposite volume key + +From: Wade Wang + +commit 87b696209007b7c4ef7bdfe39ea0253404a43770 upstream. + +Some Plantronics headset as the below send an unexcept opposite +volume key's HID report for each volume key press after 200ms, like +unecepted Volume Up Key following Volume Down key pressed by user. +This patch adds a quirk to hid-plantronics for these devices, which +will ignore the second unexcepted opposite volume key if it happens +within 220ms from the last one that was handled. + Plantronics EncorePro 500 Series (047f:431e) + Plantronics Blackwire_3325 Series (047f:430c) + +The patch was tested on the mentioned model, it shouldn't affect +other models, however, this quirk might be needed for them too. +Auto-repeat (when a key is held pressed) is not affected per test +result. + +Cc: stable@vger.kernel.org +Signed-off-by: Wade Wang +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hid/hid-ids.h | 2 ++ + drivers/hid/hid-plantronics.c | 23 +++++++++++++++++++++++ + 2 files changed, 25 insertions(+) + +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -916,6 +916,8 @@ + #define USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3220_SERIES 0xc056 + #define USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3215_SERIES 0xc057 + #define USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3225_SERIES 0xc058 ++#define USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3325_SERIES 0x430c ++#define USB_DEVICE_ID_PLANTRONICS_ENCOREPRO_500_SERIES 0x431e + + #define USB_VENDOR_ID_PANASONIC 0x04da + #define USB_DEVICE_ID_PANABOARD_UBT780 0x1044 +--- a/drivers/hid/hid-plantronics.c ++++ b/drivers/hid/hid-plantronics.c +@@ -41,8 +41,10 @@ + (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) + + #define PLT_QUIRK_DOUBLE_VOLUME_KEYS BIT(0) ++#define PLT_QUIRK_FOLLOWED_OPPOSITE_VOLUME_KEYS BIT(1) + + #define PLT_DOUBLE_KEY_TIMEOUT 5 /* ms */ ++#define PLT_FOLLOWED_OPPOSITE_KEY_TIMEOUT 220 /* ms */ + + struct plt_drv_data { + unsigned long device_type; +@@ -140,6 +142,21 @@ static int plantronics_event(struct hid_ + + drv_data->last_volume_key_ts = cur_ts; + } ++ if (drv_data->quirks & PLT_QUIRK_FOLLOWED_OPPOSITE_VOLUME_KEYS) { ++ unsigned long prev_ts, cur_ts; ++ ++ /* Usages are filtered in plantronics_usages. */ ++ ++ if (!value) /* Handle key presses only. */ ++ return 0; ++ ++ prev_ts = drv_data->last_volume_key_ts; ++ cur_ts = jiffies; ++ if (jiffies_to_msecs(cur_ts - prev_ts) <= PLT_FOLLOWED_OPPOSITE_KEY_TIMEOUT) ++ return 1; /* Ignore the followed opposite volume key. */ ++ ++ drv_data->last_volume_key_ts = cur_ts; ++ } + + return 0; + } +@@ -213,6 +230,12 @@ static const struct hid_device_id plantr + { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, + USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3225_SERIES), + .driver_data = PLT_QUIRK_DOUBLE_VOLUME_KEYS }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, ++ USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3325_SERIES), ++ .driver_data = PLT_QUIRK_FOLLOWED_OPPOSITE_VOLUME_KEYS }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, ++ USB_DEVICE_ID_PLANTRONICS_ENCOREPRO_500_SERIES), ++ .driver_data = PLT_QUIRK_FOLLOWED_OPPOSITE_VOLUME_KEYS }, + { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) }, + { } + }; diff --git a/queue-4.19/revert-usb-yurex-replace-snprintf-with-the-safer-scnprintf-variant.patch b/queue-4.19/revert-usb-yurex-replace-snprintf-with-the-safer-scnprintf-variant.patch new file mode 100644 index 00000000000..8251dfd02f6 --- /dev/null +++ b/queue-4.19/revert-usb-yurex-replace-snprintf-with-the-safer-scnprintf-variant.patch @@ -0,0 +1,67 @@ +From 71c717cd8a2e180126932cc6851ff21c1d04d69a Mon Sep 17 00:00:00 2001 +From: Oliver Neukum +Date: Mon, 7 Oct 2024 11:39:47 +0200 +Subject: Revert "usb: yurex: Replace snprintf() with the safer scnprintf() variant" + +From: Oliver Neukum + +commit 71c717cd8a2e180126932cc6851ff21c1d04d69a upstream. + +This reverts commit 86b20af11e84c26ae3fde4dcc4f490948e3f8035. + +This patch leads to passing 0 to simple_read_from_buffer() +as a fifth argument, turning the read method into a nop. +The change is fundamentally flawed, as it breaks the driver. + +Signed-off-by: Oliver Neukum +Cc: stable +Link: https://lore.kernel.org/r/20241007094004.242122-1-oneukum@suse.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/misc/yurex.c | 19 ++++++++----------- + 1 file changed, 8 insertions(+), 11 deletions(-) + +--- a/drivers/usb/misc/yurex.c ++++ b/drivers/usb/misc/yurex.c +@@ -34,8 +34,6 @@ + #define YUREX_BUF_SIZE 8 + #define YUREX_WRITE_TIMEOUT (HZ*2) + +-#define MAX_S64_STRLEN 20 /* {-}922337203685477580{7,8} */ +- + /* table of devices that work with this driver */ + static struct usb_device_id yurex_table[] = { + { USB_DEVICE(YUREX_VENDOR_ID, YUREX_PRODUCT_ID) }, +@@ -404,7 +402,8 @@ static ssize_t yurex_read(struct file *f + { + struct usb_yurex *dev; + int len = 0; +- char in_buffer[MAX_S64_STRLEN]; ++ char in_buffer[20]; ++ unsigned long flags; + + dev = file->private_data; + +@@ -414,16 +413,14 @@ static ssize_t yurex_read(struct file *f + return -ENODEV; + } + +- if (WARN_ON_ONCE(dev->bbu > S64_MAX || dev->bbu < S64_MIN)) { +- mutex_unlock(&dev->io_mutex); +- return -EIO; +- } +- +- spin_lock_irq(&dev->lock); +- scnprintf(in_buffer, MAX_S64_STRLEN, "%lld\n", dev->bbu); +- spin_unlock_irq(&dev->lock); ++ spin_lock_irqsave(&dev->lock, flags); ++ len = snprintf(in_buffer, 20, "%lld\n", dev->bbu); ++ spin_unlock_irqrestore(&dev->lock, flags); + mutex_unlock(&dev->io_mutex); + ++ if (WARN_ON_ONCE(len >= sizeof(in_buffer))) ++ return -EIO; ++ + return simple_read_from_buffer(buffer, count, ppos, in_buffer, len); + } + diff --git a/queue-4.19/series b/queue-4.19/series index 8946a7de471..160d05b030f 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -261,3 +261,7 @@ net-ibm-emac-mal-fix-wrong-goto.patch ppp-fix-ppp_async_encode-illegal-access.patch net-ipv6-ensure-we-call-ipv6_mc_down-at-most-once.patch cdc-ncm-avoid-overflow-in-sanity-checking.patch +hid-plantronics-workaround-for-an-unexcepted-opposite-volume-key.patch +revert-usb-yurex-replace-snprintf-with-the-safer-scnprintf-variant.patch +usb-xhci-fix-problem-with-xhci-resume-from-suspend.patch +usb-storage-ignore-bogus-device-raised-by-jieli-br21-usb-sound-chip.patch diff --git a/queue-4.19/usb-storage-ignore-bogus-device-raised-by-jieli-br21-usb-sound-chip.patch b/queue-4.19/usb-storage-ignore-bogus-device-raised-by-jieli-br21-usb-sound-chip.patch new file mode 100644 index 00000000000..fc7b159a346 --- /dev/null +++ b/queue-4.19/usb-storage-ignore-bogus-device-raised-by-jieli-br21-usb-sound-chip.patch @@ -0,0 +1,46 @@ +From a6555cb1cb69db479d0760e392c175ba32426842 Mon Sep 17 00:00:00 2001 +From: Icenowy Zheng +Date: Tue, 1 Oct 2024 16:34:07 +0800 +Subject: usb: storage: ignore bogus device raised by JieLi BR21 USB sound chip + +From: Icenowy Zheng + +commit a6555cb1cb69db479d0760e392c175ba32426842 upstream. + +JieLi tends to use SCSI via USB Mass Storage to implement their own +proprietary commands instead of implementing another USB interface. +Enumerating it as a generic mass storage device will lead to a Hardware +Error sense key get reported. + +Ignore this bogus device to prevent appearing a unusable sdX device +file. + +Signed-off-by: Icenowy Zheng +Cc: stable +Acked-by: Alan Stern +Link: https://lore.kernel.org/r/20241001083407.8336-1-uwu@icenowy.me +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/storage/unusual_devs.h | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +--- a/drivers/usb/storage/unusual_devs.h ++++ b/drivers/usb/storage/unusual_devs.h +@@ -2412,6 +2412,17 @@ UNUSUAL_DEV( 0xc251, 0x4003, 0x0100, 0x + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_NOT_LOCKABLE), + ++/* ++ * Reported by Icenowy Zheng ++ * This is an interface for vendor-specific cryptic commands instead ++ * of real USB storage device. ++ */ ++UNUSUAL_DEV( 0xe5b7, 0x0811, 0x0100, 0x0100, ++ "ZhuHai JieLi Technology", ++ "JieLi BR21", ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL, ++ US_FL_IGNORE_DEVICE), ++ + /* Reported by Andrew Simmons */ + UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001, + "DataStor", diff --git a/queue-4.19/usb-xhci-fix-problem-with-xhci-resume-from-suspend.patch b/queue-4.19/usb-xhci-fix-problem-with-xhci-resume-from-suspend.patch new file mode 100644 index 00000000000..4cdda09a70c --- /dev/null +++ b/queue-4.19/usb-xhci-fix-problem-with-xhci-resume-from-suspend.patch @@ -0,0 +1,44 @@ +From d44238d8254a36249d576c96473269dbe500f5e4 Mon Sep 17 00:00:00 2001 +From: Jose Alberto Reguero +Date: Thu, 19 Sep 2024 20:42:02 +0200 +Subject: usb: xhci: Fix problem with xhci resume from suspend + +From: Jose Alberto Reguero + +commit d44238d8254a36249d576c96473269dbe500f5e4 upstream. + +I have a ASUS PN51 S mini pc that has two xhci devices. One from AMD, +and other from ASMEDIA. The one from ASMEDIA have problems when resume +from suspend, and keep broken until unplug the power cord. I use this +kernel parameter: xhci-hcd.quirks=128 and then it works ok. I make a +path to reset only the ASMEDIA xhci. + +Signed-off-by: Jose Alberto Reguero +Cc: stable +Link: https://lore.kernel.org/r/20240919184202.22249-1-jose.alberto.reguero@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/host/xhci-pci.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/usb/host/xhci-pci.c ++++ b/drivers/usb/host/xhci-pci.c +@@ -55,6 +55,7 @@ + #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142 + #define PCI_DEVICE_ID_ASMEDIA_1142_XHCI 0x1242 + #define PCI_DEVICE_ID_ASMEDIA_2142_XHCI 0x2142 ++#define PCI_DEVICE_ID_ASMEDIA_3042_XHCI 0x3042 + #define PCI_DEVICE_ID_ASMEDIA_3242_XHCI 0x3242 + + static const char hcd_name[] = "xhci_hcd"; +@@ -272,6 +273,10 @@ static void xhci_pci_quirks(struct devic + pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) + xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL; + ++ if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && ++ pdev->device == PCI_DEVICE_ID_ASMEDIA_3042_XHCI) ++ xhci->quirks |= XHCI_RESET_ON_RESUME; ++ + if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241) + xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7; + -- 2.47.2