From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796085452; b=N5vec5zEieqwNdzahkKiovdi2EnITCLIJLw0VM7hxMEBpPFdc182WE8pHlfPDkbdHWLz DInITiumLaz8YR2O/kvlFEdcLvsnBdvROQEiWGqS7PnO+1lRECi+1QyBpliXII+jx0NRI 9v1w4F/m62c4IS/WPA3xGzpUJmyH8YXFr7PybJOO1XD5ImFR963NqlQ8xm5GrsmbHicnt uLvP6g78IQJ+6eRi6eCI2TK9j6N/lP1x+RSj9zUy0biEU2JRGGT2rTQMm0CGWR3j58diF kmEpD/2z2PRp+TARZSExZxMZlT/h5Ey7kapWBKPNZM7MTFYBMsx5PN18xYuwunMK0BQ== 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=3USsYnqHj9vcNv0Ej9c91rKqGTly8UhKWTg2apGU3HNcT8V02MKhjJHR9UEkWlfoqaNO WBNxc/VL2pm3vst9VxHKAj0NwEbZL+wPPatPWwyI3MbiWvn7LlV+07vuJ0N9iXD9+i7e0 s403tj4vzUOv4l7G6dUfgj2JwT12yN3m5UxKhfkzIL2GyecWkzkS7RfFXLgC96hOsEuhu FBslqDDIjvQK4JlVRfGV1y81POOyk2i+MmELXOnzEXsUm2w0KzSWxQRIuxkEFMooUnPRA 65dCdc3Za6zfF51mysc48peB8X6azkX+9MyadFJ77A/Sn/c/DiXE5j/DNnEj53qB8+w== 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=d3q3b08r; arc=none smtp.remote-ip=74.125.82.48 Received: from mail-dl1-f48.google.com (mail-dl1-f48.google.com [74.125.82.48]) (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 EC9CE606A320 for ; Tue, 1 Dec 2026 00:37:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EC9CE606A320 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=d3q3b08r Received: by mail-dl1-f48.google.com with SMTP id a92af1059eb24-1a3c08d6928so16971398c88.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=lists.linux.dev; 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=d3q3b08r3KgYGMQ3fov1AolkvA1PrI5b/cFZ1+iOsC0/Htqna1UBGXYW9qAu+3nOs0 k028OiHVDJ7H53b2GNGVyRC+EkxFiUkFKVOn5ytpz1fqNUzRIBMVzpDdG3oCh+2AD2BR YqggTAPPeo42SVY/ZqYG6HL+jaYHE0WTX5amk= 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=AMmW5MWOGE/ZrgcVA8LjaWqhBH8udvlenc9r7sq/ZtaXEctvz/t3G5GVq+hHPx/gXv IXhIZUdgLI2KSe25XQD8qLp2MTZJgfM8/TwR/LRuBvaqlVj6qHyZ0MWykyOzmEpfYPx0 2co6kyZptRcl269x3G0lYTro2uwmIyD/eVBhJVOT1hoKqIn9SwEGex3Kugihax3SyT+y jH5HAZEZEZRldoGxHaE1/OOc43QRqexlVutgVyRFwP41Koyb2jtLSIQYZ6G7Z/cwuA9H 8kD/l3LqYVU3T/hgjUa3dpb+7hemr+uhUatvgmFumHFUiIbzpxaNdyYNpLHjSEtleEan It0w== X-Forwarded-Encrypted: i=1; AL+hErEC29ST4ZDSEvv5Qs/vZTJiNFhmSCBITKSdd5CuNw5jH9URLwHZfNGd7yebdXzUYVEluZZONFZyieP7iQ==@lists.linux.dev X-Gm-Message-State: APuU4Z+sqijOmjfSmzRXfnqvNI1EvV4p8euvg4AP3M9LwxPJNeSMxxOG WTgtfEAQfhdLnbsr4evDVfSbK6Fe3XCAa5WX0MT+FA9MacAby4GMNTnboc7L0887AQ== X-Gm-Gg: AZFdTZeH8Zqr4etr4oMsBTBPsiqP58Rp2fVPVot92KsK+cBQ0uvBbtYNqKTDTqg0fS8 k/w04wEKvyBcShKelB2Wk3ZTlO+FP0at55YJ1fEWhgEN6vk31YtiBHQdH/GCwT8f0z+BsiBYM31 gEZ+dJXeZKKP9VaGR4WbHkp3EmCJGK7yAjtdYUGTW1AOpbWHtUYTH9ju0bKgG1eHNHicrC9REuf sxnGb6d6sFRX/V1HxdK0OOgL11EbAMg5rNVHIQjcyqS4xa8hE0Aq4484oVtcngb2b+OO63nOYzx iFBfeK2PiEkwy7SllRpKfCn4KTGBq6NDrKMeZj4UQ+1DmeYP7gOmyOwg/3Gv8cnQlIWkqio0IzZ PHNYShq4RTFG8VRILS2VFGB7KPUUy93XKI/HZyfPWZi0zTpUvQxzgTCfuO+pNwjfhB84hEmi8MH HXywrL5xDb6esJ2QPzmrrO1rGVUgAM+tF8UpjXwGusBX2kThgH6QL4ps0gjpFCJGZhmocV9gvn3 dbCnf6SOISXXFDmQeACWV4p//LkHZRoAN0Z4/0tLPVp4zz5UozFQ7w20ijat4H3JZWcb0FrvcJ3 H2cFUTTWYANOkMBCuCDpgSQ39m7rulbwi89CAJPYnqUB7l98kdSXk51QdqJSb7zMnbm+Cw== 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: driver-core@lists.linux.dev 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