From patchwork Fri Aug 26 15:54:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sonasath, Moiz" X-Patchwork-Id: 1102562 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 p7QG0Uo6017480 for ; Fri, 26 Aug 2011 16:00:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754755Ab1HZQA1 (ORCPT ); Fri, 26 Aug 2011 12:00:27 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:49965 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754556Ab1HZQAZ (ORCPT ); Fri, 26 Aug 2011 12:00:25 -0400 Received: from dlep34.itg.ti.com ([157.170.170.115]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id p7QG0LrG013596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 26 Aug 2011 11:00:21 -0500 Received: from dlep26.itg.ti.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep34.itg.ti.com (8.13.7/8.13.8) with ESMTP id p7QG0KpF011351; Fri, 26 Aug 2011 11:00:21 -0500 (CDT) Received: from DLEE74.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id p7QG0KTb027489; Fri, 26 Aug 2011 11:00:20 -0500 (CDT) Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Fri, 26 Aug 2011 11:00:20 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id p7QG0KCJ009017; Fri, 26 Aug 2011 11:00:20 -0500 Received: from lina0132712 (lina0132712.am.dhcp.ti.com [128.247.78.215]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id p7QG0K013565; Fri, 26 Aug 2011 11:00:20 -0500 (CDT) Received: by lina0132712 (Postfix, from userid 1000) id 4FC0A42E1B7; Fri, 26 Aug 2011 10:54:22 -0500 (CDT) From: Moiz Sonasath To: , CC: , , Anand Gadiyar , Moiz Sonasath , Vikram Pandita Subject: [PATCH v5] usb: musb: Enable DMA mode1 RX for BULK endpoints Date: Fri, 26 Aug 2011 10:54:22 -0500 Message-ID: <1314374062-27548-1-git-send-email-m-sonasath@ti.com> X-Mailer: git-send-email 1.6.0.4 MIME-Version: 1.0 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, 26 Aug 2011 16:00:31 +0000 (UTC) From: Anand Gadiyar This patch enables the DMA mode1 RX support for endpoints that use BULK transactions. This will result in a throughput increase of around 30-40% for BULK transfers (mass-storage/mtp/ptp usecases) Tested: Mass-storage, MTP, PTP, ADB, RNDIS gadgets Signed-off-by: Anand Gadiyar Signed-off-by: Moiz Sonasath Signed-off-by: Vikram Pandita --- drivers/usb/musb/musb_gadget.c | 38 ++++++++++++++++++++++++++------------ 1 files changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 8c41a2e..6841f91 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -624,6 +624,7 @@ void musb_g_tx(struct musb *musb, u8 epnum) /* * Context: controller locked, IRQs blocked, endpoint selected */ + static void rxstate(struct musb *musb, struct musb_request *req) { const u8 epnum = req->epnum; @@ -634,6 +635,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 +685,16 @@ static void rxstate(struct musb *musb, struct musb_request *req) if (csr & MUSB_RXCSR_RXPKTRDY) { len = musb_readw(epio, MUSB_RXCOUNT); + + /* + * Enable DMA Mode 1 RX transfers only for endpoints using BULK transactions + */ + + if (musb_ep->type == USB_ENDPOINT_XFER_BULK && 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,10 +726,11 @@ 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 + if (use_mode_1) { csr |= MUSB_RXCSR_AUTOCLEAR; - /* csr |= MUSB_RXCSR_DMAMODE; */ + 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 @@ -725,26 +738,27 @@ static void rxstate(struct musb *musb, struct musb_request *req) */ musb_writew(epio, MUSB_RXCSR, csr | MUSB_RXCSR_DMAMODE); -#else + musb_writew(epio, MUSB_RXCSR, csr); + + } else { if (!musb_ep->hb_mult && musb_ep->hw_ep->rx_double_buffered) csr |= MUSB_RXCSR_AUTOCLEAR; -#endif + csr |= MUSB_RXCSR_DMAENAB; musb_writew(epio, MUSB_RXCSR, csr); + } if (request->actual < request->length) { int transfer_size = 0; -#ifdef USE_MODE1 + if (use_mode_1) { transfer_size = min(request->length - request->actual, channel->max_len); -#else + musb_ep->dma->desired_mode = 1; + } 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 - musb_ep->dma->desired_mode = 1; + musb_ep->dma->desired_mode = 0; + } use_dma = c->channel_program( channel,