From patchwork Fri Jul 29 04:45:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 1018912 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6T4jOuv015580 for ; Fri, 29 Jul 2011 04:45:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752793Ab1G2EpP (ORCPT ); Fri, 29 Jul 2011 00:45:15 -0400 Received: from na3sys009aog120.obsmtp.com ([74.125.149.140]:46359 "EHLO na3sys009aog120.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751535Ab1G2EpO (ORCPT ); Fri, 29 Jul 2011 00:45:14 -0400 Received: from mail-fx0-f41.google.com ([209.85.161.41]) (using TLSv1) by na3sys009aob120.postini.com ([74.125.148.12]) with SMTP ID DSNKTjI62OwLrPS1Usz0DLXdVfQNEbsSpoDL@postini.com; Thu, 28 Jul 2011 21:45:14 PDT Received: by mail-fx0-f41.google.com with SMTP id 9so2008984fxg.28 for ; Thu, 28 Jul 2011 21:45:12 -0700 (PDT) Received: by 10.204.163.193 with SMTP id b1mr221113bky.366.1311914712405; Thu, 28 Jul 2011 21:45:12 -0700 (PDT) Received: from localhost (cs181221225.pp.htv.fi [82.181.221.225]) by mx.google.com with ESMTPS id r24sm454684bkr.26.2011.07.28.21.45.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jul 2011 21:45:11 -0700 (PDT) Date: Fri, 29 Jul 2011 07:45:10 +0300 From: Felipe Balbi To: Vikram Pandita Cc: balbi@ti.com, linux-usb@vger.kernel.org, gadiyar@ti.com, linux-omap@vger.kernel.org, Moiz Sonasath Subject: Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage Message-ID: <20110729044508.GY9069@legolas.emea.dhcp.ti.com> Reply-To: balbi@ti.com References: <1311138718-5072-1-git-send-email-vikram.pandita@ti.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1311138718-5072-1-git-send-email-vikram.pandita@ti.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 29 Jul 2011 04:45:24 +0000 (UTC) Hi, On Tue, Jul 19, 2011 at 10:11:58PM -0700, Vikram Pandita wrote: > From: Anand Gadiyar > > This patch enables the DMA mode1 RX support. > This feature is enabled based on the short_not_ok flag passed from > gadget drivers. > > This will result in a thruput performance gain of around > 40% for USB mass-storage/mtp use cases. > > Signed-off-by: Anand Gadiyar > Signed-off-by: Moiz Sonasath > Signed-off-by: Vikram Pandita > Tested-by: Vikram Pandita applied this one, but I changed commit log and code comment a little bit. Here's updated commit: commit e9c281b174f188adb7950ea8f6a55ca07be69914 Author: Anand Gadiyar Date: Tue Jul 19 22:11:58 2011 -0700 usb: musb: Enable DMA mode1 RX for transfers without short packets This patch enables DMA mode1 for the RX patch when we know there won't be any short packets. We check that by looking into the short_no_ok flag, if it's true we enable mode1, otherwise we use mode0 to transfer the data. This will result in a throughput performance gain of around 40% for USB mass-storage/mtp use cases. [ balbi@ti.com : updated commit log and code comments slightly ] Signed-off-by: Anand Gadiyar Signed-off-by: Moiz Sonasath Signed-off-by: Vikram Pandita Tested-by: Vikram Pandita Signed-off-by: Felipe Balbi diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index b67a062..d314f58 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -634,6 +634,7 @@ static void rxstate(struct musb *musb, struct musb_request *req) u16 len; u16 csr = musb_readw(epio, MUSB_RXCSR); struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; + u8 use_mode_1; if (hw_ep->is_shared_fifo) musb_ep = &hw_ep->ep_in; @@ -683,6 +684,18 @@ static void rxstate(struct musb *musb, struct musb_request *req) if (csr & MUSB_RXCSR_RXPKTRDY) { len = musb_readw(epio, MUSB_RXCOUNT); + + /* + * Enable Mode 1 on RX transfers only when short_not_ok flag + * is set. Currently short_not_ok flag is set only from + * file_storage and f_mass_storage drivers + */ + + if (request->short_not_ok && len == musb_ep->packet_sz) + use_mode_1 = 1; + else + use_mode_1 = 0; + if (request->actual < request->length) { #ifdef CONFIG_USB_INVENTRA_DMA if (is_buffer_mapped(req)) { @@ -714,37 +727,41 @@ static void rxstate(struct musb *musb, struct musb_request *req) * then becomes usable as a runtime "use mode 1" hint... */ - csr |= MUSB_RXCSR_DMAENAB; -#ifdef USE_MODE1 - csr |= MUSB_RXCSR_AUTOCLEAR; - /* csr |= MUSB_RXCSR_DMAMODE; */ - - /* this special sequence (enabling and then - * disabling MUSB_RXCSR_DMAMODE) is required - * to get DMAReq to activate - */ - musb_writew(epio, MUSB_RXCSR, - csr | MUSB_RXCSR_DMAMODE); -#else - if (!musb_ep->hb_mult && - musb_ep->hw_ep->rx_double_buffered) + /* Experimental: Mode1 works with mass storage use cases */ + if (use_mode_1) { csr |= MUSB_RXCSR_AUTOCLEAR; -#endif - musb_writew(epio, MUSB_RXCSR, csr); + musb_writew(epio, MUSB_RXCSR, csr); + csr |= MUSB_RXCSR_DMAENAB; + musb_writew(epio, MUSB_RXCSR, csr); + + /* + * this special sequence (enabling and then + * disabling MUSB_RXCSR_DMAMODE) is required + * to get DMAReq to activate + */ + musb_writew(epio, MUSB_RXCSR, + csr | MUSB_RXCSR_DMAMODE); + musb_writew(epio, MUSB_RXCSR, csr); + + } else { + if (!musb_ep->hb_mult && + musb_ep->hw_ep->rx_double_buffered) + csr |= MUSB_RXCSR_AUTOCLEAR; + csr |= MUSB_RXCSR_DMAENAB; + musb_writew(epio, MUSB_RXCSR, csr); + } if (request->actual < request->length) { int transfer_size = 0; -#ifdef USE_MODE1 - transfer_size = min(request->length - request->actual, - channel->max_len); -#else - transfer_size = min(request->length - request->actual, - (unsigned)len); -#endif - if (transfer_size <= musb_ep->packet_sz) - musb_ep->dma->desired_mode = 0; - else + if (use_mode_1) { + transfer_size = min(request->length - request->actual, + channel->max_len); musb_ep->dma->desired_mode = 1; + } else { + transfer_size = min(request->length - request->actual, + (unsigned)len); + musb_ep->dma->desired_mode = 0; + } use_dma = c->channel_program( channel,