lkml.org 
[lkml]   [2019]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 004/102] usb: chipidea: udc: workaround for endpoint conflict issue
    Date
    From: Peter Chen <peter.chen@nxp.com>

    commit c19dffc0a9511a7d7493ec21019aefd97e9a111b upstream.

    An endpoint conflict occurs when the USB is working in device mode
    during an isochronous communication. When the endpointA IN direction
    is an isochronous IN endpoint, and the host sends an IN token to
    endpointA on another device, then the OUT transaction may be missed
    regardless the OUT endpoint number. Generally, this occurs when the
    device is connected to the host through a hub and other devices are
    connected to the same hub.

    The affected OUT endpoint can be either control, bulk, isochronous, or
    an interrupt endpoint. After the OUT endpoint is primed, if an IN token
    to the same endpoint number on another device is received, then the OUT
    endpoint may be unprimed (cannot be detected by software), which causes
    this endpoint to no longer respond to the host OUT token, and thus, no
    corresponding interrupt occurs.

    There is no good workaround for this issue, the only thing the software
    could do is numbering isochronous IN from the highest endpoint since we
    have observed most of device number endpoint from the lowest.

    Cc: <stable@vger.kernel.org> #v3.14+
    Cc: Fabio Estevam <festevam@gmail.com>
    Cc: Greg KH <gregkh@linuxfoundation.org>
    Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
    Cc: Jun Li <jun.li@nxp.com>
    Signed-off-by: Peter Chen <peter.chen@nxp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/usb/chipidea/udc.c | 20 ++++++++++++++++++++
    1 file changed, 20 insertions(+)

    --- a/drivers/usb/chipidea/udc.c
    +++ b/drivers/usb/chipidea/udc.c
    @@ -1621,6 +1621,25 @@ static int ci_udc_pullup(struct usb_gadg
    static int ci_udc_start(struct usb_gadget *gadget,
    struct usb_gadget_driver *driver);
    static int ci_udc_stop(struct usb_gadget *gadget);
    +
    +/* Match ISOC IN from the highest endpoint */
    +static struct usb_ep *ci_udc_match_ep(struct usb_gadget *gadget,
    + struct usb_endpoint_descriptor *desc,
    + struct usb_ss_ep_comp_descriptor *comp_desc)
    +{
    + struct ci_hdrc *ci = container_of(gadget, struct ci_hdrc, gadget);
    + struct usb_ep *ep;
    +
    + if (usb_endpoint_xfer_isoc(desc) && usb_endpoint_dir_in(desc)) {
    + list_for_each_entry_reverse(ep, &ci->gadget.ep_list, ep_list) {
    + if (ep->caps.dir_in && !ep->claimed)
    + return ep;
    + }
    + }
    +
    + return NULL;
    +}
    +
    /**
    * Device operations part of the API to the USB controller hardware,
    * which don't involve endpoints (or i/o)
    @@ -1634,6 +1653,7 @@ static const struct usb_gadget_ops usb_g
    .vbus_draw = ci_udc_vbus_draw,
    .udc_start = ci_udc_start,
    .udc_stop = ci_udc_stop,
    + .match_ep = ci_udc_match_ep,
    };

    static int init_eps(struct ci_hdrc *ci)

    \
     
     \ /
      Last update: 2019-07-08 18:14    [W:4.101 / U:0.416 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site