Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp874869pxb; Thu, 28 Jan 2021 02:26:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxM8SIrp3ivA2OABVKRzuzERwa3GRL4uEj4Qls6YgXu2pUrdv+zncS+LvYRejQ0dqR3o37P X-Received: by 2002:a17:906:f759:: with SMTP id jp25mr10069708ejb.207.1611829583196; Thu, 28 Jan 2021 02:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611829583; cv=none; d=google.com; s=arc-20160816; b=i0XYQPPn0mU7zBtps280wPj5Kj9tqUbpEASQBSiWycBmyNXEr8GoWkZfNxZOC8uA8n i+mWRsiUH8lteMfX8JZi2hhUfMqpxn+1zBHS7k4tLoaoxpumXxNchzhpWs0PmqjmiYoc G96zGyNWESFmssj/0ACm+Tc8mzt5HSTQaBgvGOsOxGhP1wOsoFyaQtVr/J0ICsKFDYgs Th1A6REOVrKyju+eTu+0JFwXk5O48/ahKBSZ90LBE1zCitvFjrqQvQZxuS6Q3W9384BA zVoxFhJqqFthiSSGWgoLFIMPZhkJGgucKDQ+HgXIxM/qeboSgpzfwKRbgBztuPJScQgt m+Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=Gmohf92thXCgnWNXBIkteP5MCZIewZGUS0ihSmdrono=; b=nyKhkHp8ApQmcRnuEsi+BtYx3xpsJ8NFQbhlfD86xvwsc/KJ9NZL8inOdRlb+fKNIE z6VcMlW5ljOblrmt29GeS8zMCohsyxumxUHM81knJU+8bE5Rl6ZTWi31R8Zt+E5rEE1p m3x4FfYy2/2nQCONYMJdKOLtwAqbSK0/Nc3kvaNY8CxaAnWpjrhQtGWmumj7rwlrvA8F SEVwUeLTYkRQsRZ3NgpfwVgbzQ4H4cUQrHa/iMy8AXpN4xZ/sw7oUnmsi8MCByilFa5p TQgB/n+3E+6XuZJuDGNL4RvqxzPGjGBwUmIa4FDqvGKdUAz1OdNryvjKGUl+/yYpPpqt qYOg== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w24si2542393eds.15.2021.01.28.02.25.59; Thu, 28 Jan 2021 02:26:23 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232126AbhA1KYw (ORCPT + 99 others); Thu, 28 Jan 2021 05:24:52 -0500 Received: from mail-ot1-f48.google.com ([209.85.210.48]:42960 "EHLO mail-ot1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232507AbhA1KYC (ORCPT ); Thu, 28 Jan 2021 05:24:02 -0500 Received: by mail-ot1-f48.google.com with SMTP id f6so4661706ots.9; Thu, 28 Jan 2021 02:23:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gmohf92thXCgnWNXBIkteP5MCZIewZGUS0ihSmdrono=; b=Lx1h/7KJdOhtRKDsXT8IpfRsREpCGJ30jtR9gVh2L4x4KIW5qYhsP5ytfREUEkKvOV yfQIaFvCFao/B5TME2HYKZ3M2O+6uP1a1RUoDz1wr6Wrrphxs0grrMEMftRK4vB7R5Jd VUfvLu8KwQ5E/RiMGadrWEqVA4SamJDYPV8sL7zR88xGk6etZZffdX8/qJmaar/nldrJ xlYPRTFjyX/QGGT7iBWHrCFc16fNoQZRMVgyDgUSdbP09lT/wcJQIaFgIrPjVaWbHm1l XIRR6Psb1+ME8q/eguu+mIyvGgg7DXq5n9hbnekX734kZy9kbWW84I2bT3oVgJsol1pJ 4YBQ== X-Gm-Message-State: AOAM530IPxAxuNTQiDUVKlwWPoAnbIZk/bRXQuKXOxxaJ8Yz5l9iwqzz t/N405oz6NNonaldyVCck1BK4P9GXB3AYBLPg0A= X-Received: by 2002:a9d:7a4a:: with SMTP id z10mr11170677otm.206.1611829401499; Thu, 28 Jan 2021 02:23:21 -0800 (PST) MIME-Version: 1.0 References: <20201231060319.137133-1-kai.heng.feng@canonical.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 28 Jan 2021 11:23:08 +0100 Message-ID: Subject: Re: [PATCH] PM: sleep: core: Resume suspended device if direct-complete is disabled To: Takashi Iwai Cc: Kai-Heng Feng , "Rafael J. Wysocki" , "Kenneth R. Crudup" , Pavel Machek , Len Brown , Greg Kroah-Hartman , "open list:HIBERNATION (aka Software Suspend, aka swsusp)" , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2021 at 9:11 AM Takashi Iwai wrote: > > On Thu, 31 Dec 2020 07:03:19 +0100, > Kai-Heng Feng wrote: > > > > 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 > > Kai-Heng, is this fix still needed for 5.11? > > The description mentions about HD-audio controller, while the recent > revert was the HD-audio codec, so I suppose it's still affected? Regardless, this is not the right fix, because it doesn't take driver flags into account AFAICS. > > --- > > 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 > >