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: 495145 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4633512jap; Tue, 10 Aug 2021 22:21:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHB6HMVK58mxb48zgGQ6T1j5mfXwbo6mR0Fhcp8OaKsluWBN0rg6bObbN7L4EScGYX2qHb X-Received: by 2002:a05:6e02:1a03:: with SMTP id s3mr315381ild.63.1628659270264; Tue, 10 Aug 2021 22:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628659270; cv=none; d=google.com; s=arc-20160816; b=00saFMzJDR7a7xkWM/6Xfozs1UzF+mnNL6BA4fLbTYEjehFErOCg2cWESQrD3gAOcf 28JmNZlsoCGF+DhZoBY7cQqOCK2/s8m/QcPO1Et/sHbp9WUaGLH0OHY9INNC+ZiYR4QX ihR/isT4gzgO9R5H5iLHdxpdyrXw3IVXeErtQeKRdXyegDWsBJ6nXEOX2K74a/g3YPq8 xtNNaXuB9eXfH5JTHVVn0Wg2644jB0PNibG9CJZiR/n0Jc6kSk+B15ujkyP+ypECrUW7 MvfEJTY/WbDdHGqGya2kFhdl2Uza8DQBwb5h2BYlr8pjyCQx5/tYS2oCXvHgYZmdFtSL bxvQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=+XJ7EP0hOZhzV9mAsci1OAWe7gXCZSWRDHJrS8jiH/Q=; b=L+MgzutOFbCGXQPEKvPu/fWGWHj+3cGjT4g6ulr0/w8d73yEShq/sbnX/T7eCZHAqy fOMRh06ZLAGRyGWgL4wD/TwC/QVqT7d5B5b2PAFzSzchKCP8QS9Ex+r1wsL0nJeAp12p EtceYyvHM2ruxDy88tSbDBArqx7w0MD9DhaHJ09wUj6/2hj8ordsbvYW5fwf/VOv+0As t6ettdwR0luinHYSTVeq36zNhD3oeiUcSAEimKlS1DRQs1F5XugQ2rhE0ckMOWUDzSUo sW7Oy2+SzdAdA4kCh2ZG0d0I+oWH5qOTNvJXTu83WoJLJYnVRQUhAwz6ww+ERSDltDJD QwlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J7V5OBHZ; 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 d12si24694671ilg.4.2021.08.10.22.21.10; Tue, 10 Aug 2021 22:21:10 -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=J7V5OBHZ; 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 S234229AbhHKFVc (ORCPT + 7 others); Wed, 11 Aug 2021 01:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233389AbhHKFVb (ORCPT ); Wed, 11 Aug 2021 01:21:31 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D908FC061765 for ; Tue, 10 Aug 2021 22:21:08 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id g12-20020a17090a7d0cb0290178f80de3d8so2708002pjl.2 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=tuPETqKysxC4+AAMDAxkDwlrtg7zp7Se9SupBTZ5Vv7Ob3n6UaqwExw0sKZJ9feftN RIWwfrhN1iK2AdBc+tgmOSGbgX1fHminH+Mu9SJ/xE1vbVwBePAEOnI2HGlGpUA86M8K 0t8uP+XHYJskhiBWH41Cg+bifUiaQLGUjPXKmaHTOyIiUhpDalgzadniWgpmIYIWeY8X TzOV4rYARAh/2XqXmvwo3hPTyoIZKLelElsFubJJ6nDza1eUlvmvLxVialMJ6+bfb7UK UrMfW8f5ieftPIDYj1phwWO8nxPZ7vEXgLAOe6Le7Yfu6wMTChD/AX+q+wha0BNcGVOt DGSg== X-Gm-Message-State: AOAM5336ybk8K1FcZ//4xg1p4N0qK0AN2gkM0CMFXsIwrKQQamg/xmDa iNdwfParW5n+6u9BHv8JtMPC7A== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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(-) -- 2.31.1.272.g89b43f80a514 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",