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 B141AC433F5 for ; Mon, 28 Mar 2022 16:16:54 +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 DE37117B4; Mon, 28 Mar 2022 18:16:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DE37117B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1648484212; bh=+GRU5+zjx/jn/l4vBFsBpTQ0g6phxQ6QWi9IaN5Lamo=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TrcsrcGpDrbWVcM2JM/gtjn5MtLpHK2H9oXkl3bjT74b65J+vaZHxAaiD/WUgWZNG 1OahZb0wtOhQd3CIi7bsFBClvFZuWUsq/UgpgtYS0BQuS6D7W95YoL+pZS0rEIgxdI 1Pn4n254SVdpcSS+o46IyndY+w3gUuO45U/p548E= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 730B7F800CB; Mon, 28 Mar 2022 18:16:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CC1E3F8024C; Mon, 28 Mar 2022 18:16:00 +0200 (CEST) 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 9D70EF800FA for ; Mon, 28 Mar 2022 18:15:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9D70EF800FA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="aui3z9lU"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="bskkfPk2" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 43FA4210EE; Mon, 28 Mar 2022 16:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1648484153; 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=q4Xt99w9xbYhH0KUJ1KGjk1nQO3I91qbWeC7RgiTOTM=; b=aui3z9lUJWoZzWioOA8gh+7KdVc2GhaSTiJZeV/8K/6sR11p+AbaHSYw/F37iTj2PmKMpH OfD7F/F/FV9ox1gfV6AO3I8z5Hq5M8/PCmY4mj251JXBns0TSvyfwdf9atJudq0BD7aWJf XTPbQY3ekdaRKj1DhcgYMM3z5mp9ylM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1648484153; 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=q4Xt99w9xbYhH0KUJ1KGjk1nQO3I91qbWeC7RgiTOTM=; b=bskkfPk2ufk9FbJgwzGfb4xiY/0rkelwLXX7jkO+0rUVN/6D+4WWR0agYzQzWZhNquLwaz 7YscciewtgELbSCA== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 2DF91A3B82; Mon, 28 Mar 2022 16:15:53 +0000 (UTC) Date: Mon, 28 Mar 2022 18:15:53 +0200 Message-ID: From: Takashi Iwai To: Mohan Kumar D Subject: Re: [PATCH] ALSA: hda: Avoid unsol event during RPM suspending In-Reply-To: <7cbfca20-bd1a-9ca0-f0e2-2ecf5fa74f45@nvidia.com> References: <20220328091411.31488-1-mkumard@nvidia.com> <7f7934e6-137c-4d8d-049b-0ed5e57cf00b@nvidia.com> <7cbfca20-bd1a-9ca0-f0e2-2ecf5fa74f45@nvidia.com> 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 Cc: jonathanh@nvidia.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, linux-kernel@vger.kernel.org, tiwai@suse.com, thierry.reding@gmail.com, ville.syrjala@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, 28 Mar 2022 15:51:17 +0200, Mohan Kumar D wrote: > > > On 3/28/2022 4:27 PM, Takashi Iwai wrote: > > External email: Use caution opening links or attachments > > > > > > On Mon, 28 Mar 2022 12:19:03 +0200, > > Mohan Kumar D wrote: > >> > >> On 3/28/2022 3:12 PM, Takashi Iwai wrote: > >>> External email: Use caution opening links or attachments > >>> > >>> > >>> On Mon, 28 Mar 2022 11:14:11 +0200, > >>> Mohan Kumar wrote: > >>>> There is a corner case with unsol event handling during codec runtime > >>>> suspending state. When the codec runtime suspend call initiated, the > >>>> codec->in_pm atomic variable would be 0, currently the codec runtime > >>>> suspend function calls snd_hdac_enter_pm() which will just increments > >>>> the codec->in_pm atomic variable. Consider unsol event happened just > >>>> after this step and before snd_hdac_leave_pm() in the codec runtime > >>>> suspend function. The snd_hdac_power_up_pm() in the unsol event > >>>> flow in hdmi_present_sense_via_verbs() function would just increment > >>>> the codec->in_pm atomic variable without calling pm_runtime_get_sync > >>>> function. > >>>> > >>>> As codec runtime suspend flow is already in progress and in parallel > >>>> unsol event is also accessing the codec verbs, as soon as codec > >>>> suspend flow completes and clocks are switched off before completing > >>>> the unsol event handling as both functions doesn't wait for each other. > >>>> This will result in below errors > >>>> > >>>> [ 589.428020] tegra-hda 3510000.hda: azx_get_response timeout, switching > >>>> to polling mode: last cmd=0x505f2f57 > >>>> [ 589.428344] tegra-hda 3510000.hda: spurious response 0x80000074:0x5, > >>>> last cmd=0x505f2f57 > >>>> [ 589.428547] tegra-hda 3510000.hda: spurious response 0x80000065:0x5, > >>>> last cmd=0x505f2f57 > >>>> > >>>> To avoid this, the unsol event flow should not perform any codec verb > >>>> related operations during RPM_SUSPENDING state. > >>>> > >>>> Signed-off-by: Mohan Kumar > >>> Thanks, that's a hairy problem... > >>> > >>> The logic sounds good, but can we check the PM state before calling > >>> snd_hda_power_up_pm()? > >> If am not wrong, PM apis exposed either provide RPM_ACTIVE or > >> RPM_SUSPENDED status. Don't see anything which provides info on > >> RPM_SUSPENDING. We might need to exactly know this state to fix this > >> issue. > > Well, maybe my question wasn't clear. What I meant was that your > > change below > > > >> ret = snd_hda_power_up_pm(codec); > >> - if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) > >> + if ((ret < 0 && pm_runtime_suspended(dev)) || > >> + (dev->power.runtime_status == RPM_SUSPENDING)) > >> goto out; > > can be rather like: > > > >> + if (dev->power.runtime_status == RPM_SUSPENDING) > >> + return; > >> ret = snd_hda_power_up_pm(codec); > >> if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) > > so that it skips unneeded power up/down calls. > > > > Basically the state is set at drivers/base/power/runtime.c > > rpm_suspend() just before calling the device's runtime_suspend > > callback. So the state is supposed to be same before and after > > snd_hda_power_up_pm() in that case. > Thanks!, Make sense, will push the updated patch after testing with > latest suggestion. Thanks. Also don't forget to cover a case the test bot complained: the reference to power.runtime_status needs #ifdef CONFIG_PM. Takashi