From patchwork Tue Dec 7 21:43:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Stuart X-Patchwork-Id: 384232 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB7Lh5gd025525 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 7 Dec 2010 21:43:27 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id oB7LfVKQ030842 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 7 Dec 2010 15:41:31 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id oB7LfUt5028207; Tue, 7 Dec 2010 15:41:30 -0600 (CST) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 1210380627; Tue, 7 Dec 2010 15:41:30 -0600 (CST) X-Original-To: Davinci-linux-open-source@linux.davincidsp.com Delivered-To: Davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id DF4DA80626 for ; Tue, 7 Dec 2010 15:41:28 -0600 (CST) Received: from red.ext.ti.com (localhost [127.0.0.1]) by dflp52.itg.ti.com (8.13.7/8.13.7) with ESMTP id oB7LfSIs020708 for ; Tue, 7 Dec 2010 15:41:28 -0600 (CST) Received: from psmtp.com (na3sys009amx259.postini.com [74.125.149.143]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id oB7LfSY7014310 for ; Tue, 7 Dec 2010 15:41:28 -0600 Received: from source ([69.43.201.109]) by na3sys009amx259.postini.com ([74.125.148.10]) with SMTP; Tue, 07 Dec 2010 13:41:28 PST Received: from [192.168.0.7] ([66.237.213.142]) by smtp.seektech.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 7 Dec 2010 13:41:40 -0800 Message-ID: <4CFEAA69.4030503@seektech.com> Date: Tue, 07 Dec 2010 13:43:05 -0800 From: Paul Stuart User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: linux-usb@vger.kernel.org Subject: [PATCH v2] USB: musb: Prevent Transmit Buffer Descriptor corruption X-OriginalArrivalTime: 07 Dec 2010 21:41:40.0420 (UTC) FILETIME=[885B5840:01CB9657] X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S: 3.46926/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: Davinci-linux-open-source@linux.davincidsp.com, sshtylyov@mvista.com, balbi@ti.com X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Dec 2010 21:43:27 +0000 (UTC) --- a/drivers/usb/musb/cppi_dma.c 2010-12-06 20:09:04.000000000 -0800 +++ b/drivers/usb/musb/cppi_dma.c 2010-12-07 11:22:04.000000000 -0800 @@ -625,6 +625,14 @@ cppi_next_tx_segment(struct musb *musb, * size; for RNDIS there _is_ only that last packet. */ for (i = 0; i < n_bds; ) { + + /* wait for DMA to release ownership of this bd */ + if (unlikely(bd->hw_options & CPPI_OWN_SET)) { + do { + cpu_relax(); + } while (bd->hw_options & CPPI_OWN_SET); + } + if (++i < n_bds && bd->next) bd->hw_next = bd->next->dma; else