From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752733AbbJTMga (ORCPT ); Tue, 20 Oct 2015 08:36:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:35851 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752706AbbJTMgY (ORCPT ); Tue, 20 Oct 2015 08:36:24 -0400 Date: Tue, 20 Oct 2015 14:36:21 +0200 Message-ID: From: Takashi Iwai To: Lars-Peter Clausen Cc: Vinod Koul , alsa-devel@alsa-project.org, Russell King , Shengjiu Wang , Laurent Pinchart , Dan Williams , Jonah Petri , Matt Campbell , Qiao Zhou , Kuninori Morimoto , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] ALSA: pcm_dmaengine: Properly synchronize DMA on shutdown In-Reply-To: <56262810.3040201@metafoo.de> References: <1445334391-12272-1-git-send-email-lars@metafoo.de> <1445334391-12272-5-git-send-email-lars@metafoo.de> <56262810.3040201@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.5 (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 On Tue, 20 Oct 2015 13:40:00 +0200, Lars-Peter Clausen wrote: > > On 10/20/2015 01:17 PM, Takashi Iwai wrote: > > On Tue, 20 Oct 2015 11:46:31 +0200, > > Lars-Peter Clausen wrote: > >> > >> Use the new dmaengine_synchronize() function to make sure that all complete > >> callbacks have finished running before the runtime data, which is accessed > >> in the completed callback, is freed. > >> > >> This fixes a long standing use-after-free race condition that has been > >> observed on some systems. > > > > What if a substream is restarted immediately after the stop? > > > > What can happen is that you get a complete callback and the associated > snd_pcm_period_elapsed() too early, before the period has actually elapsed, > but I don't think that this is a problem if the DMA driver properly > implements residue reporting. > > This fails if we rely on period counting, but that is broken anyway and > already prone to other race conditions. > > I've tested this series with xrun injection and some modifications to the > DMA driver to always trigger the race condition when the stream is stopped. > And I've not seen any issues after the transfer re-started. (There is a > dead-lock condition though but that does not seem to be related to this series) OK, then I'm fine with the changes. I suppose this will go through dmaengine tree? If so, feel free to take my ack: Reviewed-by: Takashi Iwai thanks, Takashi