Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4853039pxj; Wed, 9 Jun 2021 03:35:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGMTJk5RbzRehZ0K/hU+tmFsuiCzfrtH116k+QjLMng6Pz8Ysm5aMZLGTGoUARl4G40bA4 X-Received: by 2002:a17:906:d781:: with SMTP id pj1mr28506558ejb.136.1623234917224; Wed, 09 Jun 2021 03:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623234917; cv=none; d=google.com; s=arc-20160816; b=MopqnHFl+GDNVigbUk0rj0t5s1vef2JltJ/tPFfCNlddXH1XHY8qkzp8c8pOtA13gR nsY8Mj5AM+vczqmd+3A+z0Jb+s2G3Xb7uDyX+DS1lg4u6YvfQwQOwmLZ/RGeX9c7rORN ltl7sOJb9PMdeRPbQXFAL2v0n+zu4yKqkBrSLlWIUKKEDLnV/q3VwLDhH+V1aibnGJXA nh76j5H3T1QWcuOpPX1+PwKY6eeRbalvrTN64DAuTh/nFDJaZ99aQ10XL0mThmFk9V5G aS/wEbHTcbRK7hanJj8y3GTy508bXBhxipuAV1iTm6HiAhEnp4SR+47Bm6Aj3XMjab5x 9Diw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KEx/Do34hbuVDnJLsyZZweZ4amRWRA/X4Hb2kYkBcLY=; b=GqkEnPq0JTcuT/18LMZpg6sRbgczDyAbXP4r7bqusrKxi8LCHnUpR+xcA/YPhbwJZo MpEqjvHC9Algqp/px3LbE3RCDOKkJ7Wif51mFi9ALWqYt4oHUpCIai6iSeTVhVPmgvAI jqXpGxmqQBWMpRB24/f2QrhZrUC82ugqRtzPKHxdrDBli26TEm1CwZv05Fm5U8EgcFt+ K8M/pomha3af3sgLCjgHlmQUAtkHCDXQJjK4CMbGs6Bdgv1Q61sjgVj2CMaLU4JgTi8e NGYJM5oZN5Nr6qtyQqLiL6k57CyRZSOu56MxptqZALUzq0tgctxpepn0jPiy0Cg3uVAW W36w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rfueq8KC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz26si1974941ejc.61.2021.06.09.03.34.52; Wed, 09 Jun 2021 03:35:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rfueq8KC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235775AbhFHTI2 (ORCPT + 99 others); Tue, 8 Jun 2021 15:08:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:34182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236650AbhFHS6n (ORCPT ); Tue, 8 Jun 2021 14:58:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 56A5261629; Tue, 8 Jun 2021 18:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177786; bh=AMWQ/w5E8AQa19L0RESJPij7OIgsmldXTH4+NicuEP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rfueq8KCRraPAjT7mgTwn6gLWHf1K9o/bKXDdA8LeLMuUCo5o4N1LaLGex3B+8Kx+ r0Gcp5UaWPaHr9Xql14ShU7GWuf6yrKu1CL9Jlj3fIiDFRu5y2ju+WTBm4grkwwRzD 8sZ+Nh2BiK0jPTiMBV88voJjUUMJIJ22U81moOtw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Wang , Takashi Iwai Subject: [PATCH 5.10 099/137] ALSA: hda: update the power_state during the direct-complete Date: Tue, 8 Jun 2021 20:27:19 +0200 Message-Id: <20210608175945.732154817@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175942.377073879@linuxfoundation.org> References: <20210608175942.377073879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hui Wang commit b8b90c17602689eeaa5b219d104bbc215d1225cc upstream. The patch_realtek.c needs to check if the power_state.event equals PM_EVENT_SUSPEND, after using the direct-complete, the suspend() and resume() will be skipped if the codec is already rt_suspended, in this case, the patch_realtek.c will always get PM_EVENT_ON even the system is really resumed from S3. We could set power_state to PMSG_SUSPEND in the prepare(), if other PM functions are called before complete(), those functions will override power_state; if no other PM functions are called before complete(), we could know the suspend() and resume() are skipped since only S3 pm functions could be skipped by direct-complete, in this case set power_state to PMSG_RESUME in the complete(). This could guarantee the first time of calling hda_codec_runtime_resume() after complete() has the correct power_state. Fixes: 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use direct-complete optimization") Cc: Signed-off-by: Hui Wang Link: https://lore.kernel.org/r/20210602145424.3132-1-hui.wang@canonical.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/hda_codec.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2973,6 +2973,7 @@ static int hda_codec_runtime_resume(stru #ifdef CONFIG_PM_SLEEP static int hda_codec_pm_prepare(struct device *dev) { + dev->power.power_state = PMSG_SUSPEND; return pm_runtime_suspended(dev); } @@ -2980,6 +2981,10 @@ static void hda_codec_pm_complete(struct { struct hda_codec *codec = dev_to_hda_codec(dev); + /* If no other pm-functions are called between prepare() and complete() */ + if (dev->power.power_state.event == PM_EVENT_SUSPEND) + dev->power.power_state = PMSG_RESUME; + if (pm_runtime_suspended(dev) && (codec->jackpoll_interval || hda_codec_need_resume(codec) || codec->forced_resume)) pm_request_resume(dev);