Re: [PATCH 2/2] Revert "Revert "drm/amdgpu: Ensure that the modifier requested is supported by plane.""

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



looks like a safe reland to me. lgtm.

On Wed, Apr 14, 2021 at 7:35 PM Qingqing Zhuo <qingqing.zhuo@xxxxxxx> wrote:
>
> This reverts commit bc3e72b3c3f20ab1583a8464e64f1a68169a28c5.
>
> The regression caused by the original patch has been
> cleared, thus introduce back the change.
>
> Signed-off-by: Qingqing Zhuo <qingqing.zhuo@xxxxxxx>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c    | 13 +++++++++++++
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 18 +++++++++++++++---
>  2 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 6304a49b02fd..0f17984fdea4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -908,6 +908,19 @@ int amdgpu_display_gem_fb_verify_and_init(
>                                          &amdgpu_fb_funcs);
>         if (ret)
>                 goto err;
> +       /* Verify that the modifier is supported. */
> +       if (!drm_any_plane_has_format(dev, mode_cmd->pixel_format,
> +                                     mode_cmd->modifier[0])) {
> +               struct drm_format_name_buf format_name;
> +               drm_dbg_kms(dev,
> +                           "unsupported pixel format %s / modifier 0x%llx\n",
> +                           drm_get_format_name(mode_cmd->pixel_format,
> +                                               &format_name),
> +                           mode_cmd->modifier[0]);
> +
> +               ret = -EINVAL;
> +               goto err;
> +       }
>
>         ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj);
>         if (ret)
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index c3cbc3d298e7..11cd441c033f 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4306,6 +4306,7 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
>  {
>         struct amdgpu_device *adev = drm_to_adev(plane->dev);
>         const struct drm_format_info *info = drm_format_info(format);
> +       int i;
>
>         enum dm_micro_swizzle microtile = modifier_gfx9_swizzle_mode(modifier) & 3;
>
> @@ -4313,11 +4314,22 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
>                 return false;
>
>         /*
> -        * We always have to allow this modifier, because core DRM still
> -        * checks LINEAR support if userspace does not provide modifers.
> +        * We always have to allow these modifiers:
> +        * 1. Core DRM checks for LINEAR support if userspace does not provide modifiers.
> +        * 2. Not passing any modifiers is the same as explicitly passing INVALID.
>          */
> -       if (modifier == DRM_FORMAT_MOD_LINEAR)
> +       if (modifier == DRM_FORMAT_MOD_LINEAR ||
> +           modifier == DRM_FORMAT_MOD_INVALID) {
>                 return true;
> +       }
> +
> +       /* Check that the modifier is on the list of the plane's supported modifiers. */
> +       for (i = 0; i < plane->modifier_count; i++) {
> +               if (modifier == plane->modifiers[i])
> +                       break;
> +       }
> +       if (i == plane->modifier_count)
> +               return false;
>
>         /*
>          * The arbitrary tiling support for multiplane formats has not been hooked
> --
> 2.17.1
>
_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux