From patchwork Wed Jun 23 04:24:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 465885 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1371208jao; Tue, 22 Jun 2021 21:25:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjI9uaBSCaEIqk7xHpC1QKjBen0Bg2Anhu/KiNc62Q7wynCIQP4rjMowqVqQYtDWihkMM3 X-Received: by 2002:a05:6402:27ce:: with SMTP id c14mr9487290ede.118.1624422304345; Tue, 22 Jun 2021 21:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624422304; cv=none; d=google.com; s=arc-20160816; b=hTNy3iKwyIWPdheDND/x8XffkdumjvWKpmcHV+wkBGKHWaRiYp+/cUmvOSHIDdyGZt 2QdQlWI4mcwKUqAQ0L2bF13ml4T6XxJmyBj6l+2oVSCSQdtFzojclixh8RW/cpqVEpkl Uywubi8mt/yWLh/fwp8lAdZxw8LKEM1Bpnniz8P45AcsagCppS3LMo7pvdCzseyivxtx SI/TES/gNkvhsbzFWHQy+opl3oMxN5OHQ/epuSG8z0qeKBeg4jjnMkZ/UuE915Ngp6Gs qAQ6IGMjVPnLmIf1IVVFnnJCtlt0UCFka5JKRQXyvmTV16XlxgPLWusucugHj/IKiclj U1Vg== 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=i/iej8nJEeTJEz38/XN8qDuyypUftBA3jiyN3tRf3/w5NBOi81poYPAGYPh6AWXUs+ nouXassqnYGLzKuAfOBK1PL3Ty4QlxP7jT9rVu293dOsz36rOdVF9Z5JRD/Uo0N8CA0s d9Tir3PPZHXPZ9DTERlEUr5Y/JzE1SFWP4UwzQKLehvb/qaUKOfXTY1hLtsJpXU1ucYy TnzyoSTt/h2y2l129jEtTrWPwsgqZauSco8oBDXFQsjO4xu5rBIq/rdKDU4q9DnbZLX4 tYf54jzbcXd4VZoWc1gcqNgGzX+Cy19ul0K3vPuJA4oHm/5bF1JTBShTz/mJzqOkdgEH MHBw== 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-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 y4si24223394edi.355.2021.06.22.21.25.04; Tue, 22 Jun 2021 21:25:04 -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=rpEpW02s; 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 S230004AbhFWE1Q (ORCPT + 8 others); Wed, 23 Jun 2021 00:27:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbhFWE1P (ORCPT ); Wed, 23 Jun 2021 00:27:15 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE94C061756 for ; Tue, 22 Jun 2021 21:24:58 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id n12so653371pgs.13 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=ZS6qGmJZ8edIpKmjwq3zo0e1dEmz/GKwCNWmOxP+7WFMA7YwmNotKMNWo2K4OtiSwJ J0TrFq5sGw5KkpN88cRX4iC4im9xaY8NB3xPmizVDWpk14C3aQ2teGcvSiR8xPtpjZnQ 7kBrU14vKm5SbuWvMvWElsck3A8RReHw9TsDSVyh6zyPZn7MxXjMVueOZAg5pTSoQDsh JYeZHoB0WWyItHI6DlY295rXrrItEYLWRgN25tEXjaf2x6O+a80T+zPqFWmhKtjDQ8AI cKDFf+ogDHfrHW7/638UYXJZyu4jKi8NoPyFee9/UNxppOW94LjK8O92UyaA1XCY1GCA jPJw== X-Gm-Message-State: AOAM530Hc8J/1ifrM7bcdBIenGWYn6vAeEnqte2TTLzKSLv6ckrCbzT+ fqjyKaIzzds8LjGKz5PCvgO1+BL/qLBllg== 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 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 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(-) -- 2.31.1.272.g89b43f80a514 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",