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); }