Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755004AbaDPUIQ (ORCPT ); Wed, 16 Apr 2014 16:08:16 -0400 Received: from smtprelay2.synopsys.com ([198.182.60.111]:55717 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751604AbaDPUIN (ORCPT ); Wed, 16 Apr 2014 16:08:13 -0400 From: Paul Zimmerman To: sundeep subbaraya , "balbi@ti.com" CC: Subbaraya Sundeep Bhatta , "Greg Kroah-Hartman" , Michal Simek , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , Subbaraya Sundeep Bhatta Subject: RE: [PATCH v2 2/2] usb: gadget: Add xilinx axi usb2 device support Thread-Topic: [PATCH v2 2/2] usb: gadget: Add xilinx axi usb2 device support Thread-Index: AQHPWWCF5z+pPb9Pf0GlHOqwGhCN35sUq20g Date: Wed, 16 Apr 2014 20:08:03 +0000 Message-ID: References: <1396510519-8555-1-git-send-email-sbhatta@xilinx.com> <113d0620-4003-417d-806b-0b79ae692829@VA3EHSMHS023.ehs.local> <20140403145853.GD14162@saruman.home> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.9.64.241] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id s3GK8SfL008188 > From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of sundeep subbaraya > Sent: Wednesday, April 16, 2014 3:39 AM > > Hi Felipe, > > On Thu, Apr 3, 2014 at 8:28 PM, Felipe Balbi wrote: > > >> +static int start_dma(struct xusb_ep *ep, u32 src, u32 dst, u32 length) > > > > please prepend this with xudc_, it makes tracing a lot easier. > > > >> +{ > >> + struct xusb_udc *udc; > >> + int rc = 0; > >> + unsigned long timeout; > >> + > >> + udc = ep->udc; > >> + /* > >> + * Set the addresses in the DMA source and > >> + * destination registers and then set the length > >> + * into the DMA length register. > >> + */ > >> + udc->write_fn(udc->base_address, XUSB_DMA_DSAR_ADDR_OFFSET, src); > >> + udc->write_fn(udc->base_address, XUSB_DMA_DDAR_ADDR_OFFSET, dst); > >> + udc->write_fn(udc->base_address, XUSB_DMA_LENGTH_OFFSET, length); > >> + > >> + /* > >> + * Wait till DMA transaction is complete and > >> + * check whether the DMA transaction was > >> + * successful. > >> + */ > >> + while ((udc->read_fn(ep->udc->base_address + XUSB_DMA_STATUS_OFFSET) & > >> + XUSB_DMA_DMASR_BUSY) == XUSB_DMA_DMASR_BUSY) { > >> + timeout = jiffies + 10000; > >> + > >> + if (time_after(jiffies, timeout)) { > >> + rc = -ETIMEDOUT; > >> + goto clean; > >> + } > >> + } > > > > don't you get an IRQ for DMA completion ? If you do, you could be using > > wait_for_completion() > > This function is called in interrupt context when buffer is ready or > free. It initiates > DMA to transfer data from IP buffer to memory. Hence it waits in busy > loop till DMA > completes If this function is called in interrupt context, then you can't use jiffies for your timeout, since jiffies may not get updated while in interrupt context. -- Paul ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?