diff mbox series

drm/i915/selftests: avoid using uninitialized context

Message ID 57xcbkebno22cops66u2uknknrhalp52jqmswj3daihkpwrd3h@h77t4o7kgkki (mailing list archive)
State New
Headers show
Series drm/i915/selftests: avoid using uninitialized context | expand

Commit Message

Krzysztof Karas Jan. 27, 2025, 11:46 a.m. UTC
There is an error path in igt_ppgtt_alloc(), which leads to ww
object being passed down to i915_gem_ww_ctx_fini() without
initialization. Correct that by zeroing the struct.

Fixes: 480ae79537b2 ("drm/i915/selftests: Prepare gtt tests for obj->mm.lock removal")
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
---
 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Krzysztof Karas Jan. 27, 2025, 1:54 p.m. UTC | #1
Hi CI-infra team,

below failure is unrelated to my patch.

Krzysztof

On 2025-01-27 at 13:22:27 +0000, Patchwork wrote:
> == Series Details ==
> 
> Series: drm/i915/selftests: avoid using uninitialized context
> URL   : https://patchwork.freedesktop.org/series/143990/
> State : failure
> 
> == Summary ==
> 
> CI Bug Log - changes from CI_DRM_16023 -> Patchwork_143990v1
> ====================================================
> 
> Summary
> -------
> 
>   **FAILURE**
> 
>   Serious unknown changes coming with Patchwork_143990v1 absolutely need to be
>   verified manually.
>   
>   If you think the reported changes have nothing to do with the changes
>   introduced in Patchwork_143990v1, please notify your bug team (I915-ci-infra@lists.freedesktop.org) to allow them
>   to document this new failure mode, which will reduce false positives in CI.
> 
>   External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/index.html
> 
> Participating hosts (36 -> 34)
> ------------------------------
> 
>   Additional (1): bat-dg2-9 
>   Missing    (3): fi-glk-j4005 bat-arlh-2 fi-snb-2520m 
> 
> Possible new issues
> -------------------
> 
>   Here are the unknown changes that may have been introduced in Patchwork_143990v1:
> 
> ### IGT changes ###
> 
> #### Possible regressions ####
> 
>   * igt@kms_flip@basic-flip-vs-dpms@b-dp1:
>     - fi-kbl-7567u:       [PASS][1] -> [DMESG-WARN][2] +1 other test dmesg-warn
>    [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/fi-kbl-7567u/igt@kms_flip@basic-flip-vs-dpms@b-dp1.html
>    [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/fi-kbl-7567u/igt@kms_flip@basic-flip-vs-dpms@b-dp1.html
> 
>   
> Known issues
> ------------
> 
>   Here are the changes found in Patchwork_143990v1 that come from known issues:
> 
> ### IGT changes ###
> 
> #### Issues hit ####
> 
>   * igt@dmabuf@all-tests@dma_fence_chain:
>     - fi-bsw-nick:        [PASS][3] -> [INCOMPLETE][4] ([i915#12904]) +1 other test incomplete
>    [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/fi-bsw-nick/igt@dmabuf@all-tests@dma_fence_chain.html
>    [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/fi-bsw-nick/igt@dmabuf@all-tests@dma_fence_chain.html
> 
>   * igt@gem_mmap@basic:
>     - bat-dg2-9:          NOTRUN -> [SKIP][5] ([i915#4083])
>    [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@gem_mmap@basic.html
> 
>   * igt@gem_mmap_gtt@basic:
>     - bat-dg2-9:          NOTRUN -> [SKIP][6] ([i915#4077]) +2 other tests skip
>    [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@gem_mmap_gtt@basic.html
> 
>   * igt@gem_render_tiled_blits@basic:
>     - bat-dg2-9:          NOTRUN -> [SKIP][7] ([i915#4079]) +1 other test skip
>    [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@gem_render_tiled_blits@basic.html
> 
>   * igt@i915_pm_rpm@module-reload:
>     - bat-dg1-7:          [PASS][8] -> [FAIL][9] ([i915#13401])
>    [8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/bat-dg1-7/igt@i915_pm_rpm@module-reload.html
>    [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg1-7/igt@i915_pm_rpm@module-reload.html
> 
>   * igt@i915_pm_rps@basic-api:
>     - bat-dg2-9:          NOTRUN -> [SKIP][10] ([i915#11681] / [i915#6621])
>    [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@i915_pm_rps@basic-api.html
> 
>   * igt@i915_selftest@live:
>     - bat-mtlp-6:         [PASS][11] -> [DMESG-FAIL][12] ([i915#12061]) +1 other test dmesg-fail
>    [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/bat-mtlp-6/igt@i915_selftest@live.html
>    [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-mtlp-6/igt@i915_selftest@live.html
> 
>   * igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
>     - bat-dg2-9:          NOTRUN -> [SKIP][13] ([i915#5190])
>    [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@kms_addfb_basic@addfb25-y-tiled-small-legacy.html
> 
>   * igt@kms_addfb_basic@basic-y-tiled-legacy:
>     - bat-dg2-9:          NOTRUN -> [SKIP][14] ([i915#4215] / [i915#5190])
>    [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@kms_addfb_basic@basic-y-tiled-legacy.html
> 
>   * igt@kms_addfb_basic@framebuffer-vs-set-tiling:
>     - bat-dg2-9:          NOTRUN -> [SKIP][15] ([i915#4212]) +7 other tests skip
>    [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@kms_addfb_basic@framebuffer-vs-set-tiling.html
> 
>   * igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
>     - bat-dg2-9:          NOTRUN -> [SKIP][16] ([i915#4103] / [i915#4213]) +1 other test skip
>    [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html
> 
>   * igt@kms_flip@basic-flip-vs-wf_vblank:
>     - bat-apl-1:          [PASS][17] -> [DMESG-WARN][18] ([i915#1982]) +1 other test dmesg-warn
>    [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/bat-apl-1/igt@kms_flip@basic-flip-vs-wf_vblank.html
>    [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-apl-1/igt@kms_flip@basic-flip-vs-wf_vblank.html
> 
>   * igt@kms_force_connector_basic@force-load-detect:
>     - bat-dg2-9:          NOTRUN -> [SKIP][19]
>    [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@kms_force_connector_basic@force-load-detect.html
> 
>   * igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence:
>     - bat-dg2-11:         [PASS][20] -> [SKIP][21] ([i915#9197]) +2 other tests skip
>    [20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/bat-dg2-11/igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence.html
>    [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-11/igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence.html
> 
>   * igt@kms_pm_backlight@basic-brightness:
>     - bat-dg2-9:          NOTRUN -> [SKIP][22] ([i915#5354])
>    [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@kms_pm_backlight@basic-brightness.html
> 
>   * igt@kms_psr@psr-sprite-plane-onoff:
>     - bat-dg2-9:          NOTRUN -> [SKIP][23] ([i915#1072] / [i915#9732]) +3 other tests skip
>    [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@kms_psr@psr-sprite-plane-onoff.html
> 
>   * igt@kms_setmode@basic-clone-single-crtc:
>     - bat-dg2-9:          NOTRUN -> [SKIP][24] ([i915#3555])
>    [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@kms_setmode@basic-clone-single-crtc.html
> 
>   * igt@prime_vgem@basic-fence-flip:
>     - bat-dg2-9:          NOTRUN -> [SKIP][25] ([i915#3708])
>    [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@prime_vgem@basic-fence-flip.html
> 
>   * igt@prime_vgem@basic-fence-mmap:
>     - bat-dg2-9:          NOTRUN -> [SKIP][26] ([i915#3708] / [i915#4077]) +1 other test skip
>    [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@prime_vgem@basic-fence-mmap.html
> 
>   * igt@prime_vgem@basic-write:
>     - bat-dg2-9:          NOTRUN -> [SKIP][27] ([i915#3291] / [i915#3708]) +2 other tests skip
>    [27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-dg2-9/igt@prime_vgem@basic-write.html
> 
>   
> #### Possible fixes ####
> 
>   * igt@dmabuf@all-tests:
>     - bat-apl-1:          [INCOMPLETE][28] ([i915#12904]) -> [PASS][29] +1 other test pass
>    [28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/bat-apl-1/igt@dmabuf@all-tests.html
>    [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-apl-1/igt@dmabuf@all-tests.html
> 
>   * igt@i915_module_load@load:
>     - {bat-mtlp-9}:       [DMESG-WARN][30] ([i915#13577]) -> [PASS][31]
>    [30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/bat-mtlp-9/igt@i915_module_load@load.html
>    [31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-mtlp-9/igt@i915_module_load@load.html
> 
>   * igt@i915_selftest@live@workarounds:
>     - {bat-mtlp-9}:       [DMESG-FAIL][32] ([i915#12061]) -> [PASS][33]
>    [32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/bat-mtlp-9/igt@i915_selftest@live@workarounds.html
>    [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/bat-mtlp-9/igt@i915_selftest@live@workarounds.html
> 
>   
> #### Warnings ####
> 
>   * igt@gem_exec_gttfill@basic:
>     - fi-pnv-d510:        [SKIP][34] -> [ABORT][35] ([i915#13169])
>    [34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16023/fi-pnv-d510/igt@gem_exec_gttfill@basic.html
>    [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/fi-pnv-d510/igt@gem_exec_gttfill@basic.html
> 
>   
>   {name}: This element is suppressed. This means it is ignored when computing
>           the status of the difference (SUCCESS, WARNING, or FAILURE).
> 
>   [i915#1072]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/1072
>   [i915#11681]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11681
>   [i915#12061]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12061
>   [i915#12904]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12904
>   [i915#13169]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13169
>   [i915#13401]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13401
>   [i915#13577]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13577
>   [i915#1982]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/1982
>   [i915#3291]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3291
>   [i915#3555]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3555
>   [i915#3708]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3708
>   [i915#4077]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4077
>   [i915#4079]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4079
>   [i915#4083]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4083
>   [i915#4103]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4103
>   [i915#4212]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4212
>   [i915#4213]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4213
>   [i915#4215]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4215
>   [i915#5190]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/5190
>   [i915#5354]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/5354
>   [i915#6621]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/6621
>   [i915#9197]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9197
>   [i915#9732]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9732
> 
> 
> Build changes
> -------------
> 
>   * Linux: CI_DRM_16023 -> Patchwork_143990v1
> 
>   CI-20190529: 20190529
>   CI_DRM_16023: 006a892140827b356eb4ad5a5e9b947477791ba8 @ git://anongit.freedesktop.org/gfx-ci/linux
>   IGT_8209: 07ec14a8b00849e82a6ee7aff433c8f564787bf0 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
>   Patchwork_143990v1: 006a892140827b356eb4ad5a5e9b947477791ba8 @ git://anongit.freedesktop.org/gfx-ci/linux
> 
> == Logs ==
> 
> For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_143990v1/index.html
Sebastian Brzezinka Jan. 27, 2025, 3:49 p.m. UTC | #2
Hi Krzysztof,

On Mon Jan 27, 2025 at 11:46 AM UTC, Krzysztof Karas wrote:
> There is an error path in igt_ppgtt_alloc(), which leads to ww
> object being passed down to i915_gem_ww_ctx_fini() without
> initialization. Correct that by zeroing the struct.
>
> Fixes: 480ae79537b2 ("drm/i915/selftests: Prepare gtt tests for obj->mm.lock removal")
> Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
> ---
>  drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> index 5816d515203a..29b9c75557da 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> @@ -154,7 +154,7 @@ static int igt_ppgtt_alloc(void *arg)
>  {
>  	struct drm_i915_private *dev_priv = arg;
>  	struct i915_ppgtt *ppgtt;
> -	struct i915_gem_ww_ctx ww;
> +	struct i915_gem_ww_ctx ww = {};

I don't thing it's a best idea to just initialize ww here, you still have
incorrect path that try to fini ww before it was initialize.

I would probably do something like this instead.
------------------------------------
diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index 5816d515203a..526518bc4dba 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -167,8 +167,10 @@ static int igt_ppgtt_alloc(void *arg)
        if (IS_ERR(ppgtt))
                        return PTR_ERR(ppgtt);

                        -       if (!ppgtt->vm.allocate_va_range)
                        -               goto err_ppgtt_cleanup;
                        +       if (!ppgtt->vm.allocate_va_range) {
                        +               i915_vm_put(&ppgtt->vm);
                        +               return 0;
                        +       }
------------------------------------
Krzysztof Karas Jan. 28, 2025, 12:11 p.m. UTC | #3
Hi Sebastian,

thanks for review.
> I don't thing it's a best idea to just initialize ww here, you still have
> incorrect path that try to fini ww before it was initialize.
Fair point - we still call i915_gem_ww_ctx_fini(), which is
useless without actual ww.

> 
> I would probably do something like this instead.
> ------------------------------------
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> index 5816d515203a..526518bc4dba 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> @@ -167,8 +167,10 @@ static int igt_ppgtt_alloc(void *arg)
>         if (IS_ERR(ppgtt))
>                         return PTR_ERR(ppgtt);
> 
>                         -       if (!ppgtt->vm.allocate_va_range)
>                         -               goto err_ppgtt_cleanup;
>                         +       if (!ppgtt->vm.allocate_va_range) {
>                         +               i915_vm_put(&ppgtt->vm);
>                         +               return 0;
>                         +       }
> ------------------------------------
Ok, I'll put that into a v2 soon.

Krzysztof
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index 5816d515203a..29b9c75557da 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -154,7 +154,7 @@  static int igt_ppgtt_alloc(void *arg)
 {
 	struct drm_i915_private *dev_priv = arg;
 	struct i915_ppgtt *ppgtt;
-	struct i915_gem_ww_ctx ww;
+	struct i915_gem_ww_ctx ww = {};
 	u64 size, last, limit;
 	int err = 0;