From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7F80C433F5 for ; Mon, 17 Jan 2022 19:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242288AbiAQT4d (ORCPT ); Mon, 17 Jan 2022 14:56:33 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:48414 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbiAQT4c (ORCPT ); Mon, 17 Jan 2022 14:56:32 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 86BC6212BB; Mon, 17 Jan 2022 19:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1642449391; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VMmfVtWZfJayBoRg9IT/rKNycU3qQzjET9EY7uXPW80=; b=kbzExjsp4JpeHHwIZRJCubyF/IB1E/jmZSzeeILWAnQH75/TrSKIkX74WmASeiVmpn5j0b hYDbjjAU6EWNB287GSpgmzFMmPDLrQfUA6QaUP12xZqZCMi3vm+3npNuDXdwWjslx5Z16T b9JchkTF2qrH3GZiAWqLpKUcBYBjFiQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1642449391; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VMmfVtWZfJayBoRg9IT/rKNycU3qQzjET9EY7uXPW80=; b=IoKUbUflFJ6ZUB0IbLwWutrHc8uD1YJs4aDa5zqZ0YgZQ83wjCIxiIon5vDtG3qOTxXi8o 3fbo1HrBdYEh5zBQ== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 70B04A3B84; Mon, 17 Jan 2022 19:56:31 +0000 (UTC) Date: Mon, 17 Jan 2022 20:56:31 +0100 Message-ID: From: Takashi Iwai To: Pierre-Louis Bossart Cc: Christophe JAILLET , alsa-devel@alsa-project.org, Kai Vehmanen , Liam Girdwood , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Ranjani Sridharan , Takashi Iwai , Mark Brown , Bard Liao Subject: Re: [PATCH] ASoC: soc-pcm: use GFP_ATOMIC in dpcm_create_debugfs_state() In-Reply-To: References: 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/25.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 17 Jan 2022 18:11:42 +0100, Pierre-Louis Bossart wrote: > > > > On 1/17/22 2:49 AM, Takashi Iwai wrote: > > On Sun, 16 Jan 2022 12:18:17 +0100, > > Christophe JAILLET wrote: > >> > >> The commit below states that dpcm_be_connect() may be called from atomic > >> context. It changes a GFP_KERNEL into a GFP_ATOMIC to deal with it. > >> > >> Another memory allocation is done in dpcm_create_debugfs_state() which is > >> called by dpcm_be_connect(). Also use GFP_ATOMIC there to be consistent > >> and be compliant with atomic context. > >> > >> Fixes: d8a9c6e1f676 ("ASoC: soc-pcm: use GFP_ATOMIC for dpcm structure") > >> Signed-off-by: Christophe JAILLET > >> --- > >> Not clear to me how dpcm_be_connect() can be called from an atomic context, > >> though. But better safe than sorry. > > > > I don't think this no longer valid for the very latest code. > > The commit b7898396f4bb dropped the spurious dpcm_lock spinlock, so > > the code path you touched must be always sleepable. > > > > Similarly, the commit d8a9c6e1f676 can be reverted now. > > Can we really revert d8a9c6e1f676? > > We did propagate the non-atomic FE property to the BE, but if both FE > and BE are both atomic that constraint would be required, no? At the kzalloc() call in dpcm_be_connect, there is no spin lock involved. It's merely protected by card->pcm_mutex, instead. The spinlock is applied at the later call with snd_soc_pcm_stream_lock_irq() only for the list manipulations. (See it's *_irq(), not *_irqsave(); that means the context being sleepable at that point.) So, we can use GFP_KERNEL safely there. GFP_ATOMIC was needed in the past where dpcm_be_connect() itself is called in dpcm_lock spinlock. It was removed recently. Takashi > > > > > > thanks, > > > > Takashi > > > >> --- > >> sound/soc/soc-pcm.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c > >> index 7abfc48b26ca..1a536a2b9dc3 100644 > >> --- a/sound/soc/soc-pcm.c > >> +++ b/sound/soc/soc-pcm.c > >> @@ -212,7 +212,7 @@ static void dpcm_create_debugfs_state(struct snd_soc_dpcm *dpcm, int stream) > >> { > >> char *name; > >> > >> - name = kasprintf(GFP_KERNEL, "%s:%s", dpcm->be->dai_link->name, > >> + name = kasprintf(GFP_ATOMIC, "%s:%s", dpcm->be->dai_link->name, > >> stream ? "capture" : "playback"); > >> if (name) { > >> dpcm->debugfs_state = debugfs_create_dir( > >> -- > >> 2.32.0 > >> >