Message ID | 53d4ed4e5b18a59a48790434f8146fb207e11c49.1680494945.git.viresh.kumar@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2054531vqo; Sun, 2 Apr 2023 21:19:49 -0700 (PDT) X-Google-Smtp-Source: AKy350ba2mn1htM8qf5vIQYZNdADD/0aLwIWiX7QOpHLB42Jc52p++osHdENGiZoeLfOlCP9K5E7 X-Received: by 2002:a17:907:70a:b0:946:bfb0:de85 with SMTP id xb10-20020a170907070a00b00946bfb0de85mr26101313ejb.70.1680495588843; Sun, 02 Apr 2023 21:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680495588; cv=none; d=google.com; s=arc-20160816; b=u4uobZ5oFIfJpdBLLl76+U0YeXj3IpBTZ6H28y029CcMvdNbdkWpsGb+n22y8t8WEO CiOXd9cglA0agn6YukbAeDpv47ZcGvryE3SYp7xSwy6kQ0hQ0qf1yChp4F82S/YpiB1H yUAlDRE62EgluPHIrZ2JZnwrD/2k37RuP92pzrjH2bsQgbENqavkhiCRX1Yo6Yrz+2lh jkqoQ0SdfXCA9srGI/a6naBltnwUm1B8fVP6+XV7dl/liZnz0kpi+XM7Ckj2uVTCleFu EBFgX3tRwz3Kuem4zrYrHbRwH7aoXUm7dAkmn/6gxgLI4YHgm9gSS89ireFdGH44imbN gJQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=IFu94iGKIxr0rnW3XDzndZIjAhiSRiBbITi+tUgIJrA=; b=iQxOZMIDWz8jYO2GRI1ys8qtsMG2MZkAvSfHPWdwxe396pDok9uB34anvllm/pyx+H jm/LwnvpbwVLAIMGKv46Eneevm51whkS/ruVIytS52AHk4KSaMeUl39urmyMFGp61whI Q/zE+Vti4indC9wBNNj621+LFbGp0TeiWg8pFqc14ZNqpBVnW5X/UYYERC4j2i0DCIEX +jc8jSlXxuLNi+VAwbhoWCBpcMqy0pIEwMhN4hTyScJqf834AZQNZY9JvlF5OivtG/Rd mGNwcJGBzJzEd/WdX7Y6YyKZqhK6KoQODNOU0VVamPuZ6DLhNqBJ+14NcCyj9uwk2QAA OxBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bPnPfkBF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lm16-20020a170906981000b00931c8c48968si3801382ejb.697.2023.04.02.21.19.25; Sun, 02 Apr 2023 21:19:48 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=bPnPfkBF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230511AbjDCEJZ (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Mon, 3 Apr 2023 00:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230057AbjDCEJX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 3 Apr 2023 00:09:23 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B22BE83F7 for <linux-kernel@vger.kernel.org>; Sun, 2 Apr 2023 21:09:22 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id ja10so26762995plb.5 for <linux-kernel@vger.kernel.org>; Sun, 02 Apr 2023 21:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680494962; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IFu94iGKIxr0rnW3XDzndZIjAhiSRiBbITi+tUgIJrA=; b=bPnPfkBFJy1+lcAM/vPKfoNGlqE1I9mlXD/IPdHdAj0hGvBd8fh4F9Xu5Z9M8pTkub zQ5xhZn4LDVRiAQVUbXPOXXsCXZGLawHNIK0pzCT+yOxM27LGGqkRbMELNKr+jUsiQyc Ys1IeooSloMOzGXDcLVm+W9OGuMqYBxWz5E3K/reC9AlOzoNtIYfGr1NsPsgx79jsUBn x8md3y8fRNV2mG4DVxirRGNVVmR1QBfPgvvJ7h9JkPgRnWfdwWQ1Nhbm7Zuc4XkztsTU +pWIdolBv+8HSyGNwPOyuBzU2Uo+HyWsyqMM0qe3HS4s0QotWsPRi+EHWPIJ77/h4oHR cNng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680494962; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IFu94iGKIxr0rnW3XDzndZIjAhiSRiBbITi+tUgIJrA=; b=uRxEwu8h8PBHxjRGfrsKjEJPYdG1XoV3AE5DWZyfX2I2iIQDT90Tvx1q4kHx0pxoTZ u9XLv6Tma9nnXcpZWT8pEr/ZNdIg7GIE1SOrV/oWUrHSTzbaQmYgsNsYqb+t/oiFhxfM ypu/vuS6w5V7jNJlUx/VDtN6ubieAoAZnYCTrfabhfUP4XWONLLC+eOcYwMV4soCAQcu Lq9zpRsN09yXrL+wE9ZTyct8VWzb9VcuSe6ffBEPxVclq0DYoCQmE9qYZI04ZEbPKm/F XgkzGaQnSiAoTzMfulGGdCNTXv4Qe8+28iq2JnCq4RU4DXVUDsfGMaCGpt98DUynf/bY PDPw== X-Gm-Message-State: AAQBX9duP3ipGH1pRUs//lvWH51LTxxPSbs3+KI+z4A9o8pkLRlXX0DJ W44AGHCH9vCBIuNuDCiL7yZeNQ== X-Received: by 2002:a17:903:210d:b0:1a2:3b6:8319 with SMTP id o13-20020a170903210d00b001a203b68319mr28578838ple.54.1680494961991; Sun, 02 Apr 2023 21:09:21 -0700 (PDT) Received: from localhost ([122.172.85.168]) by smtp.gmail.com with ESMTPSA id t8-20020a170902a5c800b0019c2b1c4ad4sm5548816plq.6.2023.04.02.21.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 21:09:21 -0700 (PDT) From: Viresh Kumar <viresh.kumar@linaro.org> To: "Rafael J. Wysocki" <rafael@kernel.org>, Viresh Kumar <viresh.kumar@linaro.org> Cc: linux-pm@vger.kernel.org, Vincent Guittot <vincent.guittot@linaro.org>, Yajun Deng <yajun.deng@linux.dev>, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: drivers with target_index() must set freq_table Date: Mon, 3 Apr 2023 09:39:16 +0530 Message-Id: <53d4ed4e5b18a59a48790434f8146fb207e11c49.1680494945.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1762127342340478676?= X-GMAIL-MSGID: =?utf-8?q?1762127342340478676?= |
Series |
cpufreq: drivers with target_index() must set freq_table
|
|
Commit Message
Viresh Kumar
April 3, 2023, 4:09 a.m. UTC
Since the cpufreq core directly uses freq_table, for cpufreq drivers
that set their target_index() callback, make it mandatory for them to
set the same.
Since this is set per policy and normally from policy->init(), do this
from cpufreq_table_validate_and_sort() which gets called right after
->init().
Reported-by: Yajun Deng <yajun.deng@linux.dev>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cpufreq.c | 5 +++++
drivers/cpufreq/freq_table.c | 9 ++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
Comments
Hi Viresh, I love your patch! Perhaps something to improve: [auto build test WARNING on rafael-pm/linux-next] [also build test WARNING on linus/master v6.3-rc5 next-20230331] [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/Viresh-Kumar/cpufreq-drivers-with-target_index-must-set-freq_table/20230403-121021 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/53d4ed4e5b18a59a48790434f8146fb207e11c49.1680494945.git.viresh.kumar%40linaro.org patch subject: [PATCH] cpufreq: drivers with target_index() must set freq_table config: i386-randconfig-a001-20230403 (https://download.01.org/0day-ci/archive/20230403/202304031904.mo4oksHT-lkp@intel.com/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) 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/3b521388b742e3d7b9bbba198655408c6d152579 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Viresh-Kumar/cpufreq-drivers-with-target_index-must-set-freq_table/20230403-121021 git checkout 3b521388b742e3d7b9bbba198655408c6d152579 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/cpufreq/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202304031904.mo4oksHT-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/cpufreq/cpufreq.c:76:6: warning: no previous prototype for function 'has_target_index' [-Wmissing-prototypes] bool has_target_index(void) ^ drivers/cpufreq/cpufreq.c:76:1: note: declare 'static' if the function is not intended to be used outside of this translation unit bool has_target_index(void) ^ static 1 warning generated. vim +/has_target_index +76 drivers/cpufreq/cpufreq.c 75 > 76 bool has_target_index(void) 77 { 78 return !!cpufreq_driver->target_index; 79 } 80
Hi Viresh, I love your patch! Perhaps something to improve: [auto build test WARNING on rafael-pm/linux-next] [also build test WARNING on linus/master v6.3-rc5 next-20230331] [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/Viresh-Kumar/cpufreq-drivers-with-target_index-must-set-freq_table/20230403-121021 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/53d4ed4e5b18a59a48790434f8146fb207e11c49.1680494945.git.viresh.kumar%40linaro.org patch subject: [PATCH] cpufreq: drivers with target_index() must set freq_table config: riscv-randconfig-r003-20230403 (https://download.01.org/0day-ci/archive/20230403/202304031955.76jRZiQR-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7) 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 # install riscv cross compiling tool for clang build # apt-get install binutils-riscv64-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/3b521388b742e3d7b9bbba198655408c6d152579 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Viresh-Kumar/cpufreq-drivers-with-target_index-must-set-freq_table/20230403-121021 git checkout 3b521388b742e3d7b9bbba198655408c6d152579 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/cpufreq/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202304031955.76jRZiQR-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/cpufreq/cpufreq.c:76:6: warning: no previous prototype for function 'has_target_index' [-Wmissing-prototypes] bool has_target_index(void) ^ drivers/cpufreq/cpufreq.c:76:1: note: declare 'static' if the function is not intended to be used outside of this translation unit bool has_target_index(void) ^ static 1 warning generated. vim +/has_target_index +76 drivers/cpufreq/cpufreq.c 75 > 76 bool has_target_index(void) 77 { 78 return !!cpufreq_driver->target_index; 79 } 80
On Mon, Apr 3, 2023 at 6:09 AM Viresh Kumar <viresh.kumar@linaro.org> wrote: > > Since the cpufreq core directly uses freq_table, for cpufreq drivers > that set their target_index() callback, make it mandatory for them to > set the same. > > Since this is set per policy and normally from policy->init(), do this > from cpufreq_table_validate_and_sort() which gets called right after > ->init(). > > Reported-by: Yajun Deng <yajun.deng@linux.dev> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > --- > drivers/cpufreq/cpufreq.c | 5 +++++ > drivers/cpufreq/freq_table.c | 9 ++++++++- > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 6d8fd3b8dcb5..09131c54703f 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -73,6 +73,11 @@ static inline bool has_target(void) > return cpufreq_driver->target_index || cpufreq_driver->target; > } > > +bool has_target_index(void) > +{ > + return !!cpufreq_driver->target_index; > +} This needs to go into a header (as a static inline) or the prototype of it needs to go into a header. > + > /* internal prototypes */ > static unsigned int __cpufreq_get(struct cpufreq_policy *policy); > static int cpufreq_init_governor(struct cpufreq_policy *policy); > diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c > index 90bfc27ed1ba..c6fc5b0ea91f 100644 > --- a/drivers/cpufreq/freq_table.c > +++ b/drivers/cpufreq/freq_table.c > @@ -10,6 +10,8 @@ > #include <linux/cpufreq.h> > #include <linux/module.h> > > +bool has_target_index(void); > + > /********************************************************************* > * FREQUENCY TABLE HELPERS * > *********************************************************************/ > @@ -355,8 +357,13 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy) > { > int ret; > > - if (!policy->freq_table) > + if (!policy->freq_table) { > + /* Freq table must be passed by drivers with target_index() */ > + if (has_target_index()) > + return -EINVAL; > + > return 0; > + } > > ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table); > if (ret) > -- > 2.31.1.272.g89b43f80a514 >
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 6d8fd3b8dcb5..09131c54703f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -73,6 +73,11 @@ static inline bool has_target(void) return cpufreq_driver->target_index || cpufreq_driver->target; } +bool has_target_index(void) +{ + return !!cpufreq_driver->target_index; +} + /* internal prototypes */ static unsigned int __cpufreq_get(struct cpufreq_policy *policy); static int cpufreq_init_governor(struct cpufreq_policy *policy); diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 90bfc27ed1ba..c6fc5b0ea91f 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -10,6 +10,8 @@ #include <linux/cpufreq.h> #include <linux/module.h> +bool has_target_index(void); + /********************************************************************* * FREQUENCY TABLE HELPERS * *********************************************************************/ @@ -355,8 +357,13 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy) { int ret; - if (!policy->freq_table) + if (!policy->freq_table) { + /* Freq table must be passed by drivers with target_index() */ + if (has_target_index()) + return -EINVAL; + return 0; + } ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table); if (ret)