drm/i915/pfit: Prevent negative coordinates in center mode
Subsystems (3)
PATCH 1/1 drm/i915/pfit: Prevent negative coordinates in center mode
When the pipe_src width or height are greater than adjusted_mode hdisplay and vdisplay, computed x and y offsets for center mode can be negative. Writing negative values into the pch_fit registers result in a state error. Add a check to clamp these values so that they are never negative.
--- drivers/gpu/drm/i915/display/intel_pfit.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/display/intel_pfit.c +11 -0
@@ -186,6 +186,7 @@ static int pch_panel_fitting(struct intel_crtc_state *crtc_state, const struct drm_connector_state *conn_state) {struct intel_display *display =to_intel_display (crtc_state); +struct intel_crtc *crtc =to_intel_crtc (crtc_state->uapi.crtc);const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;int pipe_src_w =drm_rect_width (&crtc_state->pipe_src);
@@ -204,6 +205,16 @@ static int pch_panel_fitting(struct intel_crtc_state *crtc_state, height = pipe_src_h; x = (adjusted_mode->crtc_hdisplay - width +1 )/2 ; y = (adjusted_mode->crtc_vdisplay - height +1 )/2 ; +if (adjusted_mode->crtc_hdisplay < width || + adjusted_mode->crtc_vdisplay < height) { +drm_dbg_kms (display->drm, +"[CRTC:%d:%s] pfit center mode source (%dx%d) exceeds display (%dx%d)\n" , + crtc->base.base.id, crtc->base.name, + width, height, + adjusted_mode->crtc_hdisplay, + adjusted_mode->crtc_vdisplay); +return -EINVAL ; + }break ;case DRM_MODE_SCALE_ASPECT :
Signature · 1 line
2.25.1
Quoted 23 lines · Nemesa Garg
When the
pipe_srcwidth or height are greater thanadjusted_modehdisplay and vdisplay, computed x and y offsets for center mode can be negative. Writing negative values into thepch_fitregisters result in a state error. Add a check to clamp these values so that they are never negative.Signed-off-by Nemesa Garg <[email protected]>--- drivers/gpu/drm/i915/display/intel_pfit.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/gpu/drm/i915/display/intel_pfit.c +1
-0@@ -186,6 +186,7 @@ static int pch_panel_fitting(struct intel_crtc_state *crtc_state, const struct drm_connector_state *conn_state) {struct intel_display *display =to_intel_display (crtc_state); +struct intel_crtc *crtc =to_intel_crtc (crtc_state->uapi.crtc);const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;int pipe_src_w =drm_rect_width (&crtc_state->pipe_src);
drivers/gpu/drm/i915/display/intel_pfit.c static int pch_panel_fitting(struct intel_crtc_state *crtc_state, · line 213
Quoted 9 lines
drivers/gpu/drm/i915/display/intel_pfit.c +6
-0@@ -204,6 +205,16 @@ static int pch_panel_fitting(struct intel_crtc_state *crtc_state, height = pipe_src_h; x = (adjusted_mode->crtc_hdisplay - width +1 )/2 ; y = (adjusted_mode->crtc_vdisplay - height +1 )/2 ; +if (adjusted_mode->crtc_hdisplay < width || + adjusted_mode->crtc_vdisplay < height) { + drm_dbg_kms(display->drm, + "[CRTC:%d:%s] pfit center mode source (%dx%d) exceeds display (%dx%d)\n", + crtc->base.base.id, crtc->base.name, + width, height,
width,height represent the pfit output window size. So I think it'd be better to do the check in terms of pipe_src_w,pipe_src_h.
And I guess then we can do it before we even compute x,y,width,height.
Quoted 9 lines
drivers/gpu/drm/i915/display/intel_pfit.c +4
-0+ adjusted_mode->crtc_hdisplay, + adjusted_mode->crtc_vdisplay); +return -EINVAL ; + }break ;case DRM_MODE_SCALE_ASPECT :Signature · 1 line
2.25.1
Signature · 2 lines
Ville Syrjälä Intel
Quoted 45 lines
-----Original Message-----
From: Ville Syrjälä <[email protected]>
Sent: Tuesday, March 31, 2026 11:32 PM
To: Garg, Nemesa <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] drm/i915/pfit: Prevent negative coordinates in center modeQuoted 2 lines · Nemesa Garg
When the
pipe_srcwidth or height are greater thanadjusted_modehdisplay and vdisplay, computed x and y offsets for center mode can benegative.
drivers/gpu/drm/i915/display/intel_pfit.c static int pch_panel_fitting(struct intel_crtc_state
Quoted 14 lines
Writing negative values into the
pch_fitregisters result in a state error. Add a check to clamp these values so that they are never negative.Signed-off-by Nemesa Garg <[email protected]>--- drivers/gpu/drm/i915/display/intel_pfit.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/gpu/drm/i915/display/intel_pfit.c +0
-0@@ -186,6 +186,7 @@ static int pch_panel_fitting(struct intel_crtc_state
*crtc_state,drivers/gpu/drm/i915/display/intel_pfit.c static int pch_panel_fitting(struct intel_crtc_state
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_pfit.c +1
-0const struct drm_connector_state *conn_state) {struct intel_display *display =to_intel_display (crtc_state); +struct intel_crtc *crtc =to_intel_crtc (crtc_state->uapi.crtc);const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;int pipe_src_w =drm_rect_width (&crtc_state->pipe_src);@@ -204,6 +205,16 @@ static int pch_panel_fitting(struct intel_crtc_state
*crtc_state,drivers/gpu/drm/i915/display/intel_pfit.c static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_pfit.c +4
-0height = pipe_src_h; x = (adjusted_mode->crtc_hdisplay - width +1 )/2 ; y = (adjusted_mode->crtc_vdisplay - height +1 )/2 ; +if (adjusted_mode->crtc_hdisplay < width || + adjusted_mode->crtc_vdisplay < height) { + drm_dbg_kms(display->drm, + "[CRTC:%d:%s] pfit center mode source(%dx%d) exceeds display (%dx%d)\n",
Quoted 8 lines
drivers/gpu/drm/i915/display/intel_pfit.c static int pch_panel_fitting(struct intel_crtc_state *crtc_state, · line 213
Quoted 2 lines
drivers/gpu/drm/i915/display/intel_pfit.c +2
-0+ crtc->base.base.id, crtc->base.name, + width, height,width,height represent the pfit output window size. So I think it'd be better to do the check in terms of pipe_src_w,pipe_src_h.
And I guess then we can do it before we even compute x,y,width,height.
Sure. Will change.
Thanks and Regards,
Nemesa
Quoted 13 lines
Quoted 9 lines
drivers/gpu/drm/i915/display/intel_pfit.c +4
-1+ adjusted_mode->crtc_hdisplay, + adjusted_mode->crtc_vdisplay); +return -EINVAL ; + }break ;case DRM_MODE_SCALE_ASPECT : --2.25.1
--
Ville Syrjälä
Intel
Patchwork
CI✓ i915.CI.BAT: success for drm/i915/pfit: Prevent negative coordinates in center mode
In reply to Nemesa Garg== Series Details ==
== Series Details ==
Series: drm/i915/pfit: Prevent negative coordinates in center mode
URL : https://patchwork.freedesktop.org/series/164188/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_18256 -> Patchwork_164188v1
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/index.html
Participating hosts (41 -> 40)
------------------------------
Additional (1): bat-adls-6
Missing (2): bat-dg2-13 fi-snb-2520m
Known issues
------------
Here are the changes found in Patchwork_164188v1 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@dmabuf@all-tests@dma_fence_chain:
- fi-skl-6600u: NOTRUN -> [SKIP][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/fi-skl-6600u/igt@dmabuf@all-tests@dma_fence_chain.html
* igt@gem_lmem_swapping@parallel-random-engines:
- bat-adls-6: NOTRUN -> [SKIP][2] ([i915#4613]) +3 other tests skip
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
* igt@gem_tiled_pread_basic@basic:
- bat-adls-6: NOTRUN -> [SKIP][3] ([i915#15656])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
* igt@intel_hwmon@hwmon-read:
- bat-adls-6: NOTRUN -> [SKIP][4] ([i915#7707]) +1 other test skip
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-adls-6: NOTRUN -> [SKIP][5] ([i915#4103]) +1 other test skip
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
* igt@kms_dsc@dsc-basic:
- bat-adls-6: NOTRUN -> [SKIP][6] ([i915#3555] / [i915#3840])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
* igt@kms_force_connector_basic@force-load-detect:
- bat-adls-6: NOTRUN -> [SKIP][7]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
* igt@kms_pm_backlight@basic-brightness:
- bat-adls-6: NOTRUN -> [SKIP][8] ([i915#5354])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
* igt@kms_psr@psr-primary-mmap-gtt:
- bat-adls-6: NOTRUN -> [SKIP][9] ([i915#1072] / [i915#9732]) +3 other tests skip
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
* igt@kms_setmode@basic-clone-single-crtc:
- bat-adls-6: NOTRUN -> [SKIP][10] ([i915#3555])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
* igt@prime_vgem@basic-fence-read:
- bat-adls-6: NOTRUN -> [SKIP][11] ([i915#3291]) +2 other tests skip
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-adls-6/igt@[email protected]
#### Possible fixes ####
* igt@i915_selftest@live:
- fi-skl-6600u: [INCOMPLETE][12] ([i915#15859]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18256/fi-skl-6600u/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/fi-skl-6600u/igt@[email protected]
* igt@i915_selftest@live@gem_contexts:
- fi-skl-6600u: [INCOMPLETE][14] -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18256/fi-skl-6600u/igt@i915_selftest@live@gem_contexts.html
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/fi-skl-6600u/igt@i915_selftest@live@gem_contexts.html
* igt@i915_selftest@live@workarounds:
- bat-dg2-9: [DMESG-FAIL][16] ([i915#12061]) -> [PASS][17] +1 other test pass
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18256/bat-dg2-9/igt@i915_selftest@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/bat-dg2-9/igt@i915_selftest@[email protected]
[i915#1072]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/1072
[i915#12061]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12061
[i915#15656]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/15656
[i915#15859]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/15859
[i915#3291]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3291
[i915#3555]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3555
[i915#3840]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3840
[i915#4103]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4103
[i915#4613]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4613
[i915#5354]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/5354
[i915#7707]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/7707
[i915#9732]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9732
Build changes
-------------
* Linux: CI_DRM_18256 -> Patchwork_164188v1
CI-20190529: 20190529
CI_DRM_18256: 779129c7868f4c7205901d6e57b25de52b411d1c @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_8839: 8839
Patchwork_164188v1: 779129c7868f4c7205901d6e57b25de52b411d1c @ git://anongit.freedesktop.org/gfx-ci/linux
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164188v1/index.html