Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753412AbbKCLGf (ORCPT ); Tue, 3 Nov 2015 06:06:35 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:16030 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752380AbbKCLGb (ORCPT ); Tue, 3 Nov 2015 06:06:31 -0500 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 03 Nov 2015 02:56:10 -0800 Subject: Re: [PATCH V3 2/2] dmaengine: tegra-adma: Add support for Tegra210 ADMA To: Andy Shevchenko References: <1444980919-20331-1-git-send-email-jonathanh@nvidia.com> <1444980919-20331-3-git-send-email-jonathanh@nvidia.com> <56378DB1.4020107@nvidia.com> CC: Laxman Dewangan , Vinod Koul , Stephen Warren , Thierry Reding , Alexandre Courbot , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , "Kumar Gala" , dmaengine , "linux-tegra@vger.kernel.org" , "linux-kernel@vger.kernel.org" From: Jon Hunter Message-ID: <56389524.6090300@nvidia.com> Date: Tue, 3 Nov 2015 11:06:12 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <56378DB1.4020107@nvidia.com> X-Originating-IP: [10.21.132.106] X-ClientProxiedBy: UKMAIL101.nvidia.com (10.26.138.13) To UKMAIL101.nvidia.com (10.26.138.13) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2692 Lines: 76 On 02/11/15 16:22, Jon Hunter wrote: > On 29/10/15 21:03, Andy Shevchenko wrote: >> On Fri, Oct 16, 2015 at 10:35 AM, Jon Hunter wrote: >>> Add support for the Tegra210 Audio DMA controller that is used for >>> transferring data between system memory and the Audio sub-system. >>> The driver only supports cyclic transfers because this is being solely >>> used for audio. >>> >>> This driver is based upon the work by Dara Ramesh . [snip] >>> +static int tegra_adma_alloc_chan_resources(struct dma_chan *dc) >>> +{ >>> + struct tegra_adma_chan *tdc = to_tegra_adma_chan(dc); >>> + int ret; >>> + >>> + ret = pm_runtime_get_sync(tdc2dev(tdc)); >>> + if (ret) >>> + return ret; >>> + >>> + dma_cookie_init(&tdc->vc.chan); >>> + tdc->sconfig_valid = false; >>> + >>> + return 0; >>> +} >>> + >>> +static void tegra_adma_free_chan_resources(struct dma_chan *dc) >>> +{ >>> + struct tegra_adma_chan *tdc = to_tegra_adma_chan(dc); >>> + >>> + if (tdc->desc) >>> + tegra_adma_terminate_all(dc); >> >> Seems after Lars' patchset be merged this will become redundant. >> And you may call this unconditionally of course. > > Ok. > >>> + >>> + tdc->sconfig_valid = false; >>> + vchan_free_chan_resources(&tdc->vc); >>> + >>> + pm_runtime_put(tdc2dev(tdc)); >> >> pm_runtime_get_sync() in alloc() till pm_runtime_put() in free() seems >> too much to cover in time. Imagine if user allocates resources, but >> will never use them. How possible to suspend device? > > In the current use-case (for audio) the dma channel is allocated and > freed everytime audio is started and stopped. However, if audio is > active at the time of suspend then yes it would block. May be I can move > this to the start/stop of the ADMA. I have been looking at this and although I could potentially improve this from a power perspective, I would need to ensure I handle all potential races (ie between interrupts and turning off clocks). It is do-able, but for now I would prefer to leave as is. The rationale being that the sole purpose of the DMA is for audio and in the current use case the DMA channels are acquired and freed when audio is started and stopped. I have also looked at a few other DMA drivers and several all seem to do the same. That is turn on clocks in allocate and turn them off in the free. Cheers Jon -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/