All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: linux-pm@vger.kernel.org
Cc: rjw@rjwysocki.net, artem.bityutskiy@linux.intel.com, rui.zhang@intel.com
Subject: [PATCH 2/3] intel_idle: cleanup cpuhotplug setup
Date: Wed, 27 Oct 2021 16:22:36 +0800	[thread overview]
Message-ID: <20211027082237.26759-2-rui.zhang@intel.com> (raw)
In-Reply-To: <20211027082237.26759-1-rui.zhang@intel.com>

Only limited number of CPUHP_AP_ONLINE_DYN callbacks can be registered,
thus cpuhp_remove_state() should be invoked to release the resource when
it is not used.

Fixes: fb1013a01673 ("intel_idle: Convert to hotplug state machine")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/idle/intel_idle.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index ae9d8c43e6a5..e7f2a5f85bf9 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -1676,6 +1676,8 @@ static int intel_idle_cpu_online(unsigned int cpu)
 	return 0;
 }
 
+static enum cpuhp_state intel_idle_cpuhp_state;
+
 /**
  * intel_idle_cpuidle_unregister - unregister from cpuidle framework
  */
@@ -1683,6 +1685,8 @@ static void __init intel_idle_cpuidle_unregister(struct cpuidle_driver *drv)
 {
 	int i;
 
+	if (intel_idle_cpuhp_state > 0)
+		cpuhp_remove_state(intel_idle_cpuhp_state);
 	for_each_online_cpu(i)
 		cpuidle_unregister_device(per_cpu_ptr(intel_idle_cpuidle_devices, i));
 	cpuidle_unregister_driver(drv);
@@ -1710,11 +1714,11 @@ static int __init intel_idle_cpuidle_register(struct cpuidle_driver *drv)
 		return retval;
 	}
 
-	retval = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "idle/intel:online",
-				intel_idle_cpu_online, NULL);
-	if (retval < 0) {
+	intel_idle_cpuhp_state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
+		"idle/intel:online", intel_idle_cpu_online, NULL);
+	if (intel_idle_cpuhp_state < 0) {
 		intel_idle_cpuidle_unregister(drv);
-		return retval;
+		return intel_idle_cpuhp_state;
 	}
 	return 0;
 }
-- 
2.17.1


  reply	other threads:[~2021-10-27  8:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27  8:22 [PATCH 1/3] intel_idle: cleanup code for handling with cpuidle framework Zhang Rui
2021-10-27  8:22 ` Zhang Rui [this message]
2021-11-24 13:29   ` [PATCH 2/3] intel_idle: cleanup cpuhotplug setup Rafael J. Wysocki
2021-12-07  6:22     ` Zhang Rui
2021-10-27  8:22 ` [PATCH 3/3] intel_idle: fix cpuidle_device unregistration Zhang Rui
2021-11-24 13:20   ` Rafael J. Wysocki
2021-11-24 13:43     ` Zhang Rui
2021-11-24 13:56       ` Rafael J. Wysocki
2021-11-24 13:25 ` [PATCH 1/3] intel_idle: cleanup code for handling with cpuidle framework Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211027082237.26759-2-rui.zhang@intel.com \
    --to=rui.zhang@intel.com \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.