Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp907175ybl; Tue, 28 Jan 2020 14:37:51 -0800 (PST) X-Google-Smtp-Source: APXvYqyPwnY05qZx+iLxPMd5Clm11aRLlqhgZOgE/ZzlOLdSFEPnUbEdKPWNZlwTzFEwct1JUFkQ X-Received: by 2002:aca:5582:: with SMTP id j124mr4316567oib.20.1580251071394; Tue, 28 Jan 2020 14:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580251071; cv=none; d=google.com; s=arc-20160816; b=s6+9FcwF0C0gFa2A7JkX2X6X2Iz5OrkO5hGfKMwiZRdS7WS0MdPEuHst8gfhr9QWrJ 04xVGXL4MWgJTLBALsuwyaNueyVOjkn4eMs7eV0zbzitS8P8+1OehkYZbsLwxPgSpmKj FmZ4ldF5UP3P5YcHrz+gu9IU5tQ1afeythEuE8Kl+nUyOVWi4StbNzOJn+76/hTovVh/ VV3f5rPlzizg3nerALYw8HUB/K95v2B9wjyO/YBdHmIW0ALeNRfVDv96Hz+D+gsGGUl3 1sBfcQSGGX3AWMGA0BJgekgWkEe1SBWFNavLbiUwYR5HuSts5El+yJRezrQ/s5lWUwlY S2Hg== 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=ktP9IGvUUCrAWLFKR3Y3fF5qOP9ixd3gTJna8cXjhHQZfbxl95pDGUoKBToB4f99qD hPKGqjHrp/wXRdhoAgEUdRKMM8mRZehBvcP8GbiQTb5o27yJtVCNvf585ieXKsSQv6ha iOgftH25RDnAh2D4QGLGQFHx9a4iziCxRUnukTRBhicb03HV+CsMkYGhNDz1DsZjqpzg 20DTJjZuw29Cgvml2WYwvYQNJzSt8UQe8ILdCo+G1eMGBK0f1jeNY1QGnseNW5gQQnpf xm2JkDHc++aquA/hPuwh6iMxM66xfilEQsHOMDwElIj9nA81Yq/S0RcqjHHZyOyZdmL+ QTYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O0Rdzrwm; 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 m90si40235otc.259.2020.01.28.14.37.39; Tue, 28 Jan 2020 14:37:51 -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=O0Rdzrwm; 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 S1726292AbgA1Wg0 (ORCPT + 99 others); Tue, 28 Jan 2020 17:36:26 -0500 Received: from mail-qv1-f68.google.com ([209.85.219.68]:44384 "EHLO mail-qv1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgA1WgV (ORCPT ); Tue, 28 Jan 2020 17:36:21 -0500 Received: by mail-qv1-f68.google.com with SMTP id n8so7075757qvg.11 for ; Tue, 28 Jan 2020 14:36:20 -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=O0RdzrwmfEH8uV6RdRU4C4h2M1E/wqsv11ZV3zenr2bD1mpDgnrxullmq3C1wF5tGu IiMrSYRWA/s18yzBA2U1EQDCzg8BLLeOahc9JivymAYeEG8DDQpKnjgqUy9iglV54qv3 ckBJez1p2rhSu527bd/DXm8xqBhOjufU9J9oMRLn+wQzBGMTo58nRwWJCXoqN4+ihvMO tNplAuPjc8GkoJZerog/r5/XdPWjYH6ykEuFLeb8v8YqhEfHcOsFvGpWXv3qN97/e74n yYb31KMeNxeIw5xT/cLoZstD7THgaeTFQb5v43F8D8Dm5UmcEoNbamDjTXGCNJzaQJTe e6TA== 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=InD6U/qm7ZWbG7ESfag/K1/EFGVBu140u5RVj0sBowXYjIeAeEiG9gi0KVlC3N/3Od ar9KCepL9ST8uLNeD/1OO3AYu1KYPU9/C/W1DFS4LkLViycSPYMfE/bpp1j516O+PO/t zMsymcZyxxyNTRKvS5hK4FVMeGzd24FLkhgrFPd9x5E3HE8gCWwZIHEaDxOWT2V4NaNV Zn8ZnQswCrYXTZ5rybm0IrZTG61ulX9ALktacnOLpBmwmw6AZf4+U+BWrxwwdp5HK3ax IcpV0q2ieNFIgl1WDICwlt1bR2iFrvUnnOSmZESaR9YJprCPjICSa0MFtgyzB3PlPNoD m1mg== X-Gm-Message-State: APjAAAWEitrk0+HhyX2sTHWkFxmM4i/ZHNLCdrqAiUd+3xnRzDfV+jzQ rCkbyYpvYQ4skWCU1OHtUlokIQ== X-Received: by 2002:a0c:ef0f:: with SMTP id t15mr25139569qvr.123.1580250980156; Tue, 28 Jan 2020 14:36:20 -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 124sm13014259qko.11.2020.01.28.14.36.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jan 2020 14:36:19 -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, rostedt@goodmis.org, will@kernel.org, catalin.marinas@arm.com, sudeep.holla@arm.com, juri.lelli@redhat.com, corbet@lwn.net Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: [Patch v9 6/8] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Date: Tue, 28 Jan 2020 17:36:05 -0500 Message-Id: <1580250967-4386-7-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1580250967-4386-1-git-send-email-thara.gopinath@linaro.org> References: <1580250967-4386-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