From patchwork Wed Aug 11 05:21:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12430073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1534C4338F for ; Wed, 11 Aug 2021 05:23:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51F4D60F55 for ; Wed, 11 Aug 2021 05:23:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 51F4D60F55 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fPdpVqvL0XgKURYJG0RMy8ksqfdF2V8Y8YMNeP+atbU=; b=SkN0+cGn0f+wSc u4LR3hoXJn9mSqgE8q32g1SbTs5k6h9C+f1Xmh4tcvJNmp5wFjxWpQdOCFCvlaKXNvLSU0o9gs87E Z3MRqcaw6ZjtvhQD8+ONxj8oIlv8CIDgk0QVbRwjAiauwkDJjSi+1sSOzBfr4cnWxpFkTzI5G8XUI C8nkC5H3fek9lctNr6bIf5RJvTWmjl0Z3xcc3fKS/RNa/c1hA8ye27YrJnXQ0GsqmjdM9UVENl6qU FEtsKZgzRUugAXTXfjwunsp5AZO3vtGE2ChSrECRAVkROP/EWhiIom4GaMlN0XcFNFNyn8G0rXTq2 8FkzVUT7oC22I0voHIaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDgfz-005cc8-Da; Wed, 11 Aug 2021 05:21:15 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDgft-005caj-47 for linux-arm-kernel@lists.infradead.org; Wed, 11 Aug 2021 05:21:13 +0000 Received: by mail-pl1-x62f.google.com with SMTP id e19so1152072pla.10 for ; Tue, 10 Aug 2021 22:21:08 -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:mime-version :content-transfer-encoding; bh=+XJ7EP0hOZhzV9mAsci1OAWe7gXCZSWRDHJrS8jiH/Q=; b=J7V5OBHZIzvtODbBFS8R213FoHL1S/wrR7vNcmrIda2ffCKudbmAYbJRWN45sQoQky 1ydBeX4PnO9mAZ8rExgp/9oYqUzmAekXb7pzxnNAVURQ5anovtARCz2QBFrOmYgxgNca fCpm37LK2Qo+38rMHY27mRBA9VxZn+cZR4KIGc6lxXdD/A2aSMiAgKcotaqqU+ET+/Cm HmsEzzFMhClealnsbaDpj/nQEyk5VN9HKTaYiuNFHsSEtBtbtmgnW7aIAPY6do3FMoIL Hq82IszkRdErwWZJGijJTotTJbkjjNkPGPT0uRUKlFBNZ0FjFBFG/OovSWqWDsh9gduX kktg== 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:mime-version :content-transfer-encoding; bh=+XJ7EP0hOZhzV9mAsci1OAWe7gXCZSWRDHJrS8jiH/Q=; b=Wf8vngu1N01F6w8xRZgsVn3TBBtEKF3rHBYq4FE3OWiONVVVULr6/ke9zhlkCPK4WO oU/lhNR9264ts9vUErrKmsx6N1j+nxLpf87YkVMrEbz/+bTmlL9VPO9HVMox0ymM2NSp dqIooI7BKuWnz3MrQwP+NhJRC3cYLeT8z4UiCzAL6nVif+6q+P7NUkUa9KP2Ek6P7Ysf Bt2oW/H7uQDRCVG1zAJjd3FtmUt0Maht0BY/kjgSihdgnwW9vPL42qz3QAcO7LyoqIqY 1rL19raNRrgJ5Tg9x0GfTXUwIRB3tUSY+sH/iAeBWfKxcwcq1t1LocAI6eWEQRM43Yz3 Gwww== X-Gm-Message-State: AOAM530OCcJ78MPmgpg6quM0Vt3ikhbbd9a//q84QWSh2ZtYoVG6+wiF qrXaDs32+nR6EKKrgZsFVKsTSQ== X-Google-Smtp-Source: ABdhPJwwqRVqnFH0DCU+u1BbGyrXRZrwxUnWmd0ikZgZlfFytrgZhZgaPk+ea0KpLfB/89mPMHFCHQ== X-Received: by 2002:a17:902:7144:b029:12b:24ce:a83c with SMTP id u4-20020a1709027144b029012b24cea83cmr10157315plm.54.1628659268440; Tue, 10 Aug 2021 22:21:08 -0700 (PDT) Received: from localhost ([122.172.201.85]) by smtp.gmail.com with ESMTPSA id e35sm5147978pjk.28.2021.08.10.22.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 22:21:08 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Sudeep Holla Cc: linux-pm@vger.kernel.org, Vincent Guittot , Lukasz Luba , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: vexpress: Set CPUFREQ_IS_COOLING_DEV flag Date: Wed, 11 Aug 2021 10:51:04 +0530 Message-Id: <0efe0c7b1c07591f07a905021f455b033441784f.1628659212.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210810_222109_217628_473CC1D7 X-CRM114-Status: GOOD ( 17.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reuse the cpufreq core's registration of cooling device by setting the CPUFREQ_IS_COOLING_DEV flag. Set this only if bL switcher isn't enabled. Signed-off-by: Viresh Kumar --- Sudeep, is this broken ? I wonder why we didn't do it earlier. drivers/cpufreq/vexpress-spc-cpufreq.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/cpufreq/vexpress-spc-cpufreq.c b/drivers/cpufreq/vexpress-spc-cpufreq.c index 28c4c3254337..618b263434ca 100644 --- a/drivers/cpufreq/vexpress-spc-cpufreq.c +++ b/drivers/cpufreq/vexpress-spc-cpufreq.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -47,7 +46,6 @@ static bool bL_switching_enabled; #define ACTUAL_FREQ(cluster, freq) ((cluster == A7_CLUSTER) ? freq << 1 : freq) #define VIRT_FREQ(cluster, freq) ((cluster == A7_CLUSTER) ? freq >> 1 : freq) -static struct thermal_cooling_device *cdev[MAX_CLUSTERS]; static struct clk *clk[MAX_CLUSTERS]; static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS + 1]; static atomic_t cluster_usage[MAX_CLUSTERS + 1]; @@ -455,11 +453,6 @@ static int ve_spc_cpufreq_exit(struct cpufreq_policy *policy) struct device *cpu_dev; int cur_cluster = cpu_to_cluster(policy->cpu); - if (cur_cluster < MAX_CLUSTERS) { - cpufreq_cooling_unregister(cdev[cur_cluster]); - cdev[cur_cluster] = NULL; - } - cpu_dev = get_cpu_device(policy->cpu); if (!cpu_dev) { pr_err("%s: failed to get cpu%d device\n", __func__, @@ -471,17 +464,6 @@ static int ve_spc_cpufreq_exit(struct cpufreq_policy *policy) return 0; } -static void ve_spc_cpufreq_ready(struct cpufreq_policy *policy) -{ - int cur_cluster = cpu_to_cluster(policy->cpu); - - /* Do not register a cpu_cooling device if we are in IKS mode */ - if (cur_cluster >= MAX_CLUSTERS) - return; - - cdev[cur_cluster] = of_cpufreq_cooling_register(policy); -} - static struct cpufreq_driver ve_spc_cpufreq_driver = { .name = "vexpress-spc", .flags = CPUFREQ_HAVE_GOVERNOR_PER_POLICY | @@ -492,7 +474,6 @@ static struct cpufreq_driver ve_spc_cpufreq_driver = { .get = ve_spc_cpufreq_get_rate, .init = ve_spc_cpufreq_init, .exit = ve_spc_cpufreq_exit, - .ready = ve_spc_cpufreq_ready, .attr = cpufreq_generic_attr, }; @@ -552,6 +533,9 @@ static int ve_spc_cpufreq_probe(struct platform_device *pdev) for (i = 0; i < MAX_CLUSTERS; i++) mutex_init(&cluster_lock[i]); + if (!is_bL_switching_enabled()) + ve_spc_cpufreq_driver.flags |= CPUFREQ_IS_COOLING_DEV; + ret = cpufreq_register_driver(&ve_spc_cpufreq_driver); if (ret) { pr_info("%s: Failed registering platform driver: %s, err: %d\n",