drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c:230:26: warning: 'best_m' is used uninitialized
From: kernel test robot
Date: Wed Nov 15 2023 - 04:15:22 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c42d9eeef8e5ba9292eda36fd8e3c11f35ee065c
commit: ce62f8ea7e3f8a8e788c3b5ea0195f1224575b66 drm/bridge: imx: Add i.MX93 MIPI DSI support
date: 4 weeks ago
config: arc-randconfig-001-20231115 (https://download.01.org/0day-ci/archive/20231115/202311151746.f7u7dzbZ-lkp@xxxxxxxxx/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231115/202311151746.f7u7dzbZ-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/202311151746.f7u7dzbZ-lkp@xxxxxxxxx/
All warnings (new ones prefixed by >>):
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c: In function 'dphy_pll_get_configure_from_opts.isra':
>> drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c:230:26: warning: 'best_m' is used uninitialized [-Wuninitialized]
230 | unsigned long m, best_m;
| ^~~~~~
>> drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c:229:39: warning: 'best_n' is used uninitialized [-Wuninitialized]
229 | unsigned int min_n, max_n, n, best_n;
| ^~~~~~
vim +/best_m +230 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c
218
219 static int
220 dphy_pll_get_configure_from_opts(struct imx93_dsi *dsi,
221 struct phy_configure_opts_mipi_dphy *dphy_opts,
222 struct dphy_pll_cfg *cfg)
223 {
224 struct device *dev = dsi->dev;
225 unsigned long fin = dsi->ref_clk_rate;
226 unsigned long fout;
227 unsigned long best_fout = 0;
228 unsigned int fvco_div;
> 229 unsigned int min_n, max_n, n, best_n;
> 230 unsigned long m, best_m;
231 unsigned long min_delta = ULONG_MAX;
232 unsigned long delta;
233 u64 tmp;
234
235 if (dphy_opts->hs_clk_rate < DATA_RATE_MIN_SPEED ||
236 dphy_opts->hs_clk_rate > DATA_RATE_MAX_SPEED) {
237 dev_dbg(dev, "invalid data rate per lane: %lu\n",
238 dphy_opts->hs_clk_rate);
239 return -EINVAL;
240 }
241
242 fout = data_rate_to_fout(dphy_opts->hs_clk_rate);
243
244 /* DPHY Databook 3.3.6.1 Output Frequency */
245 /* Fout = Fvco / Fvco_div = (Fin * M) / (Fvco_div * N) */
246 /* Fvco_div could be 1/2/4/8 according to Fout range. */
247 fvco_div = 8UL / min(DIV_ROUND_UP(fout, FVCO_DIV_FACTOR), 8UL);
248
249 /* limitation: 2MHz <= Fin / N <= 8MHz */
250 min_n = DIV_ROUND_UP_ULL((u64)fin, MHZ(8));
251 max_n = DIV_ROUND_DOWN_ULL((u64)fin, MHZ(2));
252
253 /* clamp possible N(s) */
254 min_n = clamp(min_n, N_MIN, N_MAX);
255 max_n = clamp(max_n, N_MIN, N_MAX);
256
257 dev_dbg(dev, "Fout = %lu, Fvco_div = %u, n_range = [%u, %u]\n",
258 fout, fvco_div, min_n, max_n);
259
260 for (n = min_n; n <= max_n; n++) {
261 /* M = (Fout * N * Fvco_div) / Fin */
262 m = DIV_ROUND_CLOSEST(fout * n * fvco_div, fin);
263
264 /* check M range */
265 if (m < M_MIN || m > M_MAX)
266 continue;
267
268 /* calculate temporary Fout */
269 tmp = m * fin;
270 do_div(tmp, n * fvco_div);
271 if (tmp < FOUT_MIN || tmp > FOUT_MAX)
272 continue;
273
274 delta = abs(fout - tmp);
275 if (delta < min_delta) {
276 best_n = n;
277 best_m = m;
278 min_delta = delta;
279 best_fout = tmp;
280 }
281 }
282
283 if (best_fout) {
284 cfg->m = best_m;
285 cfg->n = best_n;
286 dev_dbg(dev, "best Fout = %lu, m = %u, n = %u\n",
287 best_fout, cfg->m, cfg->n);
288 } else {
289 dev_dbg(dev, "failed to find best Fout\n");
290 return -EINVAL;
291 }
292
293 return 0;
294 }
295
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki