From: Greg Kroah-Hartman Date: Mon, 9 Jan 2017 11:27:47 +0000 (+0100) Subject: 4.4-stable patches X-Git-Tag: v4.4.42~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=df15bcffbbafbe636821d2e7372cf125d521968a;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: stable-fixup-hotplug-fix-unused-function-warning.patch usb-dwc3-ep0-add-dwc3_ep0_prepare_one_trb.patch usb-dwc3-ep0-explicitly-call-dwc3_ep0_prepare_one_trb.patch usb-dwc3-gadget-always-unmap-ep0-requests.patch --- diff --git a/queue-4.4/series b/queue-4.4/series index 3937e7f76d1..e8c1ff32433 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -58,3 +58,7 @@ usb-phy-am335x-control-fix-device-and-of_node-leaks.patch usb-serial-io_ti-bind-to-interface-after-fw-download.patch mei-bus-fix-mei_cldev_enable-kdoc.patch staging-iio-ad7606-fix-improper-setting-of-oversampling-pins.patch +usb-dwc3-gadget-always-unmap-ep0-requests.patch +usb-dwc3-ep0-add-dwc3_ep0_prepare_one_trb.patch +usb-dwc3-ep0-explicitly-call-dwc3_ep0_prepare_one_trb.patch +stable-fixup-hotplug-fix-unused-function-warning.patch diff --git a/queue-4.4/stable-fixup-hotplug-fix-unused-function-warning.patch b/queue-4.4/stable-fixup-hotplug-fix-unused-function-warning.patch new file mode 100644 index 00000000000..9b7a13563d1 --- /dev/null +++ b/queue-4.4/stable-fixup-hotplug-fix-unused-function-warning.patch @@ -0,0 +1,60 @@ +From arnd@arndb.de Mon Jan 9 12:26:47 2017 +From: Arnd Bergmann +Date: Mon, 9 Jan 2017 11:47:50 +0100 +Subject: stable-fixup: hotplug: fix unused function warning +To: stable@vger.kernel.org, Greg Kroah-Hartman +Cc: Thomas Gleixner , Dan Streetman , Andrew Morton , linux-mm@kvack.org, Michal Hocko , Yu Zhao , Arnd Bergmann , linux-kernel@vger.kernel.org +Message-ID: <20170109104811.1453295-1-arnd@arndb.de> + +From: Arnd Bergmann + +[resolves a messed up backport, so no matching upstream commit] + +The backport of upstream commit 777c6e0daebb ("hotplug: Make +register and unregister notifier API symmetric") to linux-4.4.y +introduced a harmless warning in 'allnoconfig' builds as spotted by +kernelci.org: + +kernel/cpu.c:226:13: warning: 'cpu_notify_nofail' defined but not used [-Wunused-function] + +So far, this is the only stable tree that is affected, as linux-4.6 and +higher contain commit 984581728eb4 ("cpu/hotplug: Split out cpu down functions") +that makes the function used in all configurations, while older longterm +releases so far don't seem to have a backport of 777c6e0daebb. + +The fix for the warning is trivial: move the unused function back +into the #ifdef section where it was before. + +Link: https://kernelci.org/build/id/586fcacb59b514049ef6c3aa/logs/ +Fixes: 1c0f4e0ebb79 ("hotplug: Make register and unregister notifier API symmetric") in v4.4.y +Signed-off-by: Arnd Bergmann +Signed-off-by: Greg Kroah-Hartman +--- + kernel/cpu.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +--- a/kernel/cpu.c ++++ b/kernel/cpu.c +@@ -223,10 +223,6 @@ static int cpu_notify(unsigned long val, + return __cpu_notify(val, v, -1, NULL); + } + +-static void cpu_notify_nofail(unsigned long val, void *v) +-{ +- BUG_ON(cpu_notify(val, v)); +-} + EXPORT_SYMBOL(register_cpu_notifier); + EXPORT_SYMBOL(__register_cpu_notifier); + +@@ -245,6 +241,11 @@ void __unregister_cpu_notifier(struct no + EXPORT_SYMBOL(__unregister_cpu_notifier); + + #ifdef CONFIG_HOTPLUG_CPU ++static void cpu_notify_nofail(unsigned long val, void *v) ++{ ++ BUG_ON(cpu_notify(val, v)); ++} ++ + /** + * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU + * @cpu: a CPU id diff --git a/queue-4.4/usb-dwc3-ep0-add-dwc3_ep0_prepare_one_trb.patch b/queue-4.4/usb-dwc3-ep0-add-dwc3_ep0_prepare_one_trb.patch new file mode 100644 index 00000000000..9e1d3bcc691 --- /dev/null +++ b/queue-4.4/usb-dwc3-ep0-add-dwc3_ep0_prepare_one_trb.patch @@ -0,0 +1,83 @@ +From 7931ec86c1b738e4e90e58c6d95e5f720d45ee56 Mon Sep 17 00:00:00 2001 +From: Felipe Balbi +Date: Tue, 20 Dec 2016 13:57:32 +0200 +Subject: usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb() + +From: Felipe Balbi + +commit 7931ec86c1b738e4e90e58c6d95e5f720d45ee56 upstream. + +For now this is just a cleanup patch, no functional +changes. We will be using the new function to fix a +bug introduced long ago by commit 0416e494ce7d +("usb: dwc3: ep0: correct cache sync issue in case +of ep0_bounced") and further worsened by commit +c0bd5456a470 ("usb: dwc3: ep0: handle non maxpacket +aligned transfers > 512") + +Reported-by: Janusz Dziedzic +Signed-off-by: Felipe Balbi +Signed-off-by: Greg Kroah-Hartman + + +--- + drivers/usb/dwc3/ep0.c | 30 ++++++++++++++++++------------ + 1 file changed, 18 insertions(+), 12 deletions(-) + +--- a/drivers/usb/dwc3/ep0.c ++++ b/drivers/usb/dwc3/ep0.c +@@ -55,20 +55,13 @@ static const char *dwc3_ep0_state_string + } + } + +-static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, +- u32 len, u32 type, bool chain) ++static void dwc3_ep0_prepare_one_trb(struct dwc3 *dwc, u8 epnum, ++ dma_addr_t buf_dma, u32 len, u32 type, bool chain) + { +- struct dwc3_gadget_ep_cmd_params params; + struct dwc3_trb *trb; + struct dwc3_ep *dep; + +- int ret; +- + dep = dwc->eps[epnum]; +- if (dep->flags & DWC3_EP_BUSY) { +- dwc3_trace(trace_dwc3_ep0, "%s still busy", dep->name); +- return 0; +- } + + trb = &dwc->ep0_trb[dep->free_slot]; + +@@ -89,15 +82,28 @@ static int dwc3_ep0_start_trans(struct d + trb->ctrl |= (DWC3_TRB_CTRL_IOC + | DWC3_TRB_CTRL_LST); + +- if (chain) ++ trace_dwc3_prepare_trb(dep, trb); ++} ++ ++static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, ++ u32 len, u32 type, bool chain) ++{ ++ struct dwc3_gadget_ep_cmd_params params; ++ struct dwc3_ep *dep; ++ int ret; ++ ++ dep = dwc->eps[epnum]; ++ if (dep->flags & DWC3_EP_BUSY) { ++ dwc3_trace(trace_dwc3_ep0, "%s still busy", dep->name); + return 0; ++ } ++ ++ dwc3_ep0_prepare_one_trb(dwc, epnum, buf_dma, len, type, chain); + + memset(¶ms, 0, sizeof(params)); + params.param0 = upper_32_bits(dwc->ep0_trb_addr); + params.param1 = lower_32_bits(dwc->ep0_trb_addr); + +- trace_dwc3_prepare_trb(dep, trb); +- + ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, + DWC3_DEPCMD_STARTTRANSFER, ¶ms); + if (ret < 0) { diff --git a/queue-4.4/usb-dwc3-ep0-explicitly-call-dwc3_ep0_prepare_one_trb.patch b/queue-4.4/usb-dwc3-ep0-explicitly-call-dwc3_ep0_prepare_one_trb.patch new file mode 100644 index 00000000000..851aa928003 --- /dev/null +++ b/queue-4.4/usb-dwc3-ep0-explicitly-call-dwc3_ep0_prepare_one_trb.patch @@ -0,0 +1,127 @@ +From 19ec31230eb3084431bc2e565fd085f79f564274 Mon Sep 17 00:00:00 2001 +From: Felipe Balbi +Date: Tue, 20 Dec 2016 14:08:48 +0200 +Subject: usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb() + +From: Felipe Balbi + +commit 19ec31230eb3084431bc2e565fd085f79f564274 upstream. + +Let's call dwc3_ep0_prepare_one_trb() explicitly +because there are occasions where we will need more +than one TRB to handle an EP0 transfer. + +A follow-up patch will fix one bug related to +multiple-TRB Data Phases when it comes to +mapping/unmapping requests for DMA. + +Reported-by: Janusz Dziedzic +Signed-off-by: Felipe Balbi +Signed-off-by: Greg Kroah-Hartman + + +--- + drivers/usb/dwc3/ep0.c | 28 +++++++++++++++------------- + 1 file changed, 15 insertions(+), 13 deletions(-) + +--- a/drivers/usb/dwc3/ep0.c ++++ b/drivers/usb/dwc3/ep0.c +@@ -85,8 +85,7 @@ static void dwc3_ep0_prepare_one_trb(str + trace_dwc3_prepare_trb(dep, trb); + } + +-static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, +- u32 len, u32 type, bool chain) ++static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum) + { + struct dwc3_gadget_ep_cmd_params params; + struct dwc3_ep *dep; +@@ -98,8 +97,6 @@ static int dwc3_ep0_start_trans(struct d + return 0; + } + +- dwc3_ep0_prepare_one_trb(dwc, epnum, buf_dma, len, type, chain); +- + memset(¶ms, 0, sizeof(params)); + params.param0 = upper_32_bits(dwc->ep0_trb_addr); + params.param1 = lower_32_bits(dwc->ep0_trb_addr); +@@ -317,8 +314,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc + { + int ret; + +- ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8, ++ dwc3_ep0_prepare_one_trb(dwc, 0, dwc->ctrl_req_addr, 8, + DWC3_TRBCTL_CONTROL_SETUP, false); ++ ret = dwc3_ep0_start_trans(dwc, 0); + WARN_ON(ret < 0); + } + +@@ -877,9 +875,9 @@ static void dwc3_ep0_complete_data(struc + + dwc->ep0_next_event = DWC3_EP0_COMPLETE; + +- ret = dwc3_ep0_start_trans(dwc, epnum, +- dwc->ctrl_req_addr, 0, +- DWC3_TRBCTL_CONTROL_DATA, false); ++ dwc3_ep0_prepare_one_trb(dwc, epnum, dwc->ctrl_req_addr, ++ 0, DWC3_TRBCTL_CONTROL_DATA, false); ++ ret = dwc3_ep0_start_trans(dwc, epnum); + WARN_ON(ret < 0); + } + } +@@ -961,9 +959,10 @@ static void __dwc3_ep0_do_control_data(s + req->direction = !!dep->number; + + if (req->request.length == 0) { +- ret = dwc3_ep0_start_trans(dwc, dep->number, ++ dwc3_ep0_prepare_one_trb(dwc, dep->number, + dwc->ctrl_req_addr, 0, + DWC3_TRBCTL_CONTROL_DATA, false); ++ ret = dwc3_ep0_start_trans(dwc, dep->number); + } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) + && (dep->number == 0)) { + u32 transfer_size = 0; +@@ -981,7 +980,7 @@ static void __dwc3_ep0_do_control_data(s + if (req->request.length > DWC3_EP0_BOUNCE_SIZE) { + transfer_size = ALIGN(req->request.length - maxpacket, + maxpacket); +- ret = dwc3_ep0_start_trans(dwc, dep->number, ++ dwc3_ep0_prepare_one_trb(dwc, dep->number, + req->request.dma, + transfer_size, + DWC3_TRBCTL_CONTROL_DATA, +@@ -993,9 +992,10 @@ static void __dwc3_ep0_do_control_data(s + + dwc->ep0_bounced = true; + +- ret = dwc3_ep0_start_trans(dwc, dep->number, ++ dwc3_ep0_prepare_one_trb(dwc, dep->number, + dwc->ep0_bounce_addr, transfer_size, + DWC3_TRBCTL_CONTROL_DATA, false); ++ ret = dwc3_ep0_start_trans(dwc, dep->number); + } else { + ret = usb_gadget_map_request(&dwc->gadget, &req->request, + dep->number); +@@ -1004,9 +1004,10 @@ static void __dwc3_ep0_do_control_data(s + return; + } + +- ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma, ++ dwc3_ep0_prepare_one_trb(dwc, dep->number, req->request.dma, + req->request.length, DWC3_TRBCTL_CONTROL_DATA, + false); ++ ret = dwc3_ep0_start_trans(dwc, dep->number); + } + + WARN_ON(ret < 0); +@@ -1020,8 +1021,9 @@ static int dwc3_ep0_start_control_status + type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3 + : DWC3_TRBCTL_CONTROL_STATUS2; + +- return dwc3_ep0_start_trans(dwc, dep->number, ++ dwc3_ep0_prepare_one_trb(dwc, dep->number, + dwc->ctrl_req_addr, 0, type, false); ++ return dwc3_ep0_start_trans(dwc, dep->number); + } + + static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) diff --git a/queue-4.4/usb-dwc3-gadget-always-unmap-ep0-requests.patch b/queue-4.4/usb-dwc3-gadget-always-unmap-ep0-requests.patch new file mode 100644 index 00000000000..b10b7a0bf2a --- /dev/null +++ b/queue-4.4/usb-dwc3-gadget-always-unmap-ep0-requests.patch @@ -0,0 +1,48 @@ +From d62145929992f331fdde924d5963ab49588ccc7d Mon Sep 17 00:00:00 2001 +From: Felipe Balbi +Date: Tue, 20 Dec 2016 14:14:40 +0200 +Subject: usb: dwc3: gadget: always unmap EP0 requests + +From: Felipe Balbi + +commit d62145929992f331fdde924d5963ab49588ccc7d upstream. + +commit 0416e494ce7d ("usb: dwc3: ep0: correct cache +sync issue in case of ep0_bounced") introduced a bug +where we would leak DMA resources which would cause +us to starve the system of them resulting in failing +DMA transfers. + +Fix the bug by making sure that we always unmap EP0 +requests since those are *always* mapped. + +Fixes: 0416e494ce7d ("usb: dwc3: ep0: correct cache + sync issue in case of ep0_bounced") +Cc: +Tested-by: Tomasz Medrek +Reported-by: Janusz Dziedzic +Signed-off-by: Felipe Balbi +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/dwc3/gadget.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -259,11 +259,11 @@ void dwc3_gadget_giveback(struct dwc3_ep + if (req->request.status == -EINPROGRESS) + req->request.status = status; + +- if (dwc->ep0_bounced && dep->number == 0) ++ if (dwc->ep0_bounced && dep->number <= 1) + dwc->ep0_bounced = false; +- else +- usb_gadget_unmap_request(&dwc->gadget, &req->request, +- req->direction); ++ ++ usb_gadget_unmap_request(&dwc->gadget, &req->request, ++ req->direction); + + dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n", + req, dep->name, req->request.actual,