Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2047024ybl; Sat, 11 Jan 2020 08:01:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyumegyffJ8xAUaXLfp7fkGiaAhrDImuVXPJAWqf4iUlPCvzWz9ZG1cd9Bltjm0/x9hOcM3 X-Received: by 2002:aca:4442:: with SMTP id r63mr6985565oia.33.1578758501485; Sat, 11 Jan 2020 08:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578758501; cv=none; d=google.com; s=arc-20160816; b=GUwcZUXwaSYuir2re3UAdC63phLlH1C7eP13oHuqk8o3UcprfchavARba3WZmJ3FtZ 0DatbQXuByUqmy6ijQ9nLjTvTQmkUogapU6dAVLCMZabr6xd2i/gEo0wgOxXHsM37RDY 5qOcqxr9wY2SrzUkPLQzEFo8s391lf0pb+4IT/jA5S6ZYN/uplN/7S+tG7Zqimn9K5+4 XgTfdOnxT8Tylgl4eDR3QmcMJXu/azGlat9Da1T/AvHEMnzFKXkwjt2gi9YXFlNxxRH1 2d+AUVhngBO2zGAtjMaEuyklKNAeZQ6rcx3gVRUkMkHCyBbaUxCW2/8tz3HmINEDtPoi h82w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=OghplwU/tPhbSguv+TUOhHr2qr6XCiHT707bOgXEuSc=; b=hwZLOytcB61nGtCjMKP4wL1iQT6c9E3VwDdAZlOP4pxTt0pImuPQIlTCDxKje9auH5 HKqn7euFP8mLKMYY56UcGm3KGg/BA3RH8qxh8LK7F8FpKuLS+ach7fAWvXBBXpgJGCE6 w26IPXereWP+f/wPACNojTuqxVz+0E4H8n2trSpCjgT3+I9wiTfZcTiPDcyPNbofBg/t vAjzXRcfmsEAZuj8stEZBpLx3SOxg5zYZRZyJR/kAE2l6eupmlQN20cCqN+u89VFKadv zgPUm8evdDM2wIrX7PMv+LIe6i0IxRrVWbfKHsEWLOQef0KilBtCDlO6SXQQrbAreHtr CGpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ham7ewAI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id v141si3194198oif.161.2020.01.11.08.01.29; Sat, 11 Jan 2020 08:01:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ham7ewAI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730344AbgAKP7U (ORCPT + 99 others); Sat, 11 Jan 2020 10:59:20 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:41455 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730221AbgAKP7S (ORCPT ); Sat, 11 Jan 2020 10:59:18 -0500 Received: by mail-qk1-f194.google.com with SMTP id x129so4772629qke.8 for ; Sat, 11 Jan 2020 07:59:17 -0800 (PST) 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; bh=OghplwU/tPhbSguv+TUOhHr2qr6XCiHT707bOgXEuSc=; b=ham7ewAIx9vW+TQV9h/j3lhNQhOswY8Q9Uq8F5XxHeOx76r3u6DuqOkHxztUOpHKUs dIZseFKGTnhnLtdSNTMQo4a6HseQSHpl8EEo9hjc8SLyByxd8hESrX+j4wVTYleGmSCA mu08wEV1mG9TiZOrJg48w5z5FtABHQfhv1ffORZCvPBLwZYuZQ8SpaXkd0342f2NfF5b s/J9o5GA9tsTG0JJDpHPKRZtmFjYZuOhVJv9Ck0FvzyCyLdqs2VYqOuLfutWYAaeIlfw fK+jmARSwXza8z2VTMJ+LxB7iZlVqvR1EEmRxh3EJUCM8rNvs78wBySlQ0qD2EDzTpKP l47A== 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; bh=OghplwU/tPhbSguv+TUOhHr2qr6XCiHT707bOgXEuSc=; b=Q5tl3pASpxZ1bwCkQBRGOfcZJMCL8Vb8OaAWuuCAHzzmAaoIVRgZd6wE5f0oHtE41w 6u1BU82cBDFZIPDJc4YoYNRz+Uu8CTF7NjAjypT30E5jkjy1EjqkaJ0vl6bLq6p8UDIC P1dqPAdUkShujedZLMkZqHJTyzY1ERUS+WbQ2AAmcwF16f4lUTxt/8oY25xthXm/3pkh WDI/sxWVNn3hv7sb9K7avnqoRhQP6gdrGkDVl0aK88oyFZ0GViw+Xe4/aXOPZnx4V9Gd ZRImuAWGVGBWVvYsfQl0fj0JPJT0EA7F2NDijb7dqJWUZjxtGGv4TYe4htK/u2iVBxqm B6Qw== X-Gm-Message-State: APjAAAWd0KdeVouocZlLXMP2xy+Fe7rgWZv7+S4IkyXeYiJ8y9s2Pvmh T+RK/EGeeHzM/fJ2SQBjSkmP/SCwpCo= X-Received: by 2002:a37:a68f:: with SMTP id p137mr8495687qke.328.1578758357423; Sat, 11 Jan 2020 07:59:17 -0800 (PST) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id l49sm2843478qtk.7.2020.01.11.07.59.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 11 Jan 2020 07:59:16 -0800 (PST) From: Thara Gopinath To: mingo@redhat.com, peterz@infradead.org, ionela.voinescu@arm.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rui.zhang@intel.com, qperret@google.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: [Patch v7 6/7] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Date: Sat, 11 Jan 2020 10:59:05 -0500 Message-Id: <1578758346-507-7-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1578758346-507-1-git-send-email-thara.gopinath@linaro.org> References: <1578758346-507-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thermal governors can request for a cpu's maximum supported frequency to be capped in case of an overheat event. This in turn means that the maximum capacity available for tasks to run on the particular cpu is reduced. Delta between the original maximum capacity and capped maximum capacity is known as thermal pressure. Enable cpufreq cooling device to update the thermal pressure in event of a capped maximum frequency. Signed-off-by: Thara Gopinath --- v6->v7 - Changed the input argument in arch_set_thermal_pressure from capped capacity to delta capacity(thermal pressure) as per Ionela's review comments. Hence the calculation for delta capacity(thermal pressure) is moved to cpufreq_cooling.c. drivers/thermal/cpufreq_cooling.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c index fe83d7a..4ae8c85 100644 --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -431,6 +431,10 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; + struct cpumask *cpus; + unsigned int frequency; + unsigned long max_capacity, capacity; + int ret; /* Request state should be less than max_level */ if (WARN_ON(state > cpufreq_cdev->max_level)) @@ -442,8 +446,19 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, cpufreq_cdev->cpufreq_state = state; - return freq_qos_update_request(&cpufreq_cdev->qos_req, - get_state_freq(cpufreq_cdev, state)); + frequency = get_state_freq(cpufreq_cdev, state); + + ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency); + + if (ret > 0) { + cpus = cpufreq_cdev->policy->cpus; + max_capacity = arch_scale_cpu_capacity(cpumask_first(cpus)); + capacity = frequency * max_capacity; + capacity /= cpufreq_cdev->policy->cpuinfo.max_freq; + arch_set_thermal_pressure(cpus, max_capacity - capacity); + } + + return ret; } /* Bind cpufreq callbacks to thermal cooling device ops */ -- 2.1.4