From a313a1033907bc7b3e9dd2305e6d26153070c6b6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 12 Aug 2020 14:18:49 +0200 Subject: [PATCH] 5.4-stable patches added patches: hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch nvme-add-a-identify-namespace-identification-descriptor-list-quirk.patch --- ...urn-multiple-bytes-in-battery-report.patch | 61 ++++++++++++++ ...identification-descriptor-list-quirk.patch | 84 +++++++++++++++++++ queue-5.4/series | 2 + 3 files changed, 147 insertions(+) create mode 100644 queue-5.4/hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch create mode 100644 queue-5.4/nvme-add-a-identify-namespace-identification-descriptor-list-quirk.patch diff --git a/queue-5.4/hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch b/queue-5.4/hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch new file mode 100644 index 00000000000..485e512c9ee --- /dev/null +++ b/queue-5.4/hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch @@ -0,0 +1,61 @@ +From 4f57cace81438cc873a96f9f13f08298815c9b51 Mon Sep 17 00:00:00 2001 +From: Grant Likely +Date: Fri, 10 Jul 2020 16:19:39 +0100 +Subject: HID: input: Fix devices that return multiple bytes in battery report + +From: Grant Likely + +commit 4f57cace81438cc873a96f9f13f08298815c9b51 upstream. + +Some devices, particularly the 3DConnexion Spacemouse wireless 3D +controllers, return more than just the battery capacity in the battery +report. The Spacemouse devices return an additional byte with a device +specific field. However, hidinput_query_battery_capacity() only +requests a 2 byte transfer. + +When a spacemouse is connected via USB (direct wire, no wireless dongle) +and it returns a 3 byte report instead of the assumed 2 byte battery +report the larger transfer confuses and frightens the USB subsystem +which chooses to ignore the transfer. Then after 2 seconds assume the +device has stopped responding and reset it. This can be reproduced +easily by using a wired connection with a wireless spacemouse. The +Spacemouse will enter a loop of resetting every 2 seconds which can be +observed in dmesg. + +This patch solves the problem by increasing the transfer request to 4 +bytes instead of 2. The fix isn't particularly elegant, but it is simple +and safe to backport to stable kernels. A further patch will follow to +more elegantly handle battery reports that contain additional data. + +Signed-off-by: Grant Likely +Cc: Darren Hart +Cc: Jiri Kosina +Cc: Benjamin Tissoires +Cc: stable@vger.kernel.org +Tested-by: Darren Hart +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/hid-input.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/hid/hid-input.c ++++ b/drivers/hid/hid-input.c +@@ -350,13 +350,13 @@ static int hidinput_query_battery_capaci + u8 *buf; + int ret; + +- buf = kmalloc(2, GFP_KERNEL); ++ buf = kmalloc(4, GFP_KERNEL); + if (!buf) + return -ENOMEM; + +- ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 2, ++ ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 4, + dev->battery_report_type, HID_REQ_GET_REPORT); +- if (ret != 2) { ++ if (ret < 2) { + kfree(buf); + return -ENODATA; + } diff --git a/queue-5.4/nvme-add-a-identify-namespace-identification-descriptor-list-quirk.patch b/queue-5.4/nvme-add-a-identify-namespace-identification-descriptor-list-quirk.patch new file mode 100644 index 00000000000..586a20a8a88 --- /dev/null +++ b/queue-5.4/nvme-add-a-identify-namespace-identification-descriptor-list-quirk.patch @@ -0,0 +1,84 @@ +From 5bedd3afee8eb01ccd256f0cd2cc0fa6f841417a Mon Sep 17 00:00:00 2001 +From: Christoph Hellwig +Date: Tue, 28 Jul 2020 13:09:03 +0200 +Subject: nvme: add a Identify Namespace Identification Descriptor list quirk + +From: Christoph Hellwig + +commit 5bedd3afee8eb01ccd256f0cd2cc0fa6f841417a upstream. + +Add a quirk for a device that does not support the Identify Namespace +Identification Descriptor list despite claiming 1.3 compliance. + +Fixes: ea43d9709f72 ("nvme: fix identify error status silent ignore") +Reported-by: Ingo Brunberg +Signed-off-by: Christoph Hellwig +Tested-by: Ingo Brunberg +Reviewed-by: Sagi Grimberg +Cc: Plamen Lyutov +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/nvme/host/core.c | 15 +++------------ + drivers/nvme/host/nvme.h | 7 +++++++ + drivers/nvme/host/pci.c | 2 ++ + 3 files changed, 12 insertions(+), 12 deletions(-) + +--- a/drivers/nvme/host/core.c ++++ b/drivers/nvme/host/core.c +@@ -1074,6 +1074,9 @@ static int nvme_identify_ns_descs(struct + int pos; + int len; + ++ if (ctrl->quirks & NVME_QUIRK_NO_NS_DESC_LIST) ++ return 0; ++ + c.identify.opcode = nvme_admin_identify; + c.identify.nsid = cpu_to_le32(nsid); + c.identify.cns = NVME_ID_CNS_NS_DESC_LIST; +@@ -1087,18 +1090,6 @@ static int nvme_identify_ns_descs(struct + if (status) { + dev_warn(ctrl->device, + "Identify Descriptors failed (%d)\n", status); +- /* +- * Don't treat non-retryable errors as fatal, as we potentially +- * already have a NGUID or EUI-64. If we failed with DNR set, +- * we want to silently ignore the error as we can still +- * identify the device, but if the status has DNR set, we want +- * to propagate the error back specifically for the disk +- * revalidation flow to make sure we don't abandon the +- * device just because of a temporal retry-able error (such +- * as path of transport errors). +- */ +- if (status > 0 && (status & NVME_SC_DNR)) +- status = 0; + goto free_data; + } + +--- a/drivers/nvme/host/nvme.h ++++ b/drivers/nvme/host/nvme.h +@@ -115,6 +115,13 @@ enum nvme_quirks { + * Prevent tag overlap between queues + */ + NVME_QUIRK_SHARED_TAGS = (1 << 13), ++ ++ /* ++ * The controller doesn't handle the Identify Namespace ++ * Identification Descriptor list subcommand despite claiming ++ * NVMe 1.3 compliance. ++ */ ++ NVME_QUIRK_NO_NS_DESC_LIST = (1 << 15), + }; + + /* +--- a/drivers/nvme/host/pci.c ++++ b/drivers/nvme/host/pci.c +@@ -3117,6 +3117,8 @@ static const struct pci_device_id nvme_i + { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */ + .driver_data = NVME_QUIRK_IDENTIFY_CNS | + NVME_QUIRK_DISABLE_WRITE_ZEROES, }, ++ { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */ ++ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST, }, + { PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */ + .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, }, + { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */ diff --git a/queue-5.4/series b/queue-5.4/series index 1c44f8a6f0a..14c674accf0 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -1 +1,3 @@ tracepoint-mark-__tracepoint_string-s-__used.patch +hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch +nvme-add-a-identify-namespace-identification-descriptor-list-quirk.patch -- 2.47.3