drivers/cpuidle/cpuidle-riscv-sbi.c:350:26: error: implicit declaration of function 'cpuid_to_hartid_map'

From: kernel test robot
Date: Sat Apr 02 2022 - 02:30:49 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 88e6c0207623874922712e162e25d9dafd39661e
commit: 6abf32f1d9c5009dcccded2c1e7ca899a4ab587b cpuidle: Add RISC-V SBI CPU idle driver
date: 3 weeks ago
config: riscv-randconfig-r015-20220402 (https://download.01.org/0day-ci/archive/20220402/202204021409.IwExY1Pb-lkp@xxxxxxxxx/config)
compiler: riscv32-linux-gcc (GCC) 11.2.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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6abf32f1d9c5009dcccded2c1e7ca899a4ab587b
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 6abf32f1d9c5009dcccded2c1e7ca899a4ab587b
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=riscv SHELL=/bin/bash drivers/cpuidle/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All error/warnings (new ones prefixed by >>):

In file included from include/asm-generic/bug.h:22,
from arch/riscv/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/percpu.h:5,
from include/linux/cpuidle.h:14,
from drivers/cpuidle/cpuidle-riscv-sbi.c:11:
drivers/cpuidle/cpuidle-riscv-sbi.c: In function 'sbi_cpuidle_init_cpu':
>> drivers/cpuidle/cpuidle-riscv-sbi.c:350:26: error: implicit declaration of function 'cpuid_to_hartid_map' [-Werror=implicit-function-declaration]
350 | cpuid_to_hartid_map(cpu));
| ^~~~~~~~~~~~~~~~~~~
include/linux/printk.h:418:33: note: in definition of macro 'printk_index_wrap'
418 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/printk.h:132:17: note: in expansion of macro 'printk'
132 | printk(fmt, ##__VA_ARGS__); \
| ^~~~~~
include/linux/printk.h:576:9: note: in expansion of macro 'no_printk'
576 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~
drivers/cpuidle/cpuidle-riscv-sbi.c:349:17: note: in expansion of macro 'pr_debug'
349 | pr_debug("HART%ld: failed to parse DT idle states\n",
| ^~~~~~~~
>> include/linux/kern_levels.h:5:25: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~
include/linux/printk.h:418:25: note: in definition of macro 'printk_index_wrap'
418 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~
include/linux/printk.h:132:17: note: in expansion of macro 'printk'
132 | printk(fmt, ##__VA_ARGS__); \
| ^~~~~~
include/linux/printk.h:576:9: note: in expansion of macro 'no_printk'
576 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~
include/linux/kern_levels.h:15:25: note: in expansion of macro 'KERN_SOH'
15 | #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
| ^~~~~~~~
include/linux/printk.h:576:19: note: in expansion of macro 'KERN_DEBUG'
576 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~
drivers/cpuidle/cpuidle-riscv-sbi.c:349:17: note: in expansion of macro 'pr_debug'
349 | pr_debug("HART%ld: failed to parse DT idle states\n",
| ^~~~~~~~
>> include/linux/kern_levels.h:5:25: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~
include/linux/printk.h:418:25: note: in definition of macro 'printk_index_wrap'
418 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~
include/linux/printk.h:489:9: note: in expansion of macro 'printk'
489 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~
include/linux/kern_levels.h:11:25: note: in expansion of macro 'KERN_SOH'
11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
| ^~~~~~~~
include/linux/printk.h:489:16: note: in expansion of macro 'KERN_ERR'
489 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~
drivers/cpuidle/cpuidle-riscv-sbi.c:358:17: note: in expansion of macro 'pr_err'
358 | pr_err("HART%ld: failed to init idle states\n",
| ^~~~~~
drivers/cpuidle/cpuidle-riscv-sbi.c: In function 'sbi_cpuidle_probe':
>> include/linux/kern_levels.h:5:25: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~
include/linux/printk.h:418:25: note: in definition of macro 'printk_index_wrap'
418 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~
include/linux/printk.h:132:17: note: in expansion of macro 'printk'
132 | printk(fmt, ##__VA_ARGS__); \
| ^~~~~~
include/linux/printk.h:576:9: note: in expansion of macro 'no_printk'
576 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~
include/linux/kern_levels.h:15:25: note: in expansion of macro 'KERN_SOH'
15 | #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
| ^~~~~~~~
include/linux/printk.h:576:19: note: in expansion of macro 'KERN_DEBUG'
576 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~
drivers/cpuidle/cpuidle-riscv-sbi.c:566:25: note: in expansion of macro 'pr_debug'
566 | pr_debug("HART%ld: idle driver init failed\n",
| ^~~~~~~~
cc1: some warnings being treated as errors


vim +/cpuid_to_hartid_map +350 drivers/cpuidle/cpuidle-riscv-sbi.c

317
318 static int sbi_cpuidle_init_cpu(struct device *dev, int cpu)
319 {
320 struct cpuidle_driver *drv;
321 unsigned int state_count = 0;
322 int ret = 0;
323
324 drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL);
325 if (!drv)
326 return -ENOMEM;
327
328 drv->name = "sbi_cpuidle";
329 drv->owner = THIS_MODULE;
330 drv->cpumask = (struct cpumask *)cpumask_of(cpu);
331
332 /* RISC-V architectural WFI to be represented as state index 0. */
333 drv->states[0].enter = sbi_cpuidle_enter_state;
334 drv->states[0].exit_latency = 1;
335 drv->states[0].target_residency = 1;
336 drv->states[0].power_usage = UINT_MAX;
337 strcpy(drv->states[0].name, "WFI");
338 strcpy(drv->states[0].desc, "RISC-V WFI");
339
340 /*
341 * If no DT idle states are detected (ret == 0) let the driver
342 * initialization fail accordingly since there is no reason to
343 * initialize the idle driver if only wfi is supported, the
344 * default archictectural back-end already executes wfi
345 * on idle entry.
346 */
347 ret = dt_init_idle_driver(drv, sbi_cpuidle_state_match, 1);
348 if (ret <= 0) {
349 pr_debug("HART%ld: failed to parse DT idle states\n",
> 350 cpuid_to_hartid_map(cpu));
351 return ret ? : -ENODEV;
352 }
353 state_count = ret + 1; /* Include WFI state as well */
354
355 /* Initialize idle states from DT. */
356 ret = sbi_cpuidle_dt_init_states(dev, drv, cpu, state_count);
357 if (ret) {
358 pr_err("HART%ld: failed to init idle states\n",
359 cpuid_to_hartid_map(cpu));
360 return ret;
361 }
362
363 ret = cpuidle_register(drv, NULL);
364 if (ret)
365 goto deinit;
366
367 cpuidle_cooling_register(drv);
368
369 return 0;
370 deinit:
371 sbi_cpuidle_deinit_cpu(cpu);
372 return ret;
373 }
374

--
0-DAY CI Kernel Test Service
https://01.org/lkp