All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: [linux-next:master 7785/8263] kernel/power/energy_model.c:649 em_dev_register_pd_no_update() error: we previously assumed 'dev->em_pd' could be null (see line 594)
Date: Thu, 11 Sep 2025 23:48:01 +0800	[thread overview]
Message-ID: <202509112313.0XfkfKPl-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: "Rafael J. Wysocki" <rjw@rjwysocki.net>

Hi Rafael,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   8f21d9da46702c4d6951ba60ca8a05f42870fe8f
commit: e0423541477dfb684fbc6e6b5386054bc650f264 [7785/8263] PM: EM: Add function for registering a PD without capacity update
:::::: branch date: 9 hours ago
:::::: commit date: 30 hours ago
config: x86_64-randconfig-161-20250911 (https://download.01.org/0day-ci/archive/20250911/202509112313.0XfkfKPl-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202509112313.0XfkfKPl-lkp@intel.com/

smatch warnings:
kernel/power/energy_model.c:649 em_dev_register_pd_no_update() error: we previously assumed 'dev->em_pd' could be null (see line 594)

vim +649 kernel/power/energy_model.c

e0423541477dfb Rafael J. Wysocki 2025-09-05  564  
e0423541477dfb Rafael J. Wysocki 2025-09-05  565  /**
e0423541477dfb Rafael J. Wysocki 2025-09-05  566   * em_dev_register_pd_no_update() - Register a perf domain for a device
e0423541477dfb Rafael J. Wysocki 2025-09-05  567   * @dev : Device to register the PD for
e0423541477dfb Rafael J. Wysocki 2025-09-05  568   * @nr_states : Number of performance states in the new PD
e0423541477dfb Rafael J. Wysocki 2025-09-05  569   * @cb : Callback functions for populating the energy model
e0423541477dfb Rafael J. Wysocki 2025-09-05  570   * @cpus : CPUs to include in the new PD (mandatory if @dev is a CPU device)
e0423541477dfb Rafael J. Wysocki 2025-09-05  571   * @microwatts : Whether or not the power values in the EM will be in uW
e0423541477dfb Rafael J. Wysocki 2025-09-05  572   *
e0423541477dfb Rafael J. Wysocki 2025-09-05  573   * Like em_dev_register_perf_domain(), but does not trigger a CPU capacity
e0423541477dfb Rafael J. Wysocki 2025-09-05  574   * update after registering the PD, even if @dev is a CPU device.
e0423541477dfb Rafael J. Wysocki 2025-09-05  575   */
e0423541477dfb Rafael J. Wysocki 2025-09-05  576  int em_dev_register_pd_no_update(struct device *dev, unsigned int nr_states,
e0423541477dfb Rafael J. Wysocki 2025-09-05  577  				 const struct em_data_callback *cb,
e0423541477dfb Rafael J. Wysocki 2025-09-05  578  				 const cpumask_t *cpus, bool microwatts)
27871f7a8a341e Quentin Perret    2018-12-03  579  {
3ee7be9e10dd5f Rafael J. Wysocki 2025-03-06  580  	struct em_perf_table *em_table;
27871f7a8a341e Quentin Perret    2018-12-03  581  	unsigned long cap, prev_cap = 0;
91362463114eb6 Lukasz Luba       2022-03-21  582  	unsigned long flags = 0;
1bc138c6229599 Lukasz Luba       2020-06-10  583  	int cpu, ret;
27871f7a8a341e Quentin Perret    2018-12-03  584  
1bc138c6229599 Lukasz Luba       2020-06-10  585  	if (!dev || !nr_states || !cb)
27871f7a8a341e Quentin Perret    2018-12-03  586  		return -EINVAL;
27871f7a8a341e Quentin Perret    2018-12-03  587  
27871f7a8a341e Quentin Perret    2018-12-03  588  	/*
27871f7a8a341e Quentin Perret    2018-12-03  589  	 * Use a mutex to serialize the registration of performance domains and
27871f7a8a341e Quentin Perret    2018-12-03  590  	 * let the driver-defined callback functions sleep.
27871f7a8a341e Quentin Perret    2018-12-03  591  	 */
27871f7a8a341e Quentin Perret    2018-12-03  592  	mutex_lock(&em_pd_mutex);
27871f7a8a341e Quentin Perret    2018-12-03  593  
1bc138c6229599 Lukasz Luba       2020-06-10 @594  	if (dev->em_pd) {
27871f7a8a341e Quentin Perret    2018-12-03  595  		ret = -EEXIST;
27871f7a8a341e Quentin Perret    2018-12-03  596  		goto unlock;
27871f7a8a341e Quentin Perret    2018-12-03  597  	}
27871f7a8a341e Quentin Perret    2018-12-03  598  
1bc138c6229599 Lukasz Luba       2020-06-10  599  	if (_is_cpu_device(dev)) {
1bc138c6229599 Lukasz Luba       2020-06-10  600  		if (!cpus) {
1bc138c6229599 Lukasz Luba       2020-06-10  601  			dev_err(dev, "EM: invalid CPU mask\n");
1bc138c6229599 Lukasz Luba       2020-06-10  602  			ret = -EINVAL;
1bc138c6229599 Lukasz Luba       2020-06-10  603  			goto unlock;
1bc138c6229599 Lukasz Luba       2020-06-10  604  		}
1bc138c6229599 Lukasz Luba       2020-06-10  605  
1bc138c6229599 Lukasz Luba       2020-06-10  606  		for_each_cpu(cpu, cpus) {
1bc138c6229599 Lukasz Luba       2020-06-10  607  			if (em_cpu_get(cpu)) {
1bc138c6229599 Lukasz Luba       2020-06-10  608  				dev_err(dev, "EM: exists for CPU%d\n", cpu);
1bc138c6229599 Lukasz Luba       2020-06-10  609  				ret = -EEXIST;
1bc138c6229599 Lukasz Luba       2020-06-10  610  				goto unlock;
1bc138c6229599 Lukasz Luba       2020-06-10  611  			}
27871f7a8a341e Quentin Perret    2018-12-03  612  			/*
1bc138c6229599 Lukasz Luba       2020-06-10  613  			 * All CPUs of a domain must have the same
1bc138c6229599 Lukasz Luba       2020-06-10  614  			 * micro-architecture since they all share the same
1bc138c6229599 Lukasz Luba       2020-06-10  615  			 * table.
27871f7a8a341e Quentin Perret    2018-12-03  616  			 */
8ec59c0f5f4966 Vincent Guittot   2019-06-17  617  			cap = arch_scale_cpu_capacity(cpu);
27871f7a8a341e Quentin Perret    2018-12-03  618  			if (prev_cap && prev_cap != cap) {
1bc138c6229599 Lukasz Luba       2020-06-10  619  				dev_err(dev, "EM: CPUs of %*pbl must have the same capacity\n",
1bc138c6229599 Lukasz Luba       2020-06-10  620  					cpumask_pr_args(cpus));
1bc138c6229599 Lukasz Luba       2020-06-10  621  
27871f7a8a341e Quentin Perret    2018-12-03  622  				ret = -EINVAL;
27871f7a8a341e Quentin Perret    2018-12-03  623  				goto unlock;
27871f7a8a341e Quentin Perret    2018-12-03  624  			}
27871f7a8a341e Quentin Perret    2018-12-03  625  			prev_cap = cap;
27871f7a8a341e Quentin Perret    2018-12-03  626  		}
1bc138c6229599 Lukasz Luba       2020-06-10  627  	}
27871f7a8a341e Quentin Perret    2018-12-03  628  
ae6ccaa650380d Lukasz Luba       2022-07-07  629  	if (microwatts)
ae6ccaa650380d Lukasz Luba       2022-07-07  630  		flags |= EM_PERF_DOMAIN_MICROWATTS;
91362463114eb6 Lukasz Luba       2022-03-21  631  	else if (cb->get_cost)
91362463114eb6 Lukasz Luba       2022-03-21  632  		flags |= EM_PERF_DOMAIN_ARTIFICIAL;
91362463114eb6 Lukasz Luba       2022-03-21  633  
3acec69a94eaaf Lukasz Luba       2024-03-08  634  	/*
3acec69a94eaaf Lukasz Luba       2024-03-08  635  	 * EM only supports uW (exception is artificial EM).
3acec69a94eaaf Lukasz Luba       2024-03-08  636  	 * Therefore, check and force the drivers to provide
3acec69a94eaaf Lukasz Luba       2024-03-08  637  	 * power in uW.
3acec69a94eaaf Lukasz Luba       2024-03-08  638  	 */
3acec69a94eaaf Lukasz Luba       2024-03-08  639  	if (!microwatts && !(flags & EM_PERF_DOMAIN_ARTIFICIAL)) {
3acec69a94eaaf Lukasz Luba       2024-03-08  640  		dev_err(dev, "EM: only supports uW power values\n");
3acec69a94eaaf Lukasz Luba       2024-03-08  641  		ret = -EINVAL;
3acec69a94eaaf Lukasz Luba       2024-03-08  642  		goto unlock;
3acec69a94eaaf Lukasz Luba       2024-03-08  643  	}
3acec69a94eaaf Lukasz Luba       2024-03-08  644  
91362463114eb6 Lukasz Luba       2022-03-21  645  	ret = em_create_pd(dev, nr_states, cb, cpus, flags);
1bc138c6229599 Lukasz Luba       2020-06-10  646  	if (ret)
27871f7a8a341e Quentin Perret    2018-12-03  647  		goto unlock;
27871f7a8a341e Quentin Perret    2018-12-03  648  
91362463114eb6 Lukasz Luba       2022-03-21 @649  	dev->em_pd->flags |= flags;
5609296750afd6 Lukasz Luba       2024-10-30  650  	dev->em_pd->min_perf_state = 0;
5609296750afd6 Lukasz Luba       2024-10-30  651  	dev->em_pd->max_perf_state = nr_states - 1;
c250d50fe2ce62 Lukasz Luba       2020-11-05  652  
3ee7be9e10dd5f Rafael J. Wysocki 2025-03-06  653  	em_table = rcu_dereference_protected(dev->em_pd->em_table,
3ee7be9e10dd5f Rafael J. Wysocki 2025-03-06  654  					     lockdep_is_held(&em_pd_mutex));
3ee7be9e10dd5f Rafael J. Wysocki 2025-03-06  655  	em_cpufreq_update_efficiencies(dev, em_table->state);
e458716a92b57f Vincent Donnefort 2021-09-08  656  
1bc138c6229599 Lukasz Luba       2020-06-10  657  	em_debug_create_pd(dev);
1bc138c6229599 Lukasz Luba       2020-06-10  658  	dev_info(dev, "EM: created perf domain\n");
27871f7a8a341e Quentin Perret    2018-12-03  659  
27871f7a8a341e Quentin Perret    2018-12-03  660  unlock:
27871f7a8a341e Quentin Perret    2018-12-03  661  	mutex_unlock(&em_pd_mutex);
e3f1164fc9ee84 Lukasz Luba       2024-02-08  662  
27871f7a8a341e Quentin Perret    2018-12-03  663  	return ret;
27871f7a8a341e Quentin Perret    2018-12-03  664  }
e0423541477dfb Rafael J. Wysocki 2025-09-05  665  EXPORT_SYMBOL_GPL(em_dev_register_pd_no_update);
7d9895c7fbfc9c Lukasz Luba       2020-05-27  666  

:::::: The code at line 649 was first introduced by commit
:::::: 91362463114eb63ead5f02c11d58c46064c339e7 PM: EM: Use the new .get_cost() callback while registering EM

:::::: TO: Lukasz Luba <lukasz.luba@arm.com>
:::::: CC: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2025-09-11 15:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202509112313.0XfkfKPl-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.