From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796085452; b=g70vdIBsRoZBiWveRJOJz17X/wczzIXjzi8u/IRPZpcDO/L2a+3vyDeFIunNfu5KtohR 6s6VltAX9SR3PnVOWPnSn2Zmpu8IUgniDo0aHTiHrXJBSDWwSYhOUqkf6EMJ33mslUJtY +g8eKkgmnU0/KNdtThFb4H+ktZaD3LWjHv+w2CxKDnP+hevr+2rqu9ISRjNtDH3p2vG7/ 0PDLfvMfW1xNCPL9cYWkwVdk0RWf+kBryI1EPjMYpVvFPOzDOcbkUThu9vAHLqbcARsoN R3KmfWt8SgUFnvcj9hu0OPlRRjOwT/gmlbvVHtLyy0h1Z34OAUzlisLPgUPUjkWgrJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796085452; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:Content-Transfer-Encoding: In-Reply-To; bh=AtKkRXM+JUs3lcI+W1AOWEmu6bZh+dtmLlXv20sg1EM=; b=AfrhAslZarcRxHrYK6/1TuTwL4dJXhZg/5MlF8jLvz5Ja40MRPz+VtCCWrjMfbQShsX2 BCFHUH8YEfsIrQtvRgfK2loZFV0i3MS4aqdu/1tf4ZH/lRpZ83TKfVKdzegIaIf/D751i yeVTbXXrnBmUBIq6oXUj5UdOUumBvKrmFTwUGNuSTZe3PEUU+Lv9SbMMZLLadiqsNQHgw +kLNKoIIoqhVZlQ4BzAqVcGb9gaEstdUWyFA/Yu9t3VfGkzQG2YPMF4rB8KrvTH/GKeaw JCTWXnwB3gwhWJmoPzus9vZ1xUZ9mu0vQOnZCX81R5HcKh/zuZdXm6CEnwFxelpPlWw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Iu2KUxeC; arc=none smtp.remote-ip=74.125.82.171 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8219606A31A for ; Tue, 1 Dec 2026 00:37:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E8219606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Iu2KUxeC Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-386c71feeeaso8340708eec.0 for ; Mon, 30 Nov 2026 16:37:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1796085446; x=1796690246; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=AtKkRXM+JUs3lcI+W1AOWEmu6bZh+dtmLlXv20sg1EM=; b=Iu2KUxeCzDX1bZw3DSwXoVSotGqUwagdnqFac+EUCEeb9aUQKHktH7+aulYLxizoNu iC9KWMxBbYfioq8XmYcPSzK+TlNBQLrwgpQ3Ow8VO2atoVXHkcRhfN8ESHk5sUTdQQOD 4biqwSyZsrz/6tKCGP05BoJSUKW0UK5Qq7vds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796085446; x=1796690246; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=AtKkRXM+JUs3lcI+W1AOWEmu6bZh+dtmLlXv20sg1EM=; b=Vpjv0V6u3L/24l1nlv0dWcjWpjOfeLHuYatsDI0fQ21YPs4SoR78Zttqg4akKZNJLx NnlOESj9UoP8I2S7At3fzZKjRWvyHZWWSMrG5eVKbZkzsUhy+PRybWo3avDCnNG8WHOs qXCJzrxr7GUxSTr8eo7qVNCoVaHUVHICEK9CScqRDPe3i2r5rfKI9dANJvw02r1gnu/v gIV4L9Hyoh2baK6SGdwkueXoySYWlx5fbTEqn514aZmDxx2f/nKs/0EplrFSSu/B31Kb NqZZq6RpRgqccrW03grJIC9rxXxTwMeEb5ByM4PtWaEUuoRon2XkDCGHoHJsIcCx+sD6 +mNA== X-Forwarded-Encrypted: i=1; AL+hErHxVIrEfW3fBb0WpN0o5r5Ua4/RT2AwNjgx7k9wlHXozbbecRpx7Fn05DUrXwa0NQ9msTa77sttXw==@vger.kernel.org X-Gm-Message-State: APuU4Z/V0POwgVA3ql5iX1WoyR+IhkD5G2gTU4GuQPk4CW4OgzdT704o YODYaUsh9kG+q2ZPe2ioI2SPO5rg5ieb4QM4iEOu+R74bDEjrnjW2kb2jxmCzCAhYQWaiWj3jmF e7B8= X-Gm-Gg: AZFdTZeF6eX5L6YzfMqwvE0a7t7yhPEmi/IggC0mizqX1yk1m2Rg776WiQz1LD00Mgm Yka4YiX3iu/8txyC1ieuSVDqMawMPxikiibil2wYGNEoiTP5GNdyfQl/4Vthq9mg6y5A/fRkD13 K26KrMEbFE3MSBcq7O4E/DFXcbHS4cNDHQbUGWZBLg5roumJ+L1HjL7GdfoTe09xnJc10/7VSts +RPOOp+KKpcqjKB/BdOEM+YtrViszqidOdJ5v9kmWtWRkE1BE9fZse+Xa4F4kaOWSYInn0sREf4 yS7XHti+vJObkWvUJGyquhYT+9AyVwJs/nUzcOvitQoUdqU94XPvyuN5r66gr/61WiYfz/Vj1y8 v0cyZsNAyJ/Pvm19fTBdmCoC5dQr05lsIat5n+D8vDPetGcLaJ6IwlFR4mLr7nxP0af640OAbZU g/x0fZVD76xt2A1ksELcD5C8NS1D82vzYMjBGpZ1dzXS9q4qsi1kJ5ndzvmHa4bbjtY8hTDrwdf sFWmzPs8X7VGLavZtLTmsSC8sE9QH8vUJv09CjcthiJhUpwor8obZapQJg2Hu36QnuXsw6bS3kA f59CM3R6O2HF5vzl4Z4myBoHiNL2U7X7QAYJzzq5n6MwK0sz7MFd3upFe6fjDutk6th7Rw== X-Received: by 2002:a05:7301:6908:b0:381:1926:dba3 with SMTP id 5a478bee46e88-3856983c0ccmr28838804eec.0.1796085445860; Mon, 30 Nov 2026 16:37:25 -0800 (PST) Received: from localhost ([2a00:79e0:2e7c:8:d64c:d468:46b8:64da]) by smtp.gmail.com with UTF8SMTPSA id 5a478bee46e88-38566cd40c5sm126321340eec.10.2026.11.30.16.37.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 16:37:25 -0800 (PST) Date: Mon, 30 Nov 2026 16:37:23 -0800 From: Brian Norris To: "Rafael J. Wysocki (Intel)" Cc: Ulf Hansson , Linux PM , Alan Stern , Sakari Ailus , Linux Driver Core Development , Javen Xu , Andrew Lunn Subject: Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices Message-ID: References: <5129504.GXAFRqVoOG@rafael.j.wysocki> <3453261.aeNJFYEL58@rafael.j.wysocki> X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: + CC Javen Xu, Andrew Lunn for r8169 On Mon, Nov 30, 2026 at 08:25:22PM +0100, Rafael J. Wysocki (Intel) wrote: > On Mon, Nov 30, 2026 at 6:24 PM Rafael J. Wysocki (Intel) > wrote: > > > > On Mon, Nov 30, 2026 at 6:08 PM Ulf Hansson > > wrote: > > > > > > On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki wrote: > > > > Address this by rearranging rpm_resume() to call rpm_idle() also if the > > > > device was already active and drop the direct last_busy update carried > > > > out in that case as it is not necessary any more because rpm_idle() > > > > updates last_busy. Also make the rpm_resume() kerneldoc comment match > > > > the new code flow. > > > > > > While I in principle agree with the change, I am slightly worried > > > about users that call pm_runtime_resume() and who call pm_runtime_get* > > > quite soon after. I can tell if this is a common behaviour, but I am > > > sure I have seen something like that. This can also be pm_request_resume(), for the record. > > Out of curiosity, where have you seen it? > > There are not too many direct callers of pm_runtime_resume() in the > tree and the majority of them don't do anything like this AFAICS. I'm not quite sure about the particular pattern Ulf mentions, but I see lots of sketchy code the more I look. e.g., the dedicated wakeirq stuff here makes me scratch my head some: 56f487c78015 PM / Runtime: Update last_busy in rpm_resume 4990d4fe327b PM / Wakeirq: Add automated device wake IRQ handling Commit 56f487c78015 seems to suggest it's relying on a non-zero autosuspend delay to avoid problems. (Very sketchy IMO.) I can't tell if those are actual functional problems, or if that was just a suboptimal behavior / performance problem. Or maybe some Intel soundwire / intel_component_probe() (with comments!)? And there's a lot of similar-looking code elsewhere in sound/. t7xx_mode_store() (drivers/net/wwan/t7xx/t7xx_pci.c) looks buggy too. I think those tend to use autosuspend delays. But see below. > > Did you check? > > > > I don't know how many of them there are, if that's what you're asking, > > but they should at least use an autosuspend delay. Even autosuspend delay is risky, as that's just asking for a race condition. Any such users need refcounts, or proper failsafes in .runtime_idle()/.runtime_suspend(). And it's quite subtle to get the non-refcount approaches correct. There are some strange ones that I pointed out here: https://lore.kernel.org/all/aweHkBnEGG5f8veE@google.com/ drivers/net/ethernet/intel/e1000e/netdev.c drivers/net/ethernet/intel/igb/igb_main.c drivers/net/ethernet/intel/igc/igc_main.c I think they're functionally correct (due to .runtime_idle() safeguards), even if strange. But drivers/net/ethernet/realtek/r8169_main.c is a similar one, that I believe is functionally wrong today, and possibly made worse with your patch. Specifically, see: phylink_link_up -> rtl_mac_link_up() -> pm_request_resume() In that context, netif_carrier_on() has not yet run, and so rtl8169_runtime_idle() may still rearm its suspend timer (pm_schedule_suspend()). Because rtl8169_runtime_suspend() does *not* recheck netif_carrier_ok(), this means that 10 seconds later, we may runtime-suspend an active link. I believe this technically regressed with commit 8a3c76523e44 ("r8169: add support for phylink"), where the calling conditions for pm_request_resume() changed. I'm no netdev / phylink expert, but it feels like maybe the driver should be doing get()/put() in .mac_link_{up,down}(), rather than relying only on carefully crafted .runtime_idle() + pm_request_resume(). > > Also note that if the initial pm_runtime_resume() resumes the device > > and there is no autosuspend delay, it will suspend immediately even > > without this change. > > > > > Anyway, for these cases we may end up doing an unnecessary round of > > > suspend/resume of the device. Maybe not a big deal, but something that > > > could have a negative impact on probing/boot. If it's "only" unnecessary suspend/resume, I think we could live with it, or patch them up later. I'm a bit more worried about all the functional bugs hiding around the tree. > > If this adversely affects anyone, I'd like to understand why and help > > them to do the right thing because they are probably doing something > > super-fragile that works incidentally. > > > > To me, consistency in the core is more important than preserving the > > existing behavior to support such fragile cases. I agree, I think anything that's noticing this change is at best fragile and probably buggy. It's probably worth making sure we don't completely break obvious stuff, but I don't think we can maintain every fragile thing that exists today. Brian