From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753477AbaESIhp (ORCPT ); Mon, 19 May 2014 04:37:45 -0400 Received: from cantor2.suse.de ([195.135.220.15]:51950 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750874AbaESIho (ORCPT ); Mon, 19 May 2014 04:37:44 -0400 Date: Mon, 19 May 2014 10:37:39 +0200 Message-ID: From: Takashi Iwai To: Lars-Peter Clausen Cc: Linux-ALSA , Vinod Koul , Jassi Brar , Linux Kernel Mailing List , dmaengine@vger.kernel.org, Dan Williams , Tushar Behera Subject: Re: [alsa-devel] [PATCH] dma: pl330: Add support for DMA_PAUSE command In-Reply-To: <5375EDC7.5070105@metafoo.de> References: <1400037830-21211-1-git-send-email-tushar.behera@linaro.org> <5373607D.2000200@metafoo.de> <537513A8.701@metafoo.de> <5375EDC7.5070105@metafoo.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Fri, 16 May 2014 12:51:51 +0200, Lars-Peter Clausen wrote: > > On 05/16/2014 07:49 AM, Takashi Iwai wrote: > > At Thu, 15 May 2014 21:21:12 +0200, > > Lars-Peter Clausen wrote: > >> > >> On 05/15/2014 02:01 PM, Tushar Behera wrote: > >>> On 14 May 2014 17:54, Lars-Peter Clausen wrote: > >>>> On 05/14/2014 02:07 PM, Tushar Behera wrote: > >>>>> > >>>>> On 14 May 2014 17:29, Jassi Brar wrote: > >>>>>> > >>>>>> On Wed, May 14, 2014 at 8:53 AM, Tushar Behera > >>>>>> wrote: > >>>>>>> > >>>>>>> While playing back audio, pmc_dmaengine requests the DMA channel to > >>>>>>> stop DMA transmission through DMA_PAUSE command. > >>>>>>> > >>>>>>> Currently PL330 driver doesn't support DMA pause command, leaving > >>>>>>> the DMA state inconsistent when the system resumes. Instead, it would > >>>>>>> be better to terminate the DMA transfer during suspend and restart > >>>>>>> again during resume. > >>>>>>> > >>>>>>> Tested with audio playback across a suspend-resume cycle. > >>>>>>> > >>>>>> What is pmc_dmaengine? How does DMA_PAUSE help, when there is no > >>>>>> DMA_RESUME? > >>>>>> > >>>>> > >>>>> Sorry, it is a typo. > >>>>> > >>>>> sound/core/pcm_dmaengine.c:snd_dmaengine_pcm_trigger() --> > >>>>> dmaengine_pause() is called during system suspend. > >>>> > >>>> > >>>> It is only called if the DMA driver has support for pausing and resuming DMA > >>>> transfers. Or at least that is the intention. > >>>> > >>>> - Lars > >>> > >>> During suspend, snd_dmaengine_pcm_trigger():SNDRV_PCM_TRIGGER_SUSPEND > >>> is called which unconditionally calls dmaengine_pause(). Should we > >>> update snd_dmaengine_pcm_trigger() to check for DMA pause/resume > >>> support and call dmaengine_pause() or dmaengine_terminate_all() > >>> accordingly? > >> > >> As far as I understand it we do not have to do anything for TRIGGER_SUSPEND > >> if we do not set the SNDRV_PCM_INFO_RESUME flag. It looks like > >> TRIGGER_SUSPEND is called unconditionally during suspend. But since the > >> error code is ignored it should be fine if we just call dmaengine_pause() > >> and that return -ENOSYS or similar. > > > > Well, TRIGGER_SUSPEND is issued by PCM core no matter whether > > SNDRV_PCM_INFO_RESUME flag is set or not. The resume behavior depends > > on the flag (SNDRV_PCM_TRIGGER_RESUME is issued if the flag is set, > > otherwise the normal setup is done by alsa-lib at resume), but the > > suspend is always triggered in the same way. > > > > So, PCM core assumes that the driver stops the stream somehow by > > SNDRV_PCM_TRIGGER_SUSPEND. > > Ok, so we should call terminate_all() when we get a > SNDRV_PCM_TRIGGER_SUSPEND if the dmaengine driver does not support pauseing > the transfer. Thanks for the clarification. > > On a related note it seems like it is still possible to get > PAUSE_PUSH/PAUSE_RELEASE events even if SNDRV_PCM_INFO_PAUSE is not set. Do > you have an idea what should be the right thing to do in such a case? Return > -ENOSYS? That's weird. We have already a check in snd_pcm_pre_pause() in pcm_native.c to filter only for substreams with SNDRV_PCM_INFO_PAUSE flag. Could you check in which code path it is triggered? thanks, Takashi