From patchwork Sat Dec 26 18:28:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1420702 X-Patchwork-Delegate: lukma@denx.de 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=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=X2rZoB8X; 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 4D3C5H05Xvz9sWb for ; Sun, 27 Dec 2020 05:29:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0739E825AA; Sat, 26 Dec 2020 19:29:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="X2rZoB8X"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E88E08259D; Sat, 26 Dec 2020 19:29:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 321288259D for ; Sat, 26 Dec 2020 19:29:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id ADF07217A0; Sat, 26 Dec 2020 18:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609007349; bh=mafQaSfN5GTHwNLzEh02RDVR00gYjJ0dLvRnSsgvHsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X2rZoB8X/YnMIfW32acy3x+7qXLr36q++DslbIEdbtSqFxylYeyeeFQSsRExc0n/b 4tFXQpCTRNRouS4QATufwfMGZDu8ZsF21vqTDGicMPskSaVSexrAWAWIDf7i0g1Yp+ lnVItLCceghta/oGeDO56zuACVz/cZylB45nhANV/5jUOpACzWmuOGw3rQOG8wQi0g 150RGjs4tamt32yY56qFFbHY37MWwS2RcaNIQOEKx5r+Xdryk6v4R+QJtHJ4hSBw0C KtXec85XvWOJTDtKuJ6oqi+NSP93cyU3q7zNQe80M20KhrSjoAui5huJUe0BETgj64 0fqjiG9GTqbNQ== Received: by pali.im (Postfix) id 16C66F12; Sat, 26 Dec 2020 19:29:08 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Lokesh Vutla , Marek Vasut , Simon Glass Cc: Ivaylo Dimitrov , Tony Lindgren , Pavel Machek , Aaro Koskinen , Merlijn Wajer , u-boot@lists.denx.de, maemo-leste@lists.dyne.org Subject: [PATCH 1/4] serial: usbtty: Send urb data in correct order Date: Sat, 26 Dec 2020 19:28:48 +0100 Message-Id: <20201226182851.18493-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201226182851.18493-1-pali@kernel.org> References: <20201226182851.18493-1-pali@kernel.org> MIME-Version: 1.0 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 Function next_urb() selects the last urb data buffer from linked list to which next data from usbtty puts should be appended. But to check if TX data still exists it is needed to look at the first urb data buffer from linked list. So check for endpoint->tx_urb (first from the linked list) instead of current_urb (the last from the linked list). Successful call to udc_endpoint_write() may invalidate active urb and allocate new in queue which invalidate pointer returned by next_urb() function. So call next_urb() prior putting data into urb buffer and call it every time after using udc_endpoint_write() function to prevent sending data from usbtty puts in incorrect order. This patch fixes issue that usbtty code does not transmit data when they are waiting in the tx queue. Signed-off-by: Pali Rohár --- drivers/serial/usbtty.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c index 02f8edf200..4f4eb02de0 100644 --- a/drivers/serial/usbtty.c +++ b/drivers/serial/usbtty.c @@ -849,17 +849,9 @@ static int write_buffer (circbuf_t * buf) &endpoint_instance[tx_endpoint]; struct urb *current_urb = NULL; - current_urb = next_urb (device_instance, endpoint); - - if (!current_urb) { - TTYERR ("current_urb is NULL, buf->size %d\n", - buf->size); - return 0; - } - /* TX data still exists - send it now */ - if(endpoint->sent < current_urb->actual_length){ + if(endpoint->sent < endpoint->tx_urb->actual_length){ if(udc_endpoint_write (endpoint)){ /* Write pre-empted by RX */ return -1; @@ -878,6 +870,8 @@ static int write_buffer (circbuf_t * buf) */ while (buf->size > 0) { + current_urb = next_urb (device_instance, endpoint); + dest = (char*)current_urb->buffer + current_urb->actual_length; From patchwork Sat Dec 26 18:28:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1420704 X-Patchwork-Delegate: lukma@denx.de 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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ptSTmvxv; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4D3C5f3T42z9sWb for ; Sun, 27 Dec 2020 05:29:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D75DE82614; Sat, 26 Dec 2020 19:29:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ptSTmvxv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7723B825D4; Sat, 26 Dec 2020 19:29:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B5B2B825AB for ; Sat, 26 Dec 2020 19:29:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 3AE772184D; Sat, 26 Dec 2020 18:29:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609007352; bh=eYONlMF7oXEuFGzja067Xztt3iUSCsSKUU2b1b5CpNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ptSTmvxvfjn+8EKeudDxbesqWI4PGEbnHrWmuX2kG9VANqsLc057bDr9y9RACGnKx Tyo7qIZ4gtifuCOra9r/xwdtX2AJ8rdSkU4b3YopvJAzR31ueIa25BZxfic1/JGMS6 qJEMK3LBp1kk8tL/8fwOprVe6eKJ06m58XpddHShiYP0fsaycXoXYJX7ZmfrGl78rV kIURbB6n9+9n0RwvwVwmwYIpUp0usxY0rH9yO+Vs3o6N7cjsyzMIC64PUhPAcdddVe sgJ5qPJSqwdpAuOgeQ63cnu+QqXCoQh0pOWDOOkgT4Z96WqwzAlSToQfc15rjDKKo2 4dQknmY4vhg3Q== Received: by pali.im (Postfix) id 8F1A9F12; Sat, 26 Dec 2020 19:29:10 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Lokesh Vutla , Marek Vasut , Simon Glass Cc: Ivaylo Dimitrov , Tony Lindgren , Pavel Machek , Aaro Koskinen , Merlijn Wajer , u-boot@lists.denx.de, maemo-leste@lists.dyne.org Subject: [PATCH 2/4] usb: musb: Fix receiving of bigger buffers Date: Sat, 26 Dec 2020 19:28:49 +0100 Message-Id: <20201226182851.18493-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201226182851.18493-1-pali@kernel.org> References: <20201226182851.18493-1-pali@kernel.org> MIME-Version: 1.0 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 If musb_peri_rx_ep() was called to processed received HW buffer but U-Boot cannot read it yet (e.g. because U-Boot SW buffer is full) then interrupt was marked as processed but HW buffer stayed unprocessed. U-Boot tried to process this buffer again when it receive interrupt again, but it can receive it only when sender (host) send a new data. As sender (host) is not going to send a new data until U-Boot process current data this issue caused a deadlock in case sender (host) is emitting data faster than U-Boot can process it. Reading musb intrrx register automatically clears this register and mark interrupt as processed. So to prevent marking interrupt in U-Boot as processed and a new variable pending_intrrx which would contain unprocessed bits of intrrx register. And as a second step, every time when musb_peri_rx_ep() is called and there are waiting data to be processed (signaled by MUSB_RXCSR_RXPKTRDY) either acknowledge sender (via musb_peri_rx_ack()) that whole HW buffer was processed or set corresponding bit in pending_intrrx that HW buffer was not fully processed yet and next iteration is required after U-Boot allocate space for reading HW buffer. This patch fixes receiving large usb buffers, e.g. file transfer via Kermit protocol implemented by 'loadb' U-Boot command over usbtty serial console. Signed-off-by: Pali Rohár --- drivers/usb/musb/musb_udc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_udc.c b/drivers/usb/musb/musb_udc.c index 28719cc3f6..7c74422623 100644 --- a/drivers/usb/musb/musb_udc.c +++ b/drivers/usb/musb/musb_udc.c @@ -104,6 +104,8 @@ struct usb_endpoint_instance *ep0_endpoint; static struct usb_device_instance *udc_device; static int enabled; +u16 pending_intrrx; + #ifdef MUSB_DEBUG static void musb_db_regs(void) { @@ -664,7 +666,10 @@ static void musb_peri_rx_ep(unsigned int ep) /* The common musb fifo reader */ read_fifo(ep, length, data); - musb_peri_rx_ack(ep); + if (length == peri_rxcount) + musb_peri_rx_ack(ep); + else + pending_intrrx |= (1 << ep); /* * urb's actual_length is updated in @@ -677,18 +682,24 @@ static void musb_peri_rx_ep(unsigned int ep) serial_printf("ERROR : %s %d no space " "in rcv buffer\n", __PRETTY_FUNCTION__, ep); + + pending_intrrx |= (1 << ep); } } else { if (debug_level > 0) serial_printf("ERROR : %s %d problem with " "endpoint\n", __PRETTY_FUNCTION__, ep); + + pending_intrrx |= (1 << ep); } } else { if (debug_level > 0) serial_printf("ERROR : %s %d with nothing to do\n", __PRETTY_FUNCTION__, ep); + + musb_peri_rx_ack(ep); } } @@ -770,6 +781,9 @@ void udc_irq(void) intrrx = readw(&musbr->intrrx); intrtx = readw(&musbr->intrtx); + intrrx |= pending_intrrx; + pending_intrrx = 0; + if (intrrx) musb_peri_rx(intrrx); From patchwork Sat Dec 26 18:28:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1420705 X-Patchwork-Delegate: lukma@denx.de 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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=tfjGfAiF; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4D3C5s0LYTz9sWb for ; Sun, 27 Dec 2020 05:29:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A4BD0825F1; Sat, 26 Dec 2020 19:29:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="tfjGfAiF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6F3E282607; Sat, 26 Dec 2020 19:29:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D749E82580 for ; Sat, 26 Dec 2020 19:29:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 5AD43217A0; Sat, 26 Dec 2020 18:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609007354; bh=CavDJMA+rH5cfA7B0sM1331XmaXdGp/LsIwYBDmIjOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tfjGfAiFBERYEshJJS8QP/Z6LExnpQ6BvLU5W/ucL/jhkVA4hztEk4Nw5/653D+vx oNYeymLhdfz7kE1zmzHqY8MnUgPed3tmH30gTfUzCv0Gci+nO1DL9MLpWTzT7gG+fy Kh52zJkmv1wPE9sekOzKoURQzSkuaEXeBgVoytHji+mjM3Kgf2JMzdWRrAoQ0VVK4z vL4OvbV5whuD81L4/N5IzJ+UlG6gLLXWWFBy6eRU7II2smtN7lieRAI4oJlWtPhJV6 IBKVmzsJ+C8q5Jgl20ncXhQTM9y3CiTeY2P0BkFNnOvaCEzjYYJRG0GPNGTAWpGnc7 r4pnQTchjlh9g== Received: by pali.im (Postfix) id AF172F12; Sat, 26 Dec 2020 19:29:12 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Lokesh Vutla , Marek Vasut , Simon Glass Cc: Ivaylo Dimitrov , Tony Lindgren , Pavel Machek , Aaro Koskinen , Merlijn Wajer , u-boot@lists.denx.de, maemo-leste@lists.dyne.org Subject: [PATCH 3/4] usb: musb: Fix handling interrupts for EP0 and SET ADDRESS commmand Date: Sat, 26 Dec 2020 19:28:50 +0100 Message-Id: <20201226182851.18493-4-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201226182851.18493-1-pali@kernel.org> References: <20201226182851.18493-1-pali@kernel.org> MIME-Version: 1.0 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 Interrupt for EP0 is indicated in intrtx register via first bit. It is set for both RX and TX. First bit in intrrx register is reserved and not set. So remove calling musb_peri_ep0() function at every iteration of udc_irq() and musb_peri_rx() and call it only from musb_peri_tx() when correct interrupt bit in initrtx it set. Address from SET ADDRESS command must be set to faddr register only after acknowledging SERV_RXPKTRDY followed by received EP0 interrupt. So prior calling musb_peri_ep0_set_address() check for EP0 interrupt instead of (incorrect) MUSB_INTR_SOF interrupt. This patch fixes issue that host (computer) cannot register U-Boot USB device and failing with errors: usb 1-1: new full-speed USB device number 86 using xhci_hcd usb 1-1: Device not responding to setup address. usb 1-1: Device not responding to setup address. usb 1-1: device not accepting address 86, error -71 U-Boot was writing address to faddr register too early and did not wait for correct interrupt after which should update address. Signed-off-by: Pali Rohár --- drivers/usb/musb/musb_udc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/usb/musb/musb_udc.c b/drivers/usb/musb/musb_udc.c index 7c74422623..50d8bc319c 100644 --- a/drivers/usb/musb/musb_udc.c +++ b/drivers/usb/musb/musb_udc.c @@ -707,9 +707,7 @@ static void musb_peri_rx(u16 intr) { unsigned int ep; - /* Check for EP0 */ - if (0x01 & intr) - musb_peri_ep0(); + /* First bit is reserved and does not indicate interrupt for EP0 */ for (ep = 1; ep < 16; ep++) { if ((1 << ep) & intr) @@ -721,9 +719,9 @@ static void musb_peri_tx(u16 intr) { unsigned int ep; - /* Check for EP0 */ + /* Check for EP0: first bit indicates interrupt for both RX and TX */ if (0x01 & intr) - musb_peri_ep0_tx(); + musb_peri_ep0(); for (ep = 1; ep < 16; ep++) { if ((1 << ep) & intr) @@ -750,8 +748,6 @@ void udc_irq(void) musb_peri_resume(); } - musb_peri_ep0(); - if (MUSB_INTR_RESET & intrusb) { usbd_device_event_irq(udc_device, DEVICE_RESET, 0); musb_peri_reset(); @@ -790,7 +786,7 @@ void udc_irq(void) if (intrtx) musb_peri_tx(intrtx); } else { - if (MUSB_INTR_SOF & intrusb) { + if (readw(&musbr->intrtx) & 0x1) { u8 faddr; faddr = readb(&musbr->faddr); /* From patchwork Sat Dec 26 18:28:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1420706 X-Patchwork-Delegate: lukma@denx.de 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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Z+cDI+dc; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4D3C624zwBz9sWb for ; Sun, 27 Dec 2020 05:30:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 65E2982623; Sat, 26 Dec 2020 19:29:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Z+cDI+dc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D150182607; Sat, 26 Dec 2020 19:29:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ADF6C82602 for ; Sat, 26 Dec 2020 19:29:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id D809221D7A; Sat, 26 Dec 2020 18:29:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609007357; bh=JMmpU/0uROiz1tqprfAgyVFzd0qyDxjC/dWHh0MYdvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+cDI+dcyryjnpfELxPc1I8JaCuOjnv0w4Aopo6sNxfiTq7UvoC25NC0H9mer1DQL HE6UZ6aWn7X2ojRErrKLEMj7jpbmzbcmYfSxW8xo5uWxXgl+B0Fn5BrM5W3bO9aD/U PqM4BWdtnma5Fe/XPzTppJnUHBM+G2/oGlEYqt9cERivu219MWtalcaHXELkUBSVzY 1TDC7mPpeQ7bZaXe45+uIxttsUR3sBR3jNKVkuC02JgwtxyLJoyYnCzFHleLEYzDvc 2p98gFR0Gz4K4PliE5fCZnidBeXKNDzi09/aFB7zuHMYsDoFtzv0/OLT3JbqPEAVCM uwGSqk/ldNXZA== Received: by pali.im (Postfix) id 35D6EF12; Sat, 26 Dec 2020 19:29:15 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Lokesh Vutla , Marek Vasut , Simon Glass Cc: Ivaylo Dimitrov , Tony Lindgren , Pavel Machek , Aaro Koskinen , Merlijn Wajer , u-boot@lists.denx.de, maemo-leste@lists.dyne.org Subject: [PATCH 4/4] usb: musb: Ensure that we set musb dynamic FIFO buffer for every endpoint Date: Sat, 26 Dec 2020 19:28:51 +0100 Message-Id: <20201226182851.18493-5-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201226182851.18493-1-pali@kernel.org> References: <20201226182851.18493-1-pali@kernel.org> MIME-Version: 1.0 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 If we do not set FIFO buffer address and size for some endpoint which is in use then default address 0x0 would be used which is in conflict with FIFO buffer for endpoint 0 which is at fixed address 0x0. Sharing address space between more endpoint cause data loss and unexpected errors. This patch is fixing transmission of characters over usbtty serial console and allow using of usbtty for debugging purposes on Nokia N900. Signed-off-by: Pali Rohár --- drivers/usb/musb/musb_udc.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/usb/musb/musb_udc.c b/drivers/usb/musb/musb_udc.c index 50d8bc319c..ea1284850e 100644 --- a/drivers/usb/musb/musb_udc.c +++ b/drivers/usb/musb/musb_udc.c @@ -875,18 +875,8 @@ void udc_setup_ep(struct usb_device_instance *device, unsigned int id, ep0_endpoint->endpoint_address = 0xff; ep0_urb = usbd_alloc_urb(device, endpoint); } else if (MAX_ENDPOINT >= id) { - int ep_addr; - - /* Check the direction */ - ep_addr = endpoint->endpoint_address; - if (USB_DIR_IN == (ep_addr & USB_ENDPOINT_DIR_MASK)) { - /* IN */ - epinfo[(id * 2) + 1].epsize = endpoint->tx_packetSize; - } else { - /* OUT */ - epinfo[id * 2].epsize = endpoint->rcv_packetSize; - } - + epinfo[(id * 2) + 0].epsize = endpoint->rcv_packetSize; + epinfo[(id * 2) + 1].epsize = endpoint->tx_packetSize; musb_configure_ep(&epinfo[0], ARRAY_SIZE(epinfo)); } else { if (debug_level > 0)