From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH v2 0/2] Add snd_card_disconnect_sync() helper Date: Mon, 16 Oct 2017 17:37:15 +0200 Message-ID: References: <20171011101618.8736-1-tiwai@suse.de> <87fuanv70u.wl%kuninori.morimoto.gx@renesas.com> <87efq7v2qf.wl%kuninori.morimoto.gx@renesas.com> <87k1zvn8ci.wl%kuninori.morimoto.gx@renesas.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 6F4D8266D69 for ; Mon, 16 Oct 2017 17:37:17 +0200 (CEST) In-Reply-To: <87k1zvn8ci.wl%kuninori.morimoto.gx@renesas.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Kuninori Morimoto Cc: alsa-devel@alsa-project.org, Mark Brown List-Id: alsa-devel@alsa-project.org On Mon, 16 Oct 2017 04:26:42 +0200, Kuninori Morimoto wrote: > > > Hi Takashi > > > > I could confirm this by printing who's stop was called by local quick hack. > > > > > > Maybe timing reason, if kernel has Oops for some reasons, > > > then, both BE/FE snd_pcm_stop() are called. > > > If no Oops, BE snd_pcm_stop() only called. > > > > Any pending delayed work (like rtd->delayed_work)? > > This is flushed at soc_cleanup_card_resources(), but it's called at > > card removal, thus it's too late for the hot-removal of the > > component. > > Current my dirver used delayed_work, but we can control it > by snd_soc_runtime_ignore_pmdown_time(); > I think my driver now doesn't use delayed_work. > > But there is still issue. > I don't know detail, but it seems > snd_pcm_dev_disconnect() and snd_pcm_relase() are called > it the same time, both are calling snd_pcm_stop(). > > Then, snd_pcm_relase() side will calls > snd_pcm_detach_substream() and snd_pcm_dev_disconnect() side will die. This must be also specific to DPCM. Something is really wrong there. Basically snd_pcm_dev_disconnect() and snd_pcm_release() can't race since both are protected via pcm->open_mutex. snd_pcm_stop() calls are protected even more with substream lock. > Mark's suggestion (= hiding BE) can solve this ? Some of the issues might be addressed, yes, but I'm skeptical whether it covers all. The BE needs proper locking and refcounting that is coupled with the FE, I suppose. Takashi