From patchwork Sun Oct 31 05:25:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Gadiyar X-Patchwork-Id: 293212 X-Patchwork-Delegate: me@felipebalbi.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9V5T9mM009411 for ; Sun, 31 Oct 2010 05:29:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751412Ab0JaF0Y (ORCPT ); Sun, 31 Oct 2010 01:26:24 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:38029 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964Ab0JaF0X (ORCPT ); Sun, 31 Oct 2010 01:26:23 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o9V5Q8Nh032531 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 31 Oct 2010 00:26:10 -0500 Received: from linfarm476.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o9V5Q0MI013221; Sun, 31 Oct 2010 10:56:01 +0530 (IST) Received: from linfarm476.india.ti.com (localhost [127.0.0.1]) by linfarm476.india.ti.com (8.12.11/8.12.11) with ESMTP id o9V5Q0qp018728; Sun, 31 Oct 2010 10:56:00 +0530 Received: (from a0393673@localhost) by linfarm476.india.ti.com (8.12.11/8.12.11/Submit) id o9V5Pxtl018723; Sun, 31 Oct 2010 10:55:59 +0530 From: Anand Gadiyar To: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, Greg Kroah-Hartman Cc: Anand Gadiyar , Felipe Balbi , Ming Lei , Ajay Kumar Gupta , Mike Frysinger Subject: [PATCH RFC] usb: musb: fail unaligned DMA transfers on v1.8 and above Date: Sun, 31 Oct 2010 10:55:59 +0530 Message-Id: <1288502759-18618-1-git-send-email-gadiyar@ti.com> X-Mailer: git-send-email 1.5.6.6 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.3 (demeter1.kernel.org [140.211.167.41]); Sun, 31 Oct 2010 05:29:09 +0000 (UTC) Index: mainline/drivers/usb/musb/musbhsdma.c =================================================================== --- mainline.orig/drivers/usb/musb/musbhsdma.c +++ mainline/drivers/usb/musb/musbhsdma.c @@ -158,6 +158,8 @@ static int dma_channel_program(struct dm dma_addr_t dma_addr, u32 len) { struct musb_dma_channel *musb_channel = channel->private_data; + struct musb_dma_controller *controller = musb_channel->controller; + struct musb *musb = controller->private_data; DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n", musb_channel->epnum, @@ -167,6 +169,18 @@ static int dma_channel_program(struct dm BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || channel->status == MUSB_DMA_STATUS_BUSY); + /* + * The DMA engine in RTL1.8 and above cannot handle + * DMA addresses that are not aligned to a 4 byte boundary. + * It ends up masking the last two bits of the address + * programmed in DMA_ADDR. + * + * Fail such DMA transfers, so that the backup PIO mode + * can carry out the transfer + */ + if ((musb->hwvers >= MUSB_HWVERS_1800) && (dma_addr %4)) + return false; + channel->actual_len = 0; musb_channel->start_addr = dma_addr; musb_channel->len = len;