From patchwork Thu Apr 5 16:16:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 132859 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6478599ljb; Thu, 5 Apr 2018 09:17:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx48TW01LKwjXX4ReV8ssIPvzlOJTt2iVlMO+tYPnf33F2cOV1fKNN2qiy/SLbxTpSNXOMUsL X-Received: by 10.98.9.147 with SMTP id 19mr11114817pfj.125.1522945030283; Thu, 05 Apr 2018 09:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522945030; cv=none; d=google.com; s=arc-20160816; b=c4+NWXAWrqcwThAyb8vVBoJnE0okvSGCz4Kl+ESdJmxspoCEtmj/u3NDm8mMiUIQvj 6znlUxFxE1htPmmmvwRCj6y9p2OWqxmFRLZShAsDJbeKDf5oo9EwCkTusGdvmBJwjkrk VelFgIGC2nYmr2aqJ0oTlgWEpbbWed4lEGgtV6mwDvrYpUVzl+RA8YVS0Z1FERABcEEs ExJ9MHUDLr0f+3iJnQaasroDGsqMnOQIZX2nO0r1mRd0KB7gxS2SUBvX9iXMQIxsEIVy 9WJgHAcXLtfnuyjWaFAhlQ2IC3GPPWKPA+dGmfosJMc5Vs69csW2dnoQk8Mb4xHvG0XN AoYA== 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:arc-authentication-results; bh=LKbkROPJ7+yX2cTKE+YWPN3i3ijWAuW4LQ/8mPl//u4=; b=sba+36n7CdbnpOxXj72CkyDsnS6XHAkUNR+zPS00v4ZpoqHXOiP3mOMUrSX0qN034E KtSS2Dg6p4o+wjTZPPROCb/Q6dKN1hwtXgUhijfPCHOuc3OsB9OeWMyhNTx8zCxRJMiB E83Tpt/TLytFei/PQkljG87l9zcOpxvbDDwIqX5IlsyzkAo7F5qX3+HMgPqPoy1WqCUG NaZH9ajT49eL4R2/Iegsv3IB8p+xMfcB+sNqSgF6zRA78jLIdIT037M5N+kFrdu5N6os HWjFFVnbkiYbR4Rj5a5mQsJ6CH/yHn4UzwD41knpeI6M3boqJtgXABlhtUX0yYHV0oei psAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hW7pqYxP; 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 c27si5566371pgn.223.2018.04.05.09.17.09; Thu, 05 Apr 2018 09:17:10 -0700 (PDT) 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=hW7pqYxP; 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 S1751618AbeDEQRH (ORCPT + 29 others); Thu, 5 Apr 2018 12:17:07 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34025 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751179AbeDEQQ7 (ORCPT ); Thu, 5 Apr 2018 12:16:59 -0400 Received: by mail-wm0-f65.google.com with SMTP id w2so4008683wmw.1 for ; Thu, 05 Apr 2018 09:16:58 -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:in-reply-to:references; bh=LKbkROPJ7+yX2cTKE+YWPN3i3ijWAuW4LQ/8mPl//u4=; b=hW7pqYxPc9p+GcReGP3GfkWGwnwhNJGl1/U6PuPvmBXOeHm1Jfa3JNgifPFwh39ZV0 CNlZ4YSQ94llJD/l/D/QqthfR70E/K1/QGOEdkn2A4Pi2E27plNshYrt5lh6WVokDdkJ KoeGfAE7QSxWt8sqhmS7L68/8OWi4/oF+KI9M= 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=LKbkROPJ7+yX2cTKE+YWPN3i3ijWAuW4LQ/8mPl//u4=; b=Eb1fiig1pAnrc7SmqJgyylx2IdbwtPoU1nFIlhWNKrZZT9lOQyqNyU4bpoy/OHHKCs 3/UJhGbkpJ8sKl/9O5YUr4Lyd24/mc1EPxswkvPLVayl21M9d8Bhg1wSdbAlULvk/XTt ZvxYFNJeC1UjlHXVftG5C9scEr7v8BlMJ3MGHqoRzb3zUzBou/RVrfdbFXoIGIa05ZtU 4WgOMygxtNltqPaqvrMsUFNpO5gGV6h6YKlVfUqvGaQ+kCV4CGVHqlrmOl8hGWa1Jqbu uYeqhW+KF803U501BuheUMTrZ5ipKWAKN2zYK2kH0f6Hp9TP932SjJnzEcITl+9C2CyC 3ioQ== X-Gm-Message-State: ALQs6tArBEMHU1fzQ4F9T8b0wQEq4X+5LDIOdkFGERAcgppDWJVGPWzK 0f4AMZtYyydXHvdUZ+kb7Lnxvw== X-Received: by 10.28.237.11 with SMTP id l11mr9679242wmh.124.1522945018059; Thu, 05 Apr 2018 09:16:58 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:d9b6:ce30:b76c:2e56]) by smtp.gmail.com with ESMTPSA id 39sm16103904wry.89.2018.04.05.09.16.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 09:16:57 -0700 (PDT) From: Daniel Lezcano To: viresh.kumar@linaro.org, edubezval@gmail.com Cc: kevin.wangtao@linaro.org, leo.yan@linaro.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org, Philippe Ombredanne , Amit Daniel Kachhap Subject: [PATCH v3 2/7] thermal/drivers/cpu_cooling: Add Software Package Data Exchange (SPDX) Date: Thu, 5 Apr 2018 18:16:39 +0200 Message-Id: <1522945005-7165-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> References: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For license auditing purpose, let's add the SPDX tag. Signed-off-by: Daniel Lezcano Acked-by: Viresh Kumar Acked-by: Philippe Ombredanne --- drivers/thermal/cpu_cooling.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 42110ee..d7528bc 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * linux/drivers/thermal/cpu_cooling.c * @@ -8,21 +9,6 @@ * Authors: Amit Daniel * Viresh Kumar * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include From patchwork Thu Apr 5 16:16:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 132863 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6479722ljb; Thu, 5 Apr 2018 09:18:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx49gqq0ADRsyIA2rh+/PaxxQCOcWoJnNDkPKLqG/Y94M763jN3SXPktCDoPKuHXvBeU7jVS+ X-Received: by 2002:a17:902:6b49:: with SMTP id g9-v6mr23806711plt.75.1522945095237; Thu, 05 Apr 2018 09:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522945095; cv=none; d=google.com; s=arc-20160816; b=noXZBe0rjRaG8uud1mhkxr5MnNCOGSKuz8uEI4/Y6AeGXOYlH93ciM1rquK1ihya+u uk6WfPV6JIlHvuWWKsyzYo02YLO6b2k6tsbN+cGOeUvRX4ArL2/vk8IUA3HmjbXcAgIP mJPET2e1IuJoa+mX30fzEk3eujhTwfjM/edpIsJh7WrXzLE46CfC+z/rujlDCxe3Dy+9 s3j3YYUgxGXHxY45RXfaKyTGkGLUPMw2pD+QX92RTVn8LIGlJWdinLUCd6QQh3YlsBzk HWZ6LFGqJ6h94qOoXKWDFaC8TvNKrSn1Rg2fOgclwNQ+7yt19eLUzowrty9NSKpAukJ9 cJbw== 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:arc-authentication-results; bh=MIkW9DTQm3etLCbfi0N45TzrpKsVBg+3M2BS1Oo+eSk=; b=OUjS+aasQBK/AOpL8/MGvIRbtQeDH+KEl2bhtfacP7sR42+8v7mUsa/8+G8u7dphSa VfbFC+z5ZDnvp1e/1kMHc0l9QlzbiLQALp7fJ8buu+XlIhB+ToMd7jv3kovNiftiI0kt ej0zGAS4LegD0QY9sHNtrGsNwEnD0WvFPESPLltiGJlS3iN927H9FKRjb2+f41ybpCey 6r1fzGNWTVen/el97DlSOXEkVDgEFOys0SarAVYCQeStHDxWoJB8dm34g60XcGCaixz/ Kxa0llGNuZLcrTOuaoqeZDYxnQQCbg2UOu/m9r6YDK88yxA7hZwadC8GdwlTAT/DUCd7 be2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YLL78Xm6; 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 s73si6413458pfe.128.2018.04.05.09.18.14; Thu, 05 Apr 2018 09:18:15 -0700 (PDT) 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=YLL78Xm6; 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 S1751562AbeDEQRF (ORCPT + 29 others); Thu, 5 Apr 2018 12:17:05 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:55907 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751367AbeDEQRB (ORCPT ); Thu, 5 Apr 2018 12:17:01 -0400 Received: by mail-wm0-f67.google.com with SMTP id b127so7230974wmf.5 for ; Thu, 05 Apr 2018 09:17:00 -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:in-reply-to:references; bh=MIkW9DTQm3etLCbfi0N45TzrpKsVBg+3M2BS1Oo+eSk=; b=YLL78Xm6UWAYZzY4BzjA5T7pSpr7r3lDDNpilJK33pc0cgW3Bzfii34s9JSYyx6Io1 8uo41Wiih88g1s3VfSmyh8zPGyA1tVOHGnFbHIAP8fUWksEy2l0SEyKv0iJf82YgORog mCKKMkwqJmq1/O8FDWyS4JlC5etnV6UkSn1ug= 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=MIkW9DTQm3etLCbfi0N45TzrpKsVBg+3M2BS1Oo+eSk=; b=h8dpDCTQvv6MfAUkJMvFgS4AOnkyb+ol7/yE2NgHrwVNnRoXiahPKBRazyWDEbM4y6 HmMQZpl5Q5eeT0XHLiDxRYVqpSnLkG9U4egU3PnUp5EBdzNdic76cWoEWTH7k3MOoyrE 0uXOVn126uckPbASo3YxUc2caHJxLgcCpQQ0N3nRPyAjHB9NcPi2HIk9Owv+/MBpR4+B 43Iz9m843TG8ZP+v0BMbLArw5yttX7nZv/mibrMdvNLvfG+OZX8SBgJCRLDkdBWDDDBq gyvZ2shvV8l7BVdrBNaODCWxnmPwb6Rgb2fpWfhiH+Zxful83tFFtpasA9FXPkEPw9J2 O/mQ== X-Gm-Message-State: AElRT7E1GbcV1KKHgS+0b5fCf6TzeUIDi2mHxhJkhMDEKMao3fEWqQ/r qcfk8MNkbxvfn5wWqaeDdKhKBmBE7ng= X-Received: by 10.28.125.194 with SMTP id y185mr12821269wmc.160.1522945019895; Thu, 05 Apr 2018 09:16:59 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:d9b6:ce30:b76c:2e56]) by smtp.gmail.com with ESMTPSA id 39sm16103904wry.89.2018.04.05.09.16.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 09:16:59 -0700 (PDT) From: Daniel Lezcano To: viresh.kumar@linaro.org, edubezval@gmail.com Cc: kevin.wangtao@linaro.org, leo.yan@linaro.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org, Amit Daniel Kachhap Subject: [PATCH v3 3/7] thermal/drivers/cpu_cooling: Remove pointless field Date: Thu, 5 Apr 2018 18:16:40 +0200 Message-Id: <1522945005-7165-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> References: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The structure cpufreq_cooling_device provides a backpointer to the thermal device but this one is used for a trace and to unregister. For the trace, we don't really need this field and the unregister function as the same pointer passed as parameter. Remove it. Acked-by: Viresh Kumar Signed-off-by: Daniel Lezcano --- drivers/thermal/cpu_cooling.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index d7528bc..7bdc19f 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -88,7 +88,6 @@ struct cpufreq_cooling_device { unsigned int clipped_freq; unsigned int max_level; struct freq_table *freq_table; /* In descending order */ - struct thermal_cooling_device *cdev; struct cpufreq_policy *policy; struct list_head node; struct time_in_idle *idle_time; @@ -197,8 +196,7 @@ static int update_freq_table(struct cpufreq_cooling_device *cpufreq_cdev, dev = get_cpu_device(cpu); if (unlikely(!dev)) { - dev_warn(&cpufreq_cdev->cdev->device, - "No cpu device for cpu %d\n", cpu); + pr_warn("No cpu device for cpu %d\n", cpu); return -ENODEV; } @@ -762,7 +760,6 @@ __cpufreq_cooling_register(struct device_node *np, goto remove_ida; cpufreq_cdev->clipped_freq = cpufreq_cdev->freq_table[0].frequency; - cpufreq_cdev->cdev = cdev; mutex_lock(&cooling_list_lock); /* Register the notifier for first cpufreq cooling device */ @@ -922,7 +919,7 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, CPUFREQ_POLICY_NOTIFIER); - thermal_cooling_device_unregister(cpufreq_cdev->cdev); + thermal_cooling_device_unregister(cdev); ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id); kfree(cpufreq_cdev->idle_time); kfree(cpufreq_cdev->freq_table); From patchwork Thu Apr 5 16:16:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 132864 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6479961ljb; Thu, 5 Apr 2018 09:18:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx49se7gHcxJwRMgrKNnDo7seXE9P9POgpGEAQ7RwVkgdOmigMyoDMzRNKrCgd1VfH+qOVels X-Received: by 10.99.117.12 with SMTP id q12mr1872629pgc.395.1522945107972; Thu, 05 Apr 2018 09:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522945107; cv=none; d=google.com; s=arc-20160816; b=kuS51X7dowVqE5rXOZVrczDkJVnzKfcnk44+3zhkBf7ixvOWthMEvgG7/G755ESrsF wKYPgF0Hx5u6mYC2erfprMYMngNpaj7qwhjzfeRNswOld61dKPsxBYXGZb2gu1mONOw9 HKQUuxgHkfETevqa4XeaA4nhYmFMFe5SSCMLe4DneWM2KTINRysIMQlBoZuepeZdP33Q AsMTsZl7+rYDg0pSoshi5XLYgn+KK0ayb9ytnbj9JFFw7qlO6j/ffdDXQkl1aPu0ccGh sL7ipw5CvEAv6nsRX8lLnBCQPohntXBNcWFMiUZfbwHdvJUHTIQIx1r7Ji+fEvY8t87/ oT8w== 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:arc-authentication-results; bh=2B+u7r7k98kBwXfr9ac52jfD5UJK1QPtdRFSc0U8m8k=; b=ufFdV0Au5iada+fO7/ug21jdarKDkxjXPe9G9hd2QS1GrFfi5AWMdhj1iFOmfCR0O+ 2oLadxL050p5rfo3twq3ESz4HM8rhNH+zppsGyjMX1aQR2k46kpm9mfUpGZK0fK+nK+X oFWH8YmhuRsZ93HXIWTuDdEYDEpoMt27nd8dD+MAx8VGmYdXtGMGs7dkWDJCVDuxZ6i8 oZmE1kSvWfR/sDuDBep2aGcHiqcglWdqydoNatYv55RFI2DK3jkcYX1r+Ja9An8IgtKT rghdf9hGV65hTu37UjiqorNDGcb7sfBkX+0OSwpOWztn5MRl+ddFevkmKJ44+WnUE0ho QUOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e1D+GSdV; 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 f131si5833444pgc.437.2018.04.05.09.18.27; Thu, 05 Apr 2018 09:18:27 -0700 (PDT) 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=e1D+GSdV; 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 S1752016AbeDEQSZ (ORCPT + 29 others); Thu, 5 Apr 2018 12:18:25 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:42610 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751519AbeDEQRD (ORCPT ); Thu, 5 Apr 2018 12:17:03 -0400 Received: by mail-wr0-f196.google.com with SMTP id s18so29335684wrg.9 for ; Thu, 05 Apr 2018 09:17:02 -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:in-reply-to:references; bh=2B+u7r7k98kBwXfr9ac52jfD5UJK1QPtdRFSc0U8m8k=; b=e1D+GSdVaGbCzgkLpU2iEScaA8kopcXUafqIFb27J/6Wa6ky5JvxndzS7NUb8ig83D FOY8sd3FSV5yz0zwNi+Mf9HBGlfGEL2quPVM+ucal+5CpzKjDag+bVj6mPTbfzl81k27 LRwBBCoBdiJQ7QARcbTpvX4BhLtttXjPKzqI4= 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=2B+u7r7k98kBwXfr9ac52jfD5UJK1QPtdRFSc0U8m8k=; b=X1e+68w5IcuFKGxEOAsCK3+HHgmFlQBF2oGDMfsghPmjfGH15dIMWQOBSIpn7IqQsF SfxHWNA+D7QTPr5F2d77gVbr15Q/7YYUzgvQGBC0LgOh8tagtelRIIwEYuv7Rd2TwL1Z gla3GMVNAJNSIPR+5FR3rySUxxmcM8YQ142+FGkd95SyBJF80Vnpt4rzOE3VWJ34NHmp 4XNTKi6R+h+acGPfj3+VlrIuyQ+yFCzdiSZSYEJGzGP+dGcwHbL+f6cHzD2XibUvcJG0 StHAioTLYQ9LsyDCuPcwGEzDWgEwsR3LSKn+gDF36PyJVcW1VtFRQXA9Vwo17lebfYKD qLlg== X-Gm-Message-State: AElRT7E5jWq6orUspnx5dnPMETl/p2YuYPzOh4wxGqw0NTMrt0s8U7Ee nhC/zb5al5o1eNZGcRf8qQGMeA== X-Received: by 10.223.226.14 with SMTP id j14mr15877015wri.17.1522945022035; Thu, 05 Apr 2018 09:17:02 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:d9b6:ce30:b76c:2e56]) by smtp.gmail.com with ESMTPSA id 39sm16103904wry.89.2018.04.05.09.17.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 09:17:01 -0700 (PDT) From: Daniel Lezcano To: viresh.kumar@linaro.org, edubezval@gmail.com Cc: kevin.wangtao@linaro.org, leo.yan@linaro.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org, Amit Daniel Kachhap Subject: [PATCH v3 4/7] thermal/drivers/Kconfig: Convert the CPU cooling device to a choice Date: Thu, 5 Apr 2018 18:16:41 +0200 Message-Id: <1522945005-7165-5-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> References: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The next changes will add new way to cool down a CPU. In order to sanitize and make the overall cpu cooling code consistent and robust we must prevent the cpu cooling devices to co-exists with the same purpose at the same time in the kernel. Make the CPU cooling device a choice in the Kconfig, so only one CPU cooling strategy can be chosen. Signed-off-by: Daniel Lezcano --- drivers/thermal/Kconfig | 20 +++++++++++++++++--- drivers/thermal/cpu_cooling.c | 2 ++ include/linux/cpu_cooling.h | 6 +++--- 3 files changed, 22 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index b6adc54..5aaae1b 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -142,17 +142,31 @@ config THERMAL_GOV_POWER_ALLOCATOR allocating and limiting power to devices. config CPU_THERMAL - bool "generic cpu cooling support" - depends on CPU_FREQ + bool "Generic cpu cooling support" depends on THERMAL_OF help + Enable the CPU cooling features. If the system has no active + cooling device available, this option allows to use the CPU + as a cooling device. + +choice + prompt "CPU cooling strategies" + depends on CPU_THERMAL + default CPU_FREQ_THERMAL + help + Select the CPU cooling strategy. + +config CPU_FREQ_THERMAL + bool "CPU frequency cooling strategy" + depends on CPU_FREQ + help This implements the generic cpu cooling mechanism through frequency reduction. An ACPI version of this already exists (drivers/acpi/processor_thermal.c). This will be useful for platforms using the generic thermal interface and not the ACPI interface. - If you want this support, you should say Y here. +endchoice config CLOCK_THERMAL bool "Generic clock cooling support" diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 7bdc19f..5c219dc 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -22,6 +22,7 @@ #include +#ifdef CONFIG_CPU_FREQ_THERMAL /* * Cooling state <-> CPUFreq frequency * @@ -926,3 +927,4 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) kfree(cpufreq_cdev); } EXPORT_SYMBOL_GPL(cpufreq_cooling_unregister); +#endif /* CONFIG_CPU_FREQ_THERMAL */ diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index d4292eb..c0accc7 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -33,7 +33,7 @@ struct cpufreq_policy; typedef int (*get_static_t)(cpumask_t *cpumask, int interval, unsigned long voltage, u32 *power); -#ifdef CONFIG_CPU_THERMAL +#ifdef CONFIG_CPU_FREQ_THERMAL /** * cpufreq_cooling_register - function to create cpufreq cooling device. * @policy: cpufreq policy. @@ -84,7 +84,7 @@ of_cpufreq_power_cooling_register(struct device_node *np, */ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); -#else /* !CONFIG_CPU_THERMAL */ +#else /* !CONFIG_CPU_FREQ_THERMAL */ static inline struct thermal_cooling_device * cpufreq_cooling_register(struct cpufreq_policy *policy) { @@ -118,6 +118,6 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) { return; } -#endif /* CONFIG_CPU_THERMAL */ +#endif /* CONFIG_CPU_FREQ_THERMAL */ #endif /* __CPU_COOLING_H__ */ From patchwork Thu Apr 5 16:16:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 132860 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6478807ljb; Thu, 5 Apr 2018 09:17:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/DyRrdKMkErfNoUJFjUdcp+MPsTjg8Iir7n1hU5BBbdO/+nrjyIDf0x/d8g8S1lWTiQIpm X-Received: by 10.99.110.5 with SMTP id j5mr15514379pgc.246.1522945043190; Thu, 05 Apr 2018 09:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522945043; cv=none; d=google.com; s=arc-20160816; b=Tn29MbtZoXMx9lg3HkBEbjHdctpyqY19zUWDmKmvqQH7wk08DtsYlrC4ujit+x8ndY zKWJzFpAB3QwUai3Vn6lGdblLnPjS5NorEN4A4mM/jp6AxzDatHLmXN/t5B9pdlZEmBH eMOXp5KDRVTWrF7b6+SsDpGP1r+raeYwIbezNRqVRSpfS2N1yKgjClwjW661nZnsJoKl hjw2xJaWfq6dTlE8uoVEmRoFjy5XUfe/INj5cQ6yYKyvCjPzy1sEwrVcO2N6vsKAkQw1 fnuAtc+CqAUc17wTipZsbf4V/dmkJCDrtF1CD/5ceJTEH71G8QI1jjyppJFx2lcOb+Pk RP5w== 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:arc-authentication-results; bh=ck89oJBdVzVKmOxU5jKUdkTzvq18hyAz29qbhAvdUzg=; b=ImN5aYp30Mn6XJUDn6rNcxIyNneW7xVAWrOUuTUcLi80XvZI37jzEGk/S7bxPbbF2c LgNlpEjTIsHvWrH+y2oAyOC6EDNLSCz1Y3AnPIUomuxyceeLJBeppbbkDJ3DzHchuF/o pW/CEBVI/4kQtz8x2WRgl1APYF0daEdFt5MFk6qoeO/QSZVsPeEH5ykGdmH7t3zRWdSm 3o/DlVYgiHCJBHrY1FnrsyOrdgq2MiAoliAMXI5uFX9U1ZEAIqCsU3BXL399AIJO4lwX WFJvGzXRTxLnBlElu32H9Krah4zLpc8I6jDDHG5D8yEM7cAjpW9Xu+Q5JEKA2JlhezGU E+qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cRUCm+eT; 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 a17si5649311pgn.429.2018.04.05.09.17.22; Thu, 05 Apr 2018 09:17:23 -0700 (PDT) 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=cRUCm+eT; 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 S1751869AbeDEQRS (ORCPT + 29 others); Thu, 5 Apr 2018 12:17:18 -0400 Received: from mail-wr0-f169.google.com ([209.85.128.169]:46875 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbeDEQRO (ORCPT ); Thu, 5 Apr 2018 12:17:14 -0400 Received: by mail-wr0-f169.google.com with SMTP id d1so29349080wrj.13 for ; Thu, 05 Apr 2018 09:17:13 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ck89oJBdVzVKmOxU5jKUdkTzvq18hyAz29qbhAvdUzg=; b=cRUCm+eT4gQzT7d3U1rRXEUiGZ47Bbri35vigkWlAer+ehovhyozq1SvegPcKQpgCO mKuLxidzflzsSONkbOMwfvU10PiUZhGeEonSUVIssVwpjfUj7PTDAHXYFMZ/bPqnLMYA 9xbywx1lUFqOQCgHWDOCXWLRtxxKGV8TOi1Sk= 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=ck89oJBdVzVKmOxU5jKUdkTzvq18hyAz29qbhAvdUzg=; b=s0VtcROrNoQW+PkRlrLvRVuhbFcy5afsYL1lwhhXGwH81LOCFRXz0s762CKdLRYGyk 1Ooa4BID/wz1+jsbeaF8RneQ23LG7mNMhxVU/wAWZDU01qKBDLuXOFaeN2A7xxtjnW4z TTb9qSMIGt6GuUWqgrlOXAbPdNsCCGsKgB9VmYQREs4PWLVUpmBpMaQISqzfZg6+C68o ksYXnRVcLbDmOtnz4+0aVU2cqD1SyQXLk6IRXxjBqLXPU+BVfL6umRFhA/ebWrMA+tNk pecCbkgjyhk0oEZYTCuyL4HC1KrhWvFg7H2HdYVKtEDTiBT5h0fOOyNeTfbC+vFvTsx9 PMDg== X-Gm-Message-State: AElRT7E2Kgqb2PTcbWv0fMrjlMR7cdhDbA/nxKdiPgoZ2w6QXH3oRxaj pkqWjx9ju9LH+6HPpb/2rZLePw== X-Received: by 10.223.220.77 with SMTP id m13mr15422609wrj.274.1522945033006; Thu, 05 Apr 2018 09:17:13 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:d9b6:ce30:b76c:2e56]) by smtp.gmail.com with ESMTPSA id 39sm16103904wry.89.2018.04.05.09.17.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 09:17:12 -0700 (PDT) From: Daniel Lezcano To: viresh.kumar@linaro.org, edubezval@gmail.com Cc: kevin.wangtao@linaro.org, leo.yan@linaro.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org (open list:DOCUMENTATION) Subject: [PATCH v3 5/7] thermal/drivers/cpu_cooling: Add idle cooling device documentation Date: Thu, 5 Apr 2018 18:16:42 +0200 Message-Id: <1522945005-7165-6-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> References: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide some documentation for the idle injection cooling effect in order to let people to understand the rational of the approach for the idle injection CPU cooling device. Signed-off-by: Daniel Lezcano --- Documentation/thermal/cpu-idle-cooling.txt | 166 +++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 Documentation/thermal/cpu-idle-cooling.txt -- 2.7.4 diff --git a/Documentation/thermal/cpu-idle-cooling.txt b/Documentation/thermal/cpu-idle-cooling.txt new file mode 100644 index 0000000..457cd99 --- /dev/null +++ b/Documentation/thermal/cpu-idle-cooling.txt @@ -0,0 +1,166 @@ + +Situation: +---------- + +Under certain circumstances a SoC can reach the maximum temperature +limit or is unable to stabilize the temperature around a temperature +control. When the SoC has to stabilize the temperature, the kernel can +act on a cooling device to mitigate the dissipated power. When the +maximum temperature is reached and to prevent a reboot or a shutdown, +a decision must be taken to reduce the temperature under the critical +threshold, that impacts the performance. + +Another situation is when the silicon reaches a certain temperature +which continues to increase even if the dynamic leakage is reduced to +its minimum by clock gating the component. The runaway phenomena will +continue with the static leakage and only powering down the component, +thus dropping the dynamic and static leakage will allow the component +to cool down. + +Last but not least, the system can ask for a specific power budget but +because of the OPP density, we can only choose an OPP with a power +budget lower than the requested one and underuse the CPU, thus losing +performances. In other words, one OPP under uses the CPU with a power +lesser than the power budget and the next OPP exceed the power budget, +an intermediate OPP could have been used if it were present. + +Solutions: +---------- + +If we can remove the static and the dynamic leakage for a specific +duration in a controlled period, the SoC temperature will +decrease. Acting at the idle state duration or the idle cycle +injection period, we can mitigate the temperature by modulating the +power budget. + +The Operating Performance Point (OPP) density has a great influence on +the control precision of cpufreq, however different vendors have a +plethora of OPP density, and some have large power gap between OPPs, +that will result in loss of performance during thermal control and +loss of power in other scenes. + +At a specific OPP, we can assume injecting idle cycle on all CPUs, +belonging to the same cluster, with a duration greater than the +cluster idle state target residency, we drop the static and the +dynamic leakage for this period (modulo the energy needed to enter +this state). So the sustainable power with idle cycles has a linear +relation with the OPP’s sustainable power and can be computed with a +coefficient similar to: + + Power(IdleCycle) = Coef x Power(OPP) + +Idle Injection: +--------------- + +The base concept of the idle injection is to force the CPU to go to an +idle state for a specified time each control cycle, it provides +another way to control CPU power and heat in addition to +cpufreq. Ideally, if all CPUs belonging to the same cluster, inject +their idle cycle synchronously, the cluster can reach its power down +state with a minimum power consumption and static leakage +drop. However, these idle cycles injection will add extra latencies as +the CPUs will have to wakeup from a deep sleep state. + + ^ + | + | + |------- ------- ------- + |_______|_____|_______|_____|_______|___________ + + <-----> + idle <----> + running + +With the fixed idle injection duration, we can give a value which is +an acceptable performance drop off or latency when we reach a specific +temperature and we begin to mitigate by varying the Idle injection +period. + +The mitigation begins with a maximum period value which decrease when +more cooling effect is requested. When the period duration is equal to +the idle duration, then we are in a situation the platform can’t +dissipate the heat enough and the mitigation fails. In this case the +situation is considered critical and there is nothing to do. The idle +injection duration must be changed by configuration and until we reach +the cooling effect, otherwise an additionnal cooling device must be +used or ultimately decrease the SoC performance by dropping the +highest OPP point of the SoC. + +The idle injection duration value must comply with the constraints: + +- It is lesser or equal to the latency we tolerate when the mitigation + begins. It is platform dependent and will depend on the user + experience, reactivity vs performance trade off we want. This value + should be specified. + +- It is greater than the idle state’s target residency we want to go + for thermal mitigation, otherwise we end up consuming more energy. + +Minimum period +-------------- + +The idle injection duration being fixed, it is obvious the minimum +period can’t be lesser than that, otherwise we will be scheduling the +idle injection task right before the idle injection duration is +complete, so waking up the CPU to put it asleep again. + +Maximum period +-------------- + +The maximum period is the initial period when the mitigation +begins. Theoretically when we reach the thermal trip point, we have to +sustain a specified power for specific temperature but at this time we +consume: + + Power = Capacitance x Voltage^2 x Frequency x Utilisation + +... which is more than the sustainable power (or there is something +wrong on the system setup). The ‘Capacitance’ and ‘Utilisation’ are a +fixed value, ‘Voltage’ and the ‘Frequency’ are fixed artificially +because we don’t want to change the OPP. We can group the +‘Capacitance’ and the ‘Utilisation’ into a single term which is the +‘Dynamic Power Coefficient (Cdyn)’ Simplifying the above, we have: + + Pdyn = Cdyn x Voltage^2 x Frequency + +The IPA will ask us somehow to reduce our power in order to target the +sustainable power defined in the device tree. So with the idle +injection mechanism, we want an average power (Ptarget) resulting on +an amount of time running at full power on a specific OPP and idle +another amount of time. That could be put in a equation: + + P(opp)target = ((trunning x (P(opp)running) + (tidle P(opp)idle)) / + (trunning + tidle) + ... + + tidle = trunning x ((P(opp)running / P(opp)target) - 1) + +At this point if we know the running period for the CPU, that gives us +the idle injection, we need. Alternatively if we have the idle +injection duration, we can compute the running duration with: + + trunning = tidle / ((P(opp)running / P(opp)target) - 1) + +Practically, if the running power is lesses than the targeted power, +we end up with a negative time value, so obviously the equation usage +is bound to a power reduction, hence a higher OPP is needed to have +the running power greater than the targeted power. + +However, in this demonstration we ignore three aspects: + + * The static leakage is not defined here, we can introduce it in the + equation but assuming it will be zero most of the time as it is + difficult to get the values from the SoC vendors + + * The idle state wake up latency (or entry + exit latency) is not + taken into account, it must be added in the equation in order to + rigorously compute the idle injection + + * The injected idle duration must be greater than the idle state + target residency, otherwise we end up consuming more energy and + potentially invert the mitigation effect + +So the final equation is: + + trunning = (tidle - twakeup ) x + (((P(opp)dyn + P(opp)static ) - P(opp)target) / P(opp)target ) From patchwork Thu Apr 5 16:16:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 132862 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6479216ljb; Thu, 5 Apr 2018 09:17:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/gI3eANlZof4ayU5Ra9yafpljUEM3NbjpuE2wfwB9/VHVTz1dHqtMgjEOF7DNmgLJPofmL X-Received: by 2002:a17:902:96a:: with SMTP id 97-v6mr14337237plm.266.1522945066886; Thu, 05 Apr 2018 09:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522945066; cv=none; d=google.com; s=arc-20160816; b=TkZULaciec+jz6HBlEanJ03IfFmcbp9i9AeP8dNSdlTJLT0PvnIGUYA3RIpctSplII k+DEUHvDQ4q0nuwYJqflaa1OVvDoUGdSooBPKlwlZ0dhQXioZGs0VFhTP0Dc3j9qZXdz mq5IIqgyMEXy/NElsHjuDTfTQnEqrmMCyGu3vg1kFlNsgKd8afZ7+dVB2kysPqBsQ2/k rzhjbHZuvSU91oC7y9by1Kkgv7k1J7nProQeFa4MH1tnnpDVbtKrFFu78PsH/svJ6Lu8 Mbh71kX8T9T3bsjfCFJFPrFTxJqFVBG5+ph6gZ3I4wY+XGImEfeOomiMTefLABsx6h1h 37Ow== 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:arc-authentication-results; bh=jlBGW7IG0cxMqJ0R8rp6PHBq/Ooi8B6OhbGM2RsvyC0=; b=cqquGa5bmXzbUdRHD/RD/2HDJ6UNYsgiRKsbnd0SvBPL70TxaHHjq6zeApHBB185UZ Nbibn3CpeklitRvad6jv0XkHpP/1UlcvDKd1gVlg+5RVnRTYFBFTfu15iyTKviLOL1y8 55LDKrdALb4HoDUXZnjvJNR6W0wDdSPwJ6IqUp/AfjTdJLuYfUAEw0ehbVVUvVxmUogV jzyTwjabvMlO0OS1YYsmum89LFph9i3n5ztVQI1epmFIAnm86Us1S2QPS2Bd/zuCpDxM iu0H7OhGMnAiug13Y3yMuqvnvcx/mCglp/A4/rgZetIBNFDiQrDRXMBLvcqczrJw8YgB eJJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hG0dU8sJ; 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 l14si5699848pgu.581.2018.04.05.09.17.46; Thu, 05 Apr 2018 09:17:46 -0700 (PDT) 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=hG0dU8sJ; 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 S1751952AbeDEQRn (ORCPT + 29 others); Thu, 5 Apr 2018 12:17:43 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34074 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751749AbeDEQRR (ORCPT ); Thu, 5 Apr 2018 12:17:17 -0400 Received: by mail-wm0-f66.google.com with SMTP id w2so4010191wmw.1 for ; Thu, 05 Apr 2018 09:17:16 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=jlBGW7IG0cxMqJ0R8rp6PHBq/Ooi8B6OhbGM2RsvyC0=; b=hG0dU8sJpsY0+D3Pfik0wT3m50aohDX9XB8BGtKXqGHfnLbRdufGY8COCSFaixWR0L JTJZ8tqRbbrhlE3onAlw6JGqY9q7J6cv6fqL0hBaKbMKakqyk572D0qSvdsAPGbBnaU7 SNv54+WPCd19CKZzmVdvNVhWyZG0q+6gRmobI= 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=jlBGW7IG0cxMqJ0R8rp6PHBq/Ooi8B6OhbGM2RsvyC0=; b=Jx5WFlMT4sPGhRTF78EaOz+RPHY3tmET26eLrWVw6Lgt4Dk4SZzin0LiRryoQSxmMK D0P6kbe76U7udFOGU8WVAnASbCIjqinD4OkNUr1gq3Rs/CoqDDCWJ6mFzdYeN2clRI+P uMhI3gJjwfsvdktOnTLS8mhyruilaaqJ+4Ur+9HBcLEV6biR9k3uYGwcLrqI/POpactb lCj0EZkDEkGhndpRzRfjJHYWp+qgiZuiB5qb5JvddtMLQVsHqD+fEKN8Sf2VVnwE6akp pt/I5CWViX6+AfR0LGZmyqhIInH1Q8GwxvPrZjEvhltIJvRB70iZK76IoWQGey1x2Gyo kjxw== X-Gm-Message-State: ALQs6tBkFhEnem+6HEnCuNxCHTcNCCYL1HWTM9HSlgvoqj4nOk+lzgpd cI7dJJxU+DmuJaB2itkrgKHUjQ== X-Received: by 10.28.231.1 with SMTP id e1mr10178298wmh.76.1522945035586; Thu, 05 Apr 2018 09:17:15 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:d9b6:ce30:b76c:2e56]) by smtp.gmail.com with ESMTPSA id 39sm16103904wry.89.2018.04.05.09.17.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 09:17:14 -0700 (PDT) From: Daniel Lezcano To: viresh.kumar@linaro.org, edubezval@gmail.com Cc: kevin.wangtao@linaro.org, leo.yan@linaro.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org, Amit Daniel Kachhap Subject: [PATCH v3 6/7] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver Date: Thu, 5 Apr 2018 18:16:43 +0200 Message-Id: <1522945005-7165-7-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> References: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpu idle cooling driver performs synchronized idle injection across all cpus belonging to the same cluster and offers a new method to cool down a SoC. Each cluster has its own idle cooling device, each core has its own idle injection thread, each idle injection thread uses play_idle to enter idle. In order to reach the deepest idle state, each cooling device has the idle injection threads synchronized together. It has some similarity with the intel power clamp driver but it is actually designed to work on the ARM architecture via the DT with a mathematical proof with the power model which comes with the Documentation. The idle injection cycle is fixed while the running cycle is variable. That allows to have control on the device reactivity for the user experience. At the mitigation point the idle threads are unparked, they play idle the specified amount of time and they schedule themselves. The last thread sets the next idle injection deadline and when the timer expires it wakes up all the threads which in turn play idle again. Meanwhile the running cycle is changed by set_cur_state. When the mitigation ends, the threads are parked. The algorithm is self adaptive, so there is no need to handle hotplugging. If we take an example of the balanced point, we can use the DT for the hi6220. The sustainable power for the SoC is 3326mW to mitigate at 75°C. Eight cores running at full blast at the maximum OPP consumes 5280mW. The first value is given in the DT, the second is calculated from the OPP with the formula: Pdyn = Cdyn x Voltage^2 x Frequency As the SoC vendors don't want to share the static leakage values, we assume it is zero, so the Prun = Pdyn + Pstatic = Pdyn + 0 = Pdyn. In order to reduce the power to 3326mW, we have to apply a ratio to the running time. ratio = (Prun - Ptarget) / Ptarget = (5280 - 3326) / 3326 = 0,5874 We know the idle cycle which is fixed, let's assume 10ms. However from this duration we have to substract the wake up latency for the cluster idle state. In our case, it is 1.5ms. So for a 10ms latency for idle, we are really idle 8.5ms. As we know the idle duration and the ratio, we can compute the running cycle. running_cycle = 8.5 / 0.5874 = 14.47ms So for 8.5ms of idle, we have 14.47ms of running cycle, and that brings the SoC to the balanced trip point of 75°C. The driver has been tested on the hi6220 and it appears the temperature stabilizes at 75°C with an idle injection time of 10ms (8.5ms real) and running cycle of 14ms as expected by the theory above. Signed-off-by: Kevin Wangtao Signed-off-by: Daniel Lezcano --- drivers/thermal/Kconfig | 10 + drivers/thermal/cpu_cooling.c | 479 ++++++++++++++++++++++++++++++++++++++++++ include/linux/cpu_cooling.h | 6 + 3 files changed, 495 insertions(+) -- 2.7.4 diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 5aaae1b..6c34117 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -166,6 +166,16 @@ config CPU_FREQ_THERMAL This will be useful for platforms using the generic thermal interface and not the ACPI interface. +config CPU_IDLE_THERMAL + bool "CPU idle cooling strategy" + depends on CPU_IDLE + help + This implements the generic CPU cooling mechanism through + idle injection. This will throttle the CPU by injecting + fixed idle cycle. All CPUs belonging to the same cluster + will enter idle synchronously to reach the deepest idle + state. + endchoice config CLOCK_THERMAL diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 5c219dc..1eec8d6 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -10,18 +10,33 @@ * Viresh Kumar * */ +#define pr_fmt(fmt) "CPU cooling: " fmt + #include #include #include +#include #include +#include #include +#include #include #include +#include +#include +#include #include #include +#include + +#include +#include + #include +#include + #ifdef CONFIG_CPU_FREQ_THERMAL /* * Cooling state <-> CPUFreq frequency @@ -928,3 +943,467 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) } EXPORT_SYMBOL_GPL(cpufreq_cooling_unregister); #endif /* CONFIG_CPU_FREQ_THERMAL */ + +#ifdef CONFIG_CPU_IDLE_THERMAL +/** + * struct cpuidle_cooling_device - data for the idle cooling device + * @cdev: a pointer to a struct thermal_cooling_device + * @cpumask: a cpumask containing the CPU managed by the cooling device + * @timer: a hrtimer giving the tempo for the idle injection cycles + * @kref: a kernel refcount on this structure + * @count: an atomic to keep track of the last task exiting the idle cycle + * @idle_cycle: an integer defining the duration of the idle injection + * @state: an normalized integer giving the state of the cooling device + */ +struct cpuidle_cooling_device { + struct thermal_cooling_device *cdev; + struct cpumask *cpumask; + struct hrtimer timer; + struct kref kref; + atomic_t count; + unsigned int idle_cycle; + unsigned long state; +}; + +struct cpuidle_cooling_thread { + struct task_struct *tsk; + int should_run; +}; + +static DEFINE_PER_CPU(struct cpuidle_cooling_thread, cpuidle_cooling_thread); +static DEFINE_PER_CPU(struct cpuidle_cooling_device *, cpuidle_cooling_device); + +/** + * cpuidle_cooling_wakeup - Wake up all idle injection threads + * @idle_cdev: the idle cooling device + * + * Every idle injection task belonging to the idle cooling device and + * running on an online cpu will be wake up by this call. + */ +static void cpuidle_cooling_wakeup(struct cpuidle_cooling_device *idle_cdev) +{ + struct cpuidle_cooling_thread *cct; + int cpu; + + for_each_cpu_and(cpu, idle_cdev->cpumask, cpu_online_mask) { + cct = per_cpu_ptr(&cpuidle_cooling_thread, cpu); + cct->should_run = 1; + wake_up_process(cct->tsk); + } +} + +/** + * cpuidle_cooling_wakeup_fn - Running cycle timer callback + * @timer: a hrtimer structure + * + * When the mitigation is acting, the CPU is allowed to run an amount + * of time, then the idle injection happens for the specified delay + * and the idle task injection schedules itself until the timer event + * wakes the idle injection tasks again for a new idle injection + * cycle. The time between the end of the idle injection and the timer + * expiration is the allocated running time for the CPU. + * + * Always returns HRTIMER_NORESTART + */ +static enum hrtimer_restart cpuidle_cooling_wakeup_fn(struct hrtimer *timer) +{ + struct cpuidle_cooling_device *idle_cdev = + container_of(timer, struct cpuidle_cooling_device, timer); + + cpuidle_cooling_wakeup(idle_cdev); + + return HRTIMER_NORESTART; +} + +/** + * cpuidle_cooling_runtime - Running time computation + * @idle_cdev: the idle cooling device + * + * The running duration is computed from the idle injection duration + * which is fixed. If we reach 100% of idle injection ratio, that + * means the running duration is zero. If we have a 50% ratio + * injection, that means we have equal duration for idle and for + * running duration. + * + * The formula is deduced as the following: + * + * running = idle x ((100 / ratio) - 1) + * + * For precision purpose for integer math, we use the following: + * + * running = (idle x 100) / ratio - idle + * + * For example, if we have an injected duration of 50%, then we end up + * with 10ms of idle injection and 10ms of running duration. + * + * Returns a s64 nanosecond based + */ +static s64 cpuidle_cooling_runtime(struct cpuidle_cooling_device *idle_cdev) +{ + s64 next_wakeup; + unsigned long state = idle_cdev->state; + + /* + * The function should not be called when there is no + * mitigation because: + * - that does not make sense + * - we end up with a division by zero + */ + if (!state) + return 0; + + next_wakeup = (s64)((idle_cdev->idle_cycle * 100) / state) - + idle_cdev->idle_cycle; + + return next_wakeup * NSEC_PER_USEC; +} + +/** + * cpuidle_cooling_injection - Idle injection mainloop thread function + * @cpu: an integer giving the cpu number the thread is pinned on + * + * This main function does basically two operations: + * + * - Goes idle for a specific amount of time + * + * - Sets a timer to wake up all the idle injection threads after a + * running period + * + * That happens only when the mitigation is enabled, otherwise the + * task is scheduled out. + * + * In order to keep the tasks synchronized together, it is the last + * task exiting the idle period which is in charge of setting the + * timer. + * + * This function never returns. + */ +static void cpuidle_cooling_injection(unsigned int cpu) +{ + s64 next_wakeup; + + struct cpuidle_cooling_device *idle_cdev = + per_cpu(cpuidle_cooling_device, cpu); + + struct cpuidle_cooling_thread *cct = + per_cpu_ptr(&cpuidle_cooling_thread, cpu); + + atomic_inc(&idle_cdev->count); + + cct->should_run = 0; + + play_idle(idle_cdev->idle_cycle / USEC_PER_MSEC); + + /* + * The last CPU waking up is in charge of setting the + * timer. If the CPU is hotplugged, the timer will + * move to another CPU (which may not belong to the + * same cluster) but that is not a problem as the + * timer will be set again by another CPU belonging to + * the cluster, so this mechanism is self adaptive and + * does not require any hotplugging dance. + */ + if (!atomic_dec_and_test(&idle_cdev->count)) + return; + + next_wakeup = cpuidle_cooling_runtime(idle_cdev); + if (next_wakeup) + hrtimer_start(&idle_cdev->timer, ns_to_ktime(next_wakeup), + HRTIMER_MODE_REL_PINNED); +} + +static void cpuidle_cooling_setup(unsigned int cpu) +{ + struct sched_param param = { .sched_priority = MAX_USER_RT_PRIO/2 }; + + set_freezable(); + + sched_setscheduler(current, SCHED_FIFO, ¶m); +} + +static int cpuidle_cooling_should_run(unsigned int cpu) +{ + struct cpuidle_cooling_thread *cct = + per_cpu_ptr(&cpuidle_cooling_thread, cpu); + + return cct->should_run; +} + +static struct smp_hotplug_thread cpuidle_cooling_threads = { + .store = &cpuidle_cooling_thread.tsk, + .thread_fn = cpuidle_cooling_injection, + .thread_comm = "thermal-idle/%u", + .thread_should_run = cpuidle_cooling_should_run, + .setup = cpuidle_cooling_setup, +}; + +/** + * cpuidle_cooling_get_max_state - Get the maximum state + * @cdev : the thermal cooling device + * @state : a pointer to the state variable to be filled + * + * The function always gives 100 as the injection ratio is percentile + * based for consistency accros different platforms. + * + * The function can not fail, it always returns zero. + */ +static int cpuidle_cooling_get_max_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + /* + * Depending on the configuration or the hardware, the running + * cycle and the idle cycle could be different. We want unify + * that to an 0..100 interval, so the set state interface will + * be the same whatever the platform is. + * + * The state 100% will make the cluster 100% ... idle. A 0% + * injection ratio means no idle injection at all and 50% + * means for 10ms of idle injection, we have 10ms of running + * time. + */ + *state = 100; + + return 0; +} + +/** + * cpuidle_cooling_get_cur_state - Get the current cooling state + * @cdev: the thermal cooling device + * @state: a pointer to the state + * + * The function just copy the state value from the private thermal + * cooling device structure, the mapping is 1 <-> 1. + * + * The function can not fail, it always returns zero. + */ +static int cpuidle_cooling_get_cur_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + struct cpuidle_cooling_device *idle_cdev = cdev->devdata; + + *state = idle_cdev->state; + + return 0; +} + +/** + * cpuidle_cooling_set_cur_state - Set the current cooling state + * @cdev: the thermal cooling device + * @state: the target state + * + * The function checks first if we are initiating the mitigation which + * in turn wakes up all the idle injection tasks belonging to the idle + * cooling device. In any case, it updates the internal state for the + * cooling device. + * + * The function can not fail, it always returns zero. + */ +static int cpuidle_cooling_set_cur_state(struct thermal_cooling_device *cdev, + unsigned long state) +{ + struct cpuidle_cooling_device *idle_cdev = cdev->devdata; + unsigned long current_state = idle_cdev->state; + + idle_cdev->state = state; + + if (current_state == 0 && state > 0) { + pr_debug("Starting cooling cpus '%*pbl'\n", + cpumask_pr_args(idle_cdev->cpumask)); + cpuidle_cooling_wakeup(idle_cdev); + } else if (current_state > 0 && !state) { + pr_debug("Stopping cooling cpus '%*pbl'\n", + cpumask_pr_args(idle_cdev->cpumask)); + } + + return 0; +} + +/** + * cpuidle_cooling_ops - thermal cooling device ops + */ +static struct thermal_cooling_device_ops cpuidle_cooling_ops = { + .get_max_state = cpuidle_cooling_get_max_state, + .get_cur_state = cpuidle_cooling_get_cur_state, + .set_cur_state = cpuidle_cooling_set_cur_state, +}; + +/** + * cpuidle_cooling_release - Kref based release helper + * @kref: a pointer to the kref structure + * + * This function is automatically called by the kref_put function when + * the idle cooling device refcount reaches zero. At this point, we + * have the guarantee the structure is no longer in use and we can + * safely release all the ressources. + */ +static void __init cpuidle_cooling_release(struct kref *kref) +{ + struct cpuidle_cooling_device *idle_cdev = + container_of(kref, struct cpuidle_cooling_device, kref); + + if (idle_cdev->cdev) + thermal_cooling_device_unregister(idle_cdev->cdev); + + hrtimer_cancel(&idle_cdev->timer); + kfree(idle_cdev); +} + +/** + * cpuilde_cooling_unregister - Idle cooling device exit function + * + * This function unregisters the cpuidle cooling device and frees the + * ressources previously allocated by the init function. This function + * is called when the initialization fails. + */ +static void __init cpuidle_cooling_unregister(void) +{ + struct cpuidle_cooling_device *idle_cdev; + int cpu; + + for_each_possible_cpu(cpu) { + idle_cdev = per_cpu(cpuidle_cooling_device, cpu); + if (idle_cdev) + kref_put(&idle_cdev->kref, cpuidle_cooling_release); + } +} + + +/** + * cpuidle_cooling_alloc - Allocate and initialize an idle cooling device + * @cpumask: a cpumask containing all the cpus handled by the cooling device + * + * The function is called at init time only. It allocates and + * initializes the different fields of the cpuidle cooling device + * + * It returns a pointer to an cpuidle_cooling_device structure on + * success, NULL on error. + */ +static struct cpuidle_cooling_device * __init cpuidle_cooling_alloc( + cpumask_t *cpumask) +{ + struct cpuidle_cooling_device *idle_cdev; + int cpu; + + idle_cdev = kzalloc(sizeof(*idle_cdev), GFP_KERNEL); + if (!idle_cdev) + return NULL; + + /* + * The idle duration injection. As we don't have yet a way to + * specify from the DT configuration, let's default to a tick + * duration. + */ + idle_cdev->idle_cycle = TICK_USEC; + + /* + * Initialize the timer to wakeup all the idle injection tasks + */ + hrtimer_init(&idle_cdev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + + /* + * The wakeup function callback which is in charge of waking + * up all CPUs belonging to the same cluster + */ + idle_cdev->timer.function = cpuidle_cooling_wakeup_fn; + + idle_cdev->cpumask = cpumask; + + /* + * Assign on a per cpu basis belonging to the cluster, the per + * cpu cpuidle_cooling_device pointer and increment its + * refcount on it + */ + for_each_cpu(cpu, cpumask) { + kref_get(&idle_cdev->kref); + per_cpu(cpuidle_cooling_device, cpu) = idle_cdev; + } + + return idle_cdev; +} + +/** + * cpuidle_cooling_register - Idle cooling device initialization function + * + * This function is in charge of creating a cooling device per cluster + * and register it to thermal framework. For this we rely on the + * topology as there is nothing yet describing better the idle state + * power domains. + * + * We create a cpuidle cooling device per cluster. For this reason we + * must, for each cluster, allocate and initialize the cooling device + * and for each cpu belonging to this cluster, do the initialization + * on a cpu basis. + * + * This approach for creating the cooling device is needed as we don't + * have the guarantee the CPU numbering is sequential. + * + * Unfortunately, there is no API to browse from top to bottom the + * topology, cluster->cpu, only the usual for_each_possible_cpu loop. + * In order to solve that, we use a cpumask to flag the cluster_id we + * already processed. The cpumask will always have enough room for all + * the cluster because it is based on NR_CPUS and it is not possible + * to have more clusters than cpus. + * + */ +void __init cpuidle_cooling_register(void) +{ + struct cpuidle_cooling_device *idle_cdev = NULL; + struct thermal_cooling_device *cdev; + struct device_node *np; + cpumask_var_t cpumask; + char dev_name[THERMAL_NAME_LENGTH]; + int ret = -ENOMEM, cpu; + int cluster_id; + + if (!zalloc_cpumask_var(&cpumask, GFP_KERNEL)) + return; + + for_each_possible_cpu(cpu) { + + cluster_id = topology_physical_package_id(cpu); + if (cpumask_test_cpu(cluster_id, cpumask)) + continue; + + /* + * Allocate the cpuidle cooling device with the list + * of the cpus belonging to the cluster. + */ + idle_cdev = cpuidle_cooling_alloc(topology_core_cpumask(cpu)); + if (!idle_cdev) + goto out; + + /* + * The thermal cooling device name, we use the + * cluster_id as the numbering index for the idle + * cooling device. + */ + snprintf(dev_name, sizeof(dev_name), "thermal-idle-%d", + cluster_id); + + np = of_cpu_device_node_get(cpu); + cdev = thermal_of_cooling_device_register(np, dev_name, + idle_cdev, + &cpuidle_cooling_ops); + if (IS_ERR(cdev)) { + ret = PTR_ERR(cdev); + goto out; + } + + idle_cdev->cdev = cdev; + cpumask_set_cpu(cluster_id, cpumask); + } + + ret = smpboot_register_percpu_thread(&cpuidle_cooling_threads); + if (ret) + goto out; + + pr_info("Created cpuidle cooling device\n"); +out: + free_cpumask_var(cpumask); + + if (ret) { + cpuidle_cooling_unregister(); + pr_err("Failed to create idle cooling device (%d)\n", ret); + } +} +#endif /* CONFIG_CPU_IDLE_THERMAL */ diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index c0accc7..af5520d 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -120,4 +120,10 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) } #endif /* CONFIG_CPU_FREQ_THERMAL */ +#ifdef CONFIG_CPU_IDLE_THERMAL +extern void __init cpuidle_cooling_register(void); +#else /* CONFIG_CPU_IDLE_THERMAL */ +static inline void __init cpuidle_cooling_register(void) { } +#endif /* CONFIG_CPU_IDLE_THERMAL */ + #endif /* __CPU_COOLING_H__ */ From patchwork Thu Apr 5 16:16:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 132861 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6478858ljb; Thu, 5 Apr 2018 09:17:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Kwiy1aQV/FdFOM81gEQqEA9jMQ0C8ggArhpIqps+aNdEap0G1Emo2rfPIoO4L05KC7/RD X-Received: by 2002:a17:902:481:: with SMTP id e1-v6mr23500365ple.377.1522945045589; Thu, 05 Apr 2018 09:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522945045; cv=none; d=google.com; s=arc-20160816; b=HJDhQhHV3P8wlTl4VANcvwhLEEVhN3jXYFL6pwlzukULTEyMz1kq3A71IsmPRDJw78 pFEwG7qOF+h2qU/oMCalRDXyJGIxsoS7B8vcWQNL4VJS8FpnuHpO5+NPldvRcNVZRLj7 47aQYEA5XcHwn9JgmNF8kzXnc84yGZ9FaxyYBNr5eAER06vWrCi8kpSjKZ3JfIgOALQq /q8XIk9FiKZIl8vMql1ruzNt/VhMqfveAvzFf+MoKdWxrm1S7ViWVDtglvTykF/aTbMB h2N7HsdnvKnxqdf1JusoxxN+CCmN0xjAVpTJy2J98FOAJJFVWRgBdnq3JMpS94l3FDRn nhTA== 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:arc-authentication-results; bh=HMUgRsnp5i+EwldG5PrOxH3N+5NTckV2ApKZLinDzEI=; b=Dpi0lQv2js9jTN4gbOo/AOP33XkQeRi7j8lfuGYmEj8pVFQIK7da7x9Az7c0A4KLoj zGinYmAw276WE8jUTziA/VOY61xI9bDZFI7894YN9rOT0Y8uAHfjudCy8vRZ3KUtYWIO TYHi24wNmDpYz+0bRss1a9UARB7dHigIiG0fdql+HWw7pJWmiah7uTOz6PI/P9kYL9B3 /wjcgO4BFJ/6sydSQDHX3NZJh2C2z+8TmVn+czP6lYbjqCXPbGhGEHMZZopGIRZ463iY e/W9Kylk/OzRET84B8KZn4iu6ZMT4vx4bLsi98xfC1lCa0XmqzvuxU8hK8+EDO4h7N7s s5rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CJHPmo3/; 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 a17si5649311pgn.429.2018.04.05.09.17.25; Thu, 05 Apr 2018 09:17:25 -0700 (PDT) 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=CJHPmo3/; 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 S1751928AbeDEQRU (ORCPT + 29 others); Thu, 5 Apr 2018 12:17:20 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38562 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807AbeDEQRS (ORCPT ); Thu, 5 Apr 2018 12:17:18 -0400 Received: by mail-wr0-f195.google.com with SMTP id m13so29375662wrj.5 for ; Thu, 05 Apr 2018 09:17:18 -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:in-reply-to:references; bh=HMUgRsnp5i+EwldG5PrOxH3N+5NTckV2ApKZLinDzEI=; b=CJHPmo3/KQZLNxpuo/olubojS9ajydW50SLNGVqTiXAKXuYXPKCIj7NiagpO64LnSc Izq8rg1BBjNcky6uZM2nCTgG9brvNLhSZZwW31RvtL4iXgPwi+8G5g5vu8XquIh2VoK9 MIqtu57iaqM0Qul2gKFU4j4D05zuo7IfyCFdY= 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=HMUgRsnp5i+EwldG5PrOxH3N+5NTckV2ApKZLinDzEI=; b=auRYzFc20EiG/tq0p0A8TxkZZKiPvcwD5IiH4/oIJaxU6slo59fFND5tdpijtLgAzc MOXJSfj9Sqb54T3+agb1FXGKipJxtgUxTkWlP0QbTZFWiT+9SfJl2K+knf6tWpd74W22 URee8GtuaXHMcIrYH2mMR+K7WmknflbzSYG0zYFrvuQUejJkmAfwrkfW0H7SxOrxvGlL YeUfHFTriAWxWSC04bUEvqMMeGKes7LDJulBba5Ga7mrca8hUJLzkq+Cs6zg7gC/MrJZ aBbIT0VfxwuLPm5oSEO+JjMfCyTaiNf6ECJBxFTAp07A2dFMtBDpxXhl8t/+GQYSgvzi qKSQ== X-Gm-Message-State: AElRT7EWA7wPa59gFlIMTCS2Ko31PD0KE3NO/ykhHDTBDjVLSXcESIDw hkT+Rc+XoP2ffg3ks/qpvxLq+Q== X-Received: by 10.223.226.14 with SMTP id j14mr15877725wri.17.1522945037536; Thu, 05 Apr 2018 09:17:17 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:d9b6:ce30:b76c:2e56]) by smtp.gmail.com with ESMTPSA id 39sm16103904wry.89.2018.04.05.09.17.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 09:17:16 -0700 (PDT) From: Daniel Lezcano To: viresh.kumar@linaro.org, edubezval@gmail.com Cc: kevin.wangtao@linaro.org, leo.yan@linaro.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org, "Rafael J. Wysocki" Subject: [PATCH v3 7/7] cpuidle/drivers/cpuidle-arm: Register the cooling device Date: Thu, 5 Apr 2018 18:16:44 +0200 Message-Id: <1522945005-7165-8-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> References: <1522945005-7165-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Register the ARM generic cpuidle driver as a cooling device. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle-arm.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 Acked-by: Viresh Kumar diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index ddee1b6..44b4fe3 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -11,6 +11,7 @@ #define pr_fmt(fmt) "CPUidle arm: " fmt +#include #include #include #include @@ -172,6 +173,8 @@ static int __init arm_idle_init(void) goto out_fail; } + cpuidle_cooling_register(); + return 0; out_fail: