From patchwork Tue Sep 22 08:48:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chance.Yang" X-Patchwork-Id: 1368997 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vatics.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=vivotek.com header.i=@vivotek.com header.a=rsa-sha256 header.s=dkim header.b=IscxZNNc; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bwdjc1q72z9sSC for ; Tue, 22 Sep 2020 21:04:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5085C825A3; Tue, 22 Sep 2020 13:04:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=vatics.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=vivotek.com header.i=@vivotek.com header.b="IscxZNNc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1F3648236F; Tue, 22 Sep 2020 10:49:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.vivotek.com (mail.vivotek.com [60.248.39.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DCBA58236F for ; Tue, 22 Sep 2020 10:49:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=vatics.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=chance.yang@vatics.com Received: from pps.filterd (vivotekpps.vivotek.com [127.0.0.1]) by vivotekpps.vivotek.com (8.16.0.42/8.16.0.42) with SMTP id 08M8nEWf006036; Tue, 22 Sep 2020 16:49:14 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivotek.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=dkim; bh=leVWUwcsCm57Om5riMLUimhxKE2p1NiypDFZuWxneps=; b=IscxZNNcQBgj6ORnu1a4d6uqdYSOC9LvGQaKUsRuMI/teqmhbtDkaQpn2+Z4TmBgHe2i Dg+6+51c6BlklsohoBVmee329A1XBaA4X2y8icR45qPfoSvBZ808RSjNXbAhZkd7xqXD YqrnQcGMTmWXy/sUryyUy8M3QSybkExXiiM= Received: from cas01.vivotek.tw ([192.168.0.58]) by vivotekpps.vivotek.com with ESMTP id 33nbmn1eb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 22 Sep 2020 16:49:13 +0800 Received: from localhost.localdomain (172.23.4.61) by CAS01.vivotek.tw (192.168.0.58) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 22 Sep 2020 16:49:10 +0800 From: Chance.Yang To: CC: Chance.Yang , Lukasz Majewski , Marek Vasut Subject: [PATCH] usb: dwc2: Fix contorl OUT transfer issue Date: Tue, 22 Sep 2020 16:48:42 +0800 Message-ID: <20200922084842.122464-1-chance.yang@vatics.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [172.23.4.61] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-22_06:2020-09-21, 2020-09-22 signatures=0 X-Proofpoint-Spam-Reason: safe X-Mailman-Approved-At: Tue, 22 Sep 2020 13:04:13 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean In buffer DMA mode, gadget should re-configure EP 0 to received SETUP packets when doeptsiz.xfersize is equal to a setup packet size(8 bytes) and EP 0 is in WAIT_FOR_SETUP state. Since EP 0 is not enabled in WAIT_FOR_SETUP state, SETUP packets is NOT received from RxFifo and wriiten to the external memory. Signed-off-by: Chance.Yang --- drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c index 1c0505eb28..9ff9cd5694 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c @@ -421,6 +421,9 @@ static void process_ep_out_intr(struct dwc2_udc *dev) { u32 ep_intr, ep_intr_status; u8 ep_num = 0; + u32 ep_tsr = 0, xfer_size = 0; + u32 epsiz_reg = (u32)®->out_endp[ep_num].doeptsiz; + u32 req_size = sizeof(struct usb_ctrlrequest); ep_intr = readl(®->daint); debug_cond(DEBUG_OUT_EP != 0, @@ -441,10 +444,17 @@ static void process_ep_out_intr(struct dwc2_udc *dev) if (ep_num == 0) { if (ep_intr_status & TRANSFER_DONE) { - if (dev->ep0state != - WAIT_FOR_OUT_COMPLETE) + ep_tsr = readl(epsiz_reg); + xfer_size = (ep_tsr & + DOEPT_SIZ_XFER_SIZE_MAX_EP0); + + if (xfer_size == req_size && + dev->ep0state == WAIT_FOR_SETUP) { + dwc2_udc_pre_setup(); + } else if (dev->ep0state != + WAIT_FOR_OUT_COMPLETE) { complete_rx(dev, ep_num); - else { + } else { dev->ep0state = WAIT_FOR_SETUP; dwc2_udc_pre_setup(); }