From: Greg Kroah-Hartman Date: Fri, 20 Apr 2018 08:27:38 +0000 (+0200) Subject: 3.18-stable patches X-Git-Tag: v3.18.106~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6f46aa22affd843d42e8da20186dee8cc1942095;p=thirdparty%2Fkernel%2Fstable-queue.git 3.18-stable patches added patches: acpi-hotplug-pci-check-presence-of-slot-itself-in-get_slot_status.patch hid-i2c-hid-fix-size-check-and-type-usage.patch usb-dwc3-pci-properly-cleanup-resource.patch usb-fix-usb3-devices-behind-usb3-hubs-not-resuming-at-hibernate-thaw.patch --- diff --git a/queue-3.18/acpi-hotplug-pci-check-presence-of-slot-itself-in-get_slot_status.patch b/queue-3.18/acpi-hotplug-pci-check-presence-of-slot-itself-in-get_slot_status.patch new file mode 100644 index 00000000000..5b2ae93b93c --- /dev/null +++ b/queue-3.18/acpi-hotplug-pci-check-presence-of-slot-itself-in-get_slot_status.patch @@ -0,0 +1,107 @@ +From 13d3047c81505cc0fb9bdae7810676e70523c8bf Mon Sep 17 00:00:00 2001 +From: Mika Westerberg +Date: Mon, 12 Feb 2018 13:55:23 +0300 +Subject: ACPI / hotplug / PCI: Check presence of slot itself in get_slot_status() + +From: Mika Westerberg + +commit 13d3047c81505cc0fb9bdae7810676e70523c8bf upstream. + +Mike Lothian reported that plugging in a USB-C device does not work +properly in his Dell Alienware system. This system has an Intel Alpine +Ridge Thunderbolt controller providing USB-C functionality. In these +systems the USB controller (xHCI) is hotplugged whenever a device is +connected to the port using ACPI-based hotplug. + +The ACPI description of the root port in question is as follows: + + Device (RP01) + { + Name (_ADR, 0x001C0000) + + Device (PXSX) + { + Name (_ADR, 0x02) + + Method (_RMV, 0, NotSerialized) + { + // ... + } + } + +Here _ADR 0x02 means device 0, function 2 on the bus under root port (RP01) +but that seems to be incorrect because device 0 is the upstream port of the +Alpine Ridge PCIe switch and it has no functions other than 0 (the bridge +itself). When we get ACPI Notify() to the root port resulting from +connecting a USB-C device, Linux tries to read PCI_VENDOR_ID from device 0, +function 2 which of course always returns 0xffffffff because there is no +such function and we never find the device. + +In Windows this works fine. + +Now, since we get ACPI Notify() to the root port and not to the PXSX device +we should actually start our scan from there as well and not from the +non-existent PXSX device. Fix this by checking presence of the slot itself +(function 0) if we fail to do that otherwise. + +While there use pci_bus_read_dev_vendor_id() in get_slot_status(), which is +the recommended way to read Device and Vendor IDs of devices on PCI buses. + +Link: https://bugzilla.kernel.org/show_bug.cgi?id=198557 +Reported-by: Mike Lothian +Signed-off-by: Mika Westerberg +Signed-off-by: Bjorn Helgaas +Reviewed-by: Rafael J. Wysocki +Cc: Greg Kroah-Hartman +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/pci/hotplug/acpiphp_glue.c | 23 ++++++++++++++++------- + 1 file changed, 16 insertions(+), 7 deletions(-) + +--- a/drivers/pci/hotplug/acpiphp_glue.c ++++ b/drivers/pci/hotplug/acpiphp_glue.c +@@ -587,6 +587,7 @@ static unsigned int get_slot_status(stru + { + unsigned long long sta = 0; + struct acpiphp_func *func; ++ u32 dvid; + + list_for_each_entry(func, &slot->funcs, sibling) { + if (func->flags & FUNC_HAS_STA) { +@@ -597,19 +598,27 @@ static unsigned int get_slot_status(stru + if (ACPI_SUCCESS(status) && sta) + break; + } else { +- u32 dvid; +- +- pci_bus_read_config_dword(slot->bus, +- PCI_DEVFN(slot->device, +- func->function), +- PCI_VENDOR_ID, &dvid); +- if (dvid != 0xffffffff) { ++ if (pci_bus_read_dev_vendor_id(slot->bus, ++ PCI_DEVFN(slot->device, func->function), ++ &dvid, 0)) { + sta = ACPI_STA_ALL; + break; + } + } + } + ++ if (!sta) { ++ /* ++ * Check for the slot itself since it may be that the ++ * ACPI slot is a device below PCIe upstream port so in ++ * that case it may not even be reachable yet. ++ */ ++ if (pci_bus_read_dev_vendor_id(slot->bus, ++ PCI_DEVFN(slot->device, 0), &dvid, 0)) { ++ sta = ACPI_STA_ALL; ++ } ++ } ++ + return (unsigned int)sta; + } + diff --git a/queue-3.18/hid-i2c-hid-fix-size-check-and-type-usage.patch b/queue-3.18/hid-i2c-hid-fix-size-check-and-type-usage.patch new file mode 100644 index 00000000000..5bcc07a1ed4 --- /dev/null +++ b/queue-3.18/hid-i2c-hid-fix-size-check-and-type-usage.patch @@ -0,0 +1,59 @@ +From ac75a041048b8c1f7418e27621ca5efda8571043 Mon Sep 17 00:00:00 2001 +From: Aaron Ma +Date: Mon, 8 Jan 2018 10:41:40 +0800 +Subject: HID: i2c-hid: fix size check and type usage + +From: Aaron Ma + +commit ac75a041048b8c1f7418e27621ca5efda8571043 upstream. + +When convert char array with signed int, if the inbuf[x] is negative then +upper bits will be set to 1. Fix this by using u8 instead of char. + +ret_size has to be at least 3, hid_input_report use it after minus 2 bytes. + +Cc: stable@vger.kernel.org +Signed-off-by: Aaron Ma +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +--- a/drivers/hid/i2c-hid/i2c-hid.c ++++ b/drivers/hid/i2c-hid/i2c-hid.c +@@ -136,10 +136,10 @@ struct i2c_hid { + * register of the HID + * descriptor. */ + unsigned int bufsize; /* i2c buffer size */ +- char *inbuf; /* Input buffer */ +- char *rawbuf; /* Raw Input buffer */ +- char *cmdbuf; /* Command buffer */ +- char *argsbuf; /* Command arguments buffer */ ++ u8 *inbuf; /* Input buffer */ ++ u8 *rawbuf; /* Raw Input buffer */ ++ u8 *cmdbuf; /* Command buffer */ ++ u8 *argsbuf; /* Command arguments buffer */ + + unsigned long flags; /* device flags */ + +@@ -373,7 +373,8 @@ static int i2c_hid_hwreset(struct i2c_cl + + static void i2c_hid_get_input(struct i2c_hid *ihid) + { +- int ret, ret_size; ++ int ret; ++ u32 ret_size; + int size = le16_to_cpu(ihid->hdesc.wMaxInputLength); + + if (size > ihid->bufsize) +@@ -398,7 +399,7 @@ static void i2c_hid_get_input(struct i2c + return; + } + +- if (ret_size > size) { ++ if ((ret_size > size) || (ret_size <= 2)) { + dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n", + __func__, size, ret_size); + return; diff --git a/queue-3.18/series b/queue-3.18/series index 9207a60082b..e31b58c4def 100644 --- a/queue-3.18/series +++ b/queue-3.18/series @@ -12,3 +12,7 @@ resource-fix-integer-overflow-at-reallocation.patch usb-musb-gadget-misplaced-out-of-bounds-check.patch arm-dts-at91-at91sam9g25-fix-mux-mask-pinctrl-property.patch xen-netfront-fix-hang-on-device-removal.patch +acpi-hotplug-pci-check-presence-of-slot-itself-in-get_slot_status.patch +usb-fix-usb3-devices-behind-usb3-hubs-not-resuming-at-hibernate-thaw.patch +usb-dwc3-pci-properly-cleanup-resource.patch +hid-i2c-hid-fix-size-check-and-type-usage.patch diff --git a/queue-3.18/usb-dwc3-pci-properly-cleanup-resource.patch b/queue-3.18/usb-dwc3-pci-properly-cleanup-resource.patch new file mode 100644 index 00000000000..a5c67addf24 --- /dev/null +++ b/queue-3.18/usb-dwc3-pci-properly-cleanup-resource.patch @@ -0,0 +1,33 @@ +From cabdf83dadfb3d83eec31e0f0638a92dbd716435 Mon Sep 17 00:00:00 2001 +From: Thinh Nguyen +Date: Mon, 19 Mar 2018 13:07:35 -0700 +Subject: usb: dwc3: pci: Properly cleanup resource + +From: Thinh Nguyen + +commit cabdf83dadfb3d83eec31e0f0638a92dbd716435 upstream. + +Platform device is allocated before adding resources. Make sure to +properly cleanup on error case. + +Cc: +Fixes: f1c7e7108109 ("usb: dwc3: convert to pcim_enable_device()") +Signed-off-by: Thinh Nguyen +Signed-off-by: Felipe Balbi +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/dwc3/dwc3-pci.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/usb/dwc3/dwc3-pci.c ++++ b/drivers/usb/dwc3/dwc3-pci.c +@@ -143,7 +143,7 @@ static int dwc3_pci_probe(struct pci_dev + ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); + if (ret) { + dev_err(dev, "couldn't add resources to dwc3 device\n"); +- return ret; ++ goto err; + } + + pci_set_drvdata(pci, glue); diff --git a/queue-3.18/usb-fix-usb3-devices-behind-usb3-hubs-not-resuming-at-hibernate-thaw.patch b/queue-3.18/usb-fix-usb3-devices-behind-usb3-hubs-not-resuming-at-hibernate-thaw.patch new file mode 100644 index 00000000000..92f7304d3fa --- /dev/null +++ b/queue-3.18/usb-fix-usb3-devices-behind-usb3-hubs-not-resuming-at-hibernate-thaw.patch @@ -0,0 +1,60 @@ +From 64627388b50158fd24d6ad88132525b95a5ef573 Mon Sep 17 00:00:00 2001 +From: Zhengjun Xing +Date: Wed, 21 Mar 2018 13:29:42 +0800 +Subject: USB:fix USB3 devices behind USB3 hubs not resuming at hibernate thaw +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Zhengjun Xing + +commit 64627388b50158fd24d6ad88132525b95a5ef573 upstream. + +USB3 hubs don't support global suspend. + +USB3 specification 10.10, Enhanced SuperSpeed hubs only support selective +suspend and resume, they do not support global suspend/resume where the +hub downstream facing ports states are not affected. + +When system enters hibernation it first enters freeze process where only +the root hub enters suspend, usb_port_suspend() is not called for other +devices, and suspend status flags are not set for them. Other devices are +expected to suspend globally. Some external USB3 hubs will suspend the +downstream facing port at global suspend. These devices won't be resumed +at thaw as the suspend status flag is not set. + +A USB3 removable hard disk connected through a USB3 hub that won't resume +at thaw will fail to synchronize SCSI cache, return “cmd cmplt err -71” +error, and needs a 60 seconds timeout which causing system hang for 60s +before the USB host reset the port for the USB3 removable hard disk to +recover. + +Fix this by always calling usb_port_suspend() during freeze for USB3 +devices. + +Signed-off-by: Zhengjun Xing +Cc: stable +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/core/generic.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +--- a/drivers/usb/core/generic.c ++++ b/drivers/usb/core/generic.c +@@ -208,8 +208,13 @@ static int generic_suspend(struct usb_de + if (!udev->parent) + rc = hcd_bus_suspend(udev, msg); + +- /* Non-root devices don't need to do anything for FREEZE or PRETHAW */ +- else if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_PRETHAW) ++ /* ++ * Non-root USB2 devices don't need to do anything for FREEZE ++ * or PRETHAW. USB3 devices don't support global suspend and ++ * needs to be selectively suspended. ++ */ ++ else if ((msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_PRETHAW) ++ && (udev->speed < USB_SPEED_SUPER)) + rc = 0; + else + rc = usb_port_suspend(udev, msg);