Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5312784pxj; Tue, 22 Jun 2021 21:25:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkHOB0Y9pTaj+sCOBjE+5YBbuAmlojDpzobfMxCzlMa3K1WPbsTL8OdqAPK1LuSqgShmN7 X-Received: by 2002:a02:5b45:: with SMTP id g66mr7277147jab.62.1624422344811; Tue, 22 Jun 2021 21:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624422344; cv=none; d=google.com; s=arc-20160816; b=MHSZSPN7xYeWPyzA8E2ssnDvGNIF1td2zSRxNHK/LgU6ih3hB+900wY9mwokaikcXH K/PpfSdVgiFuB+tt3i293Mzq9Dt2cYXoBM4Gj982J767JnSBM8QzkN4xbW9cyh9eJy/Q 85kDPZLxdAXDHjQh0+wx0E1dLhEHg072gvrfS1zFIb9Kz6krqhgDfZWHfP5CNRLA/L0k UPHXWoN7Twam0hrKmmlh7VlRZPtFojLcr9dEiZSOjid1Z9fSOrR74ZCh26fFIquqeFA8 skWzLA+t4iumXuEjX+z5EIqcHt+0IqeSz9t4zMhmd2twk1NlqTQQV0Y+g108RuBEbxsT AZMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5xjI9Ft4Ufb3P2xW78lRK4EZEZNp1oyWp3i4UsHjcOQ=; b=LFQK/Ghbrg+A+bqCoGaqQWNbcrrqZiPeoFtEgYOvgQ8UfODsAle0i8pMCKrSRoVOAP QblSg+KVyMH6MiFkkiG/D3woznQYJ/wP/pT4lr9fzgAnYeFWL8YdcrQKxgN7DJrddNpF ATqs6G+/MjVLqSlvlXzPXJh1MTD94Wlh13B4gfxeyxbF8NqyYncmy2um41AtyI59GrPJ sgbFF3puznyczhuQYtwBI8Mft1ORsiZKYuJC6pUD0K4o9qvV4Bd72TQFX1kjp8krYcey 9lqL3JvTIglFS9FNT6bdCMpY2hew/ibdxXfQpBysuqP5OY6W2QCCf97L+fkGuMCa+Gis guEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rpEpW02s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m11si3618504ilj.100.2021.06.22.21.25.33; Tue, 22 Jun 2021 21:25:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rpEpW02s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbhFWE1Q (ORCPT + 99 others); Wed, 23 Jun 2021 00:27:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbhFWE1Q (ORCPT ); Wed, 23 Jun 2021 00:27:16 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA0DFC061574 for ; Tue, 22 Jun 2021 21:24:58 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id d12so665862pgd.9 for ; Tue, 22 Jun 2021 21:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5xjI9Ft4Ufb3P2xW78lRK4EZEZNp1oyWp3i4UsHjcOQ=; b=rpEpW02sCPhAeieY8YKGZpRQeFRKEWmgMaE/6CSFjFaN3ZcJZrsCDugxR2bqzcf/ET f34P8r8jQDJcqMM1MW2PNQZaNAn0zjuzXiQU0avd9m1CbrdadKJotqml96+36krP5uME pFS+DHTXViUW1+Cwucw0l5O4mxwrLMM+EoltAJUOJ7PkNxXydoZ4RfaycOF7Fx4bcYkN BElFXjNeV79s9YLlgwqrMGEWAvWILYCnUXvD88slIsbJURe9UmZVQ0pndtKQ3U27qgBt AuvFxv3fazKLMWj/oYdOwU2Y2VM1CLJYZc8lhbK5TC70puMICaMOSq3FOcVupklEbmAm xbng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5xjI9Ft4Ufb3P2xW78lRK4EZEZNp1oyWp3i4UsHjcOQ=; b=lZolTqR49LyDacnOZkg4GAomo2FnMqQ4t+aLzRcosky6UJ2+8ou2lNGX3gan5C+Cz1 fyEfuE1jB5bHE4jH2HqG2UBdrjd4ygHNWkErGYrUlSGf1nrLxZWVS6ZqbrnwhO+mGEHl mH9JlFeVHDjtenMmYhxFTdsPFRU+Hb9whk2RFbGlnBkKotzV9sO5ojsYfCaXHHZqYwvA rODMm6oOXqf2/7NCNpVnBqMpTEAJS79AdeS7a0BgxaSK4PqAFxlgiydSugQnUgGaoLz8 GGVetEwWpEKoAsWevbd7fgeFTWWj4S56hgX9DuvirJCrdpVhXVwpwvxds/Y96umR3Mo6 RHPA== X-Gm-Message-State: AOAM532oPpEKIcW2JyU0T/5pKT8BHPK2VO2oq3t5HnCWRjrScmQe20KY XLNpcN22j57mco3MxRUJX0fZjQ== X-Received: by 2002:a62:3344:0:b029:28c:6f0f:cb90 with SMTP id z65-20020a6233440000b029028c6f0fcb90mr6866556pfz.58.1624422298462; Tue, 22 Jun 2021 21:24:58 -0700 (PDT) Received: from localhost ([136.185.134.182]) by smtp.gmail.com with ESMTPSA id 11sm779676pfh.182.2021.06.22.21.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Jun 2021 21:24:58 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH V4 1/4] cpufreq: cppc: Migrate to ->exit() callback instead of ->stop_cpu() Date: Wed, 23 Jun 2021 09:54:39 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 367dc4aa932b ("cpufreq: Add stop CPU callback to cpufreq_driver interface") added the stop_cpu() callback to allow the drivers to do clean up before the CPU is completely down and its state can't be modified. At that time the CPU hotplug framework used to call the cpufreq core's registered notifier for different events like CPU_DOWN_PREPARE and CPU_POST_DEAD. The stop_cpu() callback was called during the CPU_DOWN_PREPARE event. This is no longer the case, cpuhp_cpufreq_offline() is called only once by the CPU hotplug core now and we don't really need two separate callbacks for cpufreq drivers, i.e. stop_cpu() and exit(), as everything can be done from the exit() callback itself. Migrate to using the exit() callback instead of stop_cpu(). Signed-off-by: Viresh Kumar --- drivers/cpufreq/cppc_cpufreq.c | 46 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 2f769b1630c5..be4f62e2c5f1 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -182,27 +182,6 @@ static int cppc_verify_policy(struct cpufreq_policy_data *policy) return 0; } -static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy) -{ - struct cppc_cpudata *cpu_data = policy->driver_data; - struct cppc_perf_caps *caps = &cpu_data->perf_caps; - unsigned int cpu = policy->cpu; - int ret; - - cpu_data->perf_ctrls.desired_perf = caps->lowest_perf; - - ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); - if (ret) - pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n", - caps->lowest_perf, cpu, ret); - - /* Remove CPU node from list and free driver data for policy */ - free_cpumask_var(cpu_data->shared_cpu_map); - list_del(&cpu_data->node); - kfree(policy->driver_data); - policy->driver_data = NULL; -} - /* * The PCC subspace describes the rate at which platform can accept commands * on the shared PCC channel (including READs which do not count towards freq @@ -352,6 +331,29 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) return ret; } +static int cppc_cpufreq_cpu_exit(struct cpufreq_policy *policy) +{ + struct cppc_cpudata *cpu_data = policy->driver_data; + struct cppc_perf_caps *caps = &cpu_data->perf_caps; + unsigned int cpu = policy->cpu; + int ret; + + cpu_data->perf_ctrls.desired_perf = caps->lowest_perf; + + ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls); + if (ret) + pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n", + caps->lowest_perf, cpu, ret); + + /* Remove CPU node from list and free driver data for policy */ + free_cpumask_var(cpu_data->shared_cpu_map); + list_del(&cpu_data->node); + kfree(policy->driver_data); + policy->driver_data = NULL; + + return 0; +} + static inline u64 get_delta(u64 t1, u64 t0) { if (t1 > t0 || t0 > ~(u32)0) @@ -451,7 +453,7 @@ static struct cpufreq_driver cppc_cpufreq_driver = { .target = cppc_cpufreq_set_target, .get = cppc_cpufreq_get_rate, .init = cppc_cpufreq_cpu_init, - .stop_cpu = cppc_cpufreq_stop_cpu, + .exit = cppc_cpufreq_cpu_exit, .set_boost = cppc_cpufreq_set_boost, .attr = cppc_cpufreq_attr, .name = "cppc_cpufreq", -- 2.31.1.272.g89b43f80a514