From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796473815; b=bIFydy61RB+DCZFdLtp433R9WVGUoUhmMX7NNhuy7w1C9d2wKzEFRsQvBQxxT1I3KgFA gjA5pS4AAKaVTJpKzF6FMjDCJaLcCERe0jxNa/1U2+EKUrKKg7a5PFoKVoZkWvbzWwwij N2WGmd0f2stDr8qxRsyhsX6xJ/fbNNvrp32Lvfwz6X3Gp1OtayBtOSzYr9jYDZKCXu2yG NZ8ehJd1FbyM3DLRmOSM6XLf89BFA7xJL9xaCDpT6httjIjTJkc7kLguWxoPswxAPhAGq 1WnE5MfFshHc67zc8/d4bXCRR2c8fQihGqRP5SDf2SfZRPyfLY9pR/qUWQBO4VOtW4w== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796473815; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=Cnx7cm0enFgBHEBwnM5yH0nfAS1z0UH5hgHReTlKx5M=; b=jwo4yAM4y28mlVcM28aYUYrwNV6Of0aapY1TDH6ZSUx6N4nzopIfMoAAZajmFOYGJkaG 0IU0E6/mWvb5gzJ5yeOjbOwl36NMfzhN6wzkoGNoTiLUMo+95Fq7B/GVG0mvMGyI1DXWl m9gK6tEn1sDlMlxqMFUjSsKmYBFHdohIRAQUP2JujuSP22/59PkT/2UyQn55yKUA8/69f Q3jmDvhracTz8hYLtVSqSzubez+V7MxGcnIIK2eFRmmw7JHewDK4qt1DxZDQlyuXbDrWJ AlLqzFv6p+Vq0wDChNFtqfoislsDQgXfxm4QkVQsa4jDPgmHmQK8J1qjXtXAan7JDBQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MUaJ57O0; arc=pass header.oldest-pass=0 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 63661606A333; Sat, 5 Dec 2026 12:30:15 +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=MUaJ57O0 Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796473815; b=YZUtVaBR6fDGI+pf2/v5HDZoij1h/FmvwOW5ragJ586Ei5kGaj2Oky1+SC5Xvj1Lj9Qj yFuWkpA+HLziTEUdEG0Z/SR5lul8zMs7K0t2AQs8KgkqT4nzSXI3xIYSHuWa0o6iGZ3Tx X/qFlKu7xaw0z1qA1jtBCmHsLGNwvbGGeYKgrdhjmb+Q2Inotqv1bSZn1drg56epH6vs4 83I08JSPAcjnsTRqd6FmMCjhQg1AsRmJZNw8p61Z083D+eKyI62JwF+8bWEUngJ9RQSXW 9s5qHt+4WdHim63EILI6uV6yCAX+u8UBhD5u14J3s+XDjuw4Js7QhMoqCEbf7E1watQ== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796473815; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=Cnx7cm0enFgBHEBwnM5yH0nfAS1z0UH5hgHReTlKx5M=; b=Ah2c8Wc/4AT3fn/MW8OkWYrMhFmWFWTQKy9NHuBaPu4dLd5FNPlacNiZ50Ujhaq5pcLN ibmbhtL6uRMqizbeTqFDUktQBPH7u8RQV9CbMun/4FNycG6rk3iD8G1TbE+2k/i3qyIWv bGKW6gaC9Z3yLOaOZUPOjIMnkk/iu2FkPj2rNjqU+77JXZ0HaqwafBlJqa0WfI5KBH2Kx s76yfJoybIVN0HhtcNM9GnwpxFh/UlgO6fGxq7pdVvx4wqTxpHts959Ug81ya/lfGXKgX gKqmqiCTh3ctwuJOLWA6kQiEpHZItGRMJhw5gk36C2FwBg7gGDsVPheWD68Y1QVq9cA== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id D4A031F0092B; Sat, 5 Dec 2026 12:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796473815; bh=Cnx7cm0enFgBHEBwnM5yH0nfAS1z0UH5hgHReTlKx5M=; h=From:Date:Subject:To:Cc:Reply-To; b=MUaJ57O02J6LbLKrLvqWxNzCMq28ZW0uR/GZLsog2sj62JaAjJ2vdF9dxrq8EaXSY YyEl86FpfXcfYejpwNC8dkPDXq3uvpfNznviEMtDraQs83qGlvV1hxXZ8XaFncrlpW P9buPjG2DJIqp1lZEw4+tC6jw2AninoxCcB471jcsPLmSJkSVmiPROg+yQ/YeqZoDi We1j40bBxlX9RQeyztI17eIwf8Qgdjbv766K2OIGT83ftVAFvlIF4k77xbjS0ccV9s SbfxKM5E2fAb2Y2uxJNvVnCmFTZJtVhgX9H9Hi2/isBztp7FpWgQZP1suxeihZtM0i tHGBOCejvigYg== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 3866F50315; Sat, 5 Dec 2026 12:30:13 +0000 (UTC) From: Arun Iyengar via B4 Relay Date: Sat, 05 Dec 2026 12:30:12 +0000 Subject: [PATCH v7] PM / devfreq: Do not change the frequency of a suspended device 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" Message-Id: <20261205-devfreq-suspend-sync-v7-1-1e5e0bef7683@gmail.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/4XQTWrDMBAF4KsEraui0a/VVe9RupClUaLS2Kllm 4bgu1dOCxEG0+UTo2+GdyMZh4SZvBxuZMA55dR3JZinA/En1x2RplAy4YxrAOA04BwH/KJ5yhf sAs3XzlPjXRO9AqWYI+XrZcCYvu/s2/tvzlP7gX5crb+Jokxl3/gYO6U89sP1fswM6+s/e2egQ F3UUjOBUQp8PZ5d+nz2/Zms4MxrRO4gvCDAIvMCQXKptoioEbuDCMooRrCxjVaGRmwR+UA4gx1 ElktCMDzI1oio/RZRNbLXiVo7abl1QoIxmm0RXSN7neiCMI8maMOtDU2NLMvyA6n9alY4AgAA X-Change-ID: 20261112-devfreq-suspend-sync-7ca8fc51550a To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Boris Brezillon , Steven Price , Liviu Dudau , Jonas Karlman , Dong Aisheng , Arun Iyengar X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796473812; l=15864; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=TWhBxAU5dExg8h5o/HPQRNPvvvm+72MXHR+3gzKA+ys=; b=a2M/UBeGQFkCAshiY+w5+v4PZ6H99T6D3b/Va3eMak1e9xt7QTRrHw5plWvvgC6iI09Irahci dhL0ZQi9JB3DImxQdvefMJuSbgfk0vpPe6VzsQpnjvOcLtCjBoDkxFG X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 X-Original-From: Arun Iyengar Reply-To: aiyengar1990@gmail.com Content-Transfer-Encoding: 7bit From: Arun Iyengar Once a driver has called devfreq_suspend_device(), its device may be powered down, but PM QoS and sysfs limits, cooling, the userspace governor's set_freq, OPP notifiers and the passive governor still reach ->target() through devfreq_update_target(). On RK3588 with the GPU clock on SCMI_CLK_GPU (not in mainline yet), TF-A then accesses the GPU GRF with its power domain off, which ends in an SError. A driver can filter these calls in ->target() only with its own flag and lock, as msm does; the suspend count cannot be used for that, as it changes outside devfreq->lock. Change the suspend count under devfreq->lock. While it is positive, devfreq_update_target() only records that an update is pending, except for passive updates from the parent, which exynos-bus needs at suspend and shutdown. devfreq_resume_device() runs the pending update. Polling governors, whose load data the driver has just reset, and the passive governor instead resume at the previous frequency within the current limits. The userspace governor without set_freq keeps the frequency from before suspend. A new mutex serializes suspend and resume, as the governor events take devfreq->lock. A failed devfreq_suspend_device() still suspends devfreq, as before. A failed devfreq_resume_device() leaves it suspended, as lima then powers the device down; the next resume retries. Callers that ignore the error suspend again later, which is not counted. devfreq_suspend() always counts and devfreq_resume() always resumes. Suggested-by: Boris Brezillon Link: https://lore.kernel.org/r/20261110140232.061d6844@fedora1.home Signed-off-by: Arun Iyengar --- Orange Pi 5 (RK3588S, v7.3 + panthor patch [1], GPU clock on SCMI_CLK_GPU): min/max_freq, set_freq and cooling limits written while the GPU is runtime suspended apply on resume, also after s2idle and deep suspend, no SError. Forced suspend frequency error: no ->target() call while suspended (61 if it leaves devfreq running). Forced resume error: the next resume retries. Developed with Claude (Anthropic), which wrote the code and the commit messages. I reviewed every change. [1] https://lore.kernel.org/r/20261112-panthor-suspend-clk-v2-1-62e1b168052d@gmail.com --- Changes in v7: - A failed devfreq_resume_device() leaves devfreq suspended: lima powers the device down on that error (Sashiko) - A failed devfreq_suspend_device() suspends devfreq anyway and returns the error, as before this series, so callers that ignore the error no longer leave devfreq polling a powered-down device (found in our own review) - Link to v6: https://patch.msgid.link/20261204-devfreq-suspend-sync-v6-1-0ce7d67299d8@gmail.com Changes in v6: - Serialize suspend and resume with a mutex: the lock was dropped between the count change and the governor events (Sashiko) - Drop suspend_retry: a failed devfreq_suspend_device() leaves devfreq running, devfreq_resume_device() always resumes (Sashiko) - A failed resume keeps the update pending for the next resume (Sashiko) - Link to v5: https://patch.msgid.link/20261202-devfreq-suspend-sync-v5-1-ab29a3417760@gmail.com Changes in v5: - A driver's resume nested in a system suspend left suspend_retry set; its next suspend then took over the system's count - Link to v4: https://patch.msgid.link/20261201-devfreq-suspend-sync-v4-1-dd72d4b73f6c@gmail.com Changes in v4: - Drop 1/2, applied to devfreq-next - A driver's suspend after its failed suspend takes the count over instead of nesting (Sashiko) - devfreq_suspend() no longer takes over a driver's failed resume (Sashiko) - Link to v3: https://patch.msgid.link/20261119-devfreq-suspend-sync-v3-0-ef19fbf94d83@gmail.com Changes in v3: - Run the pending update instead of restoring first, so resume makes one transition; the userspace governor without set_freq keeps the frequency from before suspend (Sashiko) - Keep the passive governor out of the pending update, which evaluated it with freq 0 (Sashiko) - Leave devfreq suspended when suspend or resume fails, instead of the v2 undo: callers may power the device down regardless. A caller that ignores a failed resume recovers on its next suspend and resume (Sashiko) - Add [2] as 1/2: commit message corrected (lima on RK3528 is the mainline case, not panthor), comment shortened - Rebase on devfreq-next - Link to v2: https://patch.msgid.link/20261114-devfreq-suspend-sync-v2-1-10f0c3e14245@gmail.com Changes in v2: - Keep only the suspend count, now a plain int changed under devfreq->lock, instead of a separate suspended flag that could disagree with it when suspend and resume race (Sashiko) - Resume at the resume frequency clamped to the current limits, then run the deferred update: the userspace governor without set_freq stayed at the suspend frequency (Sashiko) - Don't defer the passive governor's parent updates: exynos-bus children must follow their parent to its suspend frequency, also at shutdown (Sashiko) - Drop pending_freq: the deferred update runs like any update_devfreq() call. If it fails, resume logs the error and still sends DEVFREQ_GOV_RESUME (Sashiko) - Undo a failed devfreq_suspend_device(), as rk3399_dmc and lima abort without resuming; an unbalanced devfreq_resume_device() is a no-op (Sashiko) - Leave polling governors to their next poll after resume; the driver has just reset their load data (Sashiko) - Link to v1: https://patch.msgid.link/20261112-devfreq-suspend-sync-v1-1-af64603ef43e@gmail.com --- drivers/devfreq/devfreq.c | 149 ++++++++++++++++++++++++----------- drivers/devfreq/governor_userspace.c | 8 +- include/linux/devfreq.h | 14 +++- 3 files changed, 121 insertions(+), 50 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 7c01b588fefa..1207d45e977d 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -409,6 +409,16 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq) if (!devfreq->governor) return -EINVAL; + /* + * The device may be powered down while it is suspended. Leave it + * alone, devfreq_resume_device() does the update. A passive device + * (freq set) still follows its parent, as exynos-bus needs. + */ + if (devfreq->suspend_count > 0 && !freq) { + devfreq->update_pending = true; + return 0; + } + /* Reevaluate the proper frequency */ err = devfreq->governor->get_target_freq(devfreq, &freq); if (err) @@ -781,6 +791,7 @@ static void devfreq_dev_release(struct device *dev) if (devfreq->opp_table) dev_pm_opp_put_opp_table(devfreq->opp_table); + mutex_destroy(&devfreq->suspend_lock); mutex_destroy(&devfreq->lock); srcu_cleanup_notifier_head(&devfreq->transition_notifier_list); kfree(devfreq); @@ -824,6 +835,7 @@ struct devfreq *devfreq_add_device(struct device *dev, } mutex_init(&devfreq->lock); + mutex_init(&devfreq->suspend_lock); mutex_lock(&devfreq->lock); devfreq->dev.parent = dev; devfreq->dev.class = devfreq_class; @@ -873,7 +885,7 @@ struct devfreq *devfreq_add_device(struct device *dev, if (IS_ERR(devfreq->opp_table)) devfreq->opp_table = NULL; - atomic_set(&devfreq->suspend_count, 0); + devfreq->suspend_count = 0; dev_set_name(&devfreq->dev, "%s", dev_name(dev)); err = device_register(&devfreq->dev); @@ -1136,81 +1148,128 @@ void devm_devfreq_remove_device(struct device *dev, struct devfreq *devfreq) } EXPORT_SYMBOL(devm_devfreq_remove_device); -/** - * devfreq_suspend_device() - Suspend devfreq of a device. - * @devfreq: the devfreq instance to be suspended - * - * This function is intended to be called by the pm callbacks - * (e.g., runtime_suspend, suspend) of the device driver that - * holds the devfreq. - */ -int devfreq_suspend_device(struct devfreq *devfreq) +static int __devfreq_suspend_device(struct devfreq *devfreq, bool sys) { unsigned long resume_freq; - int ret; + int ret = 0; if (!devfreq) return -EINVAL; - if (atomic_inc_return(&devfreq->suspend_count) > 1) - return 0; + mutex_lock(&devfreq->suspend_lock); + /* still suspended since a failed devfreq_resume_device() */ + if (!sys && devfreq->resume_failed) { + devfreq->resume_failed = false; + goto out; + } - if (devfreq->governor) { + if (!devfreq->suspend_count && devfreq->governor) ret = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_SUSPEND, NULL); - if (ret) - return ret; - } - if (devfreq->suspend_freq) { - mutex_lock(&devfreq->lock); + mutex_lock(&devfreq->lock); + if (!devfreq->suspend_count && !ret && devfreq->suspend_freq) { /* devfreq_set_target() overwrites resume_freq; keep the pre-suspend one */ - resume_freq = devfreq->previous_freq; + resume_freq = devfreq->update_pending ? devfreq->resume_freq : + devfreq->previous_freq; ret = devfreq_set_target(devfreq, devfreq->suspend_freq, 0); devfreq->resume_freq = resume_freq; - mutex_unlock(&devfreq->lock); - if (ret) - return ret; } - - return 0; + devfreq->suspend_count++; + mutex_unlock(&devfreq->lock); +out: + mutex_unlock(&devfreq->suspend_lock); + return ret; } -EXPORT_SYMBOL(devfreq_suspend_device); /** - * devfreq_resume_device() - Resume devfreq of a device. - * @devfreq: the devfreq instance to be resumed + * devfreq_suspend_device() - Suspend devfreq of a device. + * @devfreq: the devfreq instance to be suspended * * This function is intended to be called by the pm callbacks - * (e.g., runtime_resume, resume) of the device driver that - * holds the devfreq. + * (e.g., runtime_suspend, suspend) of the device driver that + * holds the devfreq. On error, devfreq is suspended anyway: a caller that + * keeps the device running must call devfreq_resume_device(). */ -int devfreq_resume_device(struct devfreq *devfreq) +int devfreq_suspend_device(struct devfreq *devfreq) { - int ret; + return __devfreq_suspend_device(devfreq, false); +} +EXPORT_SYMBOL(devfreq_suspend_device); + +static int __devfreq_resume_device(struct devfreq *devfreq, bool sys) +{ + unsigned long min_freq, max_freq, freq; + int ret = 0, err; + u32 flags; if (!devfreq) return -EINVAL; - if (atomic_dec_return(&devfreq->suspend_count) >= 1) - return 0; + mutex_lock(&devfreq->suspend_lock); + mutex_lock(&devfreq->lock); + if (!sys) + devfreq->resume_failed = false; + if (devfreq->suspend_count <= 0 || --devfreq->suspend_count > 0) { + mutex_unlock(&devfreq->lock); + goto out; + } - if (devfreq->resume_freq) { - mutex_lock(&devfreq->lock); - ret = devfreq_set_target(devfreq, devfreq->resume_freq, 0); + /* + * Run the update deferred while suspended, except for polling + * governors, which re-evaluate on fresh load data after + * DEVFREQ_GOV_RESUME, and the passive governor, which follows its + * parent. These resume within the current limits. + */ + if (devfreq->update_pending && devfreq->governor && + !IS_SUPPORTED_ATTR(devfreq->governor->attrs, POLLING_INTERVAL) && + strncmp(devfreq->governor->name, DEVFREQ_GOV_PASSIVE, + DEVFREQ_NAME_LEN)) { + ret = devfreq_update_target(devfreq, 0); + } else { + freq = devfreq->resume_freq; + if (!freq && devfreq->update_pending) + freq = devfreq->previous_freq; + if (freq) { + devfreq_get_freq_range(devfreq, &min_freq, &max_freq); + freq = clamp(freq, min_freq, max_freq); + flags = freq == max_freq ? DEVFREQ_FLAG_LEAST_UPPER_BOUND : 0; + ret = devfreq_set_target(devfreq, freq, flags); + } + } + devfreq->update_pending = ret; + /* The caller may power the device down: stay suspended */ + if (ret && !sys) { + devfreq->suspend_count++; + devfreq->resume_failed = true; mutex_unlock(&devfreq->lock); - if (ret) - return ret; + goto out; } + mutex_unlock(&devfreq->lock); if (devfreq->governor) { - ret = devfreq->governor->event_handler(devfreq, + err = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_RESUME, NULL); - if (ret) - return ret; + ret = ret ?: err; } +out: + mutex_unlock(&devfreq->suspend_lock); + return ret; +} - return 0; +/** + * devfreq_resume_device() - Resume devfreq of a device. + * @devfreq: the devfreq instance to be resumed + * + * This function is intended to be called by the pm callbacks + * (e.g., runtime_resume, resume) of the device driver that + * holds the devfreq. On error, devfreq stays suspended and the next + * devfreq_resume_device() retries; a devfreq_suspend_device() in + * between is not counted. + */ +int devfreq_resume_device(struct devfreq *devfreq) +{ + return __devfreq_resume_device(devfreq, false); } EXPORT_SYMBOL(devfreq_resume_device); @@ -1229,7 +1288,7 @@ void devfreq_suspend(void) mutex_lock(&devfreq_list_lock); list_for_each_entry(devfreq, &devfreq_list, node) { - ret = devfreq_suspend_device(devfreq); + ret = __devfreq_suspend_device(devfreq, true); if (ret) dev_err(&devfreq->dev, "failed to suspend devfreq device\n"); @@ -1250,7 +1309,7 @@ void devfreq_resume(void) mutex_lock(&devfreq_list_lock); list_for_each_entry(devfreq, &devfreq_list, node) { - ret = devfreq_resume_device(devfreq); + ret = __devfreq_resume_device(devfreq, true); if (ret) dev_warn(&devfreq->dev, "failed to resume devfreq device\n"); diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c index 8211aadb81f0..7414f6281ce3 100644 --- a/drivers/devfreq/governor_userspace.c +++ b/drivers/devfreq/governor_userspace.c @@ -24,10 +24,12 @@ static int devfreq_userspace_func(struct devfreq *df, unsigned long *freq) { struct userspace_data *data = df->governor_data; - if (data->valid) + if (data->valid) { *freq = data->user_frequency; - else - *freq = df->previous_freq; /* No user freq specified yet */ + } else { + /* No user freq specified yet: keep the one from before suspend */ + *freq = df->resume_freq ?: df->previous_freq; + } return 0; } diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 809ef29b9af5..aa7a62b0b7ee 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -169,7 +169,14 @@ struct devfreq_stats { * @stop_polling: devfreq polling status of a device. * @suspend_freq: frequency of a device set during suspend phase. * @resume_freq: frequency of a device set in resume phase. - * @suspend_count: suspend requests counter for a device. + * @suspend_lock: serializes suspend and resume. + * @suspend_count: suspend requests counter for a device, changed under + * @suspend_lock and @lock. While it is positive, frequency + * updates are deferred until resume, except the passive + * governor's parent updates. + * @update_pending: a frequency update is due at resume. + * @resume_failed: devfreq_resume_device() failed, devfreq is still + * suspended. * @stats: Statistics of devfreq device behavior * @transition_notifier_list: list head of DEVFREQ_TRANSITION_NOTIFIER notifier * @cdev: Cooling device pointer if the devfreq has cooling property @@ -212,7 +219,10 @@ struct devfreq { unsigned long suspend_freq; unsigned long resume_freq; - atomic_t suspend_count; + struct mutex suspend_lock; + int suspend_count; + bool update_pending; + bool resume_failed; /* information for device frequency transitions */ struct devfreq_stats stats; --- base-commit: e7c25197980f6edcf38a8167996eb4626a0a5c0d change-id: 20261112-devfreq-suspend-sync-7ca8fc51550a Best regards, -- Arun Iyengar