drivers/idle/intel_idle.c:160:43: warning: Uninitialized variable: tick

From: kernel test robot
Date: Thu Nov 05 2020 - 15:31:25 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4ef8451b332662d004df269d4cdeb7d9f31419b5
commit: 3f649ab728cda8038259d8f14492fe400fbab911 treewide: Remove uninitialized_var() usage
date: 4 months ago
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

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


"cppcheck warnings: (new ones prefixed by >>)"
>> drivers/idle/intel_idle.c:160:43: warning: Uninitialized variable: tick [uninitvar]
if (!static_cpu_has(X86_FEATURE_ARAT) && tick)
^

vim +160 drivers/idle/intel_idle.c

b1beab48f6148d5 Len Brown 2013-01-31 111
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 112 /**
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 113 * intel_idle - Ask the processor to enter the given idle state.
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 114 * @dev: cpuidle device of the target CPU.
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 115 * @drv: cpuidle driver (assumed to point to intel_idle_driver).
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 116 * @index: Target idle state index.
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 117 *
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 118 * Use the MWAIT instruction to notify the processor that the CPU represented by
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 119 * @dev is idle and it can try to enter the idle state corresponding to @index.
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 120 *
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 121 * If the local APIC timer is not known to be reliable in the target idle state,
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 122 * enable one-shot tick broadcasting for the target CPU before executing MWAIT.
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 123 *
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 124 * Optionally call leave_mm() for the target CPU upfront to avoid wakeups due to
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 125 * flushing user TLBs.
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 126 *
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 127 * Must be called under local_irq_disable().
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 128 */
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 129 static __cpuidle int intel_idle(struct cpuidle_device *dev,
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 130 struct cpuidle_driver *drv, int index)
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 131 {
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 132 struct cpuidle_state *state = &drv->states[index];
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 133 unsigned long eax = flg2MWAIT(state->flags);
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 134 unsigned long ecx = 1; /* break on interrupt flag */
3f649ab728cda80 Kees Cook 2020-06-03 135 bool tick;
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 136 int cpu = smp_processor_id();
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 137
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 138 /*
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 139 * leave_mm() to avoid costly and often unnecessary wakeups
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 140 * for flushing the user TLB's associated with the active mm.
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 141 */
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 142 if (state->flags & CPUIDLE_FLAG_TLB_FLUSHED)
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 143 leave_mm(cpu);
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 144
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 145 if (!static_cpu_has(X86_FEATURE_ARAT) && !lapic_timer_always_reliable) {
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 146 /*
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 147 * Switch over to one-shot tick broadcast if the target C-state
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 148 * is deeper than C1.
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 149 */
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 150 if ((eax >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) {
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 151 tick = true;
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 152 tick_broadcast_enter();
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 153 } else {
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 154 tick = false;
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 155 }
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 156 }
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 157
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 158 mwait_idle_with_hints(eax, ecx);
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 159
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 @160 if (!static_cpu_has(X86_FEATURE_ARAT) && tick)
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 161 tick_broadcast_exit();
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 162
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 163 return index;
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 164 }
30a996fbb359ed5 Rafael J. Wysocki 2020-02-06 165

:::::: The code at line 160 was first introduced by commit
:::::: 30a996fbb359ed53536a055af84a54223beabf91 intel_idle: Relocate definitions of cpuidle callbacks

:::::: TO: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
:::::: CC: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx