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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C66A4C43217 for ; Mon, 28 Nov 2022 09:25:08 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DDA141699; Mon, 28 Nov 2022 10:24:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DDA141699 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669627506; bh=0irzzZHqocYuxw8duqMGPWFGZrxq1KwgiXzwXrKfIXY=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PJkOvlRdaZrWhPYAMKElspGlvJ0mBmLTaq/Uh2b9ux9RuWcVRkVhrW3PWxP6FjIvt 1cBGDYNhLRZRh9GCQhW3P8CPFh49/a3IzSvgICcu2T9NjPLLkuaDJwyF5hSplQ8usp nvckaDi/uMoDok+Uiq6jEsIHEonkuOhiFUKDz2SY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8AF01F801D8; Mon, 28 Nov 2022 10:24:16 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8F70BF8016E; Mon, 28 Nov 2022 10:24:14 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B1217F8016E for ; Mon, 28 Nov 2022 10:24:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B1217F8016E Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="cMKxSgkE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="e72l6gZ6" Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E10B321B0C; Mon, 28 Nov 2022 09:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669627447; 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=xRzcxDxljSZx2A2E00n+nkQ2uYUP1JqeGXcAzE3P+Dg=; b=cMKxSgkEZz8ekh6dppBYqPtKL9Q6yjSbFqyxxI/vWUU1e2V/gcEJMEjFgub2MaTOlGSCj1 rvmC27jw7pCvisIL7oTicTSMIMCgU9Twu0Xt70XKXJAZ3EMzzXH+8hG/A544Ma25z0rq2r AZlStKY4EW4cmIRSjmRYmVyk1FBbiUw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669627447; 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=xRzcxDxljSZx2A2E00n+nkQ2uYUP1JqeGXcAzE3P+Dg=; b=e72l6gZ6OYjS416WitkMJqqUkKXFiRC42TrJiIOQKz3+08Wn2Pd55rZ84q2R81qCEzTbTE lEW7UJfAS0hnoaBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A3A551326E; Mon, 28 Nov 2022 09:24:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +/QkJzd+hGN4egAAMHmgww (envelope-from ); Mon, 28 Nov 2022 09:24:07 +0000 Date: Mon, 28 Nov 2022 10:24:07 +0100 Message-ID: <87wn7fzb2g.wl-tiwai@suse.de> From: Takashi Iwai To: Ricardo Ribalda Subject: Re: [PATCH v3 0/2] ALSA: core: Fix deadlock when shutdown a frozen userspace In-Reply-To: <20221127-snd-freeze-v3-0-a2eda731ca14@chromium.org> References: <20221127-snd-freeze-v3-0-a2eda731ca14@chromium.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Cc: Len Brown , alsa-devel@alsa-project.org, Kai Vehmanen , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ranjani Sridharan , Takashi Iwai , Mark Brown , Pavel Machek , "Joel Fernandes \(Google\)" , Pierre-Louis Bossart X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Mon, 28 Nov 2022 10:10:12 +0100, Ricardo Ribalda wrote: > > Since 83bfc7e793b5 ("ASoC: SOF: core: unregister clients and machine drivers in .shutdown") > we wait for userspace to close its fds. IMO, the fix above brought more problem. If you'd need to want to avoid later accesses during shutdown, the driver should rather just disconnect devices without waiting for the user-space completion. And, for that, a simple call of snd_card_disconnect() should suffice. > But that will never occur with a frozen userspace (like during kexec()). > > Lets detect the frozen userpace and act accordingly. ... and skipping the user-space sync at snd_card_disconnect_sync() as of this patch set is a dangerous move, I'm afraid. The user-space gets frozen also at the normal suspend/resume, and it implies that the sync will be lost even for the normal PM, too (although it must be a very corner case). thanks, Takashi > > To: Jaroslav Kysela > To: Takashi Iwai > To: "Rafael J. Wysocki" > To: Pavel Machek > To: Len Brown > To: Kai Vehmanen > To: Ranjani Sridharan > To: Pierre-Louis Bossart > To: Mark Brown > Cc: alsa-devel@alsa-project.org > Cc: linux-kernel@vger.kernel.org > Cc: "Joel Fernandes (Google)" > Cc: linux-pm@vger.kernel.org > Signed-off-by: Ricardo Ribalda > --- > Changes in v3: > - Wrap pm_freezing in a function > - Link to v2: https://lore.kernel.org/r/20221127-snd-freeze-v2-0-d8a425ea9663@chromium.org > > Changes in v2: > - Only use pm_freezing if CONFIG_FREEZER > - Link to v1: https://lore.kernel.org/r/20221127-snd-freeze-v1-0-57461a366ec2@chromium.org > > --- > Ricardo Ribalda (2): > freezer: Add processes_frozen() > ALSA: core: Fix deadlock when shutdown a frozen userspace > > include/linux/freezer.h | 2 ++ > kernel/freezer.c | 11 +++++++++++ > sound/core/init.c | 13 +++++++++++++ > 3 files changed, 26 insertions(+) > --- > base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4 > change-id: 20221127-snd-freeze-1ee143228326 > > Best regards, > -- > Ricardo Ribalda > 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 B0B74C4332F for ; Mon, 28 Nov 2022 09:24:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229722AbiK1JYP (ORCPT ); Mon, 28 Nov 2022 04:24:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbiK1JYO (ORCPT ); Mon, 28 Nov 2022 04:24:14 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A28C0E3; Mon, 28 Nov 2022 01:24:10 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E10B321B0C; Mon, 28 Nov 2022 09:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669627447; 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=xRzcxDxljSZx2A2E00n+nkQ2uYUP1JqeGXcAzE3P+Dg=; b=cMKxSgkEZz8ekh6dppBYqPtKL9Q6yjSbFqyxxI/vWUU1e2V/gcEJMEjFgub2MaTOlGSCj1 rvmC27jw7pCvisIL7oTicTSMIMCgU9Twu0Xt70XKXJAZ3EMzzXH+8hG/A544Ma25z0rq2r AZlStKY4EW4cmIRSjmRYmVyk1FBbiUw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669627447; 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=xRzcxDxljSZx2A2E00n+nkQ2uYUP1JqeGXcAzE3P+Dg=; b=e72l6gZ6OYjS416WitkMJqqUkKXFiRC42TrJiIOQKz3+08Wn2Pd55rZ84q2R81qCEzTbTE lEW7UJfAS0hnoaBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A3A551326E; Mon, 28 Nov 2022 09:24:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +/QkJzd+hGN4egAAMHmgww (envelope-from ); Mon, 28 Nov 2022 09:24:07 +0000 Date: Mon, 28 Nov 2022 10:24:07 +0100 Message-ID: <87wn7fzb2g.wl-tiwai@suse.de> From: Takashi Iwai To: Ricardo Ribalda Cc: Takashi Iwai , Len Brown , Pierre-Louis Bossart , Kai Vehmanen , Ranjani Sridharan , Mark Brown , Jaroslav Kysela , Pavel Machek , "Rafael J. Wysocki" , alsa-devel@alsa-project.org, "Joel Fernandes (Google)" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: Re: [PATCH v3 0/2] ALSA: core: Fix deadlock when shutdown a frozen userspace In-Reply-To: <20221127-snd-freeze-v3-0-a2eda731ca14@chromium.org> References: <20221127-snd-freeze-v3-0-a2eda731ca14@chromium.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Mon, 28 Nov 2022 10:10:12 +0100, Ricardo Ribalda wrote: > > Since 83bfc7e793b5 ("ASoC: SOF: core: unregister clients and machine drivers in .shutdown") > we wait for userspace to close its fds. IMO, the fix above brought more problem. If you'd need to want to avoid later accesses during shutdown, the driver should rather just disconnect devices without waiting for the user-space completion. And, for that, a simple call of snd_card_disconnect() should suffice. > But that will never occur with a frozen userspace (like during kexec()). > > Lets detect the frozen userpace and act accordingly. ... and skipping the user-space sync at snd_card_disconnect_sync() as of this patch set is a dangerous move, I'm afraid. The user-space gets frozen also at the normal suspend/resume, and it implies that the sync will be lost even for the normal PM, too (although it must be a very corner case). thanks, Takashi > > To: Jaroslav Kysela > To: Takashi Iwai > To: "Rafael J. Wysocki" > To: Pavel Machek > To: Len Brown > To: Kai Vehmanen > To: Ranjani Sridharan > To: Pierre-Louis Bossart > To: Mark Brown > Cc: alsa-devel@alsa-project.org > Cc: linux-kernel@vger.kernel.org > Cc: "Joel Fernandes (Google)" > Cc: linux-pm@vger.kernel.org > Signed-off-by: Ricardo Ribalda > --- > Changes in v3: > - Wrap pm_freezing in a function > - Link to v2: https://lore.kernel.org/r/20221127-snd-freeze-v2-0-d8a425ea9663@chromium.org > > Changes in v2: > - Only use pm_freezing if CONFIG_FREEZER > - Link to v1: https://lore.kernel.org/r/20221127-snd-freeze-v1-0-57461a366ec2@chromium.org > > --- > Ricardo Ribalda (2): > freezer: Add processes_frozen() > ALSA: core: Fix deadlock when shutdown a frozen userspace > > include/linux/freezer.h | 2 ++ > kernel/freezer.c | 11 +++++++++++ > sound/core/init.c | 13 +++++++++++++ > 3 files changed, 26 insertions(+) > --- > base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4 > change-id: 20221127-snd-freeze-1ee143228326 > > Best regards, > -- > Ricardo Ribalda >