From patchwork Wed Mar 24 14:11:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 409268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 365FFC433E3 for ; Wed, 24 Mar 2021 14:12:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6B0661A10 for ; Wed, 24 Mar 2021 14:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236100AbhCXOLx (ORCPT ); Wed, 24 Mar 2021 10:11:53 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:44987 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236080AbhCXOLg (ORCPT ); Wed, 24 Mar 2021 10:11:36 -0400 Received: from rpi3.fritz.box ([46.90.46.54]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPA (Nemesis) id 1MFbeC-1lRrn40rcs-00H7hq; Wed, 24 Mar 2021 15:11:28 +0100 From: Fabian Vogt To: Felipe Balbi Cc: Fabian Vogt , Greg Kroah-Hartman , Yuan-Hsin Chen , linux-usb@vger.kernel.org Subject: [PATCH 1/7] fotg210-udc: Fix DMA on EP0 for length > max packet size Date: Wed, 24 Mar 2021 15:11:09 +0100 Message-Id: <20210324141115.9384-2-fabian@ritter-vogt.de> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20210324141115.9384-1-fabian@ritter-vogt.de> References: <20210324141115.9384-1-fabian@ritter-vogt.de> X-Provags-ID: V03:K1:njokoTjywUJuwr3Ml/mPN7yDZLeWlkmx0ufXomwVLJGYhG54TrX A9YoiyRSDr2xRfHU6gxcHi4w1eXfaSxdAr6WFtsO+Dv7wb4iMP/ggwTVhj+qGDW8TFbDk3M Qz4muhYoZx83pd6+nXC/QVfypjkEdABMPtE81ZGxW16S8AKd4tA5Cl5OSWgij2jy19l09kc zsUUfyVfONvcFX3k92uOQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:/jzd01Z/Zq4=:PHbBBdjPradQpDkV1w2ANW NHu7tmp6+xHO6pM4YIz56HiI0O+/PFfMlL63P9HEbt54SWhXs0Hm7YkX12xp9WC1OoqToXUzP Z620/u3KicVV0D3LrdYzCU9RJ/eqcsTyxrGBRzB9vH/5cZOMwJE4oPXrH6gaXclxJKaw2sSGh +GCaVKu5lVxCWlis6wUyApAZDWCpXog+vN/XWU6z1YSyEA/SaVPq8qjntZ/fV5WLcow0kDJ8G OdrW3C7wuMNUZI6dwySdV3RBNr0ShEZ6Ve+LNj+iNR1N0+VRHZCZ8tMXcuG493RgfUts75ugN ooJ4WOGaGc61JhtpPFcixrOdDUoseUPtQpHXcnqe8YjZK9FeqrpAteHYPqfgJukAT8c6UKpN6 Q7J+FATM3MenjAuEd9y43IK2uOAeTBNDgNY3+Z89tsAwhtYOX5IsOEE7ZsapbN+xpTGJfmWhW 9DN7bYGj6A== Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org For a 75 Byte request, it would send the first 64 separately, then detect that the remaining 11 Byte fit into a single DMA, but due to this bug set the length to the original 75 Bytes. This leads to a DMA failure (which is ignored...) and the request completes without the remaining bytes having been sent. Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver") Signed-off-by: Fabian Vogt --- drivers/usb/gadget/udc/fotg210-udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 596fe26a7c56..482d867ac96f 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -346,7 +346,7 @@ static void fotg210_start_dma(struct fotg210_ep *ep, if (req->req.length - req->req.actual > ep->ep.maxpacket) length = ep->ep.maxpacket; else - length = req->req.length; + length = req->req.length - req->req.actual; } d = dma_map_single(dev, buffer, length, From patchwork Wed Mar 24 14:11:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 408595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7025C433C1 for ; Wed, 24 Mar 2021 14:12:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D13E619D5 for ; Wed, 24 Mar 2021 14:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236092AbhCXOLw (ORCPT ); Wed, 24 Mar 2021 10:11:52 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:41901 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236037AbhCXOLf (ORCPT ); Wed, 24 Mar 2021 10:11:35 -0400 Received: from rpi3.fritz.box ([46.90.46.54]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPA (Nemesis) id 1MAORp-1lUs4B2Pmt-00Budj; Wed, 24 Mar 2021 15:11:28 +0100 From: Fabian Vogt To: Felipe Balbi Cc: Fabian Vogt , Greg Kroah-Hartman , Yuan-Hsin Chen , linux-usb@vger.kernel.org Subject: [PATCH 2/7] fotg210-udc: Fix EP0 IN requests bigger than two packets Date: Wed, 24 Mar 2021 15:11:10 +0100 Message-Id: <20210324141115.9384-3-fabian@ritter-vogt.de> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20210324141115.9384-1-fabian@ritter-vogt.de> References: <20210324141115.9384-1-fabian@ritter-vogt.de> X-Provags-ID: V03:K1:K93fe7jTGG7rbqYX10sDM6RHCFhmFa1GvxCcO6+n1J6/hs4B90z mkQhQDFWBOUHOtlmVcnQHvRM+BGKngCNup6zBvtOvIVX5NKzhwHpOCpFHnq0Ak3yIuWosP6 nbjAiaQSUYzUHtWcgj/XGRF+r1NhofuqGThO8/re8dGbao+DXbjxtgI2dfdJ71dONbRqyuZ k+Orl3zLrshz1aRYFKqIg== X-UI-Out-Filterresults: notjunk:1; V03:K0:60utlDjooeM=:f2HufU/O5XvHtjYMS4JSte eK5I1lsKMXTvloUpB8Dp7ddtWe7+A+J9BF5wvJnFgSXTVwA+1BktKaiPrBWqZZnz4vYEvRog8 U2PiQSCGBukooTYPV0V/ucvs94RfEA9ODgZLucAHZsI28l+h5f53CR+sN6QoMRrEag38+iHj9 QUcuB8RC97Q8FF272cX/W33kujhN+cnXEMUpPEXpJPOwekbYujsDIet6CiN9IWZ1DBlIx4zxU st6EkTZBg9lyEuWHnXcIHR8/46f863La/5Rq89G4Ea+EcafEIFiH4fodwZNgfdFRHmxqQmw7P IUzqX/EBsMQKCDPzGqWE3Tt4gYXkS+xKu9+WHZoEnIgD+4b7vMYhwL2VoJ4jkVDwFZxlH3PPF yOkVQeDNjdErsb016cNb/lzeTrzQP5P6WWVc/KcUrrUuY5/s+6qxBE3ZsIXjlcOzdHcVmvEb1 50+13CVgPA== Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org For a 134 Byte packet, it sends the first two 64 Byte packets just fine, but then notice that less than a packet is remaining and call fotg210_done without actually sending the rest. Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver") Signed-off-by: Fabian Vogt --- drivers/usb/gadget/udc/fotg210-udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 482d867ac96f..539808f62e2e 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -834,7 +834,7 @@ static void fotg210_ep0in(struct fotg210_udc *fotg210) if (req->req.length) fotg210_start_dma(ep, req); - if ((req->req.length - req->req.actual) < ep->ep.maxpacket) + if (req->req.actual == req->req.length) fotg210_done(ep, req, 0); } else { fotg210_set_cxdone(fotg210); From patchwork Wed Mar 24 14:11:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 409267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 638BEC433E2 for ; Wed, 24 Mar 2021 14:12:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 365A061A17 for ; Wed, 24 Mar 2021 14:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236097AbhCXOLw (ORCPT ); Wed, 24 Mar 2021 10:11:52 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:56925 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236067AbhCXOLf (ORCPT ); Wed, 24 Mar 2021 10:11:35 -0400 Received: from rpi3.fritz.box ([46.90.46.54]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPA (Nemesis) id 1MN5W7-1l8EKr3zQT-00J2SH; Wed, 24 Mar 2021 15:11:29 +0100 From: Fabian Vogt To: Felipe Balbi Cc: Fabian Vogt , Greg Kroah-Hartman , Yuan-Hsin Chen , linux-usb@vger.kernel.org Subject: [PATCH 3/7] fotg210-udc: Remove a dubious condition leading to fotg210_done Date: Wed, 24 Mar 2021 15:11:11 +0100 Message-Id: <20210324141115.9384-4-fabian@ritter-vogt.de> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20210324141115.9384-1-fabian@ritter-vogt.de> References: <20210324141115.9384-1-fabian@ritter-vogt.de> X-Provags-ID: V03:K1:o7rQAzrbX+MaovA9pnERyxbwGl7qxIhi0dSc2LU6eF0WfIJzhfI fwrsTsUInjVHM3lQIaI3+tRqXnIA7YBHLC3qAYPHEU0QzbFxt8LuWhDfAGYOu/z82+Fyd8C e2AlePrPpOCnoP0KRdO24NNHXHClQU+l10mXffNTuc8BGBbkp8edXloS/XGRwh15yZQaif/ PJi1vzO/7FOK70mGf8ifQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:F3+MT+cQBzs=:qFacNbuliAPNGL+Xcnf6IG aCtdU2tzGoJBlVqAt6kkfwUMkC9Kfw2Ka/DaVjpNz2ckxZgSaUrQId296lUU8qIXXpPFBOWtk qdwzTpsvVaQ8gtjnjDM96h/Paj6IpzRj2BAcjzXmC9VPHHigF3xv+OqjUvVhHZ7TFxx07xu6w qgZp0dHNwR9z5ifKlVY46pXxkpruknGvGWRKOp8GesJn79liTpitZXmxAbUcC3Yj3+cImsLHu Y33RUXOtBoUkI1TSgrqygqjn+K6eHyOCjWgZmc72Kk+lDdAcdPaX1Bc9rEQA2CH2Ogn2ktHNl byGkoToNugREHRyXd76RFxDbjTS1OYGVZXrwyNauDzgZJ6TVx3ncOR5y7fd9oQIIEH+1F7bt4 YTNU8y/tRGOO9K4F9YWeKC0UK5tFrLGCLSyMGUw3YwFjG7zbgTZsH88/R73anXnmFSO2dfsqs oFB/8LnDPw== Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When the EP0 IN request was not completed but less than a packet sent, it would complete the request successfully. That doesn't make sense and can't really happen as fotg210_start_dma always sends min(length, maxpkt) bytes. Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver") Signed-off-by: Fabian Vogt --- drivers/usb/gadget/udc/fotg210-udc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 539808f62e2e..911f1a5cd1f4 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -379,8 +379,7 @@ static void fotg210_ep0_queue(struct fotg210_ep *ep, } if (ep->dir_in) { /* if IN */ fotg210_start_dma(ep, req); - if ((req->req.length == req->req.actual) || - (req->req.actual < ep->ep.maxpacket)) + if (req->req.length == req->req.actual) fotg210_done(ep, req, 0); } else { /* OUT */ u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR0); From patchwork Wed Mar 24 14:11:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 409269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 740A8C433DB for ; Wed, 24 Mar 2021 14:12:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 370A161A0C for ; Wed, 24 Mar 2021 14:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236090AbhCXOLv (ORCPT ); Wed, 24 Mar 2021 10:11:51 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:42163 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236071AbhCXOLg (ORCPT ); Wed, 24 Mar 2021 10:11:36 -0400 Received: from rpi3.fritz.box ([46.90.46.54]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPA (Nemesis) id 1M7auJ-1lJJ4G1LFl-00859F; Wed, 24 Mar 2021 15:11:29 +0100 From: Fabian Vogt To: Felipe Balbi Cc: Fabian Vogt , Greg Kroah-Hartman , Yuan-Hsin Chen , linux-usb@vger.kernel.org Subject: [PATCH 4/7] fotg210-udc: Mask GRP2 interrupts we don't handle Date: Wed, 24 Mar 2021 15:11:12 +0100 Message-Id: <20210324141115.9384-5-fabian@ritter-vogt.de> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20210324141115.9384-1-fabian@ritter-vogt.de> References: <20210324141115.9384-1-fabian@ritter-vogt.de> X-Provags-ID: V03:K1:At2rKk6Qhs3J9dB/i0kLA9Eh+Ogt4LQPaIQHzrLM1U02LgENaf1 c75ikwG+p+6E4D+h9trPHgJpG1dR+9R0UqV6tV8E4CIzaw4GcgGE3bQ3m/fUiW4QbYQ9D1w /JFZZI5ekRg/dBYHWqbQH9oGA2+MRr21ULgzOM0hYcYCRoAuFKLFJn+FbcJUaWcrREMDBSr I5G6IDk4R+epJqfjuoK+w== X-UI-Out-Filterresults: notjunk:1; V03:K0:rsCL3QtHaWA=:r9CvhJJy+2xMWYS4G7o/yc OUhaEent2Fu6K/SuUAvY6WOAHgrsr5k+iKuB4W8G80WsL866pS8CrA7c9I7uvLhrt5zbBNsLY N0HOUSlZZBhgbfjpJW2pKk6rdCvqhm8DtPKbYNc5mv+O3+qNeRO+/6q9xZIdW0CrtPX7fBb4s kta96nD8siofeBRh0ZQoJ3H1w0cPN+sZ67YQX+D6kAemxrBv2OlVNzuTW0H8tkI4G45cDrSqj hKGxFvUIQrHzNvmHhWK1sjUkHta5ww/9RcoAY7ktInko0SUAPbxHXoB3mlfx6jD5MyT4LuXtO wHEzuBCciFHyw5Qc75V6XcnLOBmdlsOI0mKMRXAgX3vZlMwCFjYIYgNWgro6+oBehAAgLOy+l tRWp2AERaJZNY2PWnZi/pUgBS9uVtsKw7CClZYhUW2Ai1sC7sm+s+rj2xg1B+nzdB9Pp1ceZR o48JebJhSQ== Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Currently it leaves unhandled interrupts unmasked, but those are never acked. In the case of a "device idle" interrupt, this leads to an effectively frozen system until plugging it in. Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver") Signed-off-by: Fabian Vogt --- drivers/usb/gadget/udc/fotg210-udc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 911f1a5cd1f4..d7693b8d7c54 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -1040,6 +1040,12 @@ static void fotg210_init(struct fotg210_udc *fotg210) value &= ~DMCR_GLINT_EN; iowrite32(value, fotg210->reg + FOTG210_DMCR); + /* enable only grp2 irqs we handle */ + iowrite32(~(DISGR2_DMA_ERROR | DISGR2_RX0BYTE_INT | DISGR2_TX0BYTE_INT + | DISGR2_ISO_SEQ_ABORT_INT | DISGR2_ISO_SEQ_ERR_INT + | DISGR2_RESM_INT | DISGR2_SUSP_INT | DISGR2_USBRST_INT), + fotg210->reg + FOTG210_DMISGR2); + /* disable all fifo interrupt */ iowrite32(~(u32)0, fotg210->reg + FOTG210_DMISGR1); From patchwork Wed Mar 24 14:11:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 409266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70DFBC433E5 for ; Wed, 24 Mar 2021 14:12:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 543C961A19 for ; Wed, 24 Mar 2021 14:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236101AbhCXOLx (ORCPT ); Wed, 24 Mar 2021 10:11:53 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:40929 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236087AbhCXOLi (ORCPT ); Wed, 24 Mar 2021 10:11:38 -0400 Received: from rpi3.fritz.box ([46.90.46.54]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPA (Nemesis) id 1MsI0K-1ldyih2sKg-00tjmg; Wed, 24 Mar 2021 15:11:29 +0100 From: Fabian Vogt To: Felipe Balbi Cc: Fabian Vogt , Greg Kroah-Hartman , Yuan-Hsin Chen , linux-usb@vger.kernel.org Subject: [PATCH 5/7] fotg210-udc: Call usb_gadget_udc_reset Date: Wed, 24 Mar 2021 15:11:13 +0100 Message-Id: <20210324141115.9384-6-fabian@ritter-vogt.de> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20210324141115.9384-1-fabian@ritter-vogt.de> References: <20210324141115.9384-1-fabian@ritter-vogt.de> X-Provags-ID: V03:K1:Q1NeB63uYjp4uOtAeL2ipXlaxqnhkCOKcyq6n9e+/HVsn7d7mm+ Q4oA8YPwwsAga+Iig56lJ0kYVtJwJggLaN2OVqxtbcWo0jcdqo2R2uSPgnLmToNmHC2JN+4 KXYboZOCeEf5ske1extqO5cAUpIREUyFddAtq0Fc3khJx2IzZiH1p++sLzjqqessAt6hX8V yxDsmR7mxLHUkjxrlolEg== X-UI-Out-Filterresults: notjunk:1; V03:K0:QJwvIADzL5U=:fFgGURQsoLlf44OOAFgsSj WIlO4uEn5SGGA4cw7ry6mcSaMuxb0H18e5nsPVsju1h6FH9RlwviaaBfpemRFjJSUnFsepLAu DrcRt7/iW0fCvs5QEmeK0pZSkTY6hQclMhkbZ92nsomB7ROlXWfmmLLdjaDVrbqOmcFHcbO+T WTrDSRaxuNODjD7cpOob8c6+qUA6ij0K9NvcOKROGzfXApvXFOAbylqOMtvHnCDVr6zDMB7Vp Ujl42sPVAxDm7jYk+EEG9Kheo+++xJCgIvi/DXd3a+H2qnZ06UyxX7XwEa5ohc1AZtcFZ4EUU 1okx8wCNcbNKx2lNmXy0XOHqE/oloWvgT+rS975zgWiITmzt6NtGJu3xIpkvR3LZQwgiEWYPn SrxtmpDX0YBvOJZK+9347TxyoEdJ+Wtpw5N7fF1RlRpveftECoL3xmy1lky18H0QCqQ54rClL GW+nidqPkA== Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Notify the UDC core that a bus reset occurred. Signed-off-by: Fabian Vogt --- drivers/usb/gadget/udc/fotg210-udc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index d7693b8d7c54..6a4c60d5b2c2 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -890,6 +890,8 @@ static irqreturn_t fotg210_irq(int irq, void *_fotg210) int_grp2 &= ~int_msk2; if (int_grp2 & DISGR2_USBRST_INT) { + usb_gadget_udc_reset(&fotg210->gadget, + fotg210->driver); value = ioread32(reg); value &= ~DISGR2_USBRST_INT; iowrite32(value, reg); From patchwork Wed Mar 24 14:11:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 408592 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82C59C433E6 for ; Wed, 24 Mar 2021 14:12:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CDC761A10 for ; Wed, 24 Mar 2021 14:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236104AbhCXOLy (ORCPT ); Wed, 24 Mar 2021 10:11:54 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:51963 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236086AbhCXOLh (ORCPT ); Wed, 24 Mar 2021 10:11:37 -0400 Received: from rpi3.fritz.box ([46.90.46.54]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPA (Nemesis) id 1Mbj3Y-1lwkYe0AxS-00dJMQ; Wed, 24 Mar 2021 15:11:30 +0100 From: Fabian Vogt To: Felipe Balbi Cc: Fabian Vogt , Greg Kroah-Hartman , Yuan-Hsin Chen , linux-usb@vger.kernel.org Subject: [PATCH 6/7] fotg210-udc: Don't DMA more than the buffer can take Date: Wed, 24 Mar 2021 15:11:14 +0100 Message-Id: <20210324141115.9384-7-fabian@ritter-vogt.de> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20210324141115.9384-1-fabian@ritter-vogt.de> References: <20210324141115.9384-1-fabian@ritter-vogt.de> X-Provags-ID: V03:K1:m0trjvSgkX2KnYa3zh9mU4XWHGFoauJhqT1RxZWS6ZdUWtsjCua eNhm3L2R+fPagi46OGFRWSSW14v/Ybr8SvB+qOdxprppYRfQy2ZlRZu035QidMRePX32K9b 0pO6isY7paiJkgjYMC78AdDxmSV3tjN6YWiDltXE+8rxQWQhTjL0PlHZyBaJp3QWmkyj7E7 csih5gkehPcrp2gPY9ktg== X-UI-Out-Filterresults: notjunk:1; V03:K0:b6JzW0xpk+c=:4Q+kcEzCrTzD2Fc1OyhW9W fWdxmhsTJ1lbaK/vlQyaxVCGA1LIcjcyIK24JqPlO3pXej7cFzEcBc/ar9JeADIkHCF9Pb/gc sgmQPaNKnVLsw/B7WeT967/v2Sp1D+ImmbO+raij9KKdVBIhtdOSQz301XahkTHaJ8xQcIonk kXi142pR1v9z4F3y+rWX9G3uZnZTV/8kys+cq2K4VW9h4wdagc8MmtvKRdDy1tOATBVqZC4RX 6GOHwGZa5iA1TR57vPWjeGLek9T5Ez80SxFSRUgS4b5e7AZ4SjtlGzfkpkV7bGrNZzd171fz0 tjxhiwzYWRvyMe/plAfJNLUomsDvE2XdGoIqUkCK4YucN4w8vFOKD7dIQDqNJkOVeO0vMCTHT GVbyJf/Ogp8bXFNLhDWv7Dn8VZGvSgdQUEfp5mNp95HLeU8q74q51APeDRWPWzT+uCt4xRWtR UaKOZSi4pA== Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Before this, it wrote as much as available into the buffer, even if it didn't fit. Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver") Signed-off-by: Fabian Vogt --- drivers/usb/gadget/udc/fotg210-udc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 6a4c60d5b2c2..7716bd1c8753 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -338,8 +338,9 @@ static void fotg210_start_dma(struct fotg210_ep *ep, } else { buffer = req->req.buf + req->req.actual; length = ioread32(ep->fotg210->reg + - FOTG210_FIBCR(ep->epnum - 1)); - length &= FIBCR_BCFX; + FOTG210_FIBCR(ep->epnum - 1)) & FIBCR_BCFX; + if (length > req->req.length - req->req.actual) + length = req->req.length - req->req.actual; } } else { buffer = req->req.buf + req->req.actual; From patchwork Wed Mar 24 14:11:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Vogt X-Patchwork-Id: 408594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42A68C433E4 for ; Wed, 24 Mar 2021 14:12:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1275461A11 for ; Wed, 24 Mar 2021 14:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236098AbhCXOLw (ORCPT ); Wed, 24 Mar 2021 10:11:52 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:34129 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236081AbhCXOLg (ORCPT ); Wed, 24 Mar 2021 10:11:36 -0400 Received: from rpi3.fritz.box ([46.90.46.54]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPA (Nemesis) id 1M1YlB-1lM2MT1g5r-0039CJ; Wed, 24 Mar 2021 15:11:30 +0100 From: Fabian Vogt To: Felipe Balbi Cc: Fabian Vogt , Greg Kroah-Hartman , Yuan-Hsin Chen , linux-usb@vger.kernel.org Subject: [PATCH 7/7] fotg210-udc: Complete OUT requests on short packets Date: Wed, 24 Mar 2021 15:11:15 +0100 Message-Id: <20210324141115.9384-8-fabian@ritter-vogt.de> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20210324141115.9384-1-fabian@ritter-vogt.de> References: <20210324141115.9384-1-fabian@ritter-vogt.de> X-Provags-ID: V03:K1:gXze9JYrTRhG3mLTX6PQa025GuPBasoBCV2n0NSKY6bgscUYKOa +n6/pXvOPSt2p4EcdcpYcqenCNkTgOy+CiVa6UaRF0qvIu52WnLA7iel0e4pMtzt3hY72Du EA18V/bHaYhBFwP8nbFeu4+Ga7Aahzj9sokqLgZZfLacC8OGTTN7C6X0r7tHZ1gn0nPp9/N Zho0WtTxqRUyqLwFBkAsw== X-UI-Out-Filterresults: notjunk:1; V03:K0:u2t0OAREHSk=:4P5amG3ZmO8NNwGzCPhTl1 m2C2aQzjhiX+k02MrA0r7ypq1bYCDSXiYoI2+Ulq/xvQBDgik0qny2KPHevUNpnhfAClehjDh hXGbXR6mbC3yAAnmq7LsLviPaNVlAQcH0W14SJJJYUgLFytuz6CPYPxWDhnqZ9PCdUbHuqFFr 3ueqnlrMbezvLOAXhCOcypG5mbQYxu9o6MavOgDJZ2nRAUcCKwDWfzGNlSUEE0In8SZQQ2PGI s2MYhFwk1aDvOyw16eXBfnkzyXiDSlBY7uoDPXhrzc14Cc1N7ZyfP5uU4OjnLZGtL0fMxPAl3 /bATjbPQQg0gCjH/r5bzPNYHtM6KclCI1/54MEaLrYSKCu5NF5khL4p5Og/ko2HylvCewYV6f FnGRWZNDZHGSCHtpRdp66hjwao1fuIQ6Q2eNafhX8VZ90b8hu1Y+Fk474p494sbcwRLPbirz4 zNt1GmypBA== Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org A short packet indicates the end of a transfer and marks the request as complete. Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver") Signed-off-by: Fabian Vogt --- drivers/usb/gadget/udc/fotg210-udc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 7716bd1c8753..6cb7daf725b9 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -863,12 +863,16 @@ static void fotg210_out_fifo_handler(struct fotg210_ep *ep) { struct fotg210_request *req = list_entry(ep->queue.next, struct fotg210_request, queue); + int disgr1 = ioread32(ep->fotg210->reg + FOTG210_DISGR1); fotg210_start_dma(ep, req); - /* finish out transfer */ + /* Complete the request when it's full or a short packet arrived. + * Like other drivers, short_not_ok isn't handled. + */ + if (req->req.length == req->req.actual || - req->req.actual < ep->ep.maxpacket) + (disgr1 & DISGR1_SPK_INT(ep->epnum - 1))) fotg210_done(ep, req, 0); }