Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5593123pxb; Mon, 28 Mar 2022 14:41:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1Z2FwcA7Nt3YjkeZaA1kjqjiXREXCUwML6xSavAhfqFCCaoiDMdlhwtIRRTXQZ7wv2hVh X-Received: by 2002:a05:6102:8:b0:325:6b5c:1332 with SMTP id j8-20020a056102000800b003256b5c1332mr10701448vsp.16.1648503696815; Mon, 28 Mar 2022 14:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648503696; cv=none; d=google.com; s=arc-20160816; b=FCtrlz3baIS8TDspIckqJ81GcWjsowak8GVreUBST1cxHpWmZ6HOamYp7HDzRyDIm6 /NTnHWhKGBfEz0iFWZ1NdajFYAohj+XoHh3/amM8cxOvZJqu6LT65NHoDUp/r6p/zviH VtJE6c1zvC4CNkpYr/X2HlUH2Jc4mqKkWe+HbkMioOYQu5upBDvLL5lm3JTL8Qs1WpT4 uPZGQRWKR++E7qesfeAtygzNO8VAw7GTJDMfCMNCiB3SYsIz6MZVcnMx6Ji6ut9PXNeQ IbZ50ALp9O1Ur6ddOnrzAnBMNGPNPQiXk2SnMaLaRx9NeOvLkHwPuTk8QuHA+1itdPr3 fwiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=peJ0z6q2TZF5h50sCrBHKMakmwhauyyZ6IVdxsum2D0=; b=eMD5DQQ98jNqXeVb54PBgDUKaQlKWsfgLEx/v3AnpzfLY45FnqGoZ4I1Iqd+OBxmTB TG5+KRkE7FtYxy8DPjIyp/Xt1PRkkZpBpnJFa10birXSC57fhC3sJ95EcAVZoCwlKVRy oViYhIqZUaeC2jqV0Mrf9AjrBN0s3xwI8GFSV4nqfOHAMeGzpjNJY+BInNB0i+ozQlfH oBH8qIZKypJ9FPX+Abt7NnVDYtcRutecaNXTQcNgLMROveEYGOMvF3bZr1kOjJkgr373 noSEiOTlnaCe6/Ve+menY7fWPRPyPKud8qkbS/P/K9XmVDISDakaPUVWVT1y4dDQbywP mRzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=H0om378W; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=3NOl+41g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q9-20020a67b049000000b003253c94bc6esi3149010vsh.209.2022.03.28.14.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:41:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=H0om378W; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=3NOl+41g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7430A7D00D; Mon, 28 Mar 2022 14:18:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240386AbiC1K7P (ORCPT + 99 others); Mon, 28 Mar 2022 06:59:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235017AbiC1K7N (ORCPT ); Mon, 28 Mar 2022 06:59:13 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68C8C54FA6 for ; Mon, 28 Mar 2022 03:57:32 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id AE45E1F37E; Mon, 28 Mar 2022 10:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1648465051; 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=peJ0z6q2TZF5h50sCrBHKMakmwhauyyZ6IVdxsum2D0=; b=H0om378WUMbRT+cGKW1yzk8Jt+FgvSEBIh4GQCBWHNRd9ytWVEa8Hdmm9GFBQL4SGYXKvN R5KZ/69FdVG/RspCVUoh5gSa6wXJG8bfDNu7RExWUBCqEDDOVCCVab5B6NoRlF2rYNkF59 gofdE0aE75N4d/0Skl6DBmsHHe2VW7U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1648465051; 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=peJ0z6q2TZF5h50sCrBHKMakmwhauyyZ6IVdxsum2D0=; b=3NOl+41gE5k/2e1ShJXAw5Uwtr8x76vp3BzgSiQhuJwzxH8OFYtJ6FatnSUjofWDvdcmes oyuveSemLwMXFVCw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 737C1A3B89; Mon, 28 Mar 2022 10:57:31 +0000 (UTC) Date: Mon, 28 Mar 2022 12:57:31 +0200 Message-ID: From: Takashi Iwai To: Mohan Kumar D Cc: tiwai@suse.com, kai.vehmanen@linux.intel.com, perex@perex.cz, ville.syrjala@linux.intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, thierry.reding@gmail.com, jonathanh@nvidia.com Subject: Re: [PATCH] ALSA: hda: Avoid unsol event during RPM suspending In-Reply-To: <7f7934e6-137c-4d8d-049b-0ed5e57cf00b@nvidia.com> References: <20220328091411.31488-1-mkumard@nvidia.com> <7f7934e6-137c-4d8d-049b-0ed5e57cf00b@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 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, Takashi