Commit 224f6e40 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'fixes-for-v4.8-rc2' of...

Merge tag 'fixes-for-v4.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus

Felipe writes:

usb: fixes for v4.8-rc1

First set of fixes for v4.8-rc cycle. Again, dwc3 is
the most active driver with over 60% of this pull
request touching it.

The most important fixes are related to scatterlist
usage with dwc3. Before this pull request, we were
increment request->actual multiple times and this
would result in request->actual being larger than
request->length.

Also, if a we received a short packet midway through
processing a scatterlist, we were not clearning HWO
bit as we should.

Other than the large dwc3 scatterlist fixes, we have
a new Device ID for Intel's Kabylake silicon.

Other drivers, such as fsl_qe_udc and renesas udc,
also got a few minor fixes. Details are in shortlog.
parents 59b71f77 a0ad85ae
...@@ -61,6 +61,7 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) ...@@ -61,6 +61,7 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
if (!simple->clks) if (!simple->clks)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, simple);
simple->dev = dev; simple->dev = dev;
for (i = 0; i < simple->num_clocks; i++) { for (i = 0; i < simple->num_clocks; i++) {
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#define PCI_DEVICE_ID_INTEL_BXT 0x0aaa #define PCI_DEVICE_ID_INTEL_BXT 0x0aaa
#define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa #define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa
#define PCI_DEVICE_ID_INTEL_APL 0x5aaa #define PCI_DEVICE_ID_INTEL_APL 0x5aaa
#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0
static const struct acpi_gpio_params reset_gpios = { 0, 0, false }; static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
static const struct acpi_gpio_params cs_gpios = { 1, 0, false }; static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
...@@ -227,6 +228,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = { ...@@ -227,6 +228,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), },
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
{ } /* Terminating Entry */ { } /* Terminating Entry */
}; };
......
...@@ -829,7 +829,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, ...@@ -829,7 +829,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
if (!req->request.no_interrupt && !chain) if (!req->request.no_interrupt && !chain)
trb->ctrl |= DWC3_TRB_CTRL_IOC | DWC3_TRB_CTRL_ISP_IMI; trb->ctrl |= DWC3_TRB_CTRL_IOC | DWC3_TRB_CTRL_ISP_IMI;
if (last) if (last && !usb_endpoint_xfer_isoc(dep->endpoint.desc))
trb->ctrl |= DWC3_TRB_CTRL_LST; trb->ctrl |= DWC3_TRB_CTRL_LST;
if (chain) if (chain)
...@@ -1955,7 +1955,8 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) ...@@ -1955,7 +1955,8 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc)
static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep, static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
struct dwc3_request *req, struct dwc3_trb *trb, struct dwc3_request *req, struct dwc3_trb *trb,
const struct dwc3_event_depevt *event, int status) const struct dwc3_event_depevt *event, int status,
int chain)
{ {
unsigned int count; unsigned int count;
unsigned int s_pkt = 0; unsigned int s_pkt = 0;
...@@ -1964,17 +1965,22 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep, ...@@ -1964,17 +1965,22 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
dep->queued_requests--; dep->queued_requests--;
trace_dwc3_complete_trb(dep, trb); trace_dwc3_complete_trb(dep, trb);
/*
* If we're in the middle of series of chained TRBs and we
* receive a short transfer along the way, DWC3 will skip
* through all TRBs including the last TRB in the chain (the
* where CHN bit is zero. DWC3 will also avoid clearing HWO
* bit and SW has to do it manually.
*
* We're going to do that here to avoid problems of HW trying
* to use bogus TRBs for transfers.
*/
if (chain && (trb->ctrl & DWC3_TRB_CTRL_HWO))
trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN) if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN)
/* return 1;
* We continue despite the error. There is not much we
* can do. If we don't clean it up we loop forever. If
* we skip the TRB then it gets overwritten after a
* while since we use them in a ring buffer. A BUG()
* would help. Lets hope that if this occurs, someone
* fixes the root cause instead of looking away :)
*/
dev_err(dwc->dev, "%s's TRB (%p) still owned by HW\n",
dep->name, trb);
count = trb->size & DWC3_TRB_SIZE_MASK; count = trb->size & DWC3_TRB_SIZE_MASK;
if (dep->direction) { if (dep->direction) {
...@@ -2013,15 +2019,7 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep, ...@@ -2013,15 +2019,7 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
s_pkt = 1; s_pkt = 1;
} }
/* if (s_pkt && !chain)
* We assume here we will always receive the entire data block
* which we should receive. Meaning, if we program RX to
* receive 4K but we receive only 2K, we assume that's all we
* should receive and we simply bounce the request back to the
* gadget driver for further processing.
*/
req->request.actual += req->request.length - count;
if (s_pkt)
return 1; return 1;
if ((event->status & DEPEVT_STATUS_LST) && if ((event->status & DEPEVT_STATUS_LST) &&
(trb->ctrl & (DWC3_TRB_CTRL_LST | (trb->ctrl & (DWC3_TRB_CTRL_LST |
...@@ -2040,13 +2038,17 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, ...@@ -2040,13 +2038,17 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
struct dwc3_trb *trb; struct dwc3_trb *trb;
unsigned int slot; unsigned int slot;
unsigned int i; unsigned int i;
int count = 0;
int ret; int ret;
do { do {
int chain;
req = next_request(&dep->started_list); req = next_request(&dep->started_list);
if (WARN_ON_ONCE(!req)) if (WARN_ON_ONCE(!req))
return 1; return 1;
chain = req->request.num_mapped_sgs > 0;
i = 0; i = 0;
do { do {
slot = req->first_trb_index + i; slot = req->first_trb_index + i;
...@@ -2054,13 +2056,22 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, ...@@ -2054,13 +2056,22 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
slot++; slot++;
slot %= DWC3_TRB_NUM; slot %= DWC3_TRB_NUM;
trb = &dep->trb_pool[slot]; trb = &dep->trb_pool[slot];
count += trb->size & DWC3_TRB_SIZE_MASK;
ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb, ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb,
event, status); event, status, chain);
if (ret) if (ret)
break; break;
} while (++i < req->request.num_mapped_sgs); } while (++i < req->request.num_mapped_sgs);
/*
* We assume here we will always receive the entire data block
* which we should receive. Meaning, if we program RX to
* receive 4K but we receive only 2K, we assume that's all we
* should receive and we simply bounce the request back to the
* gadget driver for further processing.
*/
req->request.actual += req->request.length - count;
dwc3_gadget_giveback(dep, req, status); dwc3_gadget_giveback(dep, req, status);
if (ret) if (ret)
......
...@@ -1913,6 +1913,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) ...@@ -1913,6 +1913,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
break; break;
case USB_RECIP_ENDPOINT: case USB_RECIP_ENDPOINT:
if (!cdev->config)
break;
endp = ((w_index & 0x80) >> 3) | (w_index & 0x0f); endp = ((w_index & 0x80) >> 3) | (w_index & 0x0f);
list_for_each_entry(f, &cdev->config->functions, list) { list_for_each_entry(f, &cdev->config->functions, list) {
if (test_bit(endp, f->endpoints)) if (test_bit(endp, f->endpoints))
...@@ -2124,14 +2126,14 @@ int composite_os_desc_req_prepare(struct usb_composite_dev *cdev, ...@@ -2124,14 +2126,14 @@ int composite_os_desc_req_prepare(struct usb_composite_dev *cdev,
cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL); cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL);
if (!cdev->os_desc_req) { if (!cdev->os_desc_req) {
ret = PTR_ERR(cdev->os_desc_req); ret = -ENOMEM;
goto end; goto end;
} }
/* OS feature descriptor length <= 4kB */ /* OS feature descriptor length <= 4kB */
cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL); cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL);
if (!cdev->os_desc_req->buf) { if (!cdev->os_desc_req->buf) {
ret = PTR_ERR(cdev->os_desc_req->buf); ret = -ENOMEM;
kfree(cdev->os_desc_req); kfree(cdev->os_desc_req);
goto end; goto end;
} }
......
...@@ -1490,7 +1490,9 @@ void unregister_gadget_item(struct config_item *item) ...@@ -1490,7 +1490,9 @@ void unregister_gadget_item(struct config_item *item)
{ {
struct gadget_info *gi = to_gadget_info(item); struct gadget_info *gi = to_gadget_info(item);
mutex_lock(&gi->lock);
unregister_gadget(gi); unregister_gadget(gi);
mutex_unlock(&gi->lock);
} }
EXPORT_SYMBOL_GPL(unregister_gadget_item); EXPORT_SYMBOL_GPL(unregister_gadget_item);
......
...@@ -680,6 +680,12 @@ static int rndis_reset_response(struct rndis_params *params, ...@@ -680,6 +680,12 @@ static int rndis_reset_response(struct rndis_params *params,
{ {
rndis_reset_cmplt_type *resp; rndis_reset_cmplt_type *resp;
rndis_resp_t *r; rndis_resp_t *r;
u8 *xbuf;
u32 length;
/* drain the response queue */
while ((xbuf = rndis_get_next_response(params, &length)))
rndis_free_response(params, xbuf);
r = rndis_add_response(params, sizeof(rndis_reset_cmplt_type)); r = rndis_add_response(params, sizeof(rndis_reset_cmplt_type));
if (!r) if (!r)
......
...@@ -556,7 +556,8 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, ...@@ -556,7 +556,8 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
/* Multi frame CDC protocols may store the frame for /* Multi frame CDC protocols may store the frame for
* later which is not a dropped frame. * later which is not a dropped frame.
*/ */
if (dev->port_usb->supports_multi_frame) if (dev->port_usb &&
dev->port_usb->supports_multi_frame)
goto multiframe; goto multiframe;
goto drop; goto drop;
} }
......
...@@ -2023,7 +2023,7 @@ static int uvcg_streaming_class_allow_link(struct config_item *src, ...@@ -2023,7 +2023,7 @@ static int uvcg_streaming_class_allow_link(struct config_item *src,
if (!data) { if (!data) {
kfree(*class_array); kfree(*class_array);
*class_array = NULL; *class_array = NULL;
ret = PTR_ERR(data); ret = -ENOMEM;
goto unlock; goto unlock;
} }
cl_arr = *class_array; cl_arr = *class_array;
......
...@@ -542,7 +542,7 @@ static ssize_t ep_aio(struct kiocb *iocb, ...@@ -542,7 +542,7 @@ static ssize_t ep_aio(struct kiocb *iocb,
*/ */
spin_lock_irq(&epdata->dev->lock); spin_lock_irq(&epdata->dev->lock);
value = -ENODEV; value = -ENODEV;
if (unlikely(epdata->ep)) if (unlikely(epdata->ep == NULL))
goto fail; goto fail;
req = usb_ep_alloc_request(epdata->ep, GFP_ATOMIC); req = usb_ep_alloc_request(epdata->ep, GFP_ATOMIC);
...@@ -606,7 +606,7 @@ ep_read_iter(struct kiocb *iocb, struct iov_iter *to) ...@@ -606,7 +606,7 @@ ep_read_iter(struct kiocb *iocb, struct iov_iter *to)
} }
if (is_sync_kiocb(iocb)) { if (is_sync_kiocb(iocb)) {
value = ep_io(epdata, buf, len); value = ep_io(epdata, buf, len);
if (value >= 0 && copy_to_iter(buf, value, to)) if (value >= 0 && (copy_to_iter(buf, value, to) != value))
value = -EFAULT; value = -EFAULT;
} else { } else {
struct kiocb_priv *priv = kzalloc(sizeof *priv, GFP_KERNEL); struct kiocb_priv *priv = kzalloc(sizeof *priv, GFP_KERNEL);
......
...@@ -1145,7 +1145,7 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, ...@@ -1145,7 +1145,7 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
list_del(&driver->pending); list_del(&driver->pending);
if (ret) if (ret)
goto err4; goto err5;
break; break;
} }
} }
...@@ -1154,6 +1154,9 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, ...@@ -1154,6 +1154,9 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
return 0; return 0;
err5:
device_del(&udc->dev);
err4: err4:
list_del(&udc->list); list_del(&udc->list);
mutex_unlock(&udc_lock); mutex_unlock(&udc_lock);
......
...@@ -2053,7 +2053,7 @@ static void setup_received_handle(struct qe_udc *udc, ...@@ -2053,7 +2053,7 @@ static void setup_received_handle(struct qe_udc *udc,
struct qe_ep *ep; struct qe_ep *ep;
if (wValue != 0 || wLength != 0 if (wValue != 0 || wLength != 0
|| pipe > USB_MAX_ENDPOINTS) || pipe >= USB_MAX_ENDPOINTS)
break; break;
ep = &udc->eps[pipe]; ep = &udc->eps[pipe];
......
...@@ -140,6 +140,8 @@ static int omap_otg_probe(struct platform_device *pdev) ...@@ -140,6 +140,8 @@ static int omap_otg_probe(struct platform_device *pdev)
(rev >> 4) & 0xf, rev & 0xf, config->extcon, otg_dev->id, (rev >> 4) & 0xf, rev & 0xf, config->extcon, otg_dev->id,
otg_dev->vbus); otg_dev->vbus);
platform_set_drvdata(pdev, otg_dev);
return 0; return 0;
} }
......
...@@ -514,7 +514,8 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev) ...@@ -514,7 +514,8 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
if (gpio > 0) if (gpio > 0)
dparam->enable_gpio = gpio; dparam->enable_gpio = gpio;
if (dparam->type == USBHS_TYPE_RCAR_GEN2) if (dparam->type == USBHS_TYPE_RCAR_GEN2 ||
dparam->type == USBHS_TYPE_RCAR_GEN3)
dparam->has_usb_dmac = 1; dparam->has_usb_dmac = 1;
return info; return info;
......
...@@ -871,7 +871,7 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done) ...@@ -871,7 +871,7 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
/* use PIO if packet is less than pio_dma_border or pipe is DCP */ /* use PIO if packet is less than pio_dma_border or pipe is DCP */
if ((len < usbhs_get_dparam(priv, pio_dma_border)) || if ((len < usbhs_get_dparam(priv, pio_dma_border)) ||
usbhs_pipe_is_dcp(pipe)) usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC))
goto usbhsf_pio_prepare_push; goto usbhsf_pio_prepare_push;
/* check data length if this driver don't use USB-DMAC */ /* check data length if this driver don't use USB-DMAC */
...@@ -976,7 +976,7 @@ static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt, ...@@ -976,7 +976,7 @@ static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt,
/* use PIO if packet is less than pio_dma_border or pipe is DCP */ /* use PIO if packet is less than pio_dma_border or pipe is DCP */
if ((pkt->length < usbhs_get_dparam(priv, pio_dma_border)) || if ((pkt->length < usbhs_get_dparam(priv, pio_dma_border)) ||
usbhs_pipe_is_dcp(pipe)) usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC))
goto usbhsf_pio_prepare_pop; goto usbhsf_pio_prepare_pop;
fifo = usbhsf_get_dma_fifo(priv, pkt); fifo = usbhsf_get_dma_fifo(priv, pkt);
......
...@@ -617,10 +617,13 @@ static int usbhsg_ep_enable(struct usb_ep *ep, ...@@ -617,10 +617,13 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
* use dmaengine if possible. * use dmaengine if possible.
* It will use pio handler if impossible. * It will use pio handler if impossible.
*/ */
if (usb_endpoint_dir_in(desc)) if (usb_endpoint_dir_in(desc)) {
pipe->handler = &usbhs_fifo_dma_push_handler; pipe->handler = &usbhs_fifo_dma_push_handler;
else } else {
pipe->handler = &usbhs_fifo_dma_pop_handler; pipe->handler = &usbhs_fifo_dma_pop_handler;
usbhs_xxxsts_clear(priv, BRDYSTS,
usbhs_pipe_number(pipe));
}
ret = 0; ret = 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment