[PATCH] drm/selftest: plane_helper: Put test structures in static storage

Nick Desaulniers ndesaulniers at google.com
Tue Mar 8 22:47:34 UTC 2022


On Wed, Mar 2, 2022 at 4:00 PM Nathan Chancellor <nathan at kernel.org> wrote:
>
> Clang warns on certain 32-bit architectures:
>
>   drivers/gpu/drm/selftests/test-drm_plane_helper.c:76:5: warning: stack frame size (1064) exceeds limit (1024) in 'igt_check_plane_state' [-Wframe-larger-than]
>   int igt_check_plane_state(void *ignored)
>       ^
>   1 warning generated.
>
> The structures in igt_check_plane_state() total 1008 bytes, so any small
> amount of inlining will cause the stack frame to exceed the 32-bit limit
> of 1024, triggering the warning.
>
> Move these structures to static storage, which dramatically reduces the
> amount of stack space in igt_check_plane_state(). There is no testing
> impact, as igt_check_plane_state() is only called once in the driver.
>
> Fixes: 943e6a8beeac ("mock a drm_plane in igt_check_plane_state to make the test more robust")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1600
> Reported-by: kernel test robot <lkp at intel.com>
> Suggested-by: Nick Desaulniers <ndesaulniers at google.com>
> Signed-off-by: Nathan Chancellor <nathan at kernel.org>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers at google.com>

> ---
>  drivers/gpu/drm/selftests/test-drm_plane_helper.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> index ceebeede55ea..b61273e9c403 100644
> --- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> +++ b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> @@ -77,7 +77,7 @@ int igt_check_plane_state(void *ignored)
>  {
>         int ret;
>
> -       const struct drm_crtc_state crtc_state = {
> +       static const struct drm_crtc_state crtc_state = {
>                 .crtc = ZERO_SIZE_PTR,
>                 .enable = true,
>                 .active = true,
> @@ -87,14 +87,14 @@ int igt_check_plane_state(void *ignored)
>                                 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC)
>                 },
>         };
> -       struct drm_plane plane = {
> +       static struct drm_plane plane = {
>                 .dev = NULL
>         };
> -       struct drm_framebuffer fb = {
> +       static struct drm_framebuffer fb = {
>                 .width = 2048,
>                 .height = 2048
>         };
> -       struct drm_plane_state plane_state = {
> +       static struct drm_plane_state plane_state = {
>                 .plane = &plane,
>                 .crtc = ZERO_SIZE_PTR,
>                 .fb = &fb,
>
> base-commit: 9ae2ac4d31a85ce59cc560d514a31b95f4ace154
> --
> 2.35.1
>


-- 
Thanks,
~Nick Desaulniers


More information about the dri-devel mailing list