From patchwork Mon Feb 4 18:04:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guido Kiener X-Patchwork-Id: 10796165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E86B13B4 for ; Mon, 4 Feb 2019 17:10:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F11AE2BD5C for ; Mon, 4 Feb 2019 17:10:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5D442BDB5; Mon, 4 Feb 2019 17:10:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91D742BD5C for ; Mon, 4 Feb 2019 17:10:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730747AbfBDRKc (ORCPT ); Mon, 4 Feb 2019 12:10:32 -0500 Received: from mr08.mx01.tldhost.de ([84.19.26.246]:35430 "EHLO mr08.mx01.tldhost.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728169AbfBDRKc (ORCPT ); Mon, 4 Feb 2019 12:10:32 -0500 Received: from mx01.tldhost.de (localhost [127.0.0.1]) by mx01.tldhost.de (Postfix) with ESMTP id DD02A121122 for ; Mon, 4 Feb 2019 18:05:28 +0100 (CET) Received: by mx01.tldhost.de (Postfix, from userid 1001) id CD9EC120F81; Mon, 4 Feb 2019 18:05:28 +0100 (CET) Received: from server12.tldhost.de (server12.tldhost.de [84.19.26.112]) by mx01.tldhost.de (Postfix) with ESMTPS id C9A04120F81; Mon, 4 Feb 2019 18:05:26 +0100 (CET) From: Guido Kiener To: Felipe Balbi , linux-usb@vger.kernel.org, guido.kiener@rohde-schwarz.com Subject: [PATCH 1/3] udc: net2280: Fix net2280_disable Date: Mon, 4 Feb 2019 19:04:20 +0100 Message-Id: <20190204180422.5095-1-guido@kiener-muenchen.de> X-PPP-Message-ID: <20190204170527.15170.16330@server12.tldhost.de> X-PPP-Vhost: kiener-muenchen.de X-POWERED-BY: TLDHost.de - AV:CLEAN SPAM:OK Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Guido Kiener A reset e.g. calling ep_reset_338x() can happen while endpoints are enabled. The ep_reset_338x() sets ep->desc = NULL to mark endpoint being invalid. A subsequent call of net2280_disable will fail and return -EINVAL to parent function usb_ep_disable(), which will fail, too, and do not set the member ep->enabled = false. See: https://elixir.bootlin.com/linux/v5.0-rc5/source/drivers/usb/gadget/udc/core.c#L139 This fix ignores dp->desc and allows net2280_disable() to succeed. Subsequent calls to usb_ep_enable()/usb_ep_disable() succeeds. Signed-off-by: Guido Kiener Acked-by: Alan Stern --- drivers/usb/gadget/udc/net2280.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index e7dae5379e04..7154f00dea40 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -516,8 +516,8 @@ static int net2280_disable(struct usb_ep *_ep) unsigned long flags; ep = container_of(_ep, struct net2280_ep, ep); - if (!_ep || !ep->desc || _ep->name == ep0name) { - pr_err("%s: Invalid ep=%p or ep->desc\n", __func__, _ep); + if (!_ep || _ep->name == ep0name) { + pr_err("%s: Invalid ep=%p\n", __func__, _ep); return -EINVAL; } spin_lock_irqsave(&ep->dev->lock, flags); From patchwork Mon Feb 4 18:04:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guido Kiener X-Patchwork-Id: 10796161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3090813B4 for ; Mon, 4 Feb 2019 17:10:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DCA42BDAF for ; Mon, 4 Feb 2019 17:10:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11EEA2B735; Mon, 4 Feb 2019 17:10:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 283072BDAF for ; Mon, 4 Feb 2019 17:10:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730739AbfBDRKc (ORCPT ); Mon, 4 Feb 2019 12:10:32 -0500 Received: from mr01.mx01.tldhost.de ([62.108.36.247]:46446 "EHLO mr01.mx01.tldhost.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727421AbfBDRKc (ORCPT ); Mon, 4 Feb 2019 12:10:32 -0500 X-Greylist: delayed 301 seconds by postgrey-1.27 at vger.kernel.org; Mon, 04 Feb 2019 12:10:31 EST Received: from mx01.tldhost.de (localhost [127.0.0.1]) by mx01.tldhost.de (Postfix) with ESMTP id 5530D121104 for ; Mon, 4 Feb 2019 18:05:29 +0100 (CET) Received: by mx01.tldhost.de (Postfix, from userid 1001) id 4AAA91205E1; Mon, 4 Feb 2019 18:05:29 +0100 (CET) Received: from server12.tldhost.de (server12.tldhost.de [84.19.26.112]) by mx01.tldhost.de (Postfix) with ESMTPS id 439091210F3; Mon, 4 Feb 2019 18:05:27 +0100 (CET) From: Guido Kiener To: Felipe Balbi , linux-usb@vger.kernel.org, guido.kiener@rohde-schwarz.com Subject: [PATCH 2/3] udc: net2280: Fix overrun of OUT messages Date: Mon, 4 Feb 2019 19:04:21 +0100 Message-Id: <20190204180422.5095-2-guido@kiener-muenchen.de> In-Reply-To: <20190204180422.5095-1-guido@kiener-muenchen.de> References: <20190204180422.5095-1-guido@kiener-muenchen.de> X-PPP-Message-ID: <20190204170528.15177.40847@server12.tldhost.de> X-PPP-Vhost: kiener-muenchen.de X-POWERED-BY: TLDHost.de - AV:CLEAN SPAM:OK Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Guido Kiener The OUT endpoint normally blocks (NAK) subsequent packets when a short packet is received and returns an incomplete queue entry to the gadget driver. Thereby the gadget driver can detect a short packet when reading queue entries with a length that is not equal to a multiple of packet size. The start_queue() function enables receiving OUT packets regardless of the content of the OUT FIFO. This results in a problem: When receiving is enabled more OUT packets are appended to the last short packet and the gadget driver cannot determine the end of a short packet anymore. Furthermore the remaining data in the OUT FIFO is not delivered to the gadget driver immediately and can produce timeout errors. This fix only stops OUT naking when all FIFO data is delivered to the gadget driver and the OUT FIFO is empty. Signed-off-by: Guido Kiener --- drivers/usb/gadget/udc/net2280.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 7154f00dea40..1cb58fd5d1c6 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -867,7 +867,7 @@ static void start_queue(struct net2280_ep *ep, u32 dmactl, u32 td_dma) writel(BIT(DMA_START), &dma->dmastat); - if (!ep->is_in) + if (!ep->is_in && readl(&ep->regs->ep_avail) == 0) stop_out_naking(ep); } From patchwork Mon Feb 4 18:04:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guido Kiener X-Patchwork-Id: 10796163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED0B913A4 for ; Mon, 4 Feb 2019 17:10:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBFA12B7E3 for ; Mon, 4 Feb 2019 17:10:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D08212BDB1; Mon, 4 Feb 2019 17:10:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BA712B7E3 for ; Mon, 4 Feb 2019 17:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730745AbfBDRKc (ORCPT ); Mon, 4 Feb 2019 12:10:32 -0500 Received: from mr08.mx01.tldhost.de ([84.19.26.246]:54858 "EHLO mr08.mx01.tldhost.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727620AbfBDRKc (ORCPT ); Mon, 4 Feb 2019 12:10:32 -0500 Received: from mx01.tldhost.de (localhost [127.0.0.1]) by mx01.tldhost.de (Postfix) with ESMTP id B9A81121113 for ; Mon, 4 Feb 2019 18:05:29 +0100 (CET) Received: by mx01.tldhost.de (Postfix, from userid 1001) id AEF1E120FDC; Mon, 4 Feb 2019 18:05:29 +0100 (CET) Received: from server12.tldhost.de (server12.tldhost.de [84.19.26.112]) by mx01.tldhost.de (Postfix) with ESMTPS id A7265121110; Mon, 4 Feb 2019 18:05:27 +0100 (CET) From: Guido Kiener To: Felipe Balbi , linux-usb@vger.kernel.org, guido.kiener@rohde-schwarz.com Subject: [PATCH 3/3] udc: net2280: Fix typo Date: Mon, 4 Feb 2019 19:04:22 +0100 Message-Id: <20190204180422.5095-3-guido@kiener-muenchen.de> In-Reply-To: <20190204180422.5095-1-guido@kiener-muenchen.de> References: <20190204180422.5095-1-guido@kiener-muenchen.de> X-PPP-Message-ID: <20190204170528.15183.34023@server12.tldhost.de> X-PPP-Vhost: kiener-muenchen.de X-POWERED-BY: TLDHost.de - AV:CLEAN SPAM:OK Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Guido Kiener Fix spelling of automatically. Signed-off-by: Guido Kiener --- drivers/usb/gadget/udc/net2280.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 1cb58fd5d1c6..430d582d8b6e 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -912,7 +912,7 @@ static void start_dma(struct net2280_ep *ep, struct net2280_request *req) tmp = dmactl_default; /* force packet boundaries between dma requests, but prevent the - * controller from automagically writing a last "short" packet + * controller from automatically writing a last "short" packet * (zero length) unless the driver explicitly said to do that. */ if (ep->is_in) {