From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796051283; b=c4fC5WdrOo1EycxMeLCtlJ1/HL9EhZsdQuqP9XZG5LLCJWUCdYzaKAu44h0HLISNGKYl J4g0l33DnzgAHk18tGYnyuT7R6/OOeb6bK1R9fyhrISEdcS2Rr3zI8+XB8Q2/Xo9FCLUx ivAVAo12BgufSQG1klNi6YRZTTJM+Tfc5GRZe2oD9xY6RKk8fxEt/B4evzw0HmKee0lB0 SZqWuttKMyt0eup0qpPZ0PFIDnEsLpuJBAfA08C+WZ0/cmcRLB7udS1ohRVhpjaK8O5H0 39iNS3HPPK9ZJaId4Xx1QxMq8fQtGboe8ZhPrg3R2I7SG09/QaTlMwGOYkushvoqCcg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796051283; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: Organization:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type; bh=12YO+S20h2rlunJVUIXrvjTRzGbqbuLaPE8OwhsP9Sk=; b=4EcOKQiqO09sXDaGXL4g9STwDDQDei9fJVqtD9GggZb445Qtg9fvMSD2HAAa1UqifDOl KITtRhQI2adWGP3YKbEEozi5YCr2r9xDFJLhXky73xu6Y186G0iQbMbhrm7OD5Yk4miNu DNeVB1FkejzgrIJ9zolskzb9Q2q0EJFguYmFK37I6CmlYb0bwulNnr80Hm7tp1fO9RKRg TKuu5O/QQUXfXlmGwxw/oodE7n3IeOov0gCENg5PuIJ5jPLljfocIS6R9w6tbf2Io6Bt9 GnuVMkQozbG4C/T0uet8mvt6pIzkoxLCdUm1EsvPVrksQ7otiVZpKqsHZCVhp8tyh4w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HbwTRhUd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C31E606A31C; Mon, 30 Nov 2026 15:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HbwTRhUd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E7731F0089F; Mon, 30 Nov 2026 15:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796051282; bh=12YO+S20h2rlunJVUIXrvjTRzGbqbuLaPE8OwhsP9Sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HbwTRhUdv6RACR6H6a0c1GofWR4xNhdw8Vlya8oReRKq8wFVuM5el9THRWYiF/nNr kw1bqfjLCT64Nw8qfqaABjbVuI5gohtTY/3M91J24VlDMuPux44elMtShwdAYVWBFL zROm90aWfFaPYbczMQtVa1JYnpM2B9t2HDSXluUZewnCncEkcpqooY1J3cyeGMFw4I BiB+bFjF+mc+WkMmHlAtYBP/P1ESbY4kawN+TW1I8zKZ9ZzrLK/95VmhxJ6shvW03m X2c7LtA1YhUq9X/RlSVHm36VXIzcAiivE0FDX6UrWPrY11RpH5obMTR2SwCcVl6ixt PfXNrxpzpCjHg== From: "Rafael J. Wysocki" To: Linux PM Cc: Brian Norris , Alan Stern , Sakari Ailus , Ulf Hansson , Linux Driver Core Development Subject: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices Date: Mon, 30 Nov 2026 16:07:41 +0100 Message-ID: <3453261.aeNJFYEL58@rafael.j.wysocki> Organization: Linux Kernel Development - Intel In-Reply-To: <5129504.GXAFRqVoOG@rafael.j.wysocki> References: <5129504.GXAFRqVoOG@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-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" From: "Rafael J. Wysocki" If rpm_resume() actually resumes the device successfully (that is, the device's runtime resume callback is invoked and does not fail), it calls rpm_idle() to check whether or not the device really is in use and possibly start an autosuspend timer for it or advance its last_busy timestamp. However, rpm_idle() is not called by rpm_resume() if the runtime PM status of the device is RPM_ACTIVE to start with, which is inconsistent and may be confusing. Most importantly, if no runtime PM references to the given device are held when rpm_resume() is about to return, skipping the rpm_idle() invocation means missing an opportunity to suspend the device that is not otherwise prevented from suspending. If autosuspend is used by the device, an autosuspend timer can be expected to be started for it when rpm_resume() is about to return, but that will not happen if the device's runtime PM status is RPM_ACTIVE to start with. The next opportunity to start an autosuspend timer for the device may not appear at any time soon. 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. Note that if the device is prevented from suspending when rpm_idle() is called, the overhead of calling rpm_idle() boils down to checking that the device in fact cannot be suspended, so it should not be significant. Signed-off-by: Rafael J. Wysocki --- drivers/base/power/runtime.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -833,7 +833,8 @@ static int rpm_suspend(struct device *de * suspending (deferred_resume) or wait for it to finish. If the RPM_ASYNC * flag is set then queue a resume request; otherwise run the * ->runtime_resume() callback directly. Queue an idle notification for the - * device if the resume succeeded. + * device if the resume succeeded or the device's runtime PM status was + * RPM_ACTIVE to start with. * * This function must be called under dev->power.lock with interrupts disabled. */ @@ -872,14 +873,8 @@ static int rpm_resume(struct device *dev pm_runtime_deactivate_timer(dev); if (dev->power.runtime_status == RPM_ACTIVE) { - /* - * The attempt to resume the device means that it is needed for - * something, so update its last_busy timestamp as in the case - * in which it actually resumes below. - */ - pm_runtime_mark_last_busy(dev); retval = 1; - goto out; + goto success; } if (dev->power.runtime_status == RPM_RESUMING || @@ -1009,8 +1004,11 @@ static int rpm_resume(struct device *dev } wake_up_all(&dev->power.wait_queue); - if (retval >= 0) - rpm_idle(dev, RPM_ASYNC); + if (retval < 0) + goto out; + + success: + rpm_idle(dev, RPM_ASYNC); out: if (parent && !dev->power.irq_safe) {