Message ID | 20221201085423.10360-1-di.shen@unisoc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp153458wrr; Thu, 1 Dec 2022 01:06:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf7K8rpSokMmDvJeO/qlaeekb/SZzi2+8T81NBKFK8G3c+B1Eg9O4rdVLUHbQQGbrvh1/PHH X-Received: by 2002:a05:6402:e8c:b0:468:89dd:aa0b with SMTP id h12-20020a0564020e8c00b0046889ddaa0bmr59780544eda.258.1669885586251; Thu, 01 Dec 2022 01:06:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669885586; cv=none; d=google.com; s=arc-20160816; b=v5J93PuyK2eOTt6YuSsZqlbBF0eGDNTekEdkRaJvBKB0+Vg7kMohEt6wz9m6EeOMhC V1vXzb7Fhh00XNECS5TyOP393XYkjso2hhtqiLG/JVY7VL97+C79H8rEi7f2NYRZMI/b cBXh906iLgeyRAPI2G1vtsbSaL+/wcwa9qeMMykNrgRT+l8Ey6s1TuM7qH+i/iuZJ+uW 0Qu9OcPVHz+pccNqC5ulabYaiRKJ6wyTu6eksKk2lxR28NpN7dbtMGBXXODwh/39HTDC Q1xqEVoBpv0wZ0aCmcrZmrsnIntQxZwCfIif02ekkuJqxMmlr1G1R83/JQIsKobt+aVG 18Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=14qbYOEYpzReMsIPScSsUx8HUeChG3nOvHbGQWlJUb4=; b=jpLpjhxatNmkmxkbtyMAJ8s3pzu5wshWWERgfqAiWRTkzKhVoKQEcZ91dYQtpqZxPx W2hP/UzQ/rd2Q1huPGSHlj2VW+n9BEN99FbKBucOW27NDa0N0jeINxjhitKROwh+PHS3 BO3PB9KeXsdVern1y7RfotSrlbmg1sqdXiBRS3xmpKVFyd5oAIiUXMDN7bDyn04+LrfH GBvHQsi7fHmHovW+5+jpktx+Ok66o2A+r5Ae/CgF6LEdM4iAV263xMKi9NzPuVlvADcV kN9vPg7uEfqo2ne33wQbCTRGlqCMt0OjubSXHMTgXNqCiWIg0RnIRT7xoBZNLJ67EM++ aVoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg11-20020a170907a40b00b0078df3bd80b9si3628554ejc.46.2022.12.01.01.06.02; Thu, 01 Dec 2022 01:06:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229877AbiLAI4n (ORCPT <rfc822;heyuhang3455@gmail.com> + 99 others); Thu, 1 Dec 2022 03:56:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbiLAI4i (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 1 Dec 2022 03:56:38 -0500 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA55C4A06F; Thu, 1 Dec 2022 00:56:34 -0800 (PST) Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTPS id 2B18sQ3b030588 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Thu, 1 Dec 2022 16:54:26 +0800 (CST) (envelope-from Di.Shen@unisoc.com) Received: from bj10906pcu1.spreadtrum.com (10.0.74.51) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 1 Dec 2022 16:54:27 +0800 From: Di Shen <di.shen@unisoc.com> To: <rafael@kernel.org>, <daniel.lezcano@linaro.org>, <amitk@kernel.org>, <rui.zhang@intel.com> CC: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <xuewen.yan@unisoc.com> Subject: [PATCH] thermal/of: Allow users to set governor for a thermal zone in DT Date: Thu, 1 Dec 2022 16:54:23 +0800 Message-ID: <20221201085423.10360-1-di.shen@unisoc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.74.51] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 2B18sQ3b030588 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751001948524861128?= X-GMAIL-MSGID: =?utf-8?q?1751001948524861128?= |
Series |
thermal/of: Allow users to set governor for a thermal zone in DT
|
|
Commit Message
Di Shen
Dec. 1, 2022, 8:54 a.m. UTC
The governor of all thermal zones can be initialized in
thermal_zone_device_register_with_trips(), but it is always the
def_governor, this means the governor of all thermal zones are
the same.
Allow users to set governor for a specific thermal zone in DT, in
this way, users can use different policies for thermal management.
Signed-off-by: Di Shen <di.shen@unisoc.com>
---
drivers/thermal/thermal_of.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
Hi Di, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on rafael-pm/thermal] [also build test WARNING on linus/master v6.1-rc7 next-20221201] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Di-Shen/thermal-of-Allow-users-to-set-governor-for-a-thermal-zone-in-DT/20221201-165820 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal patch link: https://lore.kernel.org/r/20221201085423.10360-1-di.shen%40unisoc.com patch subject: [PATCH] thermal/of: Allow users to set governor for a thermal zone in DT config: ia64-allyesconfig compiler: ia64-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/6ac4585641eca02d031f54111ca54507d5a3dc56 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Di-Shen/thermal-of-Allow-users-to-set-governor-for-a-thermal-zone-in-DT/20221201-165820 git checkout 6ac4585641eca02d031f54111ca54507d5a3dc56 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): In function 'thermal_of_parameters_init', inlined from 'thermal_of_zone_register' at drivers/thermal/thermal_of.c:626:8: >> drivers/thermal/thermal_of.c:370:17: warning: 'strncpy' specified bound 20 equals destination size [-Wstringop-truncation] 370 | strncpy(tzp->governor_name, governor_name, THERMAL_NAME_LENGTH); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vim +/strncpy +370 drivers/thermal/thermal_of.c 351 352 static struct thermal_zone_params *thermal_of_parameters_init(struct device_node *np) 353 { 354 struct thermal_zone_params *tzp; 355 int coef[2]; 356 int ncoef = ARRAY_SIZE(coef); 357 int prop, ret; 358 const char *governor_name; 359 360 tzp = kzalloc(sizeof(*tzp), GFP_KERNEL); 361 if (!tzp) 362 return ERR_PTR(-ENOMEM); 363 364 tzp->no_hwmon = true; 365 366 if (!of_property_read_u32(np, "sustainable-power", &prop)) 367 tzp->sustainable_power = prop; 368 369 if (!of_property_read_string(np, "policy", &governor_name)) > 370 strncpy(tzp->governor_name, governor_name, THERMAL_NAME_LENGTH); 371 372 /* 373 * For now, the thermal framework supports only one sensor per 374 * thermal zone. Thus, we are considering only the first two 375 * values as slope and offset. 376 */ 377 ret = of_property_read_u32_array(np, "coefficients", coef, ncoef); 378 if (ret) { 379 coef[0] = 1; 380 coef[1] = 0; 381 } 382 383 tzp->slope = coef[0]; 384 tzp->offset = coef[1]; 385 386 return tzp; 387 } 388
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index d4b6335ace15..5dd4101dffb6 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -355,6 +355,7 @@ static struct thermal_zone_params *thermal_of_parameters_init(struct device_node int coef[2]; int ncoef = ARRAY_SIZE(coef); int prop, ret; + const char *governor_name; tzp = kzalloc(sizeof(*tzp), GFP_KERNEL); if (!tzp) @@ -365,6 +366,9 @@ static struct thermal_zone_params *thermal_of_parameters_init(struct device_node if (!of_property_read_u32(np, "sustainable-power", &prop)) tzp->sustainable_power = prop; + if (!of_property_read_string(np, "policy", &governor_name)) + strncpy(tzp->governor_name, governor_name, THERMAL_NAME_LENGTH); + /* * For now, the thermal framework supports only one sensor per * thermal zone. Thus, we are considering only the first two