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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C9A7C433DF for ; Tue, 2 Jun 2020 12:46:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50248206A2 for ; Tue, 2 Jun 2020 12:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727055AbgFBMqW (ORCPT ); Tue, 2 Jun 2020 08:46:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:50626 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbgFBMqV (ORCPT ); Tue, 2 Jun 2020 08:46:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 17CF8ABD1; Tue, 2 Jun 2020 12:46:22 +0000 (UTC) Date: Tue, 02 Jun 2020 14:46:19 +0200 Message-ID: From: Takashi Iwai To: Macpaul Lin Cc: Jaroslav Kysela , Takashi Iwai , "Matthias Brugger" , Alexander Tsoy , "Johan Hovold" , Hui Wang , Szabolcs =?UTF-8?B?U3rFkWtl?= , , , Mediatek WSD Upstream , Macpaul Lin , , , Subject: Re: [PATCH] sound: usb: pcm: fix incorrect power state when playing sound after PM_AUTO suspend In-Reply-To: <1591098821-17910-1-git-send-email-macpaul.lin@mediatek.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 02 Jun 2020 13:53:41 +0200, Macpaul Lin wrote: > > This patch fix incorrect power state changed by usb_audio_suspend() > when CONFIG_PM is enabled. > > After receiving suspend PM message with auto flag, usb_audio_suspend() > change card's power state to SNDRV_CTL_POWER_D3hot. Only when the other > resume PM message with auto flag can change power state to > SNDRV_CTL_POWER_D0 in __usb_audio_resume(). > > However, when system is not under auto suspend, resume PM message with > auto flag might not be able to receive on time which cause the power > state was incorrect. At this time, if a player starts to play sound, > will cause snd_usb_pcm_open() to access the card and setup_hw_info() will > resume the card. > > But even the card is back to work and all function normal, the power > state is still in SNDRV_CTL_POWER_D3hot. Hm, in exactly which situation does this happen? I still don't get it. Could you elaborate how to trigger this? > Which cause the infinite loop > happened in snd_power_wait() to check the power state. Thus the > successive setting ioctl cannot be passed to card. > > Hence we suggest to change power state to SNDRV_CTL_POWER_D0 when card > has been resumed successfully. This doesn't look like a right solution for the problem, sorry. The card PM status must be recovered to D0 when the autoresume succeeds. If not, something is broken there, and it must be fixed instead of fiddling the status flag externally. thanks, Takashi > > Signed-off-by: Macpaul Lin > --- > sound/usb/pcm.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > index a4e4064..d667ecb 100644 > --- a/sound/usb/pcm.c > +++ b/sound/usb/pcm.c > @@ -1322,6 +1322,17 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre > if (err < 0) > return err; > > + /* fix incorrect power state when resuming by open and later ioctls */ > + if (IS_ENABLED(CONFIG_PM) && > + snd_power_get_state(subs->stream->chip->card) > + == SNDRV_CTL_POWER_D3hot) { > + /* set these variables for power state correction */ > + subs->stream->chip->autosuspended = 0; > + subs->stream->chip->num_suspended_intf = 1; > + dev_info(&subs->dev->dev, > + "change power state from D3hot to D0\n"); > + } > + > return snd_usb_autoresume(subs->stream->chip); > } > > -- > 1.7.9.5 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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 913D7C433E0 for ; Tue, 2 Jun 2020 12:47:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 197CB206A4 for ; Tue, 2 Jun 2020 12:47:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="RKDixqTM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 197CB206A4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 9D58C82B; Tue, 2 Jun 2020 14:46:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9D58C82B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591102038; bh=UJptocfj9K9DllMbZIS5M5yhLoHcEMEXgSIlNoYKLXc=; h=Date:From:To:Subject:In-Reply-To:Cc:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From; b=RKDixqTMn77BYLsUMBJdv2tcvOAUBZPiOgjsPPNrgc/VOZngmGeXum9eH2USVHlLw 22TJOUgkSckCppGngyFrqV0Ztr5cyGzrpCj/F0Pdb4SKPKXBXA7ccOoVPxxaZVMASj /UJRjW0RtiVmluBE0LBlNlvaQCf+6I6I4cEY8EvA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 30E98F8026F; Tue, 2 Jun 2020 14:46:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C9AD8F80260; Tue, 2 Jun 2020 14:46:26 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CA17BF80260 for ; Tue, 2 Jun 2020 14:46:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CA17BF80260 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 17CF8ABD1; Tue, 2 Jun 2020 12:46:22 +0000 (UTC) Date: Tue, 02 Jun 2020 14:46:19 +0200 Message-ID: From: Takashi Iwai To: Macpaul Lin Subject: Re: [PATCH] sound: usb: pcm: fix incorrect power state when playing sound after PM_AUTO suspend In-Reply-To: <1591098821-17910-1-git-send-email-macpaul.lin@mediatek.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: alsa-devel@alsa-project.org, Mediatek WSD Upstream , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold , Takashi Iwai , Hui Wang , Alexander Tsoy , linux-mediatek@lists.infradead.org, Matthias Brugger , Macpaul Lin , Szabolcs =?UTF-8?B?U3rFkWtl?= , linux-arm-kernel@lists.infradead.org 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 Tue, 02 Jun 2020 13:53:41 +0200, Macpaul Lin wrote: > > This patch fix incorrect power state changed by usb_audio_suspend() > when CONFIG_PM is enabled. > > After receiving suspend PM message with auto flag, usb_audio_suspend() > change card's power state to SNDRV_CTL_POWER_D3hot. Only when the other > resume PM message with auto flag can change power state to > SNDRV_CTL_POWER_D0 in __usb_audio_resume(). > > However, when system is not under auto suspend, resume PM message with > auto flag might not be able to receive on time which cause the power > state was incorrect. At this time, if a player starts to play sound, > will cause snd_usb_pcm_open() to access the card and setup_hw_info() will > resume the card. > > But even the card is back to work and all function normal, the power > state is still in SNDRV_CTL_POWER_D3hot. Hm, in exactly which situation does this happen? I still don't get it. Could you elaborate how to trigger this? > Which cause the infinite loop > happened in snd_power_wait() to check the power state. Thus the > successive setting ioctl cannot be passed to card. > > Hence we suggest to change power state to SNDRV_CTL_POWER_D0 when card > has been resumed successfully. This doesn't look like a right solution for the problem, sorry. The card PM status must be recovered to D0 when the autoresume succeeds. If not, something is broken there, and it must be fixed instead of fiddling the status flag externally. thanks, Takashi > > Signed-off-by: Macpaul Lin > --- > sound/usb/pcm.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > index a4e4064..d667ecb 100644 > --- a/sound/usb/pcm.c > +++ b/sound/usb/pcm.c > @@ -1322,6 +1322,17 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre > if (err < 0) > return err; > > + /* fix incorrect power state when resuming by open and later ioctls */ > + if (IS_ENABLED(CONFIG_PM) && > + snd_power_get_state(subs->stream->chip->card) > + == SNDRV_CTL_POWER_D3hot) { > + /* set these variables for power state correction */ > + subs->stream->chip->autosuspended = 0; > + subs->stream->chip->num_suspended_intf = 1; > + dev_info(&subs->dev->dev, > + "change power state from D3hot to D0\n"); > + } > + > return snd_usb_autoresume(subs->stream->chip); > } > > -- > 1.7.9.5 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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAFD6C433DF for ; Tue, 2 Jun 2020 12:46:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E4C6206A4 for ; Tue, 2 Jun 2020 12:46:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="X7s9OEgo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E4C6206A4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:Subject:To: From:Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=15fW90D+WAe9rC1sJbvlm/yMBbgwhb1ITzRO11n7M70=; b=X7s9OEgoD0trRv nsoLfGVD8qZVTLqFQUU2guwX/k/tRvur4XjhY/r5yV2diMbG8EgLEh1NdVftfYbjvOMFq8Qw1LC5+ 8sFbyVi1vEgA6X4uLPQ1p5EAnECdNZnyF6KHfe0LBzJAdYUiEhy1tc29MSnmOh510Q7hS57bXS2dL fAkj79Aj2QcjXFXbjIpp5uJgcbs90r04pkMSIHur/+e0ZlCDc2PYsppZjzfp07R6+C8iii4mHI5tW XAdVGnMthUrBSdhwZPdhL6hlIh7RZonZsm90X3giBSLX8dvFzx/LibVD0v3Z4rJrEj0CYFAzJMd60 BPjoHGW8yzfCXCaewLAg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jg6JO-00006h-Si; Tue, 02 Jun 2020 12:46:35 +0000 Received: from mx2.suse.de ([195.135.220.15]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jg6JE-0008Pq-Ei; Tue, 02 Jun 2020 12:46:28 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 17CF8ABD1; Tue, 2 Jun 2020 12:46:22 +0000 (UTC) Date: Tue, 02 Jun 2020 14:46:19 +0200 Message-ID: From: Takashi Iwai To: Macpaul Lin Subject: Re: [PATCH] sound: usb: pcm: fix incorrect power state when playing sound after PM_AUTO suspend In-Reply-To: <1591098821-17910-1-git-send-email-macpaul.lin@mediatek.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") X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200602_054624_646922_9DD228BF X-CRM114-Status: GOOD ( 23.05 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, Mediatek WSD Upstream , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold , Takashi Iwai , Hui Wang , Alexander Tsoy , linux-mediatek@lists.infradead.org, Matthias Brugger , Macpaul Lin , Jaroslav Kysela , Szabolcs =?UTF-8?B?U3rFkWtl?= , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On Tue, 02 Jun 2020 13:53:41 +0200, Macpaul Lin wrote: > > This patch fix incorrect power state changed by usb_audio_suspend() > when CONFIG_PM is enabled. > > After receiving suspend PM message with auto flag, usb_audio_suspend() > change card's power state to SNDRV_CTL_POWER_D3hot. Only when the other > resume PM message with auto flag can change power state to > SNDRV_CTL_POWER_D0 in __usb_audio_resume(). > > However, when system is not under auto suspend, resume PM message with > auto flag might not be able to receive on time which cause the power > state was incorrect. At this time, if a player starts to play sound, > will cause snd_usb_pcm_open() to access the card and setup_hw_info() will > resume the card. > > But even the card is back to work and all function normal, the power > state is still in SNDRV_CTL_POWER_D3hot. Hm, in exactly which situation does this happen? I still don't get it. Could you elaborate how to trigger this? > Which cause the infinite loop > happened in snd_power_wait() to check the power state. Thus the > successive setting ioctl cannot be passed to card. > > Hence we suggest to change power state to SNDRV_CTL_POWER_D0 when card > has been resumed successfully. This doesn't look like a right solution for the problem, sorry. The card PM status must be recovered to D0 when the autoresume succeeds. If not, something is broken there, and it must be fixed instead of fiddling the status flag externally. thanks, Takashi > > Signed-off-by: Macpaul Lin > --- > sound/usb/pcm.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > index a4e4064..d667ecb 100644 > --- a/sound/usb/pcm.c > +++ b/sound/usb/pcm.c > @@ -1322,6 +1322,17 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre > if (err < 0) > return err; > > + /* fix incorrect power state when resuming by open and later ioctls */ > + if (IS_ENABLED(CONFIG_PM) && > + snd_power_get_state(subs->stream->chip->card) > + == SNDRV_CTL_POWER_D3hot) { > + /* set these variables for power state correction */ > + subs->stream->chip->autosuspended = 0; > + subs->stream->chip->num_suspended_intf = 1; > + dev_info(&subs->dev->dev, > + "change power state from D3hot to D0\n"); > + } > + > return snd_usb_autoresume(subs->stream->chip); > } > > -- > 1.7.9.5 _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek 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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D04C1C433E0 for ; Tue, 2 Jun 2020 12:46:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6C69206A2 for ; Tue, 2 Jun 2020 12:46:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="P1XIlwsN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6C69206A2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:Subject:To: From:Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=BElA8P5ELgGmzFd56Lb87OYnhUqJNe1AQLuYu6MXJWc=; b=P1XIlwsNxzOvYL QdexHm5eGlnartl2elMkiEYXmz9fqOUhLBBE7nUvZX/Ya2seDDFGJ50GE31/v+pWFmEE10sK3ig/5 7LAuFsd+SezDRyuhTkjbMr3rbg+wgGUEv8JiiD092/9s1JuRt7evvZ1tewhertZUqji2B/wE+cBTY wLIhGKoOQf+Upf8NUtFJEcH8MZ5F5zxvJosKq5p5mMfBUv2KG68KnocTrGn7cKQwInir3irxiTuWY jIWljwdbBQIGJmacefEPR8PIOe7f3ImAoT+GdNl8YQQTMGOMMRh1aC5SzANPv6fZitsJr+VXPCItq YiyJstVRsxQ8/KGYMyUg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jg6JJ-0008R5-60; Tue, 02 Jun 2020 12:46:29 +0000 Received: from mx2.suse.de ([195.135.220.15]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jg6JE-0008Pq-Ei; Tue, 02 Jun 2020 12:46:28 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 17CF8ABD1; Tue, 2 Jun 2020 12:46:22 +0000 (UTC) Date: Tue, 02 Jun 2020 14:46:19 +0200 Message-ID: From: Takashi Iwai To: Macpaul Lin Subject: Re: [PATCH] sound: usb: pcm: fix incorrect power state when playing sound after PM_AUTO suspend In-Reply-To: <1591098821-17910-1-git-send-email-macpaul.lin@mediatek.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") X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200602_054624_646922_9DD228BF X-CRM114-Status: GOOD ( 23.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, Mediatek WSD Upstream , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold , Takashi Iwai , Hui Wang , Alexander Tsoy , linux-mediatek@lists.infradead.org, Matthias Brugger , Macpaul Lin , Jaroslav Kysela , Szabolcs =?UTF-8?B?U3rFkWtl?= , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 02 Jun 2020 13:53:41 +0200, Macpaul Lin wrote: > > This patch fix incorrect power state changed by usb_audio_suspend() > when CONFIG_PM is enabled. > > After receiving suspend PM message with auto flag, usb_audio_suspend() > change card's power state to SNDRV_CTL_POWER_D3hot. Only when the other > resume PM message with auto flag can change power state to > SNDRV_CTL_POWER_D0 in __usb_audio_resume(). > > However, when system is not under auto suspend, resume PM message with > auto flag might not be able to receive on time which cause the power > state was incorrect. At this time, if a player starts to play sound, > will cause snd_usb_pcm_open() to access the card and setup_hw_info() will > resume the card. > > But even the card is back to work and all function normal, the power > state is still in SNDRV_CTL_POWER_D3hot. Hm, in exactly which situation does this happen? I still don't get it. Could you elaborate how to trigger this? > Which cause the infinite loop > happened in snd_power_wait() to check the power state. Thus the > successive setting ioctl cannot be passed to card. > > Hence we suggest to change power state to SNDRV_CTL_POWER_D0 when card > has been resumed successfully. This doesn't look like a right solution for the problem, sorry. The card PM status must be recovered to D0 when the autoresume succeeds. If not, something is broken there, and it must be fixed instead of fiddling the status flag externally. thanks, Takashi > > Signed-off-by: Macpaul Lin > --- > sound/usb/pcm.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > index a4e4064..d667ecb 100644 > --- a/sound/usb/pcm.c > +++ b/sound/usb/pcm.c > @@ -1322,6 +1322,17 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre > if (err < 0) > return err; > > + /* fix incorrect power state when resuming by open and later ioctls */ > + if (IS_ENABLED(CONFIG_PM) && > + snd_power_get_state(subs->stream->chip->card) > + == SNDRV_CTL_POWER_D3hot) { > + /* set these variables for power state correction */ > + subs->stream->chip->autosuspended = 0; > + subs->stream->chip->num_suspended_intf = 1; > + dev_info(&subs->dev->dev, > + "change power state from D3hot to D0\n"); > + } > + > return snd_usb_autoresume(subs->stream->chip); > } > > -- > 1.7.9.5 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel