drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c:190:15: warning: 'success' is used uninitialized in this function

From: kernel test robot
Date: Tue Sep 05 2023 - 16:55:44 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 65d6e954e37872fd9afb5ef3fc0481bb3c2f20f4
commit: 9469d456c6a28494dd9d5cc16e17cf2d4c15c571 drm/i915/guc: Allow for very slow GuC loading
date: 6 months ago
config: x86_64-buildonly-randconfig-002-20230906 (https://download.01.org/0day-ci/archive/20230906/202309060411.7Mxcdcji-lkp@xxxxxxxxx/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230906/202309060411.7Mxcdcji-lkp@xxxxxxxxx/reproduce)

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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309060411.7Mxcdcji-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c: In function 'guc_wait_ucode':
>> drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c:190:15: warning: 'success' is used uninitialized in this function [-Wuninitialized]
190 | if (!ret || !success)
| ^


vim +/success +190 drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c

151
152 static int guc_wait_ucode(struct intel_guc *guc)
153 {
154 struct intel_gt *gt = guc_to_gt(guc);
155 struct intel_uncore *uncore = gt->uncore;
156 ktime_t before, after, delta;
157 bool success;
158 u32 status;
159 int ret, count;
160 u64 delta_ms;
161 u32 before_freq;
162
163 /*
164 * Wait for the GuC to start up.
165 *
166 * Measurements indicate this should take no more than 20ms
167 * (assuming the GT clock is at maximum frequency). So, a
168 * timeout here indicates that the GuC has failed and is unusable.
169 * (Higher levels of the driver may decide to reset the GuC and
170 * attempt the ucode load again if this happens.)
171 *
172 * FIXME: There is a known (but exceedingly unlikely) race condition
173 * where the asynchronous frequency management code could reduce
174 * the GT clock while a GuC reload is in progress (during a full
175 * GT reset). A fix is in progress but there are complex locking
176 * issues to be resolved. In the meantime bump the timeout to
177 * 200ms. Even at slowest clock, this should be sufficient. And
178 * in the working case, a larger timeout makes no difference.
179 *
180 * IFWI updates have also been seen to cause sporadic failures due to
181 * the requested frequency not being granted and thus the firmware
182 * load is attempted at minimum frequency. That can lead to load times
183 * in the seconds range. However, there is a limit on how long an
184 * individual wait_for() can wait. So wrap it in a loop.
185 */
186 before_freq = intel_rps_read_actual_frequency(&uncore->gt->rps);
187 before = ktime_get();
188 for (count = 0; count < GUC_LOAD_RETRY_LIMIT; count++) {
189 ret = wait_for(guc_load_done(uncore, &status, &success), 1000);
> 190 if (!ret || !success)
191 break;
192
193 guc_dbg(guc, "load still in progress, count = %d, freq = %dMHz\n",
194 count, intel_rps_read_actual_frequency(&uncore->gt->rps));
195 }
196 after = ktime_get();
197 delta = ktime_sub(after, before);
198 delta_ms = ktime_to_ms(delta);
199 if (ret || !success) {
200 u32 ukernel = REG_FIELD_GET(GS_UKERNEL_MASK, status);
201 u32 bootrom = REG_FIELD_GET(GS_BOOTROM_MASK, status);
202
203 guc_info(guc, "load failed: status = 0x%08X, time = %lldms, freq = %dMHz, ret = %d\n",
204 status, delta_ms, intel_rps_read_actual_frequency(&uncore->gt->rps), ret);
205 guc_info(guc, "load failed: status: Reset = %d, BootROM = 0x%02X, UKernel = 0x%02X, MIA = 0x%02X, Auth = 0x%02X\n",
206 REG_FIELD_GET(GS_MIA_IN_RESET, status),
207 bootrom, ukernel,
208 REG_FIELD_GET(GS_MIA_MASK, status),
209 REG_FIELD_GET(GS_AUTH_STATUS_MASK, status));
210
211 switch (bootrom) {
212 case INTEL_BOOTROM_STATUS_NO_KEY_FOUND:
213 guc_info(guc, "invalid key requested, header = 0x%08X\n",
214 intel_uncore_read(uncore, GUC_HEADER_INFO));
215 ret = -ENOEXEC;
216 break;
217
218 case INTEL_BOOTROM_STATUS_RSA_FAILED:
219 guc_info(guc, "firmware signature verification failed\n");
220 ret = -ENOEXEC;
221 break;
222 }
223
224 switch (ukernel) {
225 case INTEL_GUC_LOAD_STATUS_EXCEPTION:
226 guc_info(guc, "firmware exception. EIP: %#x\n",
227 intel_uncore_read(uncore, SOFT_SCRATCH(13)));
228 ret = -ENXIO;
229 break;
230
231 case INTEL_GUC_LOAD_STATUS_INIT_MMIO_SAVE_RESTORE_INVALID:
232 guc_info(guc, "illegal register in save/restore workaround list\n");
233 ret = -EPERM;
234 break;
235
236 case INTEL_GUC_LOAD_STATUS_HWCONFIG_START:
237 guc_info(guc, "still extracting hwconfig table.\n");
238 ret = -ETIMEDOUT;
239 break;
240 }
241
242 /* Uncommon/unexpected error, see earlier status code print for details */
243 if (ret == 0)
244 ret = -ENXIO;
245 } else if (delta_ms > 200) {
246 guc_warn(guc, "excessive init time: %lldms! [freq = %dMHz, before = %dMHz, status = 0x%08X, count = %d, ret = %d]\n",
247 delta_ms, intel_rps_read_actual_frequency(&uncore->gt->rps),
248 before_freq, status, count, ret);
249 } else {
250 guc_dbg(guc, "init took %lldms, freq = %dMHz, before = %dMHz, status = 0x%08X, count = %d, ret = %d\n",
251 delta_ms, intel_rps_read_actual_frequency(&uncore->gt->rps),
252 before_freq, status, count, ret);
253 }
254
255 return ret;
256 }
257

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