From patchwork Thu Jun 10 08:23:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 457840 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp177254jae; Thu, 10 Jun 2021 01:24:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGAHRSpSvn76II5xnQpcycSUCXpajvVuUSxwDSzhUegfrFVxDN4n+HXFJRIsvdD8p9QgEQ X-Received: by 2002:a17:906:8688:: with SMTP id g8mr3315073ejx.470.1623313464853; Thu, 10 Jun 2021 01:24:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623313464; cv=none; d=google.com; s=arc-20160816; b=JSZ0n+ldhMyjdAixmv1xlcNXzPL+mzaWGUav5d0wKFzKWdP7u62DYKkQYnlfU9xBRb 92dLimmQSg6tCRlnGCRGSo5BD7IbHzE53XpwMkZLjaNkzhnPOI2kc5noKoJMua3FBw06 2HRA0xYWVzm3tu0cddnGKKyBdXND+1RMgEP7KWvp4QO2rxeNVN+iPJJrLjxfgjRNtgSp jwnxWiBeQM25IGp8Bgv9QjErTGzLYQQe/FXyuSJs1RqSs1nD1b3wntwmhvpLcmMB4d3R FNRLTbvhd3mtHGpCxU64Ge74/y9VmRL/Vicq9T0+c+Zr406pBs4xPtdjQANrXNoRskBI KTXA== 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=YORa9oPGsIte4A9SIv+iSxyTgKDWii2V9/ngG7/TXzA=; b=BfLQq9pbxPxBt9zfErOOJfufPvuMQdAAMxo7Qv+oeEVpPbP5/3a5b4/7ijLwG+Vxx0 1IOHWnASN5XV/hNBWFoBrXvhL+ufRA4a7pzegQLiJagpkNQZC1PNfwpXF86IycI0uy6+ TXjbirimLQ2qNi1Y/H4bJn5C0fINY3eUfE7dlbrPQ7PDw6vnNP28JRDxAg+OMG5VpDh8 oOvHFg9QWvQfgvHRA13TVNKKoB2TXQUIRW5US726P3+uipRp9ESwhlM1ZEFQer7IJmLi sSettrFP/Obuf7tjuKN24tkHaWmdnWJk7KClvNPNbroDR0I0aQ0SB1ZkF1lsz5zsKwfu Zotw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QnZSOGTF; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 u11si1828317edx.42.2021.06.10.01.24.24; Thu, 10 Jun 2021 01:24:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-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=QnZSOGTF; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S230084AbhFJI0T (ORCPT + 8 others); Thu, 10 Jun 2021 04:26:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbhFJI0S (ORCPT ); Thu, 10 Jun 2021 04:26:18 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78A44C061574 for ; Thu, 10 Jun 2021 01:24:12 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso3357692pjp.2 for ; Thu, 10 Jun 2021 01:24:12 -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=YORa9oPGsIte4A9SIv+iSxyTgKDWii2V9/ngG7/TXzA=; b=QnZSOGTFeWsKK1KHilKfDK4pafowlzadJ9TKAa+hmsV2BZzCj+/mzNGTDxGSaBhHA3 j/7avbEiKFpACZp0062Lhq8ApmUqDHyaUNM+2SVWL6t63Mw8Jzz3JvHS46Y2baQoz7PK Psc3SuhhpdtfnOaufzA9UXg8V6Tk3nmeGGQiHBD2OTApscMEaeu6rDPiayIHvoXeTNkO OzSaPi3D8jX9cmHFu0QqCMlaONZwPocDxFUjMhN5zsfaMm9H6rzAv1z+zMDteOM3yf7A slwe6pRxRWJX0x+NuFPRLD7cdIvGV1p5JICgyLJVmWhKqBMx3+hd/fDo6PZ/zuvhmjqe wXmw== 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=YORa9oPGsIte4A9SIv+iSxyTgKDWii2V9/ngG7/TXzA=; b=M6L4pK3KiTgQxdZBjlqR2Zv8JAN4STmgYCeoQgO/6VDbd8aI8bRHNhCiBSRQyRgRog b4sXAs4+ugYBmgzWHPys4ywOorGRnC4c5lVWVc8PXQzP5JigIATN9lLDIsmmXvrdEsv5 mG6/BCZ+ScGY8XrxlRClqsd4eW9xxBhYgJHdDpGXfD0+6DUa/L3BVTKBjQ8UfecdUCkI qOyhEoIFMEHaDZ2L4qXcjSKk/zPc3urb02qwqvuVSWpEGM25SXRbEC+zV4InCK8drpq2 y33UXLy234SKDLQiyK7ROXvjazX6dQbzF9P41WjI3sxTspRPijM8is5PMVc6WdfRkiDs DVCw== X-Gm-Message-State: AOAM531Vq2/2LojtItaknCThkCLv+6fygqHd6KN02uBLtGxupUjTHK3A WY97vmr4xQa/PaM3YMEkqRi8+bMirFQs6g== X-Received: by 2002:a17:90a:8816:: with SMTP id s22mr2211669pjn.231.1623313452088; Thu, 10 Jun 2021 01:24:12 -0700 (PDT) Received: from localhost ([136.185.169.128]) by smtp.gmail.com with ESMTPSA id j2sm6913313pji.34.2021.06.10.01.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 01:24:11 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Qian Cai , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , Ionela Voinescu , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] cpufreq: cppc: Migrate to ->exit() callback instead of ->stop_cpu() Date: Thu, 10 Jun 2021 13:53:57 +0530 Message-Id: <07fa2077b682d026c47192507f320da5bbd4e10f.1623313323.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 cannot 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(-) -- 2.31.1.272.g89b43f80a514 diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 3848b4c222e1..30a861538784 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -384,27 +384,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 @@ -557,6 +536,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) @@ -665,7 +667,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",