Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp11070793pxu; Wed, 30 Dec 2020 22:06:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJysb+KwDZ7pyGYp5XLTAjwsb9Sde7xuHNx949jr8JLIOXtNHtuRLALiK2WSL//PSDQ2NUZk X-Received: by 2002:aa7:c492:: with SMTP id m18mr52972177edq.236.1609394786925; Wed, 30 Dec 2020 22:06:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609394786; cv=none; d=google.com; s=arc-20160816; b=RMU0j4le3Lw3crKcr/7/e4i2AyyLtVfabyKvam1ctkCoMQExiK8vFXgvsrsogcz79h oWuN3Rff5Re6cO/Zpnu3aKxMPRRzIUipkFUFGi4G42RkHdf+vUI///vT4mwgHANYm7Yk f5FvAQ7CBUu1bbDJrtRV8QxFrsA7AFwGCbHownd1B7pWIwbNqMviz+ZgGLssCuuPK+uH w15WfK90GSLuRsPh+35eI8cq0n6g8Ma9RYUPMfZRbuBS/6gyUebJuMJiLzkN430VLK/G 5ey9oFNnsjXSA5edkQ5vCrDcvRdpe3Y+lMFu9izLt03fIRXZcRm3r8/VeROar5Q07Svk 5Xbw== 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 :message-id:date:subject:cc:to:from; bh=scOeogyu3BE0+PBwYVXbL+cFUavwubBPzqXoF35W7x8=; b=NJiKv+JHDRTakiZlmazI9fN09NcEoRhRUzOTh6hfX51WNfKLxcbKmPIBdWr63LGism t//N0zs132rRs0zoCx3z+Nal5bCYFBABixPJAP3ZRVJdMyB6F77f8vXjgxSebTzaxTd0 3+5jCpD+9OR9a5tiJDHQ117gXni+pH9vHPmQsP+1n/lT+vyCb8QyzKKiOkfpf1WzgFSH 5Xely44BoBgw0W4bl+Tf4tWOSfPfcyfb/la3ISuiYjO6WB9YE9nhdEXw0kkGvmNGuomJ crsSaChC6cmXzspikox82heucEV8w+RWI4s5x3scfIZ6+ETQ7ZNDs7bo2yG+a0mv+Sff pbqg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z18si25251502edx.593.2020.12.30.22.05.53; Wed, 30 Dec 2020 22:06:26 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726289AbgLaGEV (ORCPT + 99 others); Thu, 31 Dec 2020 01:04:21 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:51588 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgLaGEU (ORCPT ); Thu, 31 Dec 2020 01:04:20 -0500 Received: from 1-171-101-114.dynamic-ip.hinet.net ([1.171.101.114] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kur3d-00057y-V7; Thu, 31 Dec 2020 06:03:34 +0000 From: Kai-Heng Feng To: rjw@rjwysocki.net Cc: tiwai@suse.de, kenny@panix.com, Kai-Heng Feng , Pavel Machek , Len Brown , Greg Kroah-Hartman , linux-pm@vger.kernel.org (open list:HIBERNATION (aka Software Suspend, aka swsusp)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] PM: sleep: core: Resume suspended device if direct-complete is disabled Date: Thu, 31 Dec 2020 14:03:19 +0800 Message-Id: <20201231060319.137133-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HDA controller can't be runtime-suspended after commit 215a22ed31a1 ("ALSA: hda: Refactor codjc PM to use direct-complete optimization"), which enables direct-complete for HDA codec. The HDA codec driver doesn't expect direct-complete will be disabled after it returns a positive value from prepare() callback. So freeze() is called directly when it's runtime-suspended, breaks the balance of its internal codec_powered counting. So if a device is prepared for direct-complete but PM core breaks the assumption, resume the device to keep PM operations balanced. Fixes: 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use direct-complete optimization") Signed-off-by: Kai-Heng Feng --- drivers/base/power/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 46793276598d..9c0e25a92ad0 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1849,6 +1849,10 @@ static int device_prepare(struct device *dev, pm_message_t state) (ret > 0 || dev->power.no_pm_callbacks) && !dev_pm_test_driver_flags(dev, DPM_FLAG_NO_DIRECT_COMPLETE); spin_unlock_irq(&dev->power.lock); + + if (ret > 0 && !dev->power.direct_complete) + pm_runtime_resume(dev); + return 0; } -- 2.29.2