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 433F0C433FE for ; Mon, 14 Nov 2022 14:27:05 +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 36419161F; Mon, 14 Nov 2022 15:26:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 36419161F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1668436023; bh=X1oa+xzcoyNn4knw1lgx9VihRmteQ7Hm+KkSpgRNymI=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=V5VVyAN+mci++9ZwV8C/5XfzzI0I05AuanZROuHT40KfcB6eyUP1zfjPUn0AvllUF AB1vyxaBI3kCk/4L0uoWPMapKmnqLOQxqab2fJHxYRrjBq7sMfT1BEZCpAoAeLNMX2 8mXvZ3mvVofbsiwWi4abBY8xzfTg5g131k8t+/i4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CB839F80245; Mon, 14 Nov 2022 15:26:12 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A5E32F80431; Mon, 14 Nov 2022 15:26:11 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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 5C485F800B8 for ; Mon, 14 Nov 2022 15:26:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5C485F800B8 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="T2IUx+tw"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Pev4hS0t" 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-out2.suse.de (Postfix) with ESMTPS id A2F4B2005C; Mon, 14 Nov 2022 14:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1668435968; 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=7hIDmsSTNdUxe/T4Z6QQMetz3vPTf5iMj5CVTpKdPWU=; b=T2IUx+tw0Qfmq2GkJ8mgl6iOkvg6RunWSxayp3JsOoh9xoBxjpkMDS/jFeQ0W/bGx4OSG1 mKaRpuSzAyixTd7Ha6Nm5byjKAGr4FyYzqLK9AWaZf+N95sCHHJk6/SS77W9CeCTo/pxN6 AQAabhy308pR+nySk3RCsPWIwQjg4/8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1668435968; 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=7hIDmsSTNdUxe/T4Z6QQMetz3vPTf5iMj5CVTpKdPWU=; b=Pev4hS0t8NRGugLxnxlHh6YU5NJiBlKe1QNh6RHqRCQCW0QIbAyQFioi0q/T3mRFM6dSFd z8NQtoRhBe70O7BA== 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 78F6713A92; Mon, 14 Nov 2022 14:26:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id FYnCHABQcmPWawAAMHmgww (envelope-from ); Mon, 14 Nov 2022 14:26:08 +0000 Date: Mon, 14 Nov 2022 15:26:08 +0100 Message-ID: <87r0y5394v.wl-tiwai@suse.de> From: Takashi Iwai To: Cezary Rojewski Subject: Re: [PATCH v2 2/2] ASoC: Intel: avs: Disconnect substream if suspend or resume fails In-Reply-To: References: <20221114113729.1022905-1-cezary.rojewski@intel.com> <20221114113729.1022905-3-cezary.rojewski@intel.com> <877czx4rkj.wl-tiwai@suse.de> 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: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, hdegoede@redhat.com, broonie@kernel.org, amadeuszx.slawinski@linux.intel.com 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, 14 Nov 2022 15:08:17 +0100, Cezary Rojewski wrote: > > > > On 2022-11-14 2:02 PM, Takashi Iwai wrote: > > On Mon, 14 Nov 2022 12:37:29 +0100, > > Cezary Rojewski wrote: > >> > >> To improve performance and overall system stability, suspend/resume > >> operations for ASoC cards always return success status and defer the > >> actual work. > >> > >> Because of that, if a substream fails to resume, userspace may still > >> attempt to invoke commands on it as from their perspective the operation > >> completed successfully. Set substream's state to DISCONNECTED to ensure > >> no further commands are attempted. > > ... > > > Hm, that might work, but note that, once when the stream is set with > > the disconnected state, it won't be taken back to the normal state any > > longer on most sound backends. That is, it'll be gone and won't > > revive unless you completely unload and reload the whole stuff. If > > that's the intended behavior, that's fine, of course. So just to make > > sure. > > Good point. > > Our intention: if we fail e.g.: on resume, we would like the framework > to invoke ->hw_free() and close us. Right now, if we pretend that > everything is okay, invalid actions can be performed on our > streams. This all comes down to userspace calling "just" > snd_pcm_resume(). If we had an option to opt-in to a _hw_params() + > _prepare() + _resume() path, then things would look differently. So you'd rather like to make the stream appearing and working after re-opening the stream again? Then DISCONNECTED state might be too strong. If the broken state could be recovered by the PCM PREPARE phase, then we may (ab-)use XRUN state, instead. Then application shall re-setup via PCM prepare call. But if hw_free/hw_params is required, it won't work. Other than that, there is no such PCM state that forces to close and re-open, I'm afraid. You can have an internal error state and let the stream returning an error at each operation, instead, too. And, creating a new PCM state is very difficult. It would influence way too much, IMO, as each application code has to be modified to handle the new PCM state. Takashi