Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7151804ybi; Mon, 8 Jul 2019 15:41:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkBNpfjuUz4g+2eyZbOAn+tVDp6/EJty4VeS0Z+s/lB5QCL4Tr44BrBmuFZJLREdeZaxHu X-Received: by 2002:a63:c03:: with SMTP id b3mr26975767pgl.68.1562625691293; Mon, 08 Jul 2019 15:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625691; cv=none; d=google.com; s=arc-20160816; b=zXHM06U8Fpt06U7Kky2hVY4/MIfEtmjOT7xJ6syQkdbsRue6EJHn6RSyfZNdJmboR4 2oys/Nw91ejU6+LIVZp4se1Ybuf+GUmUZ7obffgyOWqp8/9oxoM5Yjo4S1RxFYS/Zb4Z U5nzFi/P7rgUGNLfGC1A7hrYA4ZhTNkryjCOK5XMhmuI0SH82ePL68YE/N07ZLhW3Ra5 9CcDzaKks3qtduM0YWWc9gvcZ9JSSdCujE2BpSq27PUvhtBsX5CWnNSrKPDD/XDX1OYo 0Wc/IVLeQ1wysq5iAV8nyMlPkajA2UKy019uY/G7+EFqlMCVXrWDUYukV4ao2fWgJoIW RBfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mrPfnXFNNZKooawsYAmN0oJc08ml2D1sZFyYgsLqVb0=; b=nyR5WZZHvcCSX1ZGcXqR+/w0FsYDCAzsbOayr2ngq//DQ3Ta99SuKRnLm+lS/sFn/u n/LeRqMV2DnSlV8A+2YZ9L8KuylHaSslwzf9oUJYDjBPD9zclEIBRtsqDZEXFIQqSD4u y4Bdf7Bb0XVcVQCqY4HHZnmonsk6x2VaB57ceO5hb1jUVG7hSX38+pi/tLJ9gydeiwkI 62Z6G9WaejHBvE07xyDDPLQfuNTb0vMGleKjZrR+xziJaP0kRKYmHKWkDS7D8XbQZlj2 XXodBpMvvjnGVKZQYjn7576sqY6DMvPKHEwwj0hr/BFLu0rAx4kX9hoZyTBpnr9CqHwz BmFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="E/Ig25U9"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id az12si16263571plb.5.2019.07.08.15.41.16; Mon, 08 Jul 2019 15:41:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="E/Ig25U9"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391297AbfGHPrH (ORCPT + 99 others); Mon, 8 Jul 2019 11:47:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:45036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733310AbfGHPUR (ORCPT ); Mon, 8 Jul 2019 11:20:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 392C5216C4; Mon, 8 Jul 2019 15:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599216; bh=zK/2m3vIdbnCyxfHRSFwOxu839hS2Og+FGZFOvRJtp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E/Ig25U9hDPNcKDS1drAqvImA2148pbCt1PuSjUHjS6gSNf50nILTc7MOhYgo5AyU lyCjg7JnN6L51QYUX9IPrVLuJb5cR5SjcwDAoBeHrXOw4toXJ1fxkR+/BLOZlrpw2c MkZrP7AWJm5TfJjJmQwu16968cM2jq1DYtsFhj/8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabio Estevam , Sergei Shtylyov , Jun Li , Peter Chen Subject: [PATCH 4.9 004/102] usb: chipidea: udc: workaround for endpoint conflict issue Date: Mon, 8 Jul 2019 17:11:57 +0200 Message-Id: <20190708150526.209349107@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150525.973820964@linuxfoundation.org> References: <20190708150525.973820964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Chen 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: #v3.14+ Cc: Fabio Estevam Cc: Greg KH Cc: Sergei Shtylyov Cc: Jun Li Signed-off-by: Peter Chen Signed-off-by: Greg Kroah-Hartman --- 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)