Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2485808ybv; Fri, 21 Feb 2020 16:53:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzHpj2qcvv1dujG8FNMHpaDLJJESW/pZuTtuT2+rE0e6ak64x8GPI37TSjKyUE7OiX+5HJo X-Received: by 2002:a05:6830:22d8:: with SMTP id q24mr16248097otc.0.1582332793550; Fri, 21 Feb 2020 16:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582332793; cv=none; d=google.com; s=arc-20160816; b=FL1EKgGQh1l+m3AF8uaRi82v6mLc7p52+BndgC+q9BisIPL9iXXdHxiUDlzL2qUdXs ajPSmSQy3TSxEexdGHdRxM9qB/XKw1OMiJ6C7Taa+Xp4Pciw5ryWiBbdTm1jNNMPveMN bwznKbACFObC6s4vScEsWgRygpR/hRPxvlmCCLMgBwfAiUODKq/InkWQ3ga1n0ZX92bi zIqpFTeOE2InJaqW3Nk8+CoZ2qj2AK4rMQnt8VsN5V2qdyg2Tzi6LiTur4MSSk5gIro0 cYNvPm1LRkeHcapBl7UzjCoKblQGF6LaXd9rqH0UT9ZIewz6x1WQTQHfObeA4lN+PiNp wbPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p98CUcx71WuQUXfbK29pwYzUrkAutx1lZcDJt+p+2C0=; b=lOGAQTNl32AyJ7qSbjYkjTT+8bUPdhSeFY5lHXD8jAHN5j9euey7YqCsxs2yIeGV57 GK1+LhQgV8Cgq95NKE6dSX5vPqUaTwcxf2otbMULsgvrqOhy19zKdpkD+6a0dHdwB099 2qAx0HcGc9CSf8jExwUK6QMAHagdWjkZxBzrRKPlf4ocZ7fPaBpDq+l6FwM16q+NNRjP 0UmiJ3+tumnCoZ3LwzySK9CwaGGyEQX708924hbGISTGbhU+Tw0mcAElOcQTrXD8HZtt YSh5jlw7Dt+HE7Swlvbj2sRxXWFJ9kLKMQjGHnGQ5F+mIgSDhck0UhB3fvGRKvcmhBiS 8r1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RK5gwiuz; 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 m19si1586508oig.91.2020.02.21.16.53.01; Fri, 21 Feb 2020 16:53:13 -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=RK5gwiuz; 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 S1727913AbgBVAwi (ORCPT + 99 others); Fri, 21 Feb 2020 19:52:38 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:42916 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727780AbgBVAw2 (ORCPT ); Fri, 21 Feb 2020 19:52:28 -0500 Received: by mail-qv1-f66.google.com with SMTP id dc14so1794918qvb.9 for ; Fri, 21 Feb 2020 16:52:27 -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 :mime-version:content-transfer-encoding; bh=p98CUcx71WuQUXfbK29pwYzUrkAutx1lZcDJt+p+2C0=; b=RK5gwiuzd8mbfs3DxPIt8ns0qWRUrb6cGtSIH/KMj1riAyGQ6mSHAqtuIWk8HXk/qX MJ/el423LkdNl5y9sDgoRRu718ZWFkQnd3ivNr5cSC72gZgQ+38K80Sa3mlE2pq3mqCu PC5+FbtRk6ALLlRYkrH0IQhx8RaT5sC71/EGKkW07I9+dg81YRFopmXT64kxGTAbLpYU AHHkyFf8BpkqeU5kwYlthxx3q3qsno/UrzFzapzB1RpOBhKlogyrlPVMwp7QEwee5HyO kj1UVYvCO9GIo78aik7VNJOiEU1ltpGkdzhNRhs23jKjTkztjiYsUf8X0AXdWSWH6b3X 7/Cw== 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=p98CUcx71WuQUXfbK29pwYzUrkAutx1lZcDJt+p+2C0=; b=WX2GQdH8SmvFc0YblvZxdnDskSWc/4impy2Gfn+2KpLkdTWggNqW+BSB4KX+vYP2L6 PxVbDhz+W4HO+9y7q2Lsm1JUqte6FVUzvQT7n0yOs3XMoeo38RUkQE2vU9LuOPkPaGAS DWf9cwgExlBBbcKh4v1m8Wd+FDGG4BMviCZCAzfHiYSN8fPDIsbaJIluPKCMfy2AXA00 35k8oUS26mWatcyfn7FCYhhvzXWZWytGyiWJ0GkKMDhIOXdiSY9KYNCCbnSFNJ5wfiDv lTA6FlDFJu9wT/zt3/KtT2f7qO+GmyAr7IG0iaXeNnrjXLZovRli9ljFtYFfBEbc2Cqz y6FQ== X-Gm-Message-State: APjAAAVkqvi7U9qUXjvqf4+aKtOizCy/QEV+nFYNhvo4oeMIC5P4rdu2 DWSOPSnjMcqRLr6S14NO5LXpHg== X-Received: by 2002:ad4:58a8:: with SMTP id ea8mr32484103qvb.93.1582332746682; Fri, 21 Feb 2020 16:52:26 -0800 (PST) Received: from pop-os.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id 12sm359559qkj.136.2020.02.21.16.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 16:52:26 -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 v10 8/9] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Date: Fri, 21 Feb 2020 19:52:12 -0500 Message-Id: <20200222005213.3873-9-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200222005213.3873-1-thara.gopinath@linaro.org> References: <20200222005213.3873-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 fe83d7a210d4..4ae8c856c88e 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.20.1