Re: [PATCH] drm/i915/pfit: Prevent negative coordinates in center mode

kernel test robot
2026-04-07T03:49:25Z

Hi Nemesa,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-i915/for-linux-next]
[also build test WARNING on drm-i915/for-linux-next-fixes drm-tip/drm-tip linus/master v7.0-rc6 next-20260401]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Nemesa-Garg/drm-i915-pfit-Prevent-negative-coordinates-in-center-mode/20260403-100828
base: https://gitlab.freedesktop.org/drm/i915/kernel.git for-linux-next
patch link: https://lore.kernel.org/r/20260331181656.77300-1-nemesa.garg%40intel.com
patch subject: [PATCH] drm/i915/pfit: Prevent negative coordinates in center mode
config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20260403/202604032320.Bmwm7fST-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260403/202604032320.Bmwm7fST-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604032320.Bmwm7fST-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/display/intel_pfit.c:209:9: warning: variable 'width' is uninitialized when used here [-Wuninitialized]
209 | width, height,
| ^~~~~
include/drm/drm_print.h:653:52: note: expanded from macro 'drm_dbg_kms'
653 | drm_dev_dbg(__drm_to_dev(drm), DRM_UT_KMS, fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~
include/drm/drm_print.h:563:39: note: expanded from macro 'drm_dev_dbg'
563 | __drm_dev_dbg(NULL, dev, cat, fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~
drivers/gpu/drm/i915/display/intel_pfit.c:194:22: note: initialize the variable 'width' to silence this warning
194 | int ret, x, y, width, height;
| ^
| = 0
>> drivers/gpu/drm/i915/display/intel_pfit.c:209:16: warning: variable 'height' is uninitialized when used here [-Wuninitialized]
209 | width, height,
| ^~~~~~
include/drm/drm_print.h:653:52: note: expanded from macro 'drm_dbg_kms'
653 | drm_dev_dbg(__drm_to_dev(drm), DRM_UT_KMS, fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~
include/drm/drm_print.h:563:39: note: expanded from macro 'drm_dev_dbg'
563 | __drm_dev_dbg(NULL, dev, cat, fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~
drivers/gpu/drm/i915/display/intel_pfit.c:194:30: note: initialize the variable 'height' to silence this warning
194 | int ret, x, y, width, height;
| ^
| = 0
2 warnings generated.

vim +/width +209 drivers/gpu/drm/i915/display/intel_pfit.c

183
184 /* adjusted_mode has been preset to be the panel's fixed mode */
185 static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
186 const struct drm_connector_state *conn_state)
187 {
188 struct intel_display *display = to_intel_display(crtc_state);
189 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
190 const struct drm_display_mode *adjusted_mode =
191 &crtc_state->hw.adjusted_mode;
192 int pipe_src_w = drm_rect_width(&crtc_state->pipe_src);
193 int pipe_src_h = drm_rect_height(&crtc_state->pipe_src);
194 int ret, x, y, width, height;
195
196 /* Native modes don't need fitting */
197 if (adjusted_mode->crtc_hdisplay == pipe_src_w &&
198 adjusted_mode->crtc_vdisplay == pipe_src_h &&
199 crtc_state->output_format != INTEL_OUTPUT_FORMAT_YCBCR420)
200 return 0;
201
202 switch (conn_state->scaling_mode) {
203 case DRM_MODE_SCALE_CENTER:
204 if (adjusted_mode->crtc_hdisplay < pipe_src_w ||
205 adjusted_mode->crtc_vdisplay < pipe_src_h) {
206 drm_dbg_kms(display->drm,
207 "[CRTC:%d:%s] pfit center mode source (%dx%d) exceeds display (%dx%d)\n",
208 crtc->base.base.id, crtc->base.name,
> 209 width, height,
210 adjusted_mode->crtc_hdisplay,
211 adjusted_mode->crtc_vdisplay);
212 return -EINVAL;
213 }
214 width = pipe_src_w;
215 height = pipe_src_h;
216 x = (adjusted_mode->crtc_hdisplay - width + 1)/2;
217 y = (adjusted_mode->crtc_vdisplay - height + 1)/2;
218 break;
219
220 case DRM_MODE_SCALE_ASPECT:
221 /* Scale but preserve the aspect ratio */
222 {
223 u32 scaled_width = adjusted_mode->crtc_hdisplay * pipe_src_h;
224 u32 scaled_height = pipe_src_w * adjusted_mode->crtc_vdisplay;
225
226 if (scaled_width > scaled_height) { /* pillar */
227 width = scaled_height / pipe_src_h;
228 if (width & 1)
229 width++;
230 x = (adjusted_mode->crtc_hdisplay - width + 1) / 2;
231 y = 0;
232 height = adjusted_mode->crtc_vdisplay;
233 } else if (scaled_width < scaled_height) { /* letter */
234 height = scaled_width / pipe_src_w;
235 if (height & 1)
236 height++;
237 y = (adjusted_mode->crtc_vdisplay - height + 1) / 2;
238 x = 0;
239 width = adjusted_mode->crtc_hdisplay;
240 } else {
241 x = y = 0;
242 width = adjusted_mode->crtc_hdisplay;
243 height = adjusted_mode->crtc_vdisplay;
244 }
245 }
246 break;
247
248 case DRM_MODE_SCALE_NONE:
249 WARN_ON(adjusted_mode->crtc_hdisplay != pipe_src_w);
250 WARN_ON(adjusted_mode->crtc_vdisplay != pipe_src_h);
251 fallthrough;
252 case DRM_MODE_SCALE_FULLSCREEN:
253 x = y = 0;
254 width = adjusted_mode->crtc_hdisplay;
255 height = adjusted_mode->crtc_vdisplay;
256 break;
257
258 default:
259 MISSING_CASE(conn_state->scaling_mode);
260 return -EINVAL;
261 }
262
263 drm_rect_init(&crtc_state->pch_pfit.dst,
264 x, y, width, height);
265 crtc_state->pch_pfit.enabled = true;
266
267 /*
268 * SKL+ have unified scalers for pipes/planes so the
269 * checks are done in a single place for all scalers.
270 */
271 if (DISPLAY_VER(display) >= 9)
272 return 0;
273
274 ret = intel_pch_pfit_check_dst_window(crtc_state);
275 if (ret)
276 return ret;
277
278 ret = intel_pch_pfit_check_src_size(crtc_state);
279 if (ret)
280 return ret;
281
282 ret = intel_pch_pfit_check_scaling(crtc_state);
283 if (ret)
284 return ret;
285
286 ret = intel_pch_pfit_check_timings(crtc_state);
287 if (ret)
288 return ret;
289
290 ret = intel_pch_pfit_check_cloning(crtc_state);
291 if (ret)
292 return ret;
293
294 return 0;
295 }
296

--
0-DAY CI Kernel Test Service