Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA090C433F5 for ; Fri, 19 Nov 2021 13:51:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC7B161547 for ; Fri, 19 Nov 2021 13:51:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235578AbhKSNyR (ORCPT ); Fri, 19 Nov 2021 08:54:17 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:40674 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235574AbhKSNyR (ORCPT ); Fri, 19 Nov 2021 08:54:17 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 86BFA21637; Fri, 19 Nov 2021 13:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1637329874; 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=3U5Mz4XSHc9uIhZuvE/ReOpDKhEiCOXpv6d+xy6j5lw=; b=p8QnQeRRKeFyELws7bLLwRpwSmCGb+/xOznp6/OO3phCMsHouNF0+4rgusUy4m6EACkKLY fqJ4MyGPxomjf+1ZruJiUQZ3/L3xBaFgmu6wpt8gv/gOfGU0h0PAd5AMXRRt/e+BN4CNM7 +iOJn/pdwd/kPYwl210eOGq1AUBv7lA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1637329874; 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=3U5Mz4XSHc9uIhZuvE/ReOpDKhEiCOXpv6d+xy6j5lw=; b=hhwkJGNEy3BseOaXS0Jp5v4lp69sxyhXtHQjGrdSXdf5BGU6eKl7h+afq/aDYwhmYAt5t4 mZyYqWtSHNiUvTAw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 7CE26A3B81; Fri, 19 Nov 2021 13:51:14 +0000 (UTC) Date: Fri, 19 Nov 2021 14:51:14 +0100 Message-ID: From: Takashi Iwai To: Heiner Kallweit Cc: alsa-devel@alsa-project.org, Linux PM Subject: Re: Warning due to "ALSA: hda: intel: More comprehensive PM runtime setup for controller driver" In-Reply-To: References: 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Thu, 18 Nov 2021 23:13:50 +0100, Heiner Kallweit wrote: > > On 18.11.2021 22:28, Takashi Iwai wrote: > > On Thu, 18 Nov 2021 21:33:34 +0100, > > Heiner Kallweit wrote: > >> > >> I get the following warning caused by 4f66a9ef37d3 ("ALSA: hda: intel: More > >> comprehensive PM runtime setup for controller driver"): > >> > >> snd_hda_intel 0000:00:1f.3: Unbalanced pm_runtime_enable! > >> > >> Not sure how this patch was tested because the warning is obvious. > >> The patch doesn't consider what the PCI sub-system does with regard to > >> RPM. Have a look at pci_pm_init(). > >> > >> I'd understand to add the call to pm_runtime_dont_use_autosuspend(), > >> but for all other added calls I see no justification. > >> > >> If being unsure about when to use which RPM call best involve > >> linux-pm@vger.kernel.org. > > > > Thanks for the notice. It's been through Intel CI and tests on a few > > local machines, maybe we haven't checked carefully those errors but > > only concentrated on the other issues, as it seems. > > > > There were two problems: one was the runtime PM being kicked off even > > during the PCI driver remove call, and another was the proper runtime > > PM setup after re-binding. > > > > Having a look at the commit message of "ALSA: hda: fix general protection > fault in azx_runtime_idle" the following sounds weird: > > - pci-driver.c:pm_runtime_put_sync() leads to a call > to rpm_idle() which again calls azx_runtime_idle() > > rpm_idle() is only called if usage_count is 1 when entering > pm_runtime_put_sync. And this should not be the case. > pm_runtime_get_sync() increments the usage counter before remove() > is called, and remove() should also increment the usage counter. > This doesn't seem to happen. Maybe for whatever reason > pm_runtime_get_noresume() isn't called in azx_free(), or azx_free() > isn't called from remove(). > I think you should trace the call chain from the PCI core calling > remove() to pm_runtime_get_noresume() getting called or not. Neither of them, supposedly. Now I took a deeper look at the code around it and dug into the git log, and found that the likely problem was the recent PCI core code refactoring (removal of pci->driver, etc) that have been already reverted; that was why linux-next-20211109 was broken and linux-next-20211110 worked. With the leftover pci->driver, the stale runtime PM callback was called at the pm_runtime_put_sync() call in pci_device_remove(). In anyway, I'll drop the invalid calls of pm_runtime_enable() / disable() & co. Maybe keeping pm_runtime_forbid() and pm_runtime_dont_use_autosuspend() at remove still makes some sense as a counter-part for the probe calls, though. thanks, Takashi